Last active
February 10, 2021 22:45
-
-
Save nabobalis/8c6c8e98b23df393b012efae47ad0f3c to your computer and use it in GitHub Desktop.
Sample Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
from sunpy import map as smap | |
import pyflct | |
import astropy.units as u | |
from astropy.coordinates import SkyCoord | |
from sunpy.net import Fido | |
from sunpy.net import attrs as a | |
def crop(smap): | |
top_right = SkyCoord(-850 * u.arcsec, -300 * | |
u.arcsec, frame=smap.coordinate_frame) | |
bottom_left = SkyCoord(-1050 * u.arcsec, -450 * | |
u.arcsec, frame=smap.coordinate_frame) | |
return(smap.submap(bottom_left, top_right)) | |
attrs_time = a.Time('2015/10/16 21:30:00', '2015/10/16 22:00:00') | |
result = Fido.search(attrs_time, a.Instrument.aia, a.Wavelength(304*u.AA)) | |
files = Fido.fetch(result) | |
amap = smap.Map(files[50]) | |
bmap = smap.Map(files[51]) | |
amap_submap = crop(amap) | |
bmap_submap = crop(bmap) | |
image1 = amap_submap.data / amap_submap.data.max() | |
image2 = bmap_submap.data / bmap_submap.data.max() | |
# If I recall deltas is meant to be in pixel size so 0.6" * 725km to get units of velocity in km/s | |
vel_x, vel_y, vm = pyflct.flct(image1, image2, 12, 0.6*725, 2, biascor=True) | |
X = np.arange(0, amap_submap.data.shape[1], 1) | |
Y = np.arange(0, amap_submap.data.shape[0], 1) | |
U, V = np.meshgrid(X, Y) | |
fig = plt.figure(figsize=(12, 4)) | |
ax1 = fig.add_subplot(121) | |
ax1.imshow(image1, origin="lower", vmin=np.percentile( | |
image1, 20), vmax=np.percentile(image1, 99)) | |
ax1.set_title("First Image "+str(amap_submap.date.value)) | |
ax2 = fig.add_subplot(122) | |
ax2.imshow(image2, origin="lower", vmin=np.percentile( | |
image2, 20), vmax=np.percentile(image2, 99)) | |
ax2.quiver(U, V, vel_x, vel_y, scale=5000) | |
ax2.set_title("Second Image "+str(bmap_submap.date.value)) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment