Skip to content

Commit

Permalink
Don't leave me adaptmap
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair committed Jun 9, 2024
1 parent 188a7ee commit 594c87d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
12 changes: 8 additions & 4 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ Full Changelog
1.0.0 (2024-05-31)
==================

* First release that keeps API the same from `pfsspy` to `sunkit-magex`.
The main difference is that you will need to replace the import like so:
This is the first release and aims to keep the API the same from `pfsspy` to
`sunkit-magex`. The main difference is that you will need to replace the
import like so:

.. code-block:: python
Expand All @@ -20,5 +21,8 @@ Full Changelog
from sunkit_magex import pfss as pfsspy
from sunkit_magex.pfss import tracing
The main breaking changes is that the old sunpy Map classes were removed and added to sunpy.
You will need to make sure you have sunpy 6.0.0 installed.
The main changes from the previous release of `pfsspy` are as follows:

* The ``GongSynopticMap`` class has moved into `sunpy`, note that the new
class in ``sunpy`` is slightly different in that it does not modify the
header.
2 changes: 2 additions & 0 deletions sunkit_magex/pfss/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Import this to register map sources
import sunkit_magex.pfss.map as _
from sunkit_magex.pfss import coords, fieldline, sample_data, tracing, utils
from sunkit_magex.pfss.input import Input
from sunkit_magex.pfss.output import Output
Expand Down
24 changes: 24 additions & 0 deletions sunkit_magex/pfss/map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
Custom `sunpy.map.GenericMap` sub-classes for different magnetogram sources.
"""
import sunpy.map

__all__ = ['ADAPTMap']


class ADAPTMap(sunpy.map.GenericMap):
def __init__(self, data, header, **kwargs):
if 'date-obs' not in header:
header['date-obs'] = header['maptime']
# Fix CTYPE
if header['ctype1'] == 'Long':
header['ctype1'] = 'CRLN-CAR'
if header['ctype2'] == 'Lat':
header['ctype2'] = 'CRLT-CAR'

super().__init__(data, header, **kwargs)

@classmethod
def is_datasource_for(cls, data, header, **kwargs):
"""Determines if header corresponds to an ADAPT map."""
return header.get('model') == 'ADAPT'
12 changes: 12 additions & 0 deletions sunkit_magex/pfss/tests/test_map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import astropy.io

import sunpy.map

import sunkit_magex.pfss.map


def test_adapt_map(adapt_test_file):
with astropy.io.fits.open(adapt_test_file) as adapt_fits:
for map_slice in adapt_fits[0].data:
m = sunpy.map.Map((map_slice, adapt_fits[0].header))
assert isinstance(m, sunkit_magex.pfss.map.ADAPTMap)

0 comments on commit 594c87d

Please sign in to comment.