<commit_before>"""
This module provides routines for applying solar rotation functions to
mapcubes.
"""

import numpy as np
from astropy import units as u

# SunPy imports
from sunpy.physics.transforms.differential_rotation import rot_hpc
from sunpy.image.coalignment import apply_shifts

__author__ = '<NAME>'

__all__ = ['mapcube_solar_derotate']


def mapcube_solar_derotate(mc, layer_index=0, clip=True,
                               return_displacements_only=False,
                               with_displacements=False, **kwargs):
    """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
    to compensate for solar rotation.

    Parameters
    ----------
    mc : `~sunpy.map.MapCube`
        A mapcube of shape (ny, nx, nt), where nt is the number of layers in
        the mapcube.

    layer_index : int
        Solar derotation displacements of all maps in the mapcube are assumed
        to be relative to the layer in the mapcube indexed by layer_index.

    clip : bool
        If True, then clip off x, y edges in the datacube that are potentially<commit_msg>updates to doumentation<commit_after>"""
This module provides routines for applying solar rotation functions to
mapcubes.
"""

import numpy as np
from astropy import units as u

# SunPy imports
from sunpy.physics.transforms.differential_rotation import rot_hpc
from sunpy.image.coalignment import apply_shifts

__author__ = '<NAME>'

__all__ = ['mapcube_solar_derotate']


def mapcube_solar_derotate(mc, layer_index=0, clip=True,
                               return_displacements_only=False,
                               with_displacements=False, **kwargs):
    """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
    to compensate for solar rotation.

    Parameters
    ----------
    mc : `sunpy.map.MapCube`
        A mapcube of shape (ny, nx, nt), where nt is the number of layers in
        the mapcube.

    layer_index : int
        Solar derotation displacements of all maps in the mapcube are assumed
        to be relative to the layer in the mapcube indexed by layer_index.

    clip : bool
        If True, then clip off x, y edges in the datacube that are potentially
{'fraction_non_alphanumeric': 0.0417541404245393, 'fraction_numerical': 0.00046652670865407047, 'mean_word_length': 2.9888372093023254, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3389294', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1105, 'n_words': 593}