Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for aiaprep - issue #1691 #1756

Merged
merged 4 commits into from
May 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The routine aiaprep now guaranteed to return 4096 by 4096 pixel map.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wafels It will also work for full-disk images that have been resized (2048^2, 1024^2, etc.), but not submaps.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So full field of view and centered on the Sun? What is the problem with
submaps?

On Mon, May 16, 2016 at 12:48 PM, Larry Manley notifications@github.com
wrote:

In CHANGELOG.md
#1756 (comment):

@@ -1,6 +1,6 @@
Latest


+* Fixed aiaprep to return properly sized map.

@wafels https://github.com/wafels It will also work for full-disk
images that have been resized (2048^2, 1024^2, etc.), but not submaps.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/sunpy/sunpy/pull/1756/files/e4299af358aa0ea61d676789839b0feec7754479#r63384608

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aiaprep is for derotating, recentering, and scaling to exactly 0.6 arcsec/pixel and is therefore not appropriate for submaps.


* 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you assure it doesn't work for a submap? I've just tried and it didn't show any error or warning that I should not being doing this. Maybe raising an error if the dimensions are not right would be better than just proceed as normal and produce bad data:

>>> saia_map = aia_map.submap(u.Quantity([30, 809], u.pix), u.Quantity([35, 789], u.pix))
>>> saia_map_prep = sunpy.instr.aia.aiaprep(saia_map)
>>> saia_map.dimensions
Pair(x=<Quantity 779.0 pix>, y=<Quantity 754.0 pix>)
>>> saia_map_prep.dimensions
Pair(x=<Quantity 754.0 pix>, y=<Quantity 741.0 pix>)
>>> saia_map.xrange     
>>> <Quantity [-1156.8,  712.8] arcsec>
>>> saia_map_prep.xrange    
<Quantity [-903.6, 906. ] arcsec>
>>> saia_map.yrange     
<Quantity [-1144.8,  664.8] arcsec>
>>> saia_map_prep.yrange
<Quantity [-873.6, 904.8] arcsec>

center = np.floor(tempmap.meta['crpix1'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you only use crpix1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crpix1 and crpix2 will always be the same (recenter=True) - aiaprep doesn't work on submaps

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add that as a comment to clairify for future Stu?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment and docstring?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just an inline comment above the line will suffice, it's a suble implementation detail that's all.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additionally a test that catches the submap case would be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestions on how to do that? Just checking the equality of the dimensions wouldn't be sufficient. Rather than raising an error, how about a warning and document that aiaprep should be used before anything else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer an error than a warning, as warning could be disable... and this should be a "not to do".
I'm not too familiar with AIA operations to know whether they will have images with different sizes in some situations (or not squared). I know sometimes they've pointed out but I don't know how often that happens and how we should prep these images. In any case I would say that the size of both axis being the same and that the observing range is larger than the sun size could be a good start.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All AIA images are 4096x4096. There's a Quality keyword that, if non-zero, indicates through bit flags if it's a calibration image, dark image, etc.

# 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