Commit 16fef465 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files
parent 6a19fcba
......@@ -65,7 +65,7 @@ class RelativeSpectralResponse(object):
if wvl_unit not in ['micrometers', 'nanometers']:
raise ValueError('Unknown wavelength unit %s.' % wvl_unit)
self.rsr_wvl = [] # wavelength positions with 1 nm precision
self.rsrs_wvl = [] # wavelength positions with 1 nm precision
self.rsrs = {} # RSR values with 1 nm precision
self.rsrs_norm01 = {} # RSR values with 1 nm precision
self.bands = []
......@@ -132,16 +132,16 @@ class RelativeSpectralResponse(object):
self.rsrs_norm01[bN] = rsr = np.array(rsrs_norm01[bN], dtype=np.float)
self.rsrs[bN] = rsr / np.trapz(x=wvl, y=rsr) # TODO seems like we NEED nanometers here; BUT WHY??
self.rsr_wvl = np.array(wvl)
self.rsrs_wvl = np.array(wvl)
self.bands = bandnames
# FIXME this is not the GMS algorithm to calculate center wavelengths
# calculate center wavelengths
# TODO seems like we NEED nanometers here; BUT WHY??:
self.wvl = np.array([np.trapz(x=self.rsr_wvl, y=self.rsr_wvl * self.rsrs[band]) for band in self.bands])
self.wvl = np.array([np.trapz(x=self.rsrs_wvl, y=self.rsrs_wvl * self.rsrs[band]) for band in self.bands])
# self.wvl = self.wvl if self.wvl_unit == 'micrometers' else np.array([int(i) for i in self.wvl])
self.rsr_wvl = self.rsr_wvl if self.wvl_unit == 'nanometers' else self.rsr_wvl / 1000
self.rsrs_wvl = self.rsrs_wvl if self.wvl_unit == 'nanometers' else self.rsrs_wvl / 1000
self.wvl = self.wvl if self.wvl_unit == 'nanometers' else self.wvl / 1000
self.conv.update({key: value for key, value in zip(self.bands, self.wvl)})
......@@ -152,7 +152,7 @@ class RelativeSpectralResponse(object):
def instrument(self, bands):
return {
'rspf': np.vstack([self[band] for band in bands]),
'wvl_rsp': np.copy(self.rsr_wvl),
'wvl_rsp': np.copy(self.rsrs_wvl),
'wvl_inst': np.copy(self.wvl),
'sol_irr': None
}
......@@ -160,7 +160,7 @@ class RelativeSpectralResponse(object):
def convert_wvl_unit(self):
"""Convert the wavelength unit to nanometers if they are in micrometers or vice versa."""
factor = 1/1000 if self.wvl_unit == 'nanometers' else 1000
self.rsr_wvl = self.rsr_wvl * factor
self.rsrs_wvl = self.rsrs_wvl * factor
self.wvl = self.wvl * factor
self.wvl_unit = 'nanometers' if self.wvl_unit == 'micrometers' else 'micrometers'
......@@ -189,7 +189,7 @@ class RelativeSpectralResponse(object):
bands2plot = [band] if band else self.bands
for band in bands2plot:
rsrs = list(self.rsrs_norm01[band]) if normalize else list(self.rsrs[band])
plt.plot(self.rsr_wvl, rsrs, '-', label='Band %s' % band)
plt.plot(self.rsrs_wvl, rsrs, '-', label='Band %s' % band)
plt.title(' '.join(['Spectral response functions', self.satellite, self.sensor]))
plt.xlabel('wavelength [%s]' % self.wvl_unit)
plt.ylabel('spectral response')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment