Skip to content

Commit

Permalink
Merge pull request #1756 from larrymanley/aiaprep_fix
Browse files Browse the repository at this point in the history
Fix for aiaprep - issue #1691
  • Loading branch information
Cadair committed May 18, 2016
2 parents 3a1a6a9 + 056119f commit 95bbe48
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.idea
.pydevproject
.settings
.project
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Latest
------
* Fixed `aiaprep` to return properly sized map.

* Deprecation warnings fixed when using image coalignment.
* Sunpy is now Python 3.x compatible (3.4 and 3.5).
Expand Down
11 changes: 10 additions & 1 deletion sunpy/instr/aia.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Provides processing routines for data captured with the AIA instrument on SDO.
"""
import numpy as np
import astropy.units as u

from sunpy.map.sources.sdo import AIAMap
Expand Down Expand Up @@ -49,7 +50,15 @@ def aiaprep(aiamap):
scale = 0.6*u.arcsec # pragma: no cover # can't test this because it needs a full res image
scale_factor = aiamap.scale.x / scale

newmap = aiamap.rotate(recenter=True, scale=scale_factor.value, missing=aiamap.min())
tempmap = aiamap.rotate(recenter=True, scale=scale_factor.value, missing=aiamap.min())

# extract center from padded aiamap.rotate output
# crpix1 and crpix2 will be equal (recenter=True), as aiaprep does not work with submaps
center = np.floor(tempmap.meta['crpix1'])
range_side = (center + np.array([-1, 1]) * aiamap.data.shape[0] / 2) * u.pix
newmap = tempmap.submap(range_side, range_side)

newmap.meta['r_sun'] = newmap.meta['rsun_obs'] / newmap.meta['cdelt1']
newmap.meta['lvl_num'] = 1.5

return newmap
2 changes: 2 additions & 0 deletions sunpy/instr/tests/test_aia.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
def test_aiaprep():
# Test that header info for the map has been correctly updated
# Check all of these for Map attributes and .meta values?
# Check array shape
assert prep_map.data.shape == original.data.shape
# Check crpix values
assert prep_map.meta['crpix1'] == prep_map.data.shape[1]/2.0 + 0.5
assert prep_map.meta['crpix2'] == prep_map.data.shape[0]/2.0 + 0.5
Expand Down

0 comments on commit 95bbe48

Please sign in to comment.