Skip to content

Commit

Permalink
Merge pull request #84 from dhomeier/translate-unit-none
Browse files Browse the repository at this point in the history
Accept `component.units=None` in translators input
  • Loading branch information
dhomeier authored Jan 31, 2023
2 parents 5e9cd27 + 1c6c2d1 commit 4f74ebd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion glue_astronomy/translators/nddata.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def to_object(self, data_or_subset, attribute=None):

values = data.get_data(attribute)
values, mask = _get_value_and_mask(subset_state, data, values)
values = values * u.Unit(component.units)
values = u.Quantity(values, unit=component.units)

if has_fitswcs:
result = CCDData(values, mask=mask, wcs=wcs, meta=data.meta)
Expand Down
2 changes: 1 addition & 1 deletion glue_astronomy/translators/spectral_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def to_object(self, data_or_subset, attribute=None, cls=SpectralCube):
values = values.copy()
mask = BooleanArrayMask(mask, wcs=wcs)

values = values * u.Unit(component.units)
values = u.Quantity(values, unit=component.units)

# Drop Stokes axis if there is one for FITS WCS
if isinstance(wcs, WCS) and wcs.sub([WCSSUB_STOKES]).naxis > 0:
Expand Down
2 changes: 1 addition & 1 deletion glue_astronomy/translators/spectrum1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def parse_attributes(attributes):
if attribute_label not in ('flux', 'uncertainty'):
attribute_label = 'flux'

values = values * u.Unit(component.units)
values = u.Quantity(values, unit=component.units)

# If the attribute is uncertainty, we must coerce it to a
# specific uncertainty type. If no value exists in the glue
Expand Down

0 comments on commit 4f74ebd

Please sign in to comment.