print("done") vsini=np.asarray(vsini) labels = np.vstack((teff,rstar,feh,vsini)).T # pickle things pickling_on = open('cannon2_specmatch_labels_snr' + str(target_snr) + '.pkl', "wb") pickle.dump(labels,pickling_on) # ---- normalizes spectra via Gaussian filter ----------------- # training set spectra_tr_norm = [] for spectrum1,val1 in zip(spectra_tr,err_tr): spectrum1,val1 = gauss_norm(spectrum1,lib.wav,val1,3) spectra_tr_norm.append(spectrum1) spectra_tr_norm = np.asarray(spectra_tr_norm) # validation set spectra_val_norm = [] for spectrum2,val2 in zip(spectra_val,err_val): spectrum2,val2 = gauss_norm(spectrum2,lib.wav,val2,3) spectra_val_norm.append(spectrum2) spectra_val_norm = np.asarray(spectra_val_norm) # --- remove Na doublet (not a good feature to fit - activity-driven) na_min = 5887
lib_path = input('Enter path to SpecMatch-Emp library: ') # e.g., '/Users/abehmard/.specmatchemp/library.h5' wavlim = [4990, 6094.9099] # wavelength range up to 12th HIRES order lib = specmatchemp.library.read_hdf(lib_path,wavlim=wavlim) # subset of SpecMatch-Emp library that suits user purposes (this version = cool stars) cool = lib.library_params.query('Teff < 5200 and radius < 1') print("There are "+str(len(lib.library_spectra[cool.lib_index,:,:]))+" targets in this training set") bad_stars = [input('Enter names of targets to exclude: ')] # e.g., 'GL570B' cool = cool[~cool['cps_name'].isin(bad_stars)] print("Removing unwanted stars, there are now "+str(len(lib.library_spectra[cool.lib_index,:,:]))+" targets in this training set") # normalizes training spectra via Gaussian filter for ind in cool.lib_index: lib.library_spectra[ind,0],lib.library_spectra[ind,1] = gauss_norm(lib.library_spectra[ind,0],lib.wav,lib.library_spectra[ind,1],3) # removes Na doublet - activity-driven feature spectra_tr,errs_tr,wavs_tr = rm_Na_doublt(lib.library_spectra[cool.lib_index,0],lib.library_spectra[cool.lib_index,1],lib.wav) # copies and broadens training set augment=6 # broaden spectra copies up to augment-1 km/s kernel_width=51 # ~ +/-25 km/s cool_size=len(cool.lib_index) broad_spectra_tr=[] vsini=[] for ind in range(cool_size): for i in np.arange(0,augment,1): broad_spectrum_tr = broaden_smsyn(spectra_tr[ind],kernel_width,1,0,i+1e-10) broad_spectra_tr.append(broad_spectrum_tr)