-
-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7262 from nabobalis/doc_map
Fix map metadata how to
- Loading branch information
Showing
5 changed files
with
39 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Created a how to guide on fixing metadata that is either missing or incorrect before passing the header into the `~sunpy.map.Map` class. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.. _sunpy-how-to-fix-map-metadata: | ||
|
||
************************* | ||
Fixing incorrect metadata | ||
************************* | ||
|
||
There will be times where you will come across a FITS files with either incorrect, missing or unparsable metadata and reading these files into `~sunpy.map.Map` will cause an error. | ||
Therefore, to load these files into a `~sunpy.map.Map`, you will need to correct the metadata beforehand. | ||
|
||
In the example below, the units in the FITS header, as controlled by the ``CUNIT1`` and ``CUNIT2`` keywords, are incorrect. | ||
Before loading the file into a `~sunpy.map.Map`, we will correct these keywords to have the correct units. | ||
|
||
.. code-block:: python | ||
>>> from astropy.io import fits | ||
>>> from sunpy.map import Map | ||
>>> import sunpy.data.sample | ||
>>> filepath = sunpy.data.sample.AIA_171_IMAGE # doctest: +REMOTE_DATA | ||
>>> data, header = fits.getdata(filepath, header=True) # doctest: +REMOTE_DATA | ||
>>> # Note that it is case insensitive for the keys | ||
>>> header['cunit1'] = 'arcsec' # doctest: +REMOTE_DATA | ||
>>> header['cunit2'] = 'arcsec' # doctest: +REMOTE_DATA | ||
>>> updated_map = Map(data, header) # doctest: +REMOTE_DATA | ||
This applies for any keyword in the `FITS standard <https://fits.gsfc.nasa.gov/fits_standard.html>`__. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters