Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question

Im trying to plot three plots

1. the actual CCF data in a plot

2. the mean of the CCF data in a plot

3. the residual of the CCF data, which is the CCF data - mean

I have plot 1 and 2 operating okay

 

import matplotlib.pyplot as plt
import glob
from astropy.io import fits
from astropy.wcs import WCS
import numpy as np

# Step 1: Import the necessary libraries and modules

# Step 2: Create the main figure and axis objects for the initial plot
fig, ax = plt.subplots(figsize=(10, 10))

# Step 3: Get the file paths of FITS files
data_dir = glob.glob('/Users/petrderuyter/Desktop/harpn_sun_release_package_ccf_2018/2018-01-18/*.fits')

# Step 4: Initialize empty lists for storing wavelength and flux data
lams = []
fluxs = []

# Step 5: Read and process each FITS file
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)

# Step 6: Calculate the mean flux
mean_ccf = np.mean(fluxs, axis=0)

# Step 7: Create a new figure and axis objects for the second plot (mean data)
fig_mean, ax_mean = plt.subplots(figsize=(10, 10))

# Step 8: Plot the mean data on the second axis
ax_mean.plot(lams[1], mean_ccf, color='k', linewidth=2)

#Calculate the residual
mean_ccf = np.mean(data_dir)
residuals = data_dir - mean_ccf

# Step 9: Customize the plot
ax_mean.set_xlabel('RV [km/s]')
ax_mean.set_ylabel('Normalized CCF')

# Step 10: Set the title and display the plots
plt.title('Mean CCF')
plt.show()

# Step 11: Print the mean flux
print(mean_ccf)

# Plot residuals
plt.plot(residuals, marker='o')
plt.axhline(0, color='red', linestyle='--')  # Add a horizontal line at y=0
plt.xlabel('Index')
plt.ylabel('Residual')
plt.title('Residual Plot of CCF Data')
plt.grid(True)
plt.show()

V
110000
100000
90000
80000
70000
60000
50000
40000
30000
110000
100000
90000
80000
70000
60000
50000
40000
0
0
10
10
20
20
30
30
40
40
50
50
expand button
Transcribed Image Text:V 110000 100000 90000 80000 70000 60000 50000 40000 30000 110000 100000 90000 80000 70000 60000 50000 40000 0 0 10 10 20 20 30 30 40 40 50 50
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education