예제 #1
0
def calculateLons(initial_submap, curr_submap, Coords):
    """
    Calculates where the coordinates should be given a time difference between current and initial
    Coords is the Coord = {"lon":(lon0,lonf), "lat":(lat0,latf)} object
    """

    import astropy.units as u
    from astropy.coordinates import SkyCoord
    from sunpy.coordinates import RotatedSunFrame

    # Subtract Time of current map to previous map

    dinit = initial_submap.date
    dcurr = curr_submap.date
    dt = dcurr - dinit

    startlon0, startlonF = Coords["lon"][0], Coords["lon"][1]
    dlon = startlonF - startlon0
    startlat0, startlatF = Coords["lat"][0], Coords["lat"][1]

    start_coord = SkyCoord(
        startlon0,
        Coords["lat"][0],
        frame="heliographic_stonyhurst",
        obstime=dinit,
    )
    rotated_coord = RotatedSunFrame(base=start_coord, duration=dt.to(
        u.second)).transform_to(start_coord.frame)

    rotlon0 = rotated_coord.lon
    rotlonF = rotated_coord.lon + dlon

    rotCoords = {
        "lon": (rotlon0, rotlonF),
        "lat": (startlat0, startlatF),
    }  # Latitude is constant

    return rotCoords
예제 #2
0
sidereal_period = 360 * u.deg / sidereal_rotation_rate
print(sidereal_period)

##############################################################################
# We use `~sunpy.coordinates.metaframes.RotatedSunFrame` to rotate the
# meridian by one sidereal period using each of the available
# differential-rotation models.  See
# :func:`~sunpy.physics.differential_rotation.diff_rot` for details on each
# model.

rotated_meridian = {}
for model in ['howard', 'snodgrass', 'allen', 'rigid']:
    rotated_meridian[model] = SkyCoord(
        RotatedSunFrame(base=meridian,
                        duration=sidereal_period,
                        rotation_model=model))

##############################################################################
# Finally, we plot the differentially rotated meridians over the map, using
# :meth:`~sunpy.map.GenericMap.draw_quadrangle` to conveniently draw a line
# of constant longitude in the original frame between two endpoints.  (One
# could instead use :meth:`astropy.visualization.wcsaxes.WCSAxes.plot_coord`,
# but then ``meridian`` would need to consist of a sequence of many points
# spanning all latitudes between the two poles to render as desired.)
# Note that the "rigid" model appears as the meridian again as expected for a
# rotation of exactly one sidereal period.

plt.figure()
aiamap.plot(clip_interval=(0.5, 99.9) * u.percent)
##############################################################################
# First, load an AIA observation and define a coordinate in its coordinate
# frame (here, helioprojective Cartesian).  The appropriate rate of rotation
# is determined from the heliographic latitude of the coordinate.

aiamap = sunpy.map.Map(AIA_171_IMAGE)
point = SkyCoord(187 * u.arcsec, 283 * u.arcsec, frame=aiamap.coordinate_frame)

##############################################################################
# We can differentially rotate this coordinate by using
# `~sunpy.coordinates.metaframes.RotatedSunFrame` with an array of observation
# times.  Let's define a daily cadence for +/- five days.

durations = np.concatenate([range(-5, 0), range(1, 6)]) * u.day
diffrot_point = RotatedSunFrame(base=point, duration=durations)

##############################################################################
# To see what this coordinate looks like in "real" helioprojective
# Cartesian coordinates, we can transform it back to the original frame.
# Since these coordinates are represented in the original frame, they will not
# account for the changing position of the observer over this same time range.

transformed_diffrot_point = diffrot_point.transform_to(aiamap.coordinate_frame)
print(transformed_diffrot_point)

##############################################################################
# Let's plot the original coordinate and the differentially rotated
# coordinates on top of the AIA observation.

fig = plt.figure()
예제 #4
0
##############################################################################
# Let's define the output frame to be five days in the future for an observer
# at Earth (i.e., about five degrees offset in heliographic longitude compared
# to the location of AIA in the original observation).

out_time = in_time + 5 * u.day
out_frame = Helioprojective(observer='earth', obstime=out_time)

##############################################################################
# For the reprojection, the definition of the target frame can be
# counter-intuitive.  We will be transforming from the original frame to the
# `~sunpy.coordinates.metaframes.RotatedSunFrame` version of the output frame
# with ``rotated_time`` set to the time of the original frame.

rot_frame = RotatedSunFrame(base=out_frame, rotated_time=in_time)
print(rot_frame)

##############################################################################
# Construct a WCS object for the output map with the target
# ``RotatedSunHelioprojective`` frame specified instead of the regular
# `~sunpy.coordinates.frames.Helioprojective` frame.
# If one has an actual ``Map`` object at the desired output
# time (e.g., the actual AIA observation at the output time), one can use the
# WCS object from that ``Map`` object (e.g., ``mymap.wcs``) instead of
# constructing a custom WCS.

out_shape = aiamap.data.shape
out_center = SkyCoord(0 * u.arcsec, 0 * u.arcsec, frame=out_frame)
header = sunpy.map.make_fitswcs_header(out_shape,
                                       out_center,
예제 #5
0
aiamap = sunpy.map.Map(AIA_171_IMAGE)
fig = plt.figure()
ax = plt.subplot(projection=aiamap)
aiamap.plot(clip_interval=(1., 99.95) * u.percent)

##############################################################################
# Lines of constant longitude prior to differential rotation

# sphinx_gallery_defer_figures

overlay1 = ax.get_coords_overlay('heliographic_stonyhurst')
overlay1[0].set_ticks(spacing=15. * u.deg)
overlay1[1].set_ticks(spacing=90. * u.deg)
overlay1.grid(ls='-', color='white')

##############################################################################
# Differentially rotating the lines of constant longitude by 27 days
# Be aware that the differentially rotated lines are plotted in the
# original coordinate frame, so it doesn't account for any motion of the
# observer over 27 days.

rs_hgs = RotatedSunFrame(base=HeliographicStonyhurst(obstime=aiamap.date),
                         duration=27 * u.day)
overlay2 = ax.get_coords_overlay(rs_hgs)
overlay2[0].set_ticks(spacing=15. * u.deg)
overlay2[1].set_ticks(spacing=90. * u.deg)
overlay2.grid(ls='-', color='blue')

plt.show()