Skip to content

Commit

Permalink
Merge pull request #7378 from alasdairwilson/invalid_fits_unit_example
Browse files Browse the repository at this point in the history
add replacement to mapbase for unit: counts / pixel -> ct/pix
  • Loading branch information
nabobalis committed Jan 11, 2024
2 parents ebe5b48 + a7db5e6 commit 71e1c39
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sunpy/map/mapbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,15 +727,16 @@ def max(self, *args, **kwargs):
def _parse_fits_unit(unit_str):
replacements = {'gauss': 'G',
'dn': 'ct',
'dn/s': 'ct/s'}
'dn/s': 'ct/s',
'counts / pixel': 'ct/pix',}
if unit_str.lower() in replacements:
unit_str = replacements[unit_str.lower()]
unit = u.Unit(unit_str, format='fits', parse_strict='silent')
if isinstance(unit, u.UnrecognizedUnit):
warn_metadata(f'Could not parse unit string "{unit_str}" as a valid FITS unit.\n'
f'See {_META_FIX_URL} for how to fix metadata before loading it '
'with sunpy.map.Map.\n'
'See https://fits.gsfc.nasa.gov/fits_standard.html for'
'See https://fits.gsfc.nasa.gov/fits_standard.html for '
'the FITS unit standards.')
unit = None
return unit
Expand Down

0 comments on commit 71e1c39

Please sign in to comment.