Skip to content
This repository was archived by the owner on Aug 24, 2023. It is now read-only.

Commit f1fecd0

Browse files
authored
Merge pull request #332 from dstansby/open-closed
Plot open/closed map in the examples
2 parents c719101 + ca427fe commit f1fecd0

File tree

5 files changed

+31
-18
lines changed

5 files changed

+31
-18
lines changed

doc/source/changes.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@
33
Changelog
44
=========
55

6+
1.0.1
7+
-----
8+
Bug fixes
9+
~~~~~~~~~
10+
- Fixed compatibility of map validity checks with sunpy 3.1.
11+
- Updated this changelog to make it clear that pfsspy 1.0.0 depends on
12+
sunpy >= 3.0.
13+
614
1.0.0
715
-----
816

917
New requirements
1018
~~~~~~~~~~~~~~~~
11-
pfsspy now depends on python >= 3.7, and now does *not* depend on Matplotlib.
19+
pfsspy now depends on python >= 3.7, sunpy >=3,
20+
and now does *not* depend on Matplotlib.
1221

1322
New features
1423
~~~~~~~~~~~~

examples/using_pfsspy/open_closed_map.py renamed to examples/using_pfsspy/plot_open_closed_map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
###############################################################################
2828
# Set the model parameters
29-
nrho = 60
29+
nrho = 40
3030
rss = 2.5
3131

3232
###############################################################################
@@ -44,7 +44,7 @@
4444

4545
r = const.R_sun
4646
# Number of steps in cos(latitude)
47-
nsteps = 90
47+
nsteps = 45
4848
lon_1d = np.linspace(0, 2 * np.pi, nsteps * 2 + 1)
4949
lat_1d = np.arcsin(np.linspace(-1, 1, nsteps + 1))
5050
lon, lat = np.meshgrid(lon_1d, lat_1d, indexing='ij')

pfsspy/fieldline.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,12 @@ def __init__(self, x, y, z, output):
130130
# Field line is open if one end is on the solar surface and one on
131131
# the source surface
132132
atol = 0.1
133-
self._is_open = np.abs(self._r[0] - self._r[-1]) > atol
134-
self._polarity = -np.sign(self._r[0] - self._r[-1]) * self._is_open
133+
if len(self._r) <= 1:
134+
self._is_open = False
135+
self._polarity = 0
136+
else:
137+
self._is_open = np.abs(self._r[0] - self._r[-1]) > atol
138+
self._polarity = -np.sign(self._r[0] - self._r[-1]) * self._is_open
135139

136140
def __len__(self):
137141
return len(self._x)

pfsspy/utils.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,18 +195,18 @@ def is_full_sun_synoptic_map(m, error=False):
195195
def _is_full_sun_car(m, error=False):
196196
shape = m.data.shape
197197

198-
dphi = m.meta['cdelt1']
199-
phi = shape[1] * dphi
200-
if not np.allclose(phi, 360, atol=0.1):
198+
dphi = m.scale.axis1
199+
phi = shape[1] * u.pix * dphi
200+
if not np.allclose(np.abs(phi), 360 * u.deg, atol=0.1 * u.deg):
201201
if error:
202202
raise ValueError('Number of points in phi direction times '
203203
'CDELT1 must be close to 360 degrees. '
204204
f'Instead got {dphi} x {shape[0]} = {phi}')
205205
return False
206206

207-
dtheta = m.meta['cdelt2']
208-
theta = shape[0] * dtheta
209-
if not np.allclose(theta, 180, atol=0.1):
207+
dtheta = m.scale.axis2
208+
theta = shape[0] * u.pix * dtheta
209+
if not np.allclose(theta, 180 * u.deg, atol=0.1 * u.deg):
210210
if error:
211211
raise ValueError('Number of points in theta direction times '
212212
'CDELT2 must be close to 180 degrees. '
@@ -218,18 +218,18 @@ def _is_full_sun_car(m, error=False):
218218
def _is_full_sun_cea(m, error=False):
219219
shape = m.data.shape
220220

221-
dphi = m.meta['cdelt1']
222-
phi = shape[1] * dphi
223-
if not np.allclose(phi, 360, atol=0.1):
221+
dphi = m.scale.axis1
222+
phi = shape[1] * u.pix * dphi
223+
if not np.allclose(np.abs(phi), 360 * u.deg, atol=0.1 * u.deg):
224224
if error:
225225
raise ValueError('Number of points in phi direction times '
226226
'CDELT1 must be close to 360 degrees. '
227227
f'Instead got {dphi} x {shape[1]} = {phi}')
228228
return False
229229

230-
dtheta = m.meta['cdelt2']
231-
theta = shape[0] * dtheta * np.pi / 2
232-
if not np.allclose(theta, 180, atol=0.1):
230+
dtheta = m.scale.axis2
231+
theta = shape[0] * u.pix * dtheta * np.pi / 2
232+
if not np.allclose(theta, 180 * u.deg, atol=0.1 * u.deg):
233233
if error:
234234
raise ValueError('Number of points in theta direction times '
235235
'CDELT2 times pi/2 must be close to '

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ install_requires =
3636
numpy
3737
scikit-image
3838
scipy
39-
sunpy>=3
39+
sunpy>=3,!=3.1.0
4040

4141
[options.extras_require]
4242
docs =

0 commit comments

Comments
 (0)