Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

I am trying to simplify this code, in python,  so that I do not have to list each file separately.  

Is there a way that I can access the FITS files via a folder on my Desktop to produce one plot of several FITS files.

 

 

import numpy as np
import matplotlib.pyplot as plt
from astropy.io import fits
from astropy.wcs import WCS
%matplotlib inline
%matplotlib widget


plt.figure(figsize=(10,10))
legends = []

def plot_fits_file(file_path):
    # used this data to test ----------
    # lam = np.random.random(100)
    # flux = np.random.random(100)
    # --------------------

    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]

    plt.plot(lam, flux)
    plt.ylim(0, )
    plt.xlabel('RV[km/s]')
    plt.ylabel('Normalized CCF')
    legends.append(file_path) 

spec_list = [
    '~/Desktop/r.HARPN.2018-01-18T14:25:36.145_CCF_A.fits',
    '~/Desktop/r.HARPN.2018-01-18T14:20:10.645_CCF_A.fits',
    '~/Desktop/r.HARPN.2018-01-18T14:31:00.875_CCF_A.fits',
    '~/Desktop/r.HARPN.2018-01-18T14:36:26.373_CCF_A.fits']

for file_path in spec_list:
    plot_fits_file(file_path)


plt.show()

←
00
80000
60000
40000
20000
0 T
10
T
20
Figure 1
30
RV[km/s]
40
50
expand button
Transcribed Image Text:← 00 80000 60000 40000 20000 0 T 10 T 20 Figure 1 30 RV[km/s] 40 50
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY