コード例 #1
0
 def parseProfile(self):
     
     '''
     Parse the sphinx file 2, which includes all line profile info.
     
     The output is stored in dict self['sph2'].
     
     '''
     
     self['sph2'] = dict()
     self['sph2']['nobeam'] = dict()
     self['sph2']['beam'] = dict()
     self['sph2']['nobeam_cont'] = dict()
     self['sph2']['beam_cont'] = dict()
     data = self.getFile(wildcard='2',delimiter=' ')
     data_col_1 = [d[0] for d in data]
     data_i = 6
     data_j = DataIO.findString(data_i,data_col_1)
     self['sph2']['nobeam']['velocity'] = array([float(line[0]) 
                                           for line in data[data_i:data_j]])
     
     #-- Reverse this flux grid. Sphinx output files give the mirrored
     #   flux grid for the associated velocity grid.
     self['sph2']['nobeam']['flux'] = array([DataIO.convertFloat(line[-1],\
                                                                  nans=1) 
                                           for line in data[data_i:data_j]])
     self['sph2']['nobeam']['flux'] = self['sph2']['nobeam']['flux'][::-1]
     data_k = data_j + 4
     data_l = DataIO.findString(data_k,data_col_1)
     self['sph2']['beam']['velocity'] =  array([float(line[0]) 
                                           for line in data[data_k:data_l]])
     self['sph2']['beam']['flux'] =      array([float(line[-1]) 
                                           for line in data[data_k:data_l]])  
     self['sph2']['beam']['norm_flux'] = array([float(line[1]) 
                                           for line in data[data_k:data_l]])
     self['sph2']['beam']['tmb'] =       array([float(line[2]) 
                                           for line in data[data_k:data_l]])
     
     #-- Set the continuum value for the different profiles
     self.setContinuum('nobeam','flux')
     for lp in ['flux','norm_flux','tmb']:
         self.setContinuum('beam',lp)
         
     #-- Check if the velocity is correctly monotonously increasing
     if self['sph2']['beam']['velocity'][0] > self['sph2']['beam']['velocity'][-1]:
         self['sph2']['beam']['velocity'] = self['sph2']['beam']['velocity'][::-1]
         self['sph2']['beam']['flux'] = self['sph2']['beam']['flux'][::-1]
         self['sph2']['beam']['norm_flux'] = self['sph2']['beam']['norm_flux'][::-1]
         self['sph2']['beam']['tmb'] = self['sph2']['beam']['tmb'][::-1]
     if self['sph2']['nobeam']['velocity'][0] > self['sph2']['nobeam']['velocity'][-1]:
         self['sph2']['nobeam']['velocity'] = self['sph2']['nobeam']['velocity'][::-1]
         self['sph2']['nobeam']['flux'] = self['sph2']['nobeam']['flux'][::-1]
     
     #-- Check for NaNs in the profile.
     if True in list(isnan(self['sph2']['nobeam']['flux'])):
         self.nans_present = True
         print "WARNING! There are NaN's in the intrinsic line profile " + \
               "with model id %s:"\
               %(os.path.split(os.path.split(self.fn)[0])[1])
         print os.path.split(self.fn.replace('sph*','sph2'))[1]
コード例 #2
0
    def parseProfile(self):
        '''
        Parse the sphinx file 2, which includes all line profile info.
        
        The output is stored in dict self.sph2.
        
        '''

        self.sph2 = dict()
        self.contents['sph2'] = self.sph2
        self.sph2['nobeam'] = dict()
        self.sph2['beam'] = dict()
        self.sph2['nobeam_cont'] = dict()
        self.sph2['beam_cont'] = dict()
        data = self.getFile(self.filename.replace('*', '2'))
        data_col_1 = [d[0] for d in data]
        data_i = 6
        data_j = DataIO.findString(data_i, data_col_1)
        self.sph2['nobeam']['velocity'] = array(
            [float(line[0]) for line in data[data_i:data_j]])
        #-- Reverse this flux grid. Sphinx output files give the mirrored
        #   flux grid for the associated velocity grid.
        self.sph2['nobeam']['flux'] =     array([DataIO.convertFloat(line[-1],\
                                                                     nans=1)
                                              for line in data[data_i:data_j]])
        self.sph2['nobeam']['flux'] = self.sph2['nobeam']['flux'][::-1]
        data_k = data_j + 4
        data_l = DataIO.findString(data_k, data_col_1)
        self.sph2['beam']['velocity'] = array(
            [float(line[0]) for line in data[data_k:data_l]])
        self.sph2['beam']['flux'] = array(
            [float(line[-1]) for line in data[data_k:data_l]])
        self.sph2['beam']['norm_flux'] = array(
            [float(line[1]) for line in data[data_k:data_l]])
        self.sph2['beam']['tmb'] = array(
            [float(line[2]) for line in data[data_k:data_l]])

        self.setContinuum('nobeam', 'flux')
        for lp in ['flux', 'norm_flux', 'tmb']:
            self.setContinuum('beam', lp)
        if self.sph2['beam']['velocity'][0] > self.sph2['beam']['velocity'][-1]:
            self.sph2['beam']['velocity'] = self.sph2['beam']['velocity'][::-1]
            self.sph2['beam']['flux'] = self.sph2['beam']['flux'][::-1]
            self.sph2['beam']['norm_flux'] = self.sph2['beam'][
                'norm_flux'][::-1]
            self.sph2['beam']['tmb'] = self.sph2['beam']['tmb'][::-1]
        if self.sph2['nobeam']['velocity'][0] > self.sph2['nobeam'][
                'velocity'][-1]:
            self.sph2['nobeam']['velocity'] = self.sph2['nobeam'][
                'velocity'][::-1]
            self.sph2['nobeam']['flux'] = self.sph2['nobeam']['flux'][::-1]
        if True in list(isnan(self.sph2['nobeam']['flux'])):
            self.nans_present = True
            print "WARNING! There are NaN's in the intrinsic line profile " + \
                  "with model id %s:"\
                  %(os.path.split(os.path.split(self.filename)[0])[1])
            print os.path.split(self.filename.replace('sph*', 'sph2'))[1]
コード例 #3
0
ファイル: SphinxReader.py プロジェクト: FungKu01/ComboCode
    def parseProfile(self):

        """
        Parse the sphinx file 2, which includes all line profile info.
        
        The output is stored in dict self.sph2.
        
        """

        self.sph2 = dict()
        self.contents["sph2"] = self.sph2
        self.sph2["nobeam"] = dict()
        self.sph2["beam"] = dict()
        self.sph2["nobeam_cont"] = dict()
        self.sph2["beam_cont"] = dict()
        data = self.getFile(self.filename.replace("*", "2"))
        data_col_1 = [d[0] for d in data]
        data_i = 6
        data_j = DataIO.findString(data_i, data_col_1)
        self.sph2["nobeam"]["velocity"] = array([float(line[0]) for line in data[data_i:data_j]])
        # -- Reverse this flux grid. Sphinx output files give the mirrored
        #   flux grid for the associated velocity grid.
        self.sph2["nobeam"]["flux"] = array([DataIO.convertFloat(line[-1], nans=1) for line in data[data_i:data_j]])
        self.sph2["nobeam"]["flux"] = self.sph2["nobeam"]["flux"][::-1]
        data_k = data_j + 4
        data_l = DataIO.findString(data_k, data_col_1)
        self.sph2["beam"]["velocity"] = array([float(line[0]) for line in data[data_k:data_l]])
        self.sph2["beam"]["flux"] = array([float(line[-1]) for line in data[data_k:data_l]])
        self.sph2["beam"]["norm_flux"] = array([float(line[1]) for line in data[data_k:data_l]])
        self.sph2["beam"]["tmb"] = array([float(line[2]) for line in data[data_k:data_l]])

        self.setContinuum("nobeam", "flux")
        for lp in ["flux", "norm_flux", "tmb"]:
            self.setContinuum("beam", lp)
        if self.sph2["beam"]["velocity"][0] > self.sph2["beam"]["velocity"][-1]:
            self.sph2["beam"]["velocity"] = self.sph2["beam"]["velocity"][::-1]
            self.sph2["beam"]["flux"] = self.sph2["beam"]["flux"][::-1]
            self.sph2["beam"]["norm_flux"] = self.sph2["beam"]["norm_flux"][::-1]
            self.sph2["beam"]["tmb"] = self.sph2["beam"]["tmb"][::-1]
        if self.sph2["nobeam"]["velocity"][0] > self.sph2["nobeam"]["velocity"][-1]:
            self.sph2["nobeam"]["velocity"] = self.sph2["nobeam"]["velocity"][::-1]
            self.sph2["nobeam"]["flux"] = self.sph2["nobeam"]["flux"][::-1]
        if True in list(isnan(self.sph2["nobeam"]["flux"])):
            self.nans_present = True
            print "WARNING! There are NaN's in the intrinsic line profile " + "with model id %s:" % (
                os.path.split(os.path.split(self.filename)[0])[1]
            )
            print os.path.split(self.filename.replace("sph*", "sph2"))[1]