def makeMCMaxStars(self, models): ''' Set parameters for star_list taken from the MCMax database. Based on the model id of MCMax. @param models: model_ids for the MCMax db @type models: list(string) @return: The model instances @rtype: list(Star()) ''' star_grid = Star.makeStars(models=models,code='MCMax',id_type='MCMax',\ path=self.path) for star, model in zip(star_grid, models): filepath = os.path.join(cc.path.mout,'models',\ star['LAST_MCMAX_MODEL']) denstemp = os.path.join(filepath, 'denstemp.dat') logfile = os.path.join(filepath, 'log.dat') grid_shape = DataIO.getMCMaxOutput(filename=denstemp,incr=1,\ keyword='NGRAINS',single=0)[0] star.update({'NTHETA':int(grid_shape[1]),\ 'NRAD':int(grid_shape[0]),\ 'T_STAR':float(DataIO.getMCMaxOutput(filename=logfile,\ incr=0,\ keyword='STELLAR TEMPERATURE',\ single=0)[0][2]),\ 'R_STAR':float(DataIO.getMCMaxOutput(filename=logfile,\ incr=0,\ keyword='STELLAR RADIUS',\ single=0)[0][2])}) return star_grid
def makeMCMaxStars(self,models): ''' Set parameters for star_list taken from the MCMax database. Based on the model id of MCMax. @param models: model_ids for the MCMax db @type models: list(string) @return: The model instances @rtype: list(Star()) ''' star_grid = Star.makeStars(models=models,code='MCMax',id_type='MCMax',\ path=self.path) for star,model in zip(star_grid,models): filepath = os.path.join(cc.path.mout,'models',\ star['LAST_MCMAX_MODEL']) denstemp = os.path.join(filepath,'denstemp.dat') logfile = os.path.join(filepath,'log.dat') grid_shape = DataIO.getMCMaxOutput(filename=denstemp,incr=1,\ keyword='NGRAINS',single=0)[0] star.update({'NTHETA':int(grid_shape[1]),\ 'NRAD':int(grid_shape[0]),\ 'T_STAR':float(DataIO.getMCMaxOutput(filename=logfile,\ incr=0,\ keyword='STELLAR TEMPERATURE',\ single=0)[0][2]),\ 'R_STAR':float(DataIO.getMCMaxOutput(filename=logfile,\ incr=0,\ keyword='STELLAR RADIUS',\ single=0)[0][2])}) return star_grid
def setModels(self,star_grid=[],models=[]): ''' Load the models and remember them. @keyword star_grid: The parameter sets, if not given: model ids needed (default: []) @type star_grid: list[Star()] @keyword models: the PACS ids, only relevant if star_grid == [] and if instrument == PACS. In all other cases a star_grid is required. (default: []) @type models: list[string] @keyword extra_keywords: any instrument specific keywords that you need (default: dict()) @type extra_keywords: dict ''' #-- The unresolved-data case if self.instrument: instr = self.instrument.instrument.upper() print '***********************************' print '* Checking Sphinx models for comparison with %s.'%instr if instr == 'SPIRE': models = [] if not star_grid and not models: raise IOError('Statistics.setModels requires either ' + \ 'star_grid or models to be defined.') #-- star_grid can be reconstructed for PACS through its database elif not star_grid: star_grid = Star.makeStars(models=models,id_type='PACS',\ path=path_code,code=self.code) self.instrument.addStarPars(star_grid) if set([s['MOLECULE'] and 1 or 0 for s in star_grid]) == set([0]): return self.instrument.prepareSphinx(star_grid) self.star_grid = [star for star in star_grid if star['LAST_%s_MODEL'%instr] <> None] #-- The FREQ_RESO case else: if not star_grid: raise IOError('Statistics.setModels requires a ' + \ 'star_grid to be defined for freq-resolved data.') if set([s['MOLECULE'] and 1 or 0 for s in star_grid]) == set([0]): return self.star_grid = star_grid
def makeStars(self, models): ''' Make a Star list based on the Chemistry model ids. @param models: model_ids for the Chemistry db @type models: list(string) @return: the parameter sets @rtype: list[Star()] ''' star_grid = Star.makeStars(models=models,\ id_type='Chemistry',\ code='Chemistry',path=self.path) [star.addCoolingPars() for star in star_grid] return star_grid
def makeStars(self,models): ''' Make a Star list based on the Chemistry model ids. @param models: model_ids for the Chemistry db @type models: list(string) @return: the parameter sets @rtype: list[Star()] ''' star_grid = Star.makeStars(models=models,\ id_type='Chemistry',\ code='Chemistry',path=self.path) [star.addCoolingPars() for star in star_grid] return star_grid