Skip to content

Commit

Permalink
JP-2067: Add units to combine1d product table (spacetelescope#6082)
Browse files Browse the repository at this point in the history
* add units to combine1d intermediate and final products

* changelog and CI restart
  • Loading branch information
tapastro authored and loicalbert committed Nov 5, 2021
1 parent a7a794d commit 46e5711
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ datamodels

- Removed obsolete keyword NDITHPTS and updated attributes for NRIMDTPT [#6083]

- Added units to CombinedSpecModel table output [#6082]

general
-------

Expand Down
13 changes: 13 additions & 0 deletions jwst/combine_1d/combine1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def __init__(self, ms, spec, exptime_key):
self.declination = np.zeros_like(self.wavelength)
self.source_id = spec.source_id
self.source_type = spec.source_type
self.flux_unit = spec.spec_table.columns['flux'].unit
self.sb_unit = spec.spec_table.columns['surf_bright'].unit

self.weight = np.ones_like(self.wavelength)
if exptime_key == "integration_time":
Expand Down Expand Up @@ -128,6 +130,8 @@ def __init__(self):
self.wcs = None
self.normalized = False
self.source_id = None
self.flux_unit = None
self.sb_unit = None

def assign_wavelengths(self, input_spectra):
"""Create an array of wavelengths to use for the output spectrum.
Expand Down Expand Up @@ -190,6 +194,9 @@ def accumulate_sums(self, input_spectra):
self.weight = np.zeros(nelem, dtype=np.float64)
self.count = np.zeros(nelem, dtype=np.float64)

self.flux_unit = input_spectra[0].flux_unit
self.sb_unit = input_spectra[0].sb_unit

n_nan = 0 # initial value
ninputs = 0
for in_spec in input_spectra:
Expand Down Expand Up @@ -283,6 +290,12 @@ def create_output_data(self):
self.count)), dtype=cmb_dtype)
output_model = datamodels.CombinedSpecModel(spec_table=data)

output_model.spec_table.columns['wavelength'].unit = 'um'
output_model.spec_table.columns['flux'].unit = self.flux_unit
output_model.spec_table.columns['error'].unit = self.flux_unit
output_model.spec_table.columns['surf_bright'].unit = self.sb_unit
output_model.spec_table.columns['sb_error'].unit = self.sb_unit

return output_model

def close(self):
Expand Down

0 comments on commit 46e5711

Please sign in to comment.