def bolometric_correction(self, component = 'tot', filternamelist = None): lightspeed = 2.998e18 #AA/s filterlist = observate.load_filters(filternamelist) mags = observate.getSED(self.spectrum[component]['wavelength'], self.spectrum[component]['f_lambda_int'], filterlist) nueff = np.array([lightspeed/f.wave_effective for f in filterlist]) #log_nuLnu = log_bc = self.spectrum[component]['log_Lbol'] - log_nuLnu return bc
imnamelist = ['mips_24.6arcsec.Jypix','pacs_70.6arcsec.Jypix', 'pacs_100.6arcsec.Jypix','pacs_160.6arcsec.Jypix', 'spire_250.6arcsec.Jypix'] errnamelist = ['x','pacs_70.6arcsec.sig','pacs_100.6arcsec.sig', 'pacs_160.6arcsec.sig','x'] rp['fudge_err'] = [0.1,0.1,0.1,0.1,0.15] #errors to use when true error images don't exist rp['impath'] = os.getenv('pyxydust')+'/imdata/NGC6822' rp['imnamelist'] = ['{0}_conv250_{1}.fits'.format(rp['impath'],name) for name in imnamelist] rp['errnamelist'] = ['{0}_{1}.fits'.format(rp['impath'],name) for name in errnamelist] ##### load the filters and the DL07 model grid dl07 = dustmodel.DraineLi() filterlist = observate.load_filters(rp['fnamelist']) ############### END USER INPUT ########## ############### MAIN #################### #do it this way so the main function can come first def main(rp): print('starting main') ##### read the images and errors data_mag, data_magerr, header = datacube.loadImageCube(rp['imnamelist'],rp['errnamelist'],rp['fudge_err']) dm = 5.0*np.log10(rp['dist'])+25 data_mag = np.where(data_mag != 0.0, data_mag-dm, 0.0) nx, ny = data_mag.shape[0], data_mag.shape[1]
dust = attenuation.Attenuator(dust_type = rp['dust_type']) fitter = sf.StarfitterGrid(rp) #set up priors in the grid fitter.initialize_grid(params = None) fitter.set_params_from_isochrone(Z = [0.0077]) fitter.stargrid.pars['R_V'] = 3.0 #fix extra dust parameters (should marginalize over, but requires thought about prior) fitter.stargrid.pars['F_BUMP'] = 0.5 #fix extra dust parameters (should marginalize over, but requires thought about prior) fitter.build_grid(attenuator = dust) ## Set up for predicting the emission in any band ## Do this after running fitter.initialize_grid() but before ## running fitter.fit_image() pred_fnamelist = ['galex_NUV', 'galex_FUV'] pred_filt = observate.load_filters(pred_fnamelist) prediction_sed, tmp1, tmp2 = fitter.basel.generateSEDs(fitter.stargrid.pars, pred_filt,attenuator = dust, wave_min = 92, wave_max = 1e7) #for i in xrange(len(pred_filt)-1) : fitter.stargrid.add_par(prediction_sed[:,0] + 5.0*np.log10(rp['dist'])+25,pred_filt[0].name) fitter.rp['outparnames']+= [pred_filt[0].name] fitter.load_data() #Chhange the number of lines to extract #fitter.rp['nlines'] = 1e4 #fitter.rp['lines'] =None #fitter.load_data() fitter.fit_image() fitter.write_catalog(outparlist = ['galex_NUV', 'LOGT','LOGL', 'A_V'])
#Example hrdspy usage. determine dispersion in integrated spectrum #as a function of wavelength for a given mass and age. import numpy as np import starmodel import isochrone import observate import cluster import matplotlib.pyplot as pl import time # choose a few filters and load them filternamelist = ['ctio_mosaic_ii_Uj','ctio_mosaic_ii_B','ctio_mosaic_ii_V', 'ctio_mosaic_ii_Rc','ctio_mosaic_ii_Ic'] filterlist = observate.load_filters(filternamelist) j, k = 1, 3 #color to plot # instantiate and load the isochrones and spectra first so you # don't have to do it for each cluster realization isoc=isochrone.Padova2007() isoc.load_all_isoc() speclib = starmodel.BaSeL3() speclib.read_all_Z() # set cluster parameters Z = 0.0076 #LMC metallicity mtot = 1e3 #1000 solar masses logage = np.arange(7.2,9.2,0.2) nreal = 10 #10 realizations of the cluster