code = compile(f.read(), "def_constants.py", "exec") exec(code) # 2. SET UP VARIABLES --------------------------------------------------------- GRAV = 'f' SPECIAL_H_NORM_LIM = [1.41,1.89] #[1.41, 1.81] these are the special values # 3. GET SPECTRAL NIR STANDARDS & TEMPLATES ----------------------------------- spTypes = [] spectra = {}.fromkeys(BANDS) for band in BANDS: spectra[band] = [] for idxTp, spTp in enumerate(SPTYPES): # Fetch standard tmpStd = nocs.main(spTp, GRAV, plot=False, std=True, normalize=False) # Normalize standard for bdIdx, band in enumerate(BANDS): if idxTp in [1,2,3] and band == 'H': norm_lims = SPECIAL_H_NORM_LIM else: norm_lims = NORM_LIMS[band]['lim'] stdToPlot = at.norm_spec(tmpStd[bdIdx], norm_lims)[0] spectra[band].append(stdToPlot) #spectra[band].append(tmpStd[bdIdx]) # Fetch template from ascii files generated by make_templ.py in templates/ folder. for bdIdx, band in enumerate(BANDS): fileNm = spTp + band + '_' + GRAV + '.txt' templRaw = ad.read(FOLDER_OUT_TMPL + fileNm, delimiter='\t', \ format='no_header')
''' This generates separate ascii files for all templates, by band (J, H, and K). The files contain five columns: wavelength, average flux, standard deviation, min flux, max flux.''' import nir_opt_comp_strip as nocs import astrotools as at with open("def_constants.py") as f: code = compile(f.read(), "def_constants.py", "exec") exec(code) GRAVS = ['f','g','b'] for sptp in SPTYPES: print(sptp) for grav in GRAVS: templ = nocs.main(sptp, grav, templ=True, plot=False) if templ is None: continue print(' ' + grav) for bdidx, band in enumerate(templ): # Create template spectrum file # columns are: wavelength, mean flux, standard deviation, min flux, max flux at.create_ascii(band, FOLDER_OUT_TMPL + sptp + BANDS[bdidx] + '_' + grav)
''' This generates separate ascii files for all templates, by band (J, H, and K). The files contain five columns: wavelength, average flux, standard deviation, min flux, max flux.''' import nir_opt_comp_strip as nocs import astrotools as at with open("def_constants.py") as f: code = compile(f.read(), "def_constants.py", "exec") exec(code) GRAVS = ['f', 'g', 'b'] for sptp in SPTYPES: print(sptp) for grav in GRAVS: templ = nocs.main(sptp, grav, templ=True, plot=False) if templ is None: continue print(' ' + grav) for bdidx, band in enumerate(templ): # Create template spectrum file # columns are: wavelength, mean flux, standard deviation, min flux, max flux at.create_ascii(band, FOLDER_OUT_TMPL + sptp + BANDS[bdidx] + '_' + grav)
code = compile(f.read(), "def_constants.py", "exec") exec(code) # 2. SET UP VARIABLES --------------------------------------------------------- GRAV = "f" SPECIAL_H_NORM_LIM = [1.41, 1.89] # [1.41, 1.81] these are the special values # 3. GET SPECTRAL NIR STANDARDS & TEMPLATES ----------------------------------- spTypes = [] spectra = {}.fromkeys(BANDS) for band in BANDS: spectra[band] = [] for idxTp, spTp in enumerate(SPTYPES): # Fetch standard tmpStd = nocs.main(spTp, GRAV, plot=False, std=True, normalize=False) # Normalize standard for bdIdx, band in enumerate(BANDS): if idxTp in [1, 2, 3] and band == "H": norm_lims = SPECIAL_H_NORM_LIM else: norm_lims = NORM_LIMS[band]["lim"] stdToPlot = at.norm_spec(tmpStd[bdIdx], norm_lims)[0] spectra[band].append(stdToPlot) # spectra[band].append(tmpStd[bdIdx]) # Fetch template from ascii files generated by make_templ.py in templates/ folder. for bdIdx, band in enumerate(BANDS): fileNm = spTp + band + "_" + GRAV + ".txt" templRaw = ad.read(FOLDER_OUT_TMPL + fileNm, delimiter="\t", format="no_header") templRawToPlot = np.array([templRaw.columns[i] for i in range(5)])