-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_cut_fits.py
40 lines (32 loc) · 1.37 KB
/
read_cut_fits.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sys
import pandas as pd
import os
import numpy as np
from analyseSpectralData_functions import *
from binary_synthesis import *
import directories
np.random.seed(1)
# ___ Variables _______________________________________________________________ Variables
RUNNAME = 'Galah_wholerange_dwarfs' # For the genereated stars
READ_FITS = True
# ___ Directory paths _________________________________________________________ Directory paths
dirs = directories.directories()
SELECTED_RANGES = [(float(sys.argv[1]), float(sys.argv[2]))]
# Check for the files
FILENAME_SPECTRA = (dirs.single_spectra + 'synthetic_single_spectra_{}.npy'.format(SELECTED_RANGES))
if os.path.isfile(FILENAME_SPECTRA) == True:
print('File exists already, skipping this step..')
exit()
else:
pass
# ___ Read and cut fits _______________________________________________________ Read and cut fits
# Read the fits files and cut them in the selected waveranges
if READ_FITS == True:
synthetic_single_fluxes, single_waveranges, corrupt_files = read_spectra_fits(
dirs.single_synth_spectra, SELECTED_RANGES, run_name=RUNNAME)
print('='*40)
del single_waveranges
del corrupt_files
print('Fits files read and cut succesfully, storing results in a separate file...')
np.save(dirs.single_spectra + 'synthetic_single_spectra_{}.npy'.format(SELECTED_RANGES),
np.vstack(synthetic_single_fluxes))