Skip to content

Commit

Permalink
Merge pull request #7642 from nabobalis/ana
Browse files Browse the repository at this point in the history
Deprecate ANA reader/writer functions
  • Loading branch information
nabobalis committed Jun 10, 2024
2 parents 878e2f4 + 2a5a61d commit 767cd79
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/7642.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ANA C code now been deprecated (`sunpy.io.ana.read`, `sunpy.io.ana.get_header`, `sunpy.io.ana.write`) and will be removed in sunpy 6.1.0.
6 changes: 4 additions & 2 deletions sunpy/io/ana.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os

from sunpy.io._header import FileHeader
from sunpy.util.decorators import deprecated
from sunpy.util.io import HDPair

try:
Expand All @@ -24,11 +25,10 @@
"C extension for ANA is missing. For more details see: "
"https://docs.sunpy.org/en/stable/installation.html#installing-without-conda"
)


__all__ = ['read', 'get_header', 'write']


@deprecated(since="6.0", message="The ANA reader is un-maintained and will be removed in the future. Please contact sunpy if you are using this.", alternative="https://github.com/ITA-Solar/helita has a ANA reader and writer.")
def read(filename, debug=False, **kwargs):
"""
Loads an ANA file and returns the data and a header in a list of (data,
Expand Down Expand Up @@ -62,6 +62,7 @@ def read(filename, debug=False, **kwargs):
return [HDPair(data['data'], FileHeader(data['header']))]


@deprecated(since="6.0", message="The ANA reader is un-maintained and will be removed in the future. Please contact sunpy if you are using this.", alternative="https://github.com/ITA-Solar/helita has a ANA reader and writer.")
def get_header(filename, debug=False):
"""
Loads an ANA file and only return the header consisting of the dimensions,
Expand Down Expand Up @@ -91,6 +92,7 @@ def get_header(filename, debug=False):
return [FileHeader(data['header'])]


@deprecated(since="6.0", message="The ANA reader is un-maintained and will be removed in the future. Please contact sunpy if you are using this.", alternative="https://github.com/ITA-Solar/helita has a ANA reader and writer.")
def write(filename, data, comments=False, compress=True, debug=False):
"""
Saves a 2D `numpy.array` as an ANA file and returns the bytes written or
Expand Down
2 changes: 2 additions & 0 deletions sunpy/io/tests/test_ana.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from sunpy.io import ana
from sunpy.tests.helpers import skip_ana

pytestmark = pytest.mark.filterwarnings("ignore::sunpy.util.exceptions.SunpyDeprecationWarning")

img_size = (456, 345)
img_src = np.arange(np.prod(img_size))
img_src.shape = img_size
Expand Down
3 changes: 3 additions & 0 deletions sunpy/io/tests/test_filetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def test_read_file_header_fits():


@skip_ana
@pytest.mark.filterwarnings("ignore::sunpy.util.exceptions.SunpyDeprecationWarning")
def test_read_file_ana():
# Aim is to verify that we can read a ANA file
hdulist = read_file(get_test_filepath("test_ana.fz"))
Expand All @@ -101,6 +102,7 @@ def test_read_file_ana():


@skip_ana
@pytest.mark.filterwarnings("ignore::sunpy.util.exceptions.SunpyDeprecationWarning")
def test_read_file_header_ana():
# Aim is to verify that we can read a header from a ANA file
hdulist = read_file_header(get_test_filepath("test_ana.fz"))
Expand All @@ -110,6 +112,7 @@ def test_read_file_header_ana():


@skip_ana
@pytest.mark.filterwarnings("ignore::sunpy.util.exceptions.SunpyDeprecationWarning")
def test_write_file_ana(tmpdir):
# Aim is to verify that we can write a ANA file and read back correctly
ana_header, ana_data = read_file(get_test_filepath("test_ana.fz"))[0][::-1]
Expand Down

0 comments on commit 767cd79

Please sign in to comment.