Skip to content

Commit

Permalink
Added optional spectral resolution setting in add_object
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Stolker committed Mar 16, 2020
1 parent 7bba144 commit 283167c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions species/data/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,9 @@ def add_object(self,
``{'SPHERE': ('spectrum.dat', 'covariance.fits')}``. No covariance data is stored if
set to None, for example, ``{'SPHERE': ('spectrum.dat', None)}``. The ``spectrum``
parameter is ignored if set to None. For GRAVITY data, the same FITS file can be
provided as spectrum and covariance matrix.
provided as spectrum and covariance matrix. The spectral resolution is calculated from
the wavelength points or can alternatively provided as third elements of the tuple,
for example ``{'SPHERE': ('spectrum.dat', 'covariance.fits', 50.)}``.
Returns
-------
Expand Down Expand Up @@ -653,10 +655,14 @@ def add_object(self,

print(' - Spectral resolution:')

for key in read_spec:
for key, value in spectrum.items():

wavelength = read_spec[key][:, 0]
spec_res = np.mean(0.5*(wavelength[1:]+wavelength[:-1])/np.diff(wavelength))
if len(value) == 2:
wavelength = read_spec[key][:, 0]
spec_res = np.mean(0.5*(wavelength[1:]+wavelength[:-1])/np.diff(wavelength))

else:
spec_res = value[2]

h5_file.create_dataset(f'objects/{object_name}/spectrum/{key}/spectrum',
data=read_spec[key])
Expand Down

0 comments on commit 283167c

Please sign in to comment.