def trans(gui, site_file): if not site_file: # return full transmission (ie. space) if no site given return numpy.array(aux.get_one(gui.interp.freq_list)) site = ExcelReader(site_file) freq_raw = numpy.array(site.read_from_col('Hz', gui.interp.freq_range.min, gui.interp.freq_range.max), dtype='float') trans_raw = numpy.array(site.read_from_col(0, gui.interp.freq_range.min, gui.interp.freq_range.max, 'COMBIN TRANS'), dtype='float') return gui.interp.interpolate(freq_raw.tolist(), trans_raw.tolist())
def get_col(file_name, col1, col1n, col2, col2n, freq_range): # convert to form understood by excel reader if col1n == 0: col1n = ' ' if col2n == 0: col2n = ' ' # read two columns from file and return them as numpy arrays data = ExcelReader(file_name) return [numpy.array(data.read_from_col(col1, freq_range.min, freq_range.max, col1n), dtype='float'), numpy.array(data.read_from_col(col2, freq_range.min, freq_range.max, col2n), dtype='float')]
def signal(gui, aperture, site_file, source_file, spec_res): source = ExcelReader(source_file) freq_raw = numpy.array(source.read_from_col('Hz', gui.interp.freq_range.min, gui.interp.freq_range.max), dtype='float') intens_raw = 1e-26 * numpy.array(source.read_from_col('Jy', gui.interp.freq_range.min, gui.interp.freq_range.max), dtype='float') intensity = gui.interp.interpolate(freq_raw.tolist(), intens_raw.tolist()) trans_list = trans(gui, site_file) return cal.TS(gui.interp.freq_array, intensity, trans_list, aperture, spec_res)
def onGenerate(self, e): # initialization -> Parse inputs ''' resol = float(self.parameter_inputs[0].GetValue()) # resolution @IndentOk d = float(self.parameter_inputs[1].GetValue()) # mirror diameters @IndentOk mirror_temp = float(self.parameter_inputs[2].GetValue()) # mirror temperature freq_start = float(self.parameter_inputs[3].GetValue()) # starting frequency freq_end = float(self.parameter_inputs[4].GetValue()) # ending frequency ratio = float(self.parameter_inputs[5].GetValue()) # signal to noise ratio ''' # path = self.output_input.GetValue() site = self.parameter_site_combo.GetValue() source = self.parameter_source_combo.GetValue() #TESTING resol = 3 d = 10.0 mirror_temp = 230.0 freq_start = 0.1 #THz freq_end = 1 #THz ratio = 5.0 # Calculate bling bling = 0 # CIB if self.background_checkboxs[0].IsChecked(): cib_excel = file_refs.CIB_ref cib = ExcelReader(cib_excel) cib.set_freq_range(freq_start, freq_end) freq = cib.read_from_col(1) temp = cib.read_from_col(4) bling += cal.bling_sub(freq, temp, resol) # CMB if self.background_checkboxs[1].IsChecked(): cmb_excel = file_refs.CMB_ref cmb = ExcelReader(cmb_excel) cmb.set_freq_range(freq_start, freq_end) freq = cmb.read_from_col(1) bling += cal.bling_CMB(freq, resol) # Galactic Emission if self.background_checkboxs[2].IsChecked(): index = self.galactic_direction_combo.GetCurrentSelection() ge = ExcelReader(file_refs.Galatic_Emission_refs[index]) ge.set_freq_range(freq_start, freq_end) freq = ge.read_from_col(1) temp = ge.read_from_col(8) bling += cal.bling_sub(freq, temp, resol) # Thermal Mirror Emission if self.background_checkboxs[3].IsChecked(): index = self.thermal_mirror_material_combo.GetCurrentSelection() tme = ExcelReader(file_refs.TME_ref) tme.set_freq_range(freq_start, freq_end) freq = tme.read_from_col(1) sigma = const.sigma[index] bling += cal.bling_TME(freq, resol, sigma, mirror_temp) # Atmospheric Radiance if self.background_checkboxs[4].IsChecked(): ar = ExcelReader(file_refs.atm_rad_refs[site]) ar.set_freq_range(freq_start, freq_end) freq = ar.read_from_col(1) rad = ar.read_from_col(4) bling += cal.bling_AR(freq, rad, resol) # Zodiacal Emission if self.background_checkboxs[5].IsChecked(): index = self.zodiacal_direction_combo.GetCurrentSelection() ze = ExcelReader(file_refs.ZODI_refs[index]) ze.set_freq_range(freq_start, freq_end) freq = ze.read_from_col(1) temp = ze.read_from_col(4) bling += cal.bling_sub(freq, temp, resol) bling_TOT = bling ** 0.5 # Source Intensity si = ExcelReader(file_refs.source_refs[source]) si.set_freq_range_Hz(freq_start*10**12, freq_end*10**12) #MODIFIED FOR TESTING freq = si.read_from_col(1) inte = si.read_from_col(5) print "Reading from source. DONE" # Source_Total Signal at = ExcelReader(file_refs.atm_tran_refs[site]) at.set_freq_range_Hz(freq_start*10**12, freq_end*10**12) tau = at.read_from_col(4) print "Reading from atmosphere transmission. DONE" print "Calculating Total Signal.." start_time = time.time() ts = cal.TS(freq, inte, tau, d, resol) end_time = time.time() print "Total Signal calculation DONE" print "Time used for integration: ", end_time - start_time ''' # Limiting Flux limiting_flux = cal.LF(freq, d, resol, ts) # Integration Time integration_time = cal.IT(freq, bling_TOT, ratio, ts) # writing # xw = ExcelXWriter(path) # xw.write_col('freq(cm^-1)', freq / (3 * 10**10)) # xw.write_col('freq(Hz)', freq) freq_THz = freq * 10 ** (-12) # xw.write_col('freq(THz)', freq_THz) # xw.write_col('wavelength(um)', (3 * 10**8) / freq * 10**6) ''' freq = np.array(freq) freq_THz = freq * 10 ** (-12) #MODIFIED FOR TESTING print "Start plotting..." # plot if self.generate_checkboxs[0].IsChecked(): # xw.write_col('Total Noise_BLING(W Hz^(-1/2))', bling_TOT) plotter.loglogplot(freq_THz, bling_TOT) if self.generate_checkboxs[1].IsChecked(): # xw.write_col('Total signal(W/m^2/sr/Hz)', ts) plotter.loglogplot(freq_THz, ts) if self.generate_checkboxs[2].IsChecked(): # xw.write_col('Limiting Flux(W)', limiting_flux) plotter.loglogplot(freq_THz, limiting_flux) if self.generate_checkboxs[3].IsChecked(): # xw.write_col('Integration Time(s)', integration_time) plotter.loglogplot(freq_THz, integration_time) # xw.save() print "Plotting. DONE" # message box alert message_dialog = wx.MessageDialog(self, message='Successfully Generated!') message_dialog.SetTitle("Successful!") if message_dialog.ShowModal() == wx.ID_OK: message_dialog.Destroy()