Skip to content

Commit

Permalink
Merge branch 'pre-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam.Dybbroe committed Mar 28, 2016
2 parents 95686de + d344ef7 commit 65f3b3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ pyspectral
[![Build Status](https://travis-ci.org/pytroll/pyspectral.png?branch=pre-master)](https://travis-ci.org/pytroll/pyspectral)
[![Coverage Status](https://coveralls.io/repos/github/pytroll/pyspectral/badge.svg?branch=pre-master)](https://coveralls.io/github/pytroll/pyspectral?branch=pre-master)
[![Code Health](https://landscape.io/github/pytroll/pyspectral/pre-master/landscape.png)](https://landscape.io/github/pytroll/pyspectral/pre-master)
[![Downloads](https://pypip.in/d/pyspectral/badge.png)](https://crate.io/package/pyspectral)
[![Version](https://pypip.in/v/pyspectral/badge.png)](https://crate.io/package/pyspectral)
[![PyPI version](https://badge.fury.io/py/pyspectral.svg)](https://badge.fury.io/py/pyspectral)
[![Research software impact](http://depsy.org/api/package/pypi/pyspectral/badge.svg)](http://depsy.org/package/python/pyspectral)


Expand Down
12 changes: 8 additions & 4 deletions pyspectral/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ def convert2wavenumber(rsr):
return retv, {'unit': unit, 'si_scale': si_scale}


def get_central_wave(wav, resp):
"""Calculate the central wavelength or the central wavenumber,
depending on what is input
def get_central_wave(wav, resp, weight=1.0):
"""Calculate the central wavelength or the central wavenumber, depending on
which parameters is input. On default the weighting funcion is
f(lambda)=1.0, but it is possible to add a custom weight, e.g. f(lambda) =
1./lambda**4 for Rayleigh scattering calculations
"""

# info: {'unit': unit, 'si_scale': si_scale}
# To get the wavelenght/wavenumber in SI units (m or m-1):
# wav = wav * info['si_scale']
Expand All @@ -96,7 +100,7 @@ def get_central_wave(wav, resp):
# Wavenumber:
# res *=

return np.trapz(resp * wav, wav) / np.trapz(resp, wav)
return np.trapz(resp * wav * weight, wav) / np.trapz(resp * weight, wav)


def sort_data(x_vals, y_vals):
Expand Down

0 comments on commit 65f3b3d

Please sign in to comment.