Exemplo n.º 1
0
 def setModelPhotometry(self):
 
     '''
     Prepare the model photometry to be compared with the data. 
     
     Two kinds: The IvS photometry with proper photometric bands, and other
     photometry to be compared with the interpolated model spectrum. 
     
     '''
     
     
     #- Collect model data and set ak if needed
     mids = [s['LAST_MCMAX_MODEL'] for s in self.star_grid]
     if not mids:
         print "No successfully calculated MCMax models found."
         return
     
     self.mwave = []
     self.mflux = []
     for model_id,s in zip(mids,self.star_grid):
         dpath = os.path.join(cc.path.mout,'models',model_id)
         fn_spec = 'spectrum{:04.1f}.dat'.format(s['RT_INCLINATION'])
         w,f = MCMax.readModelSpectrum(dpath,s['RT_SPEC'],fn_spec)
         if s['REDDENING']:
             print 'Reddening models to correct for interstellar extinction.'
             ak = self.sed.getAk(s['DISTANCE'],s['REDDENING_MAP'],\
                                 s['REDDENING_LAW'])
             f = Reddening.redden(w,f,ak,law=s['REDDENING_LAW'])
         self.mwave.append(w)
         self.mflux.append(f)
     
     if self.photbands.size:
         self.mphot_ivs = [Sed.calcPhotometry(w,f,self.photbands)
                           for w,f in zip(self.mwave,self.mflux)]
         
     for fn in self.dphot_other.keys():
         self.mphot_other[fn] = []
     if self.dphot_other.keys():
         for w,f in zip(self.mwave,self.mflux):
             interp = interp1d(w,f)
             for fn in self.dphot_other.keys():
                 finter = interp(self.dphot_other[fn]['wave'])
                 self.mphot_other[fn].append(finter)