From 283167ccf0d81fcbb98809fdcae9c3a320d7a6d8 Mon Sep 17 00:00:00 2001 From: Tomas Stolker Date: Mon, 16 Mar 2020 12:08:20 +0100 Subject: [PATCH] Added optional spectral resolution setting in add_object --- species/data/database.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/species/data/database.py b/species/data/database.py index 507c7732..f7b1f541 100644 --- a/species/data/database.py +++ b/species/data/database.py @@ -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 ------- @@ -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])