from numpy import empty from DZ_observation_reduction import spectra_reduction from shutil import copy as shu_copy #Load iraf pypeline object dz = spectra_reduction() #Entries for new files data_dict = {'reduc_tag': 'biascorr'} #Load reduction data frame dz.declare_catalogue(dz.Catalogue_folder) #Search for objects we want to treat for bias list_for_bias = dz.observation_dict['Standard_stars'] + dz.observation_dict[ 'objects'] + ['flat', 'arc', 'sky'] #Loop through the arms colors = ['Blue', 'Red'] for arm_color in colors: #Get the files to bias correct indeces_arm = (dz.reducDf.ISIARM == '{color} arm'.format( color=arm_color)) & (dz.reducDf.file_location.str.contains('raw_fits') ) & dz.reducDf.frame_tag.isin(list_for_bias) & ( dz.reducDf.valid_file) frames_type = dz.reducDf.loc[indeces_arm, 'frame_tag'].values files_folders = dz.reducDf.loc[indeces_arm, 'file_location'].values files_names = dz.reducDf.loc[indeces_arm, 'file_name'].values #Get the correction files
indmin, indmax = searchsorted(PartialWavelength, (Bot, Top)) LineHeight = max(PartialIntensity[indmin:indmax]) LineExpLoc = median(PartialWavelength[where(PartialIntensity == LineHeight)]) return PartialWavelength, PartialIntensity, LineHeight, LineExpLoc def region_indeces(wave_min, wave_max, wavenlength_range): low_trim, up_trim = searchsorted(wavenlength_range, [wave_min, wave_max]) indeces_array = array(range(low_trim, up_trim)) return indeces_array dz = Dazer() dz_reduc = spectra_reduction() script_code = dz.get_script_code() lickIndcs_extension = '_lick_indeces.txt' #Load catalogue dataframe catalogue_dict = dz.import_catalogue() catalogue_df = dz.load_excel_DF('/home/vital/Dropbox/Astrophysics/Data/WHT_observations/WHT_Galaxies_properties.xlsx') image_address = '/home/vital/Dropbox/Astrophysics/Papers/Yp_AlternativeMethods/images/telluric_correction_detail' SIII_theo = 2.469 H7_H8_ratio_theo = 1.98 #Set figure format size_dict = {'figure.figsize': (16, 10), 'axes.labelsize':20, 'legend.fontsize':20, 'font.family':'Times New Roman', 'mathtext.default':'regular', 'xtick.labelsize':20, 'ytick.labelsize':20} dz.FigConf(plotStyle='seaborn-colorblind', plotSize = size_dict, Figtype = 'Grid_size', n_columns = 1, n_rows = 2)
import os import sys sys.path.append('/home/vital/git/Dazer/Dazer/dazer/') os.environ['TCL_LIBRARY'] = '/home/vital/anaconda/python27/lib/tcl8.5' os.environ['TK_LIBRARY'] = '/home/vital/anaconda/python27/lib/tk8.5' from DZ_observation_reduction import spectra_reduction #Load iraf pypeline object dz = spectra_reduction() #Load reduction data frame dz.declare_catalogue(dz.Catalogue_folder) #Output tag data_dict = {'reduc_tag': 'flat_combine_trim'} #Loop through the arms colors = ['Blue', 'Red'] for arm_color in colors: #Get object and global indeces idx_arc = (dz.reducDf.reduc_tag == 'nflatcombine') & (dz.reducDf.ISIARM == '{color} arm'.format(color = arm_color)) & (dz.reducDf.valid_file) File_Folder = dz.reducDf.loc[idx_arc, 'file_location'].values[0] File_Name = dz.reducDf.loc[idx_arc, 'file_name'].values[0] File_Name_trim = File_Name[0:File_Name.find('.')] + '_t.fits' #Define cropping region cropping = dz.observation_dict[arm_color + '_cropping'] cropping_region = '[{rawA}:{rawB},{columnA}:{columnB}]'.format(rawA=cropping[0], rawB=cropping[1],columnA=cropping[2], columnB=cropping[3])
GridAxis.plot(x_values_ver, y_values_ver, label = files_name[j], linestyle = line_dict[str(i)], linewidth = 4) GridAxis.set_xlabel('Pixel', fontsize = font_size) GridAxis.set_ylabel('Mean pixel value', fontsize = font_size) GridAxis.set_title('Extracted spectrum', fontsize = font_size) GridAxis.legend(fontsize = font_size) plt.show() #Load the catalogues dz_vit = spectra_reduction() dz_vit.declare_catalogue(catalogue_address = '/home/vital/Astrodata/WHT_2011_11/Night1/') dz_ele = spectra_reduction() dz_ele.declare_catalogue(catalogue_address = '/home/vital/Astrodata/WHT_2011_11/Night1_Elena/') # #Plot # list_files1, list_files2 = ['master_bias_Blue.fits'], ['Zero-blue.fits'] # idx1 = dz_vit.reducDf.file_name.isin(list_files1) & (dz_vit.reducDf.ISIARM == 'Blue arm') # idx2 = dz_ele.reducDf.file_name.isin(list_files2) & (dz_ele.reducDf.ISIARM == 'Blue arm') # plotter_4_grid([idx1, idx2], [dz_vit, dz_ele]) #Loop through the files list_files1, list_files2 = ['r01725595_b.fits', 'flat_combine_Blue.fits' ], ['ccdblue1725595.fits', 'Flat.fits'] list_files1, list_files2 = ['master_bias_Blue_b.fits'], ['Zero-blue.fits'] list_files1, list_files2 = ['flat_combine_Blue.fits'], ['Flat.fits']
linestyle=line_dict[str(i)], linewidth=4) GridAxis.set_xlabel('Pixel', fontsize=font_size) GridAxis.set_ylabel('Mean pixel value', fontsize=font_size) GridAxis.set_title('Extracted spectrum', fontsize=font_size) GridAxis.legend(fontsize=font_size) plt.show() #Load the catalogues dz_vit = spectra_reduction() dz_vit.declare_catalogue( catalogue_address='/home/vital/Astrodata/WHT_2011_11/Night1/') dz_ele = spectra_reduction() dz_ele.declare_catalogue( catalogue_address='/home/vital/Astrodata/WHT_2011_11/Night1_Elena/') # #Plot # list_files1, list_files2 = ['master_bias_Blue.fits'], ['Zero-blue.fits'] # idx1 = dz_vit.reducDf.file_name.isin(list_files1) & (dz_vit.reducDf.ISIARM == 'Blue arm') # idx2 = dz_ele.reducDf.file_name.isin(list_files2) & (dz_ele.reducDf.ISIARM == 'Blue arm') # plotter_4_grid([idx1, idx2], [dz_vit, dz_ele]) #Loop through the files list_files1, list_files2 = ['r01725595_b.fits', 'flat_combine_Blue.fits' ], ['ccdblue1725595.fits', 'Flat.fits']
from pandas import read_csv from dazer_methods import Dazer from uncertainties import ufloat from DZ_observation_reduction import spectra_reduction #Define main class dz = Dazer() dz_sr = spectra_reduction() #Making the plot: dz.FigConf() #Set object and line to measure objName = 'IZW18_A1' extension = 1 S3_lines = ['S3_9069A', 'S3_9531A'] #Load catalogue dataframe catalogue_dict = dz.import_catalogue() catalogue_df = dz.load_excel_DF('/home/vital/Dropbox/Astrophysics/Data/WHT_observations/WHT_Galaxies_properties.xlsx') lickIndcs_ext = '_lick_indeces.txt' ouput_folder = '{}{}/'.format(catalogue_dict['Obj_Folder'], objName) lick_idcs_df = read_csv(ouput_folder + objName + lickIndcs_ext, delim_whitespace = True, header = 0, index_col = 0, comment='L') #Dirty trick to avoid the Line_label row #Define fits file: ratios_dict = {} for extension in [0, 1]: fits_file = '/home/vital/Astrodata/WHT_2016_04/Night1/objects/IZW18_Red_cr_f_t_w_e_{testing_extension}_fglobal.fits'.format(testing_extension=dz_sr.testing_extension) #fits_file = '/home/vital/Astrodata/WHT_2016_04/Night1/objects/IZW18_Red_cr_f_t_w_bg_e_fglobal.fits' redshift_factor = 1 + catalogue_df.loc[objName].z_Red