I am trying to get a cutouts of active regions in both AIA data and HMI data. However, the size of image is different for both the images.
Can someone help me with any python function to do so?
I tried t0 use out_hmi = map_hmi.reproject_to(map_aia.wcs)
I am not getting correct output with this.
Can you share the script you’re using to download the data (or links to the data files), the script you’re using to try and reproject the files, and what you think is wrong with the output? Without those it isn’t really possible to work out what is going wrong with your code.
keys_hmi, segments = c.query(‘hmi.M_720s[2013.01.03_01:00:00_TAI]’, key=drms.const.all, seg=‘magnetogram’)
url_hmi = ‘http://jsoc.stanford.edu’ + segments.magnetogram[0]
photosphere_full_image = fits.getdata(url_hmi)
header = dict(keys_hmi.iloc[0])
header[‘DATE-OBS’] = keys_hmi.DATE__OBS[0]
header[‘HGLN_OBS’] = 0.0
if (keys_hmi.CROTA2[0] > 5.0):
photosphere_full_image = np.rot90(photosphere_full_image,2)
keys_aia, segments = c.query(‘aia.lev1[2013.01.03_01:00:00_TAI/12s][?WAVELNTH=335?]’, key=drms.const.all, seg=‘image_lev1’)
url_aia = ‘http://jsoc.stanford.edu’ + segments.image_lev1[0] # add the jsoc.stanford.edu suffix to the segment name
chromosphere_image = fits.open(url_aia, cache = False) # download the data
chromosphere_header = dict(keys_aia.iloc[0])
chromosphere_image.verify(“fix”)
(keys_ccd.CDELT1[0])/(keys_aia.CDELT1[0])
if (keys_aia.CROTA2[0] > 5.0):
chromosphere_image[1].data = np.rot90(chromosphere_image[1].data,2)
from sunpy.map import Map
m = Map(chromosphere_image[1].data, chromosphere_header)
n = Map(photosphere_full_image, header)
out_hmi=n.reproject_to(m.wcs)
The above lines I am using to download the images and to remap them to same size.
However it is neither remapping the images nor plotting them correct. When I tried to plot them, I am getting very weird output. Also the images are not remapped.
Hello,
I will run this code and see what happens but could you post an example of the output you are getting?
Edit:
I ran this:
from astropy.io import fits
from sunpy.map import Map
import drms
import matplotlib.pyplot as plt
drms_client = drms.Client(email="nabil.freij@gmail.com")
keys_hmi, segments = drms_client.query('hmi.M_720s[2013.01.03_01:00:00_TAI]', key=drms.const.all, seg='magnetogram')
url_hmi = 'http://jsoc.stanford.edu' + segments.magnetogram[0]
hmi_data = fits.getdata(url_hmi)
header = dict(keys_hmi.iloc[0])
header['DATE-OBS'] = keys_hmi.DATE__OBS[0]
header['HGLN_OBS'] = 0.0
hmi_map = Map(hmi_data, header)
# De-rotate HMI
hmi_map = hmi_map.rotate()
keys_aia, segments = drms_client.query('aia.lev1[2013.01.03_01:00:00_TAI/12s][?WAVELNTH=335?]', key=drms.const.all, seg='image_lev1')
url_aia = 'http://jsoc.stanford.edu' + segments.image_lev1[0]
aia_map = Map(url_aia)
aia_map.plot()
plt.show()
hmi_map.plot()
plt.show()
out_hmi = hmi_map.reproject_to(aia_map.wcs)
out_hmi.plot()
plt.show()
The HMI before and after plots don’t look that different from a quick glance.
Original HMI Map:
Reproject Map:
The data array is now the same size as AIA now and according to the WCS now has the same CDELTA.
Is this what you are expecting?