I would like to represent the "residuals" part of the code (see below) as a surface (meshplot), in essence a 3D plot of 2D data # Import libraries import matplotlib.pyplot as plt import glob from astropy.io import fits from astropy.wcs import WCS import numpy as np import seaborn as sns # Initial plot fig, ax = plt.subplots(figsize=(7, 7)) # Data from the FITS data_dir = glob.glob('/Users/petrderuyter/Desktop/harpn_sun_release_package_ccf_2018/2018-04-02/*.fits') #'/Users/xxxxxxxxxxxx/Desktop/harpn_sun_release_package_ccf_2018/2018-01-18/*.fits' # Empty lists for storage lams = [] fluxs = [] # Read the FITS files and extract data 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) # Calculate mean flux mean_ccf = np.mean(fluxs, axis=0) # New figure for the mean plot fig_mean, ax_mean = plt.subplots(figsize=(7, 7)) # Mean data plot ax_mean.plot(lams[0], mean_ccf, linewidth=1) # Set labels and title for the mean plot ax_mean.set_xlabel('RV [km/s]') ax_mean.set_ylabel('Normalized CCF') ax_mean.set_title('Mean CCF') # Calculate residuals fluxs_array = np.array(fluxs) residuals = fluxs_array - mean_ccf # Residuals data plot fig_res, ax_res = plt.subplots(figsize=(7, 7)) for i in range(len(lams)):     ax_res.plot(lams[i], residuals[i], linewidth=1) # Set labels and title for the residuals plot ax_res.set_xlabel('RV [km/s]') ax_res.set_ylabel('CCF Residuals') ax_res.set_title('CCF Residuals') plt.show()

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I would like to represent the "residuals" part of the code (see below) as a surface (meshplot), in essence a 3D plot of 2D data

# Import libraries
import matplotlib.pyplot as plt
import glob
from astropy.io import fits
from astropy.wcs import WCS
import numpy as np
import seaborn as sns

# Initial plot
fig, ax = plt.subplots(figsize=(7, 7))

# Data from the FITS
data_dir = glob.glob('/Users/petrderuyter/Desktop/harpn_sun_release_package_ccf_2018/2018-04-02/*.fits')

#'/Users/xxxxxxxxxxxx/Desktop/harpn_sun_release_package_ccf_2018/2018-01-18/*.fits'

# Empty lists for storage
lams = []
fluxs = []

# Read the FITS files and extract data
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)

# Calculate mean flux
mean_ccf = np.mean(fluxs, axis=0)

# New figure for the mean plot
fig_mean, ax_mean = plt.subplots(figsize=(7, 7))

# Mean data plot
ax_mean.plot(lams[0], mean_ccf, linewidth=1)

# Set labels and title for the mean plot
ax_mean.set_xlabel('RV [km/s]')
ax_mean.set_ylabel('Normalized CCF')
ax_mean.set_title('Mean CCF')

# Calculate residuals
fluxs_array = np.array(fluxs)
residuals = fluxs_array - mean_ccf

# Residuals data plot
fig_res, ax_res = plt.subplots(figsize=(7, 7))

for i in range(len(lams)):
    ax_res.plot(lams[i], residuals[i], linewidth=1)

# Set labels and title for the residuals plot
ax_res.set_xlabel('RV [km/s]')
ax_res.set_ylabel('CCF Residuals')
ax_res.set_title('CCF Residuals')
plt.show()

 

CCF Residuals
2500
0
-2500
-5000
-7500
-10000
-12500
-15000
0
10
CCF Residuals
20
RV [km/s]
30
40
50
Transcribed Image Text:CCF Residuals 2500 0 -2500 -5000 -7500 -10000 -12500 -15000 0 10 CCF Residuals 20 RV [km/s] 30 40 50
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY