def main(fname, output=None): print("Input name", fname) print("Output name", output) tellpath = "/home/jneal/Phd/Codes/Phd-codes/WavelengthCalibration/testfiles/" # Updated for git repo #ext = 0 # for testing #hdr, data = Get_DRACS(fname, ext) #Get DRACS only finds relevant file in the path folder hdr = fits.getheader(fname) print("Observation time ", hrd[]) data = fits.getdata(fname) uncalib_combined = data["Combined"] #uncalib_noda = uncalib_data["Nod A"] #uncalib_nodb = uncalib_data["Nod B"] uncalib_data = [range(1,len(uncalib_combined)+1), uncalib_combined] # get hdr information and then find coresponding Telluric spectra calib_data = IOmodule.read_2col(tellpath + "Telluric_spectra_CRIRES_Chip-" + str(1) + ".txt") gf.print_fit_instructions() rough_a, rough_b = gf.get_rough_peaks(uncalib_data[0], uncalib_data[1], calib_data[0], calib_data[1]) rough_x_a = [coord[0] for coord in rough_a] rough_x_b = [coord[0] for coord in rough_b] good_a, good_b = gf.adv_wavelength_fitting(uncalib_data[0], uncalib_data[1], rough_x_a, calib_data[0], calib_data[1], rough_x_b) wl_map = gf.wavelength_mapping(good_a, good_b) calibrated_wl = np.polyval(wl_map, uncalib_data[0]) plt.plot(calibrated_wl, uncalib_data[1], label="Calibrated spectra") plt.plot(calib_data[0], calib_data[1], label="Telluric spectra") plt.title("Calibration Output") plt.show()
if __name__ == "__main__": # Do the test case HD30501-1 Chip-1 path = "/home/jneal/Phd/Codes/Phd-codes/WavelengthCalibration/testfiles/" # Updated for git repo #global param_nums #param_nums = 3 Dracspath = "/home/jneal/Phd/data/Crires/BDs-DRACS/" obj = "HD30501-1" objpath = Dracspath + obj + "/" chip = 0 # for testing hdr, DracsUncalibdata = Get_DRACS(objpath,0) UnCalibdata_comb = DracsUncalibdata["Combined"] #UnCalibdata_noda = DracsUncalibdata["Nod A"] #UnCalibdata_nodb = DracsUncalibdata["Nod B"] UnCalibdata = [range(1,1025), UnCalibdata_comb] Calibdata = IOmodule.read_2col(path + "Telluric_spectra_CRIRES_Chip-" + str( 1) + ".txt") #print(Calibdata) #get_rough_peaks() Test_pxl_pos = [58.4375, 189.0625, 583.0, 688.1875, 715.6875, 741.8125, 971.4375] Test_wl_pos = [2112.4897175403221, 2114.0333233870965, 2118.5533179435483, 2119.748622983871, 2120.0573441532256, 2120.358149395161, 2122.9624895161287] CoordsA = Test_pxl_pos # first one for now CoordsB = Test_wl_pos print_fit_instructions() #Comment Below line to skip this and work on next part good_coords_a, good_coords_b = adv_wavelength_fitting(UnCalibdata[0], UnCalibdata[1], CoordsA, Calibdata[0], Calibdata[1],