sunpy/sunpy — pull request #1176 by wafels (2014-09-08 19:30:11+00:00)
Title: Application of solar rotation compensation to mapcubes

Now with improved commit history!

This PR provides for the application of solar differential rotation to mapcubes. It generalizes the previous "image coalignment by template matching" code by creating a function (apply_shifts) that applies shifts to a mapcube, and returns a mapcube. This function is used by both the image coalignment and solar derotation functions. All the functions in the PR should now only accept input using astropy units where appropriate, and return astropy units, where appropriate.

From the docstrings...

*Move the layers in a mapcube according to solar rotation. The center
of the map is used to calculate the position of each mapcube layer. Shifts
are calculated relative to a specified layer in the mapcube.
When using this functionality, it is a good idea to check that the
shifts that were applied to were reasonable and expected. One way of
checking this is to animate the original mapcube, animate the derotated
mapcube, and compare the differences you see to the calculated shifts.

An example use is as follows. If you select data from the SDO cutout
service, it is common to not use the solar tracking implemented by this
service. This is because (at time of writing) the solar tracking
implemented by that service moves the image by single pixels at a time.
This is not optimal for many use cases, as it introduces artificial jumps
in the data. So with solar tracking not chosen, the selected area is
like a window through which you can see the Sun rotating underneath. If
you read all those in to a mapcube, this function will shift the images
appropriately to compensate for solar rotation so that features remain approximately under the same pixel.*

There is the tacit assumption here that *differential rotation* of each image layer is not required. This means that the x, y extent and duration of the mapcubes are small enough that differential rotation based on latitude is not required.

A question: at the moment both the "image coalignment by template matching" and solar derotation functions clip the mapcube by default, to take account of the image shifts The resulting mapcube has data at all times and positions. Perhaps the default should be no clipping so the user sees even more obviously that the data have been shifted in some way? With no clipping some positions and times in the mapcube will have no data in them. Questions? Comments?

Note that there are some private functions indicated by the leading "_" that should be replaced once a working accurate ephemeris is available to sunpy.