This notebook shows measurements of the spectral line curvature and instrumental broadening of the red detector. Link to Figure 13.
(The internal hyperlink only works on GitHub Pages or nbviewer. Do not click when viewing the notebook on GitHub.)
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
import numpy as np
from astropy.io import fits
from astropy.nddata import CCDData
import astropy.units as u
from astropy.modeling import models, fitting
from glob import glob
import os
from astropy.visualization import ZScaleInterval, ImageNormalize, LogStretch, AsymmetricPercentileInterval, ManualInterval
import h5py
from datetime import datetime, timedelta
from ccdproc import ImageFileCollection
import pandas as pd
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
from matplotlib.ticker import AutoLocator, AutoMinorLocator, FixedLocator, FixedFormatter, LogLocator
import cmcrameri.cm as cmcm
from juanfit import SpectrumFitSingle, gaussian
from scipy import ndimage
from scipy.optimize import curve_fit
from scipy.interpolate import UnivariateSpline
red_path = "../../src/EclipseSpectra2017/MikesData/VaderEclipseDayRed2017aug21/"
with h5py.File("../../sav/Eclipse/Bias/master_bias_dc_red_1s_proto.h5", 'r') as hf:
bias_dc_red_1s = hf['image'][:]
helium_im_collection = ImageFileCollection(red_path,
glob_include="HeliumrRedpoint01s_920*.fit")
helium_im_df = helium_im_collection.summary.to_pandas()
helium_image_cube = np.zeros((1040,1392,10))
for ii, row_ in helium_im_df.iterrows():
helium_image_cube[:,:,ii] = CCDData.read(os.path.join(red_path,row_["file"]),unit="adu").data - bias_dc_red_1s
WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.198356 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.198356 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.198368 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.198368 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.198380 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.198380 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.198391 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.198391 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.198403 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.198403 from DATE-OBS'.
helium_im_aver = np.mean(helium_image_cube,axis=2)
yaxis_slice = slice(300,750)
norm = ImageNormalize(helium_im_aver, stretch=LogStretch())
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),helium_im_aver,norm=norm,cmap=cmcm.lajolla, rasterized=True)
ax.axis("scaled")
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
(300.0, 750.0)
fig, ax = plt.subplots(figsize=(10,6))
ax.plot(np.arange(1392), np.mean(helium_im_aver[300:305,:],axis=0))
ax.set_xlim(1285,1300)
(1285.0, 1300.0)
helium_im_aver.shape
(1040, 1392)
class TraceSingleCurvature:
def __init__(self,image, init_start, init_end, xarray = None,ybin=5,plot_fit=None):
self.nbins = int(image.shape[0]/ybin)
self.xpos = np.zeros(self.nbins)
self.xwidth = np.zeros(self.nbins)
self.xpos_err = np.zeros(self.nbins)
self.xwidth_err = np.zeros(self.nbins)
if xarray is None:
self.xarray = np.arange(image.shape[1])
self.wvl_region_half_length = int(np.ceil((init_end - init_start)/2))
first_bin_slice = slice(init_start,init_end)
first_bin = np.mean(image[:ybin,first_bin_slice],axis=0)
xpos_guess = init_start + np.argmax(first_bin)
popt, pcov = curve_fit(gaussian_bg,xdata=self.xarray[first_bin_slice],ydata=first_bin,
p0=[self.xarray[xpos_guess], first_bin[xpos_guess - first_bin_slice.start]*2, 2, 0])
self.xpos[0] = popt[0]
self.xpos_err[0] = np.sqrt(pcov[0,0])
self.xwidth[0] = popt[2]
self.xwidth_err[0] = np.sqrt(pcov[2,2])
for ii in range(1,self.nbins):
ii_slice = slice(int(np.rint(self.xpos[ii - 1]) - self.wvl_region_half_length),
int(np.rint(self.xpos[ii - 1]) + self.wvl_region_half_length))
ii_bin = np.mean(image[int(ii*ybin):int((ii+1)*ybin),ii_slice],axis=0)
xpos_guess = ii_slice.start + np.argmax(ii_bin)
popt, pcov = curve_fit(gaussian_bg,xdata=self.xarray[ii_slice],ydata=ii_bin,
p0=[self.xarray[xpos_guess], ii_bin[xpos_guess - ii_slice.start]*2, 2, 0])
self.xpos[ii] = popt[0]
self.xpos_err[ii] = np.sqrt(pcov[0,0])
self.xwidth[ii] = popt[2]
self.xwidth_err[ii] = np.sqrt(pcov[2,2])
if plot_fit is not None:
if ii in plot_fit:
fig, ax = plt.subplots(figsize=(8,6),constrained_layout=True)
ax.step(self.xarray[ii_slice], ii_bin,where="mid")
ax.plot(np.linspace(self.xarray[ii_slice][0], self.xarray[ii_slice][-1],50),
gaussian_bg(np.linspace(self.xarray[ii_slice][0], self.xarray[ii_slice][-1],50),
*popt))
ax.text(0.02,0.97,r"$\Delta \lambda = {:.2f} \pm {:.2f}$".format(popt[2],self.xwidth_err[ii]),fontsize=16,transform=ax.transAxes,
va="top",ha="left")
def gaussian_bg(wvl, line_wvl, int_total, fwhm, bg):
return gaussian(wvl, line_wvl=line_wvl, int_total=int_total, fwhm=fwhm) + bg
test_1 = TraceSingleCurvature(helium_im_aver[300:750,:],init_start=145,init_end=157)
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),helium_im_aver,norm=norm,cmap=cmcm.lajolla, rasterized=True)
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
test_1_curve = test_1.xpos
test_1_ypix = np.arange(302,750,5)
#ax.step(test_1_curve, test_1_ypix, color="white",alpha=0.7)
ax.set_xlim(100,200)
test_1_spl = UnivariateSpline(test_1_ypix, test_1_curve)
ax.plot(test_1_spl(np.arange(305,745)),np.arange(305,745),color="red")
[<matplotlib.lines.Line2D at 0x18c01ded0>]
test_2 = TraceSingleCurvature(helium_im_aver[300:750,:],init_start=255,init_end=267)
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),helium_im_aver,norm=norm,cmap=cmcm.lajolla, rasterized=True)
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
test_2_curve = test_2.xpos
#ax.step(test_1_curve, test_1_ypix, color="white",alpha=0.7)
ax.set_xlim(200,300)
test_2_spl = UnivariateSpline(test_1_ypix, test_2_curve)
ax.plot(test_2_spl(np.arange(305,745)),np.arange(305,745),color="red")
[<matplotlib.lines.Line2D at 0x18c365b90>]
test_3 = TraceSingleCurvature(helium_im_aver[300:750,:],init_start=393,init_end=403)
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),helium_im_aver,norm=norm,cmap=cmcm.lajolla, rasterized=True)
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
test_3_curve = test_3.xpos
#ax.step(test_1_curve, test_1_ypix, color="white",alpha=0.7)
ax.set_xlim(350,450)
test_3_spl = UnivariateSpline(test_1_ypix, test_3_curve)
ax.plot(test_3_spl(np.arange(305,745)),np.arange(305,745),color="red")
[<matplotlib.lines.Line2D at 0x18c54bbd0>]
test_4 = TraceSingleCurvature(helium_im_aver[300:750,:],init_start=506,init_end=520,plot_fit=[10])
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),helium_im_aver,norm=norm,cmap=cmcm.lajolla, rasterized=True)
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
test_4_curve = test_4.xpos
#ax.step(test_1_curve, test_1_ypix, color="white",alpha=0.7)
ax.set_xlim(450,550)
test_4_spl = UnivariateSpline(test_1_ypix, test_4_curve)
ax.plot(test_4_spl(np.arange(305,745)),np.arange(305,745),color="red")
[<matplotlib.lines.Line2D at 0x18c8d0790>]
with h5py.File("../../sav/Eclipse/InstWidth/HeI_D3_2_width_red_curcorr.h5", 'r') as hf:
HeI_D3_fwhm_curcorr = hf["HeI_D3_fwhm"][:][:,0]
HeI_D3_fwhm_curcorr_err = hf["HeI_D3_fwhm_err"][:][:,0]
fig, ax = plt.subplots(figsize=(16,6),constrained_layout=True)
ax.errorbar(test_1_ypix,test_4.xwidth,test_4.xwidth_err,
color="#CC543A",ls="none",marker="o",
markersize=15,capsize=5,lw=2.5,zorder=15,markeredgecolor='white',
markeredgewidth=2.5,alpha=0.9,capthick=2.5)
ax.tick_params(labelsize=16)
fig, ax = plt.subplots(figsize=(16,6),constrained_layout=True)
ax.errorbar(test_1_ypix,test_4.xwidth,test_4.xwidth_err,
color="#CC543A",ls="none",marker="o",
markersize=15,capsize=5,lw=2.5,zorder=15,markeredgecolor='white',
markeredgewidth=2.5,alpha=0.9,capthick=2.5,label=r"uncorr")
ax.errorbar(np.arange(352, 700, 5), HeI_D3_fwhm_curcorr, HeI_D3_fwhm_curcorr_err,
color="#0089A7",ls="none",marker="D",
markersize=15,capsize=5,lw=2.5,zorder=15,markeredgecolor='white',
markeredgewidth=2.5,alpha=0.9,capthick=2.5,label=r"corr")
ax.tick_params(labelsize=16)
ax.set_ylabel("FWHM",fontsize=16)
ax.set_xlabel("CCD-Y [Pixel]",fontsize=16)
ax.axhline(2.12,color="grey",ls="--",lw=2,alpha=0.7,zorder=0)
plt.legend(fontsize=16,loc="upper left",frameon=False)
<matplotlib.legend.Legend at 0x1aeec9d50>
with h5py.File("../../sav/Eclipse/InstWidth/HeI_D3_2_width_red_uncorr.h5", 'w') as hf:
df_HeI_D3_fwhm_uncorr = hf.create_dataset("HeI_D3_fwhm_uncorr", data=test_4.xwidth)
df_HeI_D3_fwhm_uncorr_err = hf.create_dataset("HeI_D3_fwhm_uncorr_err", data=test_4.xwidth_err)
df_HeI_D3_fwhm_ccdy = hf.create_dataset("HeI_D3_fwhm_ccdy", data=test_1_ypix)
test_5 = TraceSingleCurvature(helium_im_aver[300:750,:],init_start=697,init_end=709)
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),helium_im_aver,norm=norm,cmap=cmcm.lajolla, rasterized=True)
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
test_5_curve = test_5.xpos
# ax.step(test_5_curve, test_1_ypix, color="white",alpha=0.7)
ax.set_xlim(650,750)
test_5_spl = UnivariateSpline(test_1_ypix, test_5_curve)
ax.plot(test_5_spl(np.arange(305,745)),np.arange(305,745),color="red")
[<matplotlib.lines.Line2D at 0x1af16f490>]
test_6 = TraceSingleCurvature(helium_im_aver[300:750,:],init_start=818,init_end=830)
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),helium_im_aver,norm=norm,cmap=cmcm.lajolla, rasterized=True)
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
test_6_curve = test_6.xpos
#ax.step(test_1_curve, test_1_ypix, color="white",alpha=0.7)
ax.set_xlim(770,870)
test_6_spl = UnivariateSpline(test_1_ypix, test_6_curve)
ax.plot(test_6_spl(np.arange(305,745)),np.arange(305,745),color="red")
[<matplotlib.lines.Line2D at 0x1b56bc850>]
with h5py.File("../../sav/Eclipse/InstWidth/HeI_6678_2_width_red_curcorr.h5", 'r') as hf:
HeI_6678_fwhm_curcorr = hf["HeI_6678_fwhm"][:][:,0]
HeI_6678_fwhm_curcorr_err = hf["HeI_6678_fwhm_err"][:][:,0]
fig, ax = plt.subplots(figsize=(16,6),constrained_layout=True)
ax.errorbar(test_1_ypix,test_6.xwidth,test_6.xwidth_err,
color="#CC543A",ls="none",marker="o",
markersize=15,capsize=5,lw=2.5,zorder=15,markeredgecolor='white',
markeredgewidth=2.5,alpha=0.9,capthick=2.5)
ax.tick_params(labelsize=16)
fig, ax = plt.subplots(figsize=(16,6),constrained_layout=True)
ax.errorbar(test_1_ypix,test_6.xwidth,test_6.xwidth_err,
color="#CC543A",ls="none",marker="o",
markersize=15,capsize=5,lw=2.5,zorder=15,markeredgecolor='white',
markeredgewidth=2.5,alpha=0.9,capthick=2.5,label="uncorr")
ax.errorbar(np.arange(352, 700, 5), HeI_6678_fwhm_curcorr, HeI_6678_fwhm_curcorr_err,
color="#0089A7",ls="none",marker="D",
markersize=15,capsize=5,lw=2.5,zorder=15,markeredgecolor='white',
markeredgewidth=2.5,alpha=0.9,capthick=2.5,label=r"corr")
ax.tick_params(labelsize=16)
ax.set_ylabel("FWHM",fontsize=16)
ax.set_xlabel("",fontsize=16)
ax.axhline(1.86,color="grey",ls="--",lw=2,alpha=0.7,zorder=0)
plt.legend(fontsize=16,loc="upper left",frameon=False)
<matplotlib.legend.Legend at 0x1bbca0210>
test_7 = TraceSingleCurvature(helium_im_aver[300:750,:],init_start=885,init_end=895)
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),helium_im_aver,norm=norm,cmap=cmcm.lajolla, rasterized=True)
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
test_7_curve = test_7.xpos
#ax.step(test_1_curve, test_1_ypix, color="white",alpha=0.7)
ax.set_xlim(870,970)
test_7_spl = UnivariateSpline(test_1_ypix, test_7_curve)
ax.plot(test_7_spl(np.arange(305,745)),np.arange(305,745),color="red")
[<matplotlib.lines.Line2D at 0x1bc1b7950>]
test_8 = TraceSingleCurvature(helium_im_aver[300:750,:],init_start=1169,init_end=1184)
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),helium_im_aver,norm=norm,cmap=cmcm.lajolla, rasterized=True)
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
test_8_curve = test_8.xpos
#ax.step(test_1_curve, test_1_ypix, color="white",alpha=0.7)
ax.set_xlim(1130,1230)
test_8_spl = UnivariateSpline(test_1_ypix, test_8_curve)
ax.plot(test_8_spl(np.arange(305,745)),np.arange(305,745),color="red")
[<matplotlib.lines.Line2D at 0x1c270ad10>]
test_9 = TraceSingleCurvature(helium_im_aver[300:750,:],init_start=1270,init_end=1284)
test_10 = TraceSingleCurvature(helium_im_aver[300:750,:],init_start=1285,init_end=1300)
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),helium_im_aver,norm=norm,cmap=cmcm.lajolla, rasterized=True)
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
test_9_curve = test_9.xpos
test_10_curve = test_10.xpos
#ax.step(test_1_curve, test_1_ypix, color="white",alpha=0.7)
ax.set_xlim(1230,1330)
test_9_spl = UnivariateSpline(test_1_ypix, test_9_curve)
test_10_spl = UnivariateSpline(test_1_ypix, test_10_curve)
ax.plot(test_9_spl(np.arange(305,745)),np.arange(305,745),color="red")
ax.plot(test_10_spl(np.arange(305,745)),np.arange(305,745),color="red")
[<matplotlib.lines.Line2D at 0x1c8c64c50>]
fig, ax = plt.subplots(figsize=(10,6),constrained_layout=True)
ax.pcolormesh(np.arange(1392),np.arange(1040),helium_im_aver,norm=norm,cmap=cmcm.lajolla, rasterized=True,alpha=0.5)
ax.tick_params(labelsize=16)
spls = (test_1_spl,test_2_spl,test_3_spl,test_4_spl,test_5_spl,
test_6_spl,test_7_spl,test_8_spl,test_9_spl,test_10_spl)
for spl_ in spls :
ax.plot(spl_(np.arange(305,745)),np.arange(305,745),color="red")
fig, ax = plt.subplots(figsize=(10,6))
xpos_y600 = np.array([spl_(600) for spl_ in spls])
xpos_y400 = np.array([spl_(400) for spl_ in spls])
xshift_y600 = xpos_y600 - xpos_y400
ax.scatter(xpos_y600, xshift_y600)
ax.tick_params(labelsize=16)
hydrogen_im_collection = ImageFileCollection(red_path,
glob_include="HydrogenRedpoint1s_947*.fit")
hydrogen_im_df = hydrogen_im_collection.summary.to_pandas()
hydrogen_image_cube = np.zeros((1040,1392,10))
for ii, row_ in hydrogen_im_df.iterrows():
hydrogen_image_cube[:,:,ii] = CCDData.read(os.path.join(red_path,row_["file"]),unit="adu").data - bias_dc_red_1s
WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.206852 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.206852 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.206863 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.206863 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.206875 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.206875 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.206887 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.206887 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.206898 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.206898 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.206910 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57987.206910 from DATE-OBS'.
hydrogen_im_aver = np.mean(hydrogen_image_cube,axis=2)
yaxis_slice = slice(300,750)
norm_hydrogen = ImageNormalize(hydrogen_im_aver, stretch=LogStretch())
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),hydrogen_im_aver,norm=norm_hydrogen,cmap=cmcm.lajolla, rasterized=True)
ax.axis("scaled")
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
(300.0, 750.0)
fig, ax = plt.subplots(figsize=(10,6))
ax.plot(np.arange(1392), np.mean(hydrogen_im_aver[300:305,:],axis=0))
ax.set_xlim(1320,1335)
(1320.0, 1335.0)
test_halpha1 = TraceSingleCurvature(hydrogen_im_aver[300:750,:],init_start=50,init_end=64)
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),hydrogen_im_aver,norm=norm_hydrogen,cmap=cmcm.lajolla, rasterized=True)
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
test_halpha1_curve = test_halpha1.xpos
test_halpha1_ypix = np.arange(302,750,5)
#ax.step(test_1_curve, test_1_ypix, color="white",alpha=0.7)
ax.set_xlim(0,100)
test_halpha1_spl = UnivariateSpline(test_halpha1_ypix, test_halpha1_curve)
ax.plot(test_halpha1_spl(np.arange(305,745)),np.arange(305,745),color="red")
[<matplotlib.lines.Line2D at 0x1967e5e90>]
test_halpha2 = TraceSingleCurvature(hydrogen_im_aver[300:750,:],init_start=448,init_end=462)
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),hydrogen_im_aver,norm=norm_hydrogen,cmap=cmcm.lajolla, rasterized=True)
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
test_halpha2_curve = test_halpha2.xpos
test_halpha2_ypix = np.arange(302,750,5)
#ax.step(test_1_curve, test_1_ypix, color="white",alpha=0.7)
ax.set_xlim(400,500)
test_halpha2_spl = UnivariateSpline(test_halpha2_ypix, test_halpha2_curve)
ax.plot(test_halpha2_spl(np.arange(305,745)),np.arange(305,745),color="red")
[<matplotlib.lines.Line2D at 0x19680fa90>]
test_halpha3 = TraceSingleCurvature(hydrogen_im_aver[300:750,:],init_start=870,init_end=884)
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),hydrogen_im_aver,norm=norm_hydrogen,cmap=cmcm.lajolla, rasterized=True)
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
test_halpha3_curve = test_halpha3.xpos
test_halpha3_ypix = np.arange(302,750,5)
#ax.step(test_1_curve, test_1_ypix, color="white",alpha=0.7)
ax.set_xlim(850,950)
test_halpha3_spl = UnivariateSpline(test_halpha3_ypix, test_halpha3_curve)
ax.plot(test_halpha3_spl(np.arange(305,745)),np.arange(305,745),color="red")
[<matplotlib.lines.Line2D at 0x1bbc0e8d0>]
test_halpha4 = TraceSingleCurvature(hydrogen_im_aver[300:750,:],init_start=1320,init_end=1335)
fig, ax = plt.subplots(figsize=(10,8))
ax.pcolormesh(np.arange(1392),np.arange(1040),hydrogen_im_aver,norm=norm_hydrogen,cmap=cmcm.lajolla, rasterized=True)
ax.tick_params(labelsize=16)
ax.set_ylim(yaxis_slice.start, yaxis_slice.stop)
test_halpha4_curve = test_halpha4.xpos
test_halpha4_ypix = np.arange(302,750,5)
#ax.step(test_1_curve, test_1_ypix, color="white",alpha=0.7)
ax.set_xlim(1300,1392)
test_halpha4_spl = UnivariateSpline(test_halpha4_ypix, test_halpha4_curve)
ax.plot(test_halpha4_spl(np.arange(305,745)),np.arange(305,745),color="red")
[<matplotlib.lines.Line2D at 0x18bb38c90>]
fig, ax = plt.subplots(figsize=(10,6),constrained_layout=True)
ax.pcolormesh(np.arange(1392),np.arange(1040),hydrogen_im_aver,norm=norm_hydrogen,cmap=cmcm.lajolla, rasterized=True,alpha=0.5)
ax.pcolormesh(np.arange(1392),np.arange(1040),helium_im_aver,norm=norm,cmap=cmcm.lajolla, rasterized=True,alpha=0.5)
ax.tick_params(labelsize=16)
spls_halpha = (test_halpha1_spl,test_halpha2_spl,test_halpha3_spl,test_halpha4_spl)
for spl_ in spls_halpha :
ax.plot(spl_(np.arange(305,745)),np.arange(305,745),color="red")
fig, ax = plt.subplots(figsize=(10,6),constrained_layout=True)
ax.pcolormesh(np.arange(1392),np.arange(1040),hydrogen_im_aver,norm=norm_hydrogen,cmap=cmcm.lajolla, rasterized=True,alpha=0.5)
ax.pcolormesh(np.arange(1392),np.arange(1040),helium_im_aver,norm=norm,cmap=cmcm.lajolla, rasterized=True,alpha=0.5)
ax.tick_params(labelsize=16)
spls_halpha = (test_halpha1_spl,test_halpha2_spl,test_halpha3_spl,test_halpha4_spl)
for ii, spl_ in enumerate(spls):
ax.plot(spl_(np.arange(305,745)),np.arange(305,745),color="red",label=r"He \textsc{i}" if ii == 0 else None)
for ii, spl_ in enumerate(spls_halpha):
ax.plot(spl_(np.arange(305,745)),np.arange(305,745),color="green",label=r"H$\alpha$" if ii == 0 else None)
plt.legend(fontsize=18,frameon=False,loc="upper right")
ax.set_xlabel("CCD-X [Pixel]",fontsize=18)
ax.set_ylabel("CCD-Y [Pixel]",fontsize=18)
plt.savefig(fname="../../figs/calib/curvature_red_test.png",format="png",dpi=150)
spls_all = (test_halpha1_spl, test_1_spl, test_2_spl, test_3_spl,
test_halpha2_spl, test_4_spl, test_5_spl, test_6_spl,
test_halpha3_spl, test_7_spl, test_8_spl, test_9_spl,
test_10_spl, test_halpha4_spl)
ypos_tofit = np.tile(np.arange(305,745,dtype=np.float64),(14,1)).T
xpos_tofit = np.zeros_like(ypos_tofit,dtype=np.float64)
for ii, spl_ in enumerate(spls_all):
xpos_tofit[:,ii] = spl_(ypos_tofit[:,ii])
xshift_tofit = xpos_tofit - xpos_tofit[95,:]
xpos_tofit
array([[ 56.22570049, 151.49703375, 261.66265698, ..., 1278.23717981, 1293.16125024, 1326.6066515 ], [ 56.21561998, 151.48434786, 261.65277172, ..., 1278.22325332, 1293.14469897, 1326.59082827], [ 56.20584676, 151.47197014, 261.64323387, ..., 1278.209697 , 1293.12851635, 1326.57539619], ..., [ 80.55510275, 175.37795907, 287.26301532, ..., 1307.62299695, 1322.26691809, 1356.59549076], [ 80.67558712, 175.5004037 , 287.38304405, ..., 1307.77226393, 1322.4198718 , 1356.74811832], [ 80.79636172, 175.62315862, 287.50331971, ..., 1307.92190764, 1322.57323271, 1356.90112565]])
chebyshev2d_init = models.Chebyshev2D(x_degree=1,y_degree=2)
fit_chebyshev2d = fitting.LevMarLSQFitter()
chebyshev2d_p = fit_chebyshev2d(chebyshev2d_init,xpos_tofit, ypos_tofit, xshift_tofit)
WARNING: Model is linear in parameters; consider using linear fitting methods. [astropy.modeling.fitting] WARNING:astropy:Model is linear in parameters; consider using linear fitting methods.
ypos_tofit_new = np.tile(test_1_ypix,(14,1)).T
xpos_tofit_new = np.stack((test_halpha1_curve, test_1_curve, test_2_curve, test_3_curve,
test_halpha2_curve, test_4_curve, test_5_curve, test_6_curve,
test_halpha3_curve, test_7_curve, test_8_curve, test_9_curve,
test_10_curve, test_halpha4_curve)).T
xshift_tofit_new = xpos_tofit_new - xpos_tofit_new[20,:]
chebyshev2d_p_new = fit_chebyshev2d(chebyshev2d_init,xpos_tofit_new, ypos_tofit_new, xshift_tofit_new)
ypos_plot, xpos_plot = np.mgrid[305:745,:1392]
fig, ax = plt.subplots(figsize=(12,6),constrained_layout=True)
im = ax.pcolormesh(xpos_plot, ypos_plot, chebyshev2d_p(xpos_plot, ypos_plot),rasterized=True)
testx_slice = slice(100,200)
testy_slice = slice(350,700)
test_rectangle = Rectangle((testx_slice.start, testy_slice.start),
testx_slice.stop - testx_slice.start,
testy_slice.stop - testy_slice.start,
edgecolor="red",facecolor='none',lw=2)
# ax.add_patch(test_rectangle)
ax.tick_params(labelsize=16)
ax.set_xlabel("CCD-X [Pixel]",fontsize=18)
ax.set_ylabel("CCD-Y [Pixel]",fontsize=18)
clb_ax = inset_axes(ax,width="5%",height= "100%",loc='lower left',
bbox_to_anchor=(1.02, 0., 1, 1),
bbox_transform=ax.transAxes,
borderpad=0)
clb = plt.colorbar(im,pad = 0.05,orientation='vertical',ax=ax,cax=clb_ax)
clb_ax.tick_params(labelsize=16)
clb_ax.yaxis.get_offset_text().set_fontsize(16)
clb_ax.set_ylabel('X-shift [Pixel]',fontsize=18)
plt.savefig(fname="../../figs/calib/curvature_2d_fit.png",format="png",dpi=150,bbox_inches="tight")
fig, ax = plt.subplots(figsize=(12,6),constrained_layout=True)
im = ax.pcolormesh(xpos_plot, ypos_plot, chebyshev2d_p(xpos_plot, ypos_plot) - \
chebyshev2d_p_new(xpos_plot, ypos_plot),
rasterized=True,vmin=-0.3,vmax=0.3,cmap="bwr")
fig, ax = plt.subplots(figsize=(12,6),constrained_layout=True)
ax.step(np.arange(1392), chebyshev2d_p(np.arange(1392), 446*np.ones(1392)))
ax.scatter(xpos_tofit[141,:],xshift_tofit[141,:])
ax.tick_params(labelsize=18)
fig, ax = plt.subplots(figsize=(12,6),constrained_layout=True)
ax.step(np.arange(305,745), chebyshev2d_p(xpos_tofit[:,5], np.arange(305,745)))
ax.scatter(ypos_tofit[:,5],xshift_tofit[:,5],color="red")
ax.tick_params(labelsize=18)
# class ChebyShevMappinig:
# def __init__(self,chebyshev_model):
# self.chebyshev_model = chebyshev_model
# def shift_func(self, output_coords):
# return (output_coords[0] - self.chebyshev_model(output_coords[0],output_coords[1]), output_coords[1])
# def shift_func(output_coords):
# return (output_coords[0],
# output_coords[1] + chebyshev2d_p(output_coords[1]+100,output_coords[0]+350))
# helium_trans_test = ndimage.geometric_transform(helium_im_aver[testy_slice, testx_slice],shift_func)
# fig, ax = plt.subplots(figsize=(4,8),constrained_layout=True)
# ax.pcolormesh(np.arange(testx_slice.start,testx_slice.stop),np.arange(testy_slice.start,testy_slice.stop),
# helium_trans_test,norm=norm,cmap=cmcm.lajolla,rasterized=True)
testx_slice_mapcoor = slice(40,1350)
testy_slice_mapcoor = slice(350,700)
ypos_map_coordinate, xpos_map_coordinate = np.mgrid[testy_slice_mapcoor,testx_slice_mapcoor]
xpos_map_coordinate = xpos_map_coordinate + chebyshev2d_p_new(xpos_map_coordinate, ypos_map_coordinate)
xpos_map_coordinate = xpos_map_coordinate - testx_slice_mapcoor.start
ypos_map_coordinate = ypos_map_coordinate - testy_slice_mapcoor.start
helium_trans_mapcoor = ndimage.map_coordinates(helium_im_aver[testy_slice_mapcoor, testx_slice_mapcoor],(ypos_map_coordinate, xpos_map_coordinate),
order=1)
fig, ax = plt.subplots(figsize=(16,8),constrained_layout=True)
im = ax.pcolormesh(np.arange(testx_slice_mapcoor.start,testx_slice_mapcoor.stop),np.arange(testy_slice_mapcoor.start,testy_slice_mapcoor.stop),
helium_trans_mapcoor,norm=norm,cmap=cmcm.lajolla,rasterized=True)
ax.tick_params(labelsize=18)
ax.set_xlabel("CCD-X [Pixel]",fontsize=18)
ax.set_ylabel("CCD-Y [Pixel]",fontsize=18)
ax.set_title("Corrected Helium Frame",fontsize=18)
clb_ax = inset_axes(ax,width="5%",height= "100%",loc='lower left',
bbox_to_anchor=(1.02, 0., 1, 1),
bbox_transform=ax.transAxes,
borderpad=0)
clb = plt.colorbar(im,orientation='vertical',ax=ax,cax=clb_ax)
clb_ax.tick_params(labelsize=16)
clb_ax.yaxis.get_offset_text().set_fontsize(16)
clb_ax.set_ylabel('',fontsize=16)
Text(0, 0.5, '')
hydrogen_trans_mapcoor = ndimage.map_coordinates(hydrogen_im_aver[testy_slice_mapcoor, testx_slice_mapcoor],(ypos_map_coordinate, xpos_map_coordinate),
order=1)
fig, ax = plt.subplots(figsize=(16,8),constrained_layout=True)
im = ax.pcolormesh(np.arange(testx_slice_mapcoor.start,testx_slice_mapcoor.stop),np.arange(testy_slice_mapcoor.start,testy_slice_mapcoor.stop),
hydrogen_trans_mapcoor,norm=norm_hydrogen,cmap=cmcm.lajolla,rasterized=True)
ax.tick_params(labelsize=18)
clb_ax = inset_axes(ax,width="5%",height= "100%",loc='lower left',
bbox_to_anchor=(1.02, 0., 1, 1),
bbox_transform=ax.transAxes,
borderpad=0)
clb = plt.colorbar(im,pad = 0.05,orientation='vertical',ax=ax,cax=clb_ax)
clb_ax.tick_params(labelsize=16)
clb_ax.yaxis.get_offset_text().set_fontsize(16)
clb_ax.set_ylabel('',fontsize=16)
Text(0, 0.5, '')
mylar_im_collection = ImageFileCollection(red_path,
glob_include="SunMylarRedpoint1s_740*.fit")
mylar_im_df = mylar_im_collection.summary.to_pandas()
mylar_image_cube = np.zeros((1040,1392,10))
for ii, row_ in mylar_im_df.iterrows():
mylar_image_cube[:,:,ii] = CCDData.read(os.path.join(red_path,row_["file"]),unit="adu").data - bias_dc_red_1s
mylar_im_aver = np.mean(mylar_image_cube,axis=2)
WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.707095 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.707095 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.707106 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.707106 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.707118 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.707118 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.707130 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.707130 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.707141 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.707141 from DATE-OBS'.
mylar_trans_mapcoor = ndimage.map_coordinates(mylar_im_aver[testy_slice_mapcoor, testx_slice_mapcoor],(ypos_map_coordinate, xpos_map_coordinate),order=1)
fig, (ax1, ax2) = plt.subplots(2,1,figsize=(16,8),constrained_layout=True)
im1 = ax1.pcolormesh(np.arange(testx_slice_mapcoor.start,testx_slice_mapcoor.stop),np.arange(testy_slice_mapcoor.start,testy_slice_mapcoor.stop),
mylar_im_aver[testy_slice_mapcoor, testx_slice_mapcoor],cmap=cmcm.lajolla_r,rasterized=True)
im2 = ax2.pcolormesh(np.arange(testx_slice_mapcoor.start,testx_slice_mapcoor.stop),np.arange(testy_slice_mapcoor.start,testy_slice_mapcoor.stop),
mylar_trans_mapcoor,cmap=cmcm.lajolla_r,rasterized=True)
for ax_, im_ in zip((ax1,ax2),(im1, im2)):
ax_.tick_params(labelsize=18,right=True)
clb_ax = inset_axes(ax_,width="2%",height= "100%",loc='lower left',
bbox_to_anchor=(1.02, 0., 1, 1),
bbox_transform=ax_.transAxes,
borderpad=0)
clb = plt.colorbar(im_,orientation='vertical',ax=ax_,cax=clb_ax)
clb_ax.tick_params(labelsize=16)
clb_ax.yaxis.get_offset_text().set_fontsize(16)
clb_ax.set_ylabel('',fontsize=16)
fig, ax = plt.subplots(figsize=(10,8),constrained_layout=True)
im = ax.pcolormesh(np.arange(400,600),np.arange(testy_slice_mapcoor.start,testy_slice_mapcoor.stop),
mylar_trans_mapcoor[:,300:500],cmap=cmcm.lajolla_r,rasterized=True)
ax.tick_params(labelsize=18,right=True)
clb_ax = inset_axes(ax,width="3%",height= "100%",loc='lower left',
bbox_to_anchor=(1.02, 0., 1, 1),
bbox_transform=ax.transAxes,
borderpad=0)
clb = plt.colorbar(im,pad = 0.05,orientation='vertical',ax=ax,cax=clb_ax)
clb_ax.tick_params(labelsize=16)
clb_ax.yaxis.get_offset_text().set_fontsize(16)
clb_ax.set_ylabel('',fontsize=16)
Text(0, 0.5, '')
fig, ax = plt.subplots(figsize=(16,6),constrained_layout=True)
ax.step(np.arange(testy_slice_mapcoor.start,testy_slice_mapcoor.stop),
np.mean(mylar_trans_mapcoor,axis=1),where="mid")
ax.set_yscale("log")
ax.axvspan(389,613,alpha=0.5,color="yellow")
ax.axhline(1e3,color="red")
ax.tick_params(labelsize=18)
fig, ax = plt.subplots(figsize=(10,6))
ax.step(np.arange(testy_slice_mapcoor.start,testy_slice_mapcoor.stop),
np.mean(mylar_trans_mapcoor,axis=1),where="mid")
ax.set_xlim(3,400)
(3.0, 400.0)
fname_skyflat_red_1s = ["SkyRed1s_6141.fit","SkyRed1s_6142.fit","SkyRed1s_6143.fit","SkyRed1s_6144.fit",
"SkyRed1s_6145.fit","SkyRed1s_6146.fit","SkyRed1s_6147.fit","SkyRed1s_6148.fit",
"SkyRed1s_6149.fit","SkyRed1s_6150.fit","SkyRed1s_6151.fit","SkyRed1s_6152.fit",
"SkyRed1s_6153.fit","SkyRed1s_6154.fit","SkyRed1s_6155.fit"]
skyflat_im_collection = ImageFileCollection(red_path,
filenames=fname_skyflat_red_1s)
skyflat_im_df = skyflat_im_collection.summary.to_pandas()
skyflat_im_df
file | simple | bitpix | naxis | naxis1 | naxis2 | bzero | bscale | datamin | datamax | ... | ypixsz | xbinning | ybinning | xorgsubf | yorgsubf | xpossubf | ypossubf | cblack | cwhite | swcreate | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | SkyRed1s_6141.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 824 | 4753 | Artemis Capture |
1 | SkyRed1s_6142.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 819 | 4756 | Artemis Capture |
2 | SkyRed1s_6143.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 817 | 4760 | Artemis Capture |
3 | SkyRed1s_6144.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 819 | 4756 | Artemis Capture |
4 | SkyRed1s_6145.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 817 | 4753 | Artemis Capture |
5 | SkyRed1s_6146.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 817 | 4750 | Artemis Capture |
6 | SkyRed1s_6147.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 822 | 4754 | Artemis Capture |
7 | SkyRed1s_6148.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 823 | 4757 | Artemis Capture |
8 | SkyRed1s_6149.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 820 | 4757 | Artemis Capture |
9 | SkyRed1s_6150.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 818 | 4749 | Artemis Capture |
10 | SkyRed1s_6151.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 816 | 4745 | Artemis Capture |
11 | SkyRed1s_6152.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 813 | 4752 | Artemis Capture |
12 | SkyRed1s_6153.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 819 | 4748 | Artemis Capture |
13 | SkyRed1s_6154.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 820 | 4751 | Artemis Capture |
14 | SkyRed1s_6155.fit | True | 16 | 2 | 1392 | 1040 | 32768.0 | 1.0 | 0.0 | 65535.0 | ... | 6.45 | 1 | 1 | 0 | 0 | 0 | 0 | 818 | 4751 | Artemis Capture |
15 rows × 24 columns
skyflat_image_cube = np.zeros((1040,1392,15))
for ii, row_ in skyflat_im_df.iterrows():
skyflat_image_cube[:,:,ii] = CCDData.read(os.path.join(red_path,row_["file"]),unit="adu").data - bias_dc_red_1s
skyflat_im_aver = np.mean(skyflat_image_cube,axis=2)
WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640648 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640648 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640671 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640671 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640683 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640683 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640694 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640694 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640718 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640718 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640729 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640729 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640752 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640752 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640764 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640764 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640775 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640775 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640799 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640799 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640810 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640810 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640833 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640833 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640845 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640845 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640856 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640856 from DATE-OBS'. WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640880 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.640880 from DATE-OBS'.
skyflat_trans_mapcoor = ndimage.map_coordinates(skyflat_im_aver[testy_slice_mapcoor, testx_slice_mapcoor],(ypos_map_coordinate, xpos_map_coordinate),
order=1)
fig, (ax1, ax2) = plt.subplots(2,1,figsize=(16,8),constrained_layout=True)
im1 = ax1.pcolormesh(np.arange(testx_slice_mapcoor.start,testx_slice_mapcoor.stop),np.arange(testy_slice_mapcoor.start,testy_slice_mapcoor.stop),
skyflat_im_aver[testy_slice_mapcoor, testx_slice_mapcoor],cmap=cmcm.lajolla_r,rasterized=True,vmin=1500,vmax=4000)
im2 = ax2.pcolormesh(np.arange(testx_slice_mapcoor.start,testx_slice_mapcoor.stop),np.arange(testy_slice_mapcoor.start,testy_slice_mapcoor.stop),
skyflat_trans_mapcoor,cmap=cmcm.lajolla_r,rasterized=True,vmin=1500,vmax=4000)
for ax_, im_ in zip((ax1,ax2),(im1, im2)):
ax_.tick_params(labelsize=18,right=True)
clb_ax = inset_axes(ax_,width="2%",height= "100%",loc='lower left',
bbox_to_anchor=(1.02, 0., 1, 1),
bbox_transform=ax_.transAxes,
borderpad=0)
clb = plt.colorbar(im_,orientation='vertical',ax=ax_,cax=clb_ax)
clb_ax.tick_params(labelsize=16)
clb_ax.yaxis.get_offset_text().set_fontsize(16)
clb_ax.set_ylabel('',fontsize=16)
plt.savefig(fname="../../figs/calib/skyflat_curvature_corr.png",format="png",dpi=150,bbox_inches="tight")
totality_image = CCDData.read(os.path.join(red_path,"TotalitySequenceRed_7723.fit"),unit="adu").data - bias_dc_red_1s
WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.740764 from DATE-OBS'. [astropy.wcs.wcs] WARNING:astropy:FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 57986.740764 from DATE-OBS'.
totality_trans_mapcoor = ndimage.map_coordinates(totality_image[testy_slice_mapcoor, testx_slice_mapcoor],(ypos_map_coordinate, xpos_map_coordinate),
order=1)
fig, (ax1, ax2) = plt.subplots(2,1,figsize=(16,8),constrained_layout=True)
im1 = ax1.pcolormesh(np.arange(testx_slice_mapcoor.start,testx_slice_mapcoor.stop),np.arange(testy_slice_mapcoor.start,testy_slice_mapcoor.stop),
totality_image[testy_slice_mapcoor, testx_slice_mapcoor],cmap=cmcm.lajolla,rasterized=True)
im2 = ax2.pcolormesh(np.arange(testx_slice_mapcoor.start,testx_slice_mapcoor.stop),np.arange(testy_slice_mapcoor.start,testy_slice_mapcoor.stop),
totality_trans_mapcoor,cmap=cmcm.lajolla,rasterized=True)
for ax_, im_ in zip((ax1,ax2),(im1, im2)):
ax_.tick_params(labelsize=18,right=True)
clb_ax = inset_axes(ax_,width="2%",height= "100%",loc='lower left',
bbox_to_anchor=(1.02, 0., 1, 1),
bbox_transform=ax_.transAxes,
borderpad=0)
clb = plt.colorbar(im_,pad = 0.05,orientation='vertical',ax=ax_,cax=clb_ax)
clb_ax.tick_params(labelsize=16)
clb_ax.yaxis.get_offset_text().set_fontsize(16)
clb_ax.set_ylabel('',fontsize=16)
totality_spectrum_1d = np.mean(totality_trans_mapcoor[130:140,:],axis=0)
fig, ax = plt.subplots(figsize=(16,6),constrained_layout=True)
ax.step(np.arange(testx_slice_mapcoor.start,testx_slice_mapcoor.stop),totality_spectrum_1d,where="mid")
ax.tick_params(labelsize=16)
totality_spectrum_1d_zoomin_slice = slice(580,640)
totality_spectrum_1d_zoomin = totality_spectrum_1d[totality_spectrum_1d_zoomin_slice]
totality_spectrum_1d_x = np.arange(testx_slice_mapcoor.start,testx_slice_mapcoor.stop)[totality_spectrum_1d_zoomin_slice]
totality_spectrum_corr_fit = SpectrumFitSingle(data=totality_spectrum_1d_zoomin,wvl=totality_spectrum_1d_x,line_number=1,
line_wvl_init=665,int_max_init=1200,fwhm_init=5,same_width=False,
)
totality_spectrum_corr_fit.run_lse()
totality_spectrum_corr_fit.plot(plot_fit=True)
/Users/yjzhu/Desktop/Solar/MyPy/juanfit.py:221: UserWarning: No input errors, absolute_sigma=False will be used in the Chi2 fitting. warn("No input errors, absolute_sigma=False will be used in the Chi2 fitting.")
<AxesSubplot:ylabel='Intensity'>
with h5py.File("../../sav/Eclipse/Curvature/master_curvature_red.h5", 'w') as hf:
df_x = hf.create_dataset("xpos_map_coordinate", data=xpos_map_coordinate)
df_y = hf.create_dataset("ypos_map_coordinate", data=ypos_map_coordinate)
df_x.attrs["xstart_pixel"] = testx_slice_mapcoor.start
df_x.attrs["xend_pixel"] = testx_slice_mapcoor.stop
df_y.attrs["ystart_pixel"] = testy_slice_mapcoor.start
df_y.attrs["yend_pixel"] = testy_slice_mapcoor.stop
fig, (ax1,ax2) = plt.subplots(2,1,figsize=(6,11),constrained_layout=True)
ax1.pcolormesh(np.arange(1392),np.arange(1040),helium_im_aver,norm=norm,cmap=cmcm.lajolla, rasterized=False)
# ax2.imshow(helium_im_aver,norm=norm,cmap=cmcm.lajolla,origin="lower")
ax2.imshow(hydrogen_im_aver,norm=norm_hydrogen,origin="lower",cmap=cmcm.lajolla,alpha=0.5)
ax2.imshow(helium_im_aver,norm=norm,origin="lower",cmap=cmcm.lajolla,alpha=0.5)
for ax_ in (ax1,ax2):
ax_.set_aspect("equal")
for ii, spl_ in enumerate(spls):
ax_.plot(spl_(np.arange(305,745)),np.arange(305,745),color="red",label=r"\textbf{He \textsc{i}}" if ii == 0 else None,alpha=0.6)
for ii, spl_ in enumerate(spls_halpha):
ax_.plot(spl_(np.arange(305,745)),np.arange(305,745),color="green",label=r"\textbf{H}$\boldsymbol{\alpha}$" if ii == 0 else None,alpha=0.6)
print(ax1.get_ylim())
print(ax2.get_ylim())
plt.savefig(fname="../../figs/calib/imshow_pcolormesh.png",format="png",dpi=300)
(-0.5, 1039.5) (-0.5, 1039.5)
fig, (ax1,ax2,ax3) = plt.subplots(3,1,figsize=(6,11),constrained_layout=True,gridspec_kw={"height_ratios":(3,3,1.5)})
select_rectangle = Rectangle([testx_slice_mapcoor.start,testy_slice_mapcoor.start], testx_slice_mapcoor.stop-testx_slice_mapcoor.start,
testy_slice_mapcoor.stop-testy_slice_mapcoor.start,lw=2,edgecolor="red",facecolor="none")
norm = ImageNormalize(helium_im_aver, stretch=LogStretch())
ax1.imshow(helium_im_aver,origin="lower",norm=norm,cmap=cmcm.lajolla)
ax1.add_artist(select_rectangle)
ax1.text(0.02,0.97,r"\textbf{(a)}",fontsize=16,ha="left",va="top",transform=ax1.transAxes)
ax2.imshow(hydrogen_im_aver,norm=norm_hydrogen,origin="lower",cmap=cmcm.lajolla,alpha=0.5)
ax2.imshow(helium_im_aver,norm=norm,origin="lower",cmap=cmcm.lajolla,alpha=0.5)
for ii, spl_ in enumerate(spls):
ax2.plot(spl_(np.arange(305,745)),np.arange(305,745),color="red",label=r"\textbf{He \textsc{i}}" if ii == 0 else None)
for ii, spl_ in enumerate(spls_halpha):
ax2.plot(spl_(np.arange(305,745)),np.arange(305,745),color="green",label=r"\textbf{H}$\boldsymbol{\alpha}$" if ii == 0 else None)
ax2.legend(fontsize=16,frameon=False,loc="upper right")
ax2.text(0.02,0.97,r"\textbf{(b)}",fontsize=16,ha="left",va="top",transform=ax2.transAxes)
ax3.imshow(helium_trans_mapcoor,norm=norm,origin="lower",cmap=cmcm.lajolla,
extent=[testx_slice_mapcoor.start,testx_slice_mapcoor.stop,testy_slice_mapcoor.start,testy_slice_mapcoor.stop])
ax3.text(0.02,0.97,r"\textbf{(c)}",fontsize=16,ha="left",va="top",transform=ax3.transAxes)
for ax_ in (ax1,ax2,ax3):
ax_.tick_params(labelsize=16)
ax_.set_ylabel(r"\textbf{CCD-Y [Pixel]}",fontsize=16)
ax3.set_xlabel(r"\textbf{CCD-X [Pixel]}",fontsize=16)
plt.savefig(fname="../../figs/ms/curve_corr.pdf",format="pdf",dpi=300)
plt.savefig(fname="../../figs/ms/curve_corr.png",format="png",dpi=300)