
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](https://content.bartleby.com/qna-images/question/c1c1ced3-1875-44c4-84f9-6bbf6b04c124/4d5547db-32cc-4ed5-b734-f9ec74d36523/d2xctjg_thumbnail.png)

Step by stepSolved in 3 steps

- In Python Initially, you will prompt the user for the names of two files: one will contain Customer information, and the other will contain Product information, as described below. Sample files are attached (below) to this project so you can download and review them. Some test cases may use other files, which you will not be able to see, so it is important that your program ask the user for the file names, and be able to open and read any file. The Customer Information file will be a csv file, with no header row, in which each line has the following fields, which are separated by commas. Customer_Number Customer_Name Customer_Balance Customer_Password For example, the sample file named customers.csv has several lines, and the first two are: 24155,"Carey, Drew Allison",838.41,Bo7&J 24426,"Butler, Geoffrey Barbara",722.93,Ep5& The Product Information file will be a csv file, with no header row, in which each line has the following fields, which are separated by commas:…arrow_forwardThis is a one question problem with multiple parts (part (a) to (e), please help with every part. Use matlab for the code. Goal: The intent of this problem is to have you visualize electric fields and understand spatial relationships between charge distributions and E. Instructions: Combine all parts of the problem into a single file and upload either a .pdf or image file of all parts of the question. 1. Develop a code that can plot the electric field produced by two point charges separated by a distance d where the origin is in the middle of the two charges. You may use whatever language is most convenient for you. (a) Produce a plot of the electric field produced by a dipole (equal and opposite point charges) (b) Produce a plot of the electric field of two identical point charges (c) Produce a plot of two charges with random charge values (keep them reasonably close in magnitude) (d) Discuss the electric field distributions for the three cases above. Take note of where the…arrow_forwardHow would I open a file and encrypt that file from a dictionary in Python? Attached is a picture of my current code. I am currently stuck at the getFiles() and convert(inputFile, outputFile) functions.arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





