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

Commit

Permalink
Merge pull request #236 from dstansby/errors
Browse files Browse the repository at this point in the history
Fix error throwing
  • Loading branch information
dstansby authored Oct 9, 2020
2 parents 963b095 + e53221b commit 0be3a9d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 7 additions & 0 deletions pfsspy/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ def test_validation(dipole_map, error):
assert utils.is_full_sun_synoptic_map(dipole_map, error)


def test_validation_not_full_map(dipole_map):
dipole_map.meta['cdelt1'] = 0.001
assert not utils.is_full_sun_synoptic_map(dipole_map)
with pytest.raises(ValueError):
utils.is_full_sun_synoptic_map(dipole_map, error=True)


def test_car_reproject(adapt_map):
adapt_map = utils.load_adapt(adapt_map)[0]
adapt_reproj = utils.car_to_cea(adapt_map)
Expand Down
12 changes: 8 additions & 4 deletions pfsspy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ def is_full_sun_synoptic_map(m, error=False):


def _is_full_sun_car(m, error=False):
shape = m.data.shape

dphi = m.meta['cdelt1']
phi = m.data.shape[1] * dphi
phi = shape[1] * dphi
if not np.allclose(phi, 360, atol=0.1):
if error:
raise ValueError('Number of points in phi direction times '
Expand All @@ -159,7 +161,7 @@ def _is_full_sun_car(m, error=False):
return False

dtheta = m.meta['cdelt2']
theta = m.data.shape[0] * dtheta
theta = shape[0] * dtheta
if not np.allclose(theta, 180, atol=0.1):
if error:
raise ValueError('Number of points in theta direction times '
Expand All @@ -170,8 +172,10 @@ def _is_full_sun_car(m, error=False):


def _is_full_sun_cea(m, error=False):
shape = m.data.shape

dphi = m.meta['cdelt1']
phi = m.data.shape[1] * dphi
phi = shape[1] * dphi
if not np.allclose(phi, 360, atol=0.1):
if error:
raise ValueError('Number of points in phi direction times '
Expand All @@ -180,7 +184,7 @@ def _is_full_sun_cea(m, error=False):
return False

dtheta = m.meta['cdelt2']
theta = m.data.shape[0] * dtheta * np.pi / 2
theta = shape[0] * dtheta * np.pi / 2
if not np.allclose(theta, 180, atol=0.1):
if error:
raise ValueError('Number of points in theta direction times '
Expand Down

0 comments on commit 0be3a9d

Please sign in to comment.