Skip to content

Commit

Permalink
Merge pull request #34 from Cadair/fix_tests
Browse files Browse the repository at this point in the history
Make all tests use offline test data
  • Loading branch information
Cadair committed May 1, 2024
2 parents 8dba6ba + c481f3d commit 37751cb
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 35 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ authors = [
]
dependencies = [
"astropy>=5.2.0",
"numpy>=1.21.0",
"numpy>=1.23.0",
"scikit-image>=0.19.0",
# !=1.10.0 due to https://github.com/scipy/scipy/issues/17718
"scipy>=1.8.0,!=1.10.0",
Expand All @@ -30,6 +30,7 @@ tests = [
"pytest-doctestplus",
"pytest-cov",
"pytest-xdist",
"pytest-arraydiff",
"parfive",
"reproject",
"streamtracer",
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ addopts =
--doctest-rst
-p no:unraisableexception
-p no:threadexception
--arraydiff
filterwarnings =
# Turn all warnings into errors so they do not pass silently.
error
Expand Down
15 changes: 15 additions & 0 deletions sunkit_magex/pfss/tests/arraydiff_reference/test_pfss.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-0.329488 -0.33211 -0.335096 -0.338411 -0.341925 -0.345441 -0.348733 -0.351568 -0.353699 -0.354872 -0.354863 -0.35357 -0.351078 -0.347619 -0.343447 -0.33884 -0.334197 -0.329964 -0.326437 -0.323665 -0.32152 -0.319887 -0.31883 -0.318504 -0.318961 -0.320073 -0.321598 -0.323315 -0.32516 -0.327192
-0.203879 -0.201533 -0.200296 -0.200566 -0.202051 -0.204163 -0.206781 -0.210207 -0.214347 -0.218595 -0.221403 -0.221767 -0.220625 -0.220008 -0.220001 -0.218886 -0.21755 -0.218822 -0.223863 -0.230978 -0.236272 -0.236391 -0.232192 -0.226907 -0.222675 -0.219824 -0.217414 -0.213992 -0.210018 -0.206668
-0.129005 -0.124032 -0.120547 -0.119396 -0.119205 -0.11834 -0.11804 -0.120308 -0.124851 -0.130741 -0.134523 -0.135272 -0.136055 -0.142311 -0.152509 -0.157467 -0.157587 -0.159652 -0.167457 -0.179732 -0.189573 -0.189491 -0.182316 -0.174191 -0.167182 -0.161277 -0.156182 -0.148326 -0.139967 -0.134044
-0.0826416 -0.075733 -0.0701038 -0.0676828 -0.0665345 -0.0637403 -0.0618708 -0.0641209 -0.0691448 -0.0757015 -0.0781843 -0.0763734 -0.0779981 -0.0916756 -0.113055 -0.122761 -0.122358 -0.123433 -0.130776 -0.143202 -0.152735 -0.150307 -0.141639 -0.134626 -0.129024 -0.123651 -0.119059 -0.107546 -0.0958699 -0.0887516
-0.0544937 -0.0459498 -0.0380908 -0.033296 -0.0305504 -0.0271275 -0.0264387 -0.0310709 -0.0371344 -0.042648 -0.0419418 -0.0355336 -0.0356643 -0.0522077 -0.0798337 -0.0921155 -0.092726 -0.0947818 -0.101354 -0.110393 -0.115696 -0.111882 -0.104728 -0.101161 -0.0987665 -0.0961426 -0.0944615 -0.0810949 -0.0679337 -0.0607423
-0.0369394 -0.025664 -0.0149818 -0.00778145 -0.00346145 -0.000440488 -0.00141312 -0.00883305 -0.0163064 -0.0206462 -0.0167152 -0.0059957 -0.00344729 -0.0172422 -0.0440947 -0.058528 -0.0634456 -0.0686526 -0.0746553 -0.0796352 -0.0806088 -0.0761275 -0.0711394 -0.0706035 -0.0715466 -0.0718363 -0.0726127 -0.0602888 -0.048417 -0.0426427
-0.0241803 -0.00937853 0.00415575 0.0121868 0.017006 0.0194704 0.0186133 0.0104448 0.00235859 -0.00176008 0.00391854 0.0166941 0.0215411 0.0128728 -0.00884146 -0.0245613 -0.034991 -0.0439188 -0.0496766 -0.0514482 -0.0488869 -0.0439872 -0.0404795 -0.0421929 -0.0455816 -0.0470288 -0.0479322 -0.0395706 -0.0319516 -0.0288828
-0.0110367 0.00609253 0.0208084 0.0273581 0.0318149 0.035208 0.037182 0.030747 0.0231734 0.0180723 0.0233387 0.0350863 0.0407655 0.036747 0.0222226 0.00704563 -0.00805545 -0.0204353 -0.0265372 -0.0261615 -0.020297 -0.0146266 -0.011598 -0.0150319 -0.0195249 -0.0206073 -0.0210277 -0.0177784 -0.0152602 -0.0148827
0.00728902 0.0231489 0.035606 0.0386414 0.0423907 0.0492758 0.0568256 0.0536089 0.0471062 0.0403952 0.0427222 0.0504898 0.0554766 0.0548929 0.0478614 0.0351214 0.0173585 0.00214024 -0.00510772 -0.00378185 0.00519525 0.0130584 0.0166279 0.0123925 0.00806926 0.00800465 0.00771014 0.00624281 0.00457432 0.00332968
0.0324162 0.0432887 0.0505016 0.0487239 0.0516701 0.0639439 0.0786237 0.0789808 0.0735711 0.0655485 0.0632518 0.0653 0.0684348 0.0701874 0.0692969 0.0596798 0.0417348 0.0248269 0.015737 0.0168273 0.0281229 0.0395667 0.0448468 0.0413583 0.0384859 0.0396181 0.0392827 0.0346009 0.0303966 0.02834
0.0638856 0.0676445 0.0681208 0.0612789 0.0638262 0.0817089 0.102195 0.1058 0.101689 0.0931785 0.0861757 0.0828399 0.0836121 0.0862141 0.0883414 0.0814809 0.0658414 0.04909 0.0383819 0.0386761 0.0512109 0.0664561 0.0744498 0.0739654 0.0737385 0.0756083 0.0748999 0.0692163 0.0642526 0.0615282
0.101352 0.0982088 0.0927283 0.0831136 0.0863331 0.106552 0.127647 0.13396 0.131849 0.123475 0.113369 0.106557 0.10496 0.106471 0.108202 0.103425 0.0917986 0.0776348 0.0670189 0.067039 0.0800931 0.0979096 0.109247 0.113655 0.116754 0.118819 0.117504 0.11234 0.107293 0.103217
0.150296 0.142464 0.133631 0.125326 0.12802 0.142956 0.15873 0.165769 0.165054 0.157742 0.147981 0.140482 0.137145 0.136612 0.136566 0.133223 0.125871 0.116461 0.109358 0.111142 0.123754 0.141155 0.155376 0.164992 0.171628 0.174539 0.173284 0.168818 0.162992 0.156535
0.224183 0.214995 0.206002 0.199179 0.197854 0.201986 0.207442 0.210316 0.209322 0.204561 0.197956 0.192106 0.188522 0.187143 0.186758 0.185684 0.183404 0.1809 0.1805 0.185243 0.195893 0.209967 0.223949 0.235911 0.244818 0.249606 0.249935 0.246541 0.240479 0.232727
0.33687 0.329121 0.321448 0.314516 0.3088 0.304368 0.300893 0.297907 0.295063 0.292255 0.289651 0.287587 0.286396 0.286278 0.287291 0.289412 0.292653 0.297113 0.302926 0.310137 0.318505 0.327453 0.336203 0.343962 0.350022 0.353821 0.355028 0.353598 0.349762 0.34398
27 changes: 19 additions & 8 deletions sunkit_magex/pfss/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from sunpy.map import Map

import sunkit_magex.pfss
from sunkit_magex.pfss import utils
from sunkit_magex.tests.helpers import get_dummy_map_from_header, get_fitsfile_from_header


@pytest.fixture
Expand Down Expand Up @@ -53,16 +55,25 @@ def dipole_result(dipole_map):


@pytest.fixture
def gong_map():
def adapt_test_file(tmp_path):
"""
Automatically download and unzip a sample GONG synoptic map.
Return a fake
"""
return sunkit_magex.pfss.sample_data.get_gong_map()
return get_fitsfile_from_header(
"adapt_header.header",
tmp_path / "adapt.fits",
package="sunkit_magex.pfss.tests.data"
)


@pytest.fixture
def adapt_map():
"""
Automatically download and unzip a sample GONG synoptic map.
"""
return sunkit_magex.pfss.sample_data.get_adapt_map()
def adapt_map(adapt_test_file):
return utils.load_adapt(adapt_test_file)


@pytest.fixture
def gong_map():
return get_dummy_map_from_header(
"gong_header.header",
package="sunkit_magex.pfss.tests.data"
)
75 changes: 75 additions & 0 deletions sunkit_magex/pfss/tests/data/adapt_header.header
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
SIMPLE = T / file does conform to FITS standard
BITPIX = -32 / number of bits per data pixel
NAXIS = 3 / number of data axes
NAXIS1 = 360 / length of data axis 1
NAXIS2 = 180 / length of data axis 2
NAXIS3 = 12 / length of data axis 3
EXTEND = T / FITS dataset may contain extensions
ADD_DATE= 20200101 / Date for new map
ADD_UT = 0. / UT for new map
LASTSITE= 5 / Last obs site: Mauna Loa (GONG)
LAST_OBS= 0.03888889 / Days since last obs merged
LAST_RND= 0.3416672 / Time since random flux merged
NEVODAYS= 10088. / No. of days evolved from init seed map
NMODEL = 16 / Number of realizations used in model
NREAL = 12 / Number of realizations in this file
COVERAGE= 100 / Percent of columns with 3+ obs
MISSING = -9999. / Value filled in for missing pixels
MONOINIT= 0. / Initial monopole value
MONOFINL= 0. / Final monopole value
MONODMOD= 0.2 / Model % monopole dampening
MONODPUB= 0.6 / Public % monopole dampening
MONOCUT = 1. / Flux cutoff for monopole correction
FLUXSCAL= 1.85 / Scaling applied to input data
SM_MTHD = 2 / Smoothing Type: Hanning
SM_CUT_E= 60. / Equatorial Smoothing Cutoff [deg]
SM_RAD_E= 0.03490658 / Equatorial Smoothing Radius [solar rad]
SM_CUT_P= 75. / Polar Smoothing Cutoff [deg]
SM_RAD_P= 0.042 / Polar Smoothing Radius [solar rad]
MAPTIME = '2020-01-01T00:00:00' / Date & time info for map/mag
MAPDATA = 'GONG ' / Data instrument/telescope source
MAPJUL = 2458849.5 / Julian Date of latest map/mag
MAPLON = 70.8961383741418 / Carrington long @ CM of latest map/obs
MAPCR = 2225.80306628229 / Carrington rot @ CM of latest map/obs
EPHEM_B0= -2.939296 / Solar B0 at time of latest map/mag
MAPTYPE = 'synchronic' / Type of synoptic map
MAPPARAM= 'mag ' / Map obs data parameter type
CRLNGEDG= 0. / WSA SPEC: Carr-long of leading edge
CRROTEDG= 2225 / WSA SPEC: Carr-rot of leading edge
MAPCREDG= 2226. / Carrington rot of leading edge
GRID = 1. / Uniform grid res: del(lat)=del(lng)
ATTR_RES= 1 / Attract map spatial-res: 1.0 deg/pix
LNGTYPE = 0 / Carrington Fixed: 0 to 360
LATTYPE = 0 / Latitude
MAG_TYPE= 1 / Mag: Line of Sight
HEL_TYPE= 0 / Helioseismic: Not added and/or no data
LAST_FAR= -9999. / Time since last farside DA [days]
LAST_NER= -9999. / Time since last nearside DA [days]
LAST_NPL= -9999. / Time since last north pole DA [days]
LAST_SPL= -9999. / Time since last south pole DA [days]
MODEL = 'ADAPT ' / Model Name
MODELDA = 1 / DA model: Ensemble Least Squares
MODELVER= '3.1106 ' / Model Version: [YY - 9].MMDD
MODPAR01= 0.0209 / Mean map supergran size
MODPAR02= 23.4 / Mean map supergran lifetime (hr)
MODPAR03= 8. / North: Mean map meridional flow rate
MODPAR04= -8. / South: Mean map meridional flow rate
MODPAR05= 2.913 / North: Mean map diff-rot coef A
MODPAR06= 0.405 / North: Mean map diff-rot coef B
MODPAR07= 0.422 / North: Mean map diff-rot coef C
MODPAR08= 2.913 / South: Mean map diff-rot coef A
MODPAR09= 0.405 / South: Mean map diff-rot coef B
MODPAR10= 0.422 / South: Mean map diff-rot coef C
MODPAR11= 25. / Mean map mag-field sgran cutoff (Gauss)
MODPAR12= 2.1 / Mean map random flux amp (Gauss)
WCSNAME = 'Heliocentric-cart'
CTYPE1 = 'Long ' / Coordinate axis label
CTYPE2 = 'Lat ' / Coordinate axis label
CRPIX1 = 180.5 / Current X position for center
CRPIX2 = 90.5 / Current Y position for center
CUNIT1 = 'deg ' / X axis units
CUNIT2 = 'deg ' / Y axis units
CDELT1 = 1. / X resolution [deg/pxl]
CDELT2 = 1. / Y resolution [deg/pxl]
CRVAL1 = 180. / Reference pixel value
CRVAL2 = 0. / Reference pixel value

0 comments on commit 37751cb

Please sign in to comment.