コード例 #1
0
ファイル: atmodel.py プロジェクト: qcheung/src
    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()
コード例 #2
0
ファイル: generateSED.py プロジェクト: mniebergall/atmodel
a_high = -1.56
v_radio = 0.24*10**12 #Hz
v_midIR =  4.8*10**12 #Hz

#generate SED
def SED(freq):
    result = []
    for i in range(len(freq)):
        v0 = freq[i]
        if v0 < v_radio:
            f = v0**a_radio
        elif v0 < v_midIR:
            f = v0**beta * (2 * const.h * v0**3 / const.c**2) * ((np.exp(const.h * v0 / (const.k * Td))-1)**(-1))
        else:
            f = v0**a_high
        result.append(f)
    return result
        
#xw = excel.ExcelWriter("/home/dave/SED_generate.xlsx")
freq_cm = np.array(cal.generate_freq(start = 0.05, step = 0.1, stop = 2005))
#xw.write_col("freq/cm^-1", freq_cm)
freq_hz = 3*10**10*freq_cm
#xw.write_col("freq/Hz", freq_hz)
freq_thz = freq_hz*10**(-12)
#xw.write_col("freq/THz", freq_thz)
f = np.array(SED(freq_hz))#*10**(-26)
#xw.write_col("Intensity", f)
#xw.save()

plotter.loglogplot(freq_thz, f)