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)
![40000
30000
0
10
20
RV [km/s]
30
40
93492.52
[104930.09 103464.03 101587.89 99710.74 98333.64
97645.76 98206.375 99064.03 100027.09 100870.03
101821.414 101427.24 100071.93 97552.41
79864.69 70415.9 60115.39 50119.555
34768.734 37060.95 43239.555 52353.89
81910.02
41815.21
36503.027
62804.
73144.07
95144.336 96109.86
96252.39
96249.18
97033.84
98058.13
99442.02
88459.586 92786.42
96053.164 96014.38
101030.03 102540.664 103737.98 104716.67 105623.34 106510.61
107199.984]
97626.96
101466.84
87540.8
50](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc1c1ced3-1875-44c4-84f9-6bbf6b04c124%2F2d8bade6-d343-4a21-adf4-27366d63e3c6%2Fo8iho9i_processed.png&w=3840&q=75)

Step by step
Solved in 3 steps









