I would like to just plot the data, that is the result from the mean (see code in bold). import numpy as np import matplotlib.pyplot as plt import glob from astropy.io import fits from astropy.wcs import WCS %matplotlib inline %matplotlib widget fig, ax = plt.subplots(figsize = (10,10)) # figsize changes the size of the plot) data_dir = glob.glob('/Users/xxxxxxxxx/Desktop/harpn_sun_release_package_ccf_2018/2018-01-18/*.fits') lams = [] fluxs = [] for file_path in data_dir: hdul = fits.open(file_path) data = hdul[1].data h1 = hdul[1].header flux = data[1] w = WCS(h1, naxis=1, relax=False, fix=False) lam = w.wcs_pix2world(np.arange(len(flux)), 0)[0] lams.append(lam) fluxs.append(flux) ax.plot(lam,flux) mean_flux = np.mean(fluxs, axis = 0) ax.plot(lams[0], mean_flux, color = 'k', linewidth = 2) max_rv = lams[0][np.argmin(mean_flux)] ax.vlines(max_rv, np.min(fluxs), np.max(fluxs), color = 'r', linestyle='--') ax.set_xlabel('RV [km/s]') ax.set_ylabel('Normalized CCF') plt.title('CCF') plt.show() print(mean_flux)
I would like to just plot the data, that is the result from the mean (see code in bold).
import numpy as np
import matplotlib.pyplot as plt
import glob
from astropy.io import fits
from astropy.wcs import WCS
%matplotlib inline
%matplotlib widget
fig, ax = plt.subplots(figsize = (10,10)) # figsize changes the size of the plot)
data_dir = glob.glob('/Users/xxxxxxxxx/Desktop/harpn_sun_release_package_ccf_2018/2018-01-18/*.fits')
lams = []
fluxs = []
for file_path in data_dir:
hdul = fits.open(file_path)
data = hdul[1].data
h1 = hdul[1].header
flux = data[1]
w = WCS(h1, naxis=1, relax=False, fix=False)
lam = w.wcs_pix2world(np.arange(len(flux)), 0)[0]
lams.append(lam)
fluxs.append(flux)
ax.plot(lam,flux)
mean_flux = np.mean(fluxs, axis = 0)
ax.plot(lams[0], mean_flux, color = 'k', linewidth = 2)
max_rv = lams[0][np.argmin(mean_flux)]
ax.vlines(max_rv, np.min(fluxs), np.max(fluxs), color = 'r', linestyle='--')
ax.set_xlabel('RV [km/s]')
ax.set_ylabel('Normalized CCF')
plt.title('CCF')
plt.show()
print(mean_flux)
Step by step
Solved in 3 steps