Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/tomasstolker/species into…
Browse files Browse the repository at this point in the history
… color
  • Loading branch information
Tomas Stolker committed Mar 16, 2020
2 parents 7fa0050 + 283167c commit af9e318
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions species/data/database.py
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 af9e318

Please sign in to comment.