dstansby / pfsspy

Potential Field Source Surface model package for Python
https://pfsspy.readthedocs.io/
Other
41 stars 18 forks source link

Allow user to specify the center of map coordinates in `pfsspy.utils.carr_cea_wcs_header` #358

Closed STBadman closed 2 years ago

STBadman commented 2 years ago

Currently, the function pfsspy.utils.carr_cea_wcs_header assumes that it is being constructed for a Carrington map where the center is at 0 degrees Carrington longitude. This change adds a keyword map_center_longitude which must be passed with astropy.units.deg units. The default value is 0 meaning the default behavior of the function is unchanged but now a user can manually change it, for example using 180 degrees to align Carrington 0 with the left hand edge of the map.

Although its uncommon to not be loading a magnetogram directly from a FITS file in which case the header is created automatically with the correct roll, I had a use a case where I needed this functionality: I had saved a CEA magnetogram data as a numpy.array and wanted to reconstruct a sunpy.map.Map from it, however the np.array data did have CR0 at the left hand edge and so the default behavior of the header creation was incorrect and led to a misaligned map. This fix allows the user to control this.

The build of the PR has failed for py38 due to some matplotlib deprecation warnings around get_cmap. This looks tied up in sunpy and I don't see an easy fix - can this PR still be merged?

STBadman commented 2 years ago

Thanks! Accepted your changes, and added a test for the cea header function. It checks that the default and user specified reference pixel longitudes are as expected and it checks the error handling of the keyword units is correct.