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)
Exemplo n.º 2
0
 def getAk(self,distance=None,map='marshall',law='Fitz2004Chiar2006'):
 
     '''
     Helper method to retrieve the Ak extinction magnitude for a given 
     distance.
     
     The Ak values are saved in the sed object, to cut down the overhead in 
     subsequent calls. 
     
     The law and map have to be passed as well. Defaults are marshall and 
     Fitz2004Chiar2006 respectively.
     
     @param distance: The distance to the source. If the default, the total
                      extinction is calculated in given direction. 
                      
                      (default: None)
     @type distance: float
     @keyword map: The galactic 3d extinction model. 
 
                   (default: 'marshall')
     @type map: str
     @keyword law: The reddening law
             
                   (default: 'Fitz2004Chiar2006')
     @type law: str
 
     @return: The extinction magnitude in K-band for the requested distance.
     @rtype: float
     
     '''
     
     distance = float(distance)
     if not self.ak.has_key((distance,map,law)):
         aki = Reddening.getAk(self.ll,self.bb,distance,map,law)
         self.ak[(distance,map,law)] = aki
     
     return self.ak[(distance,map,law)]
Exemplo n.º 3
0
    def getAk(self, distance=None, map='marshall', law='Fitz2004Chiar2006'):
        '''
        Helper method to retrieve the Ak extinction magnitude for a given 
        distance.
        
        The Ak values are saved in the sed object, to cut down the overhead in 
        subsequent calls. 
        
        The law and map have to be passed as well. Defaults are marshall and 
        Fitz2004Chiar2006 respectively.
        
        @param distance: The distance to the source. If the default, the total
                         extinction is calculated in given direction. 
                         
                         (default: None)
        @type distance: float
        @keyword map: The galactic 3d extinction model. 
    
                      (default: 'marshall')
        @type map: str
        @keyword law: The reddening law
                
                      (default: 'Fitz2004Chiar2006')
        @type law: str
    
        @return: The extinction magnitude in K-band for the requested distance.
        @rtype: float
        
        '''

        distance = float(distance)
        if not self.ak.has_key((distance, map, law)):
            aki = Reddening.getAk(self.ll, self.bb, distance, map, law)
            self.ak[(distance, map, law)] = aki

        return self.ak[(distance, map, law)]