Exemplo n.º 1
0
def build_corrdata_wrapper(params): 
    ''' Wrapper for calculating corrected data   

    Parameters
    ----------
    params : [ cat_corr, kwargs ] 

    '''

    cat_corr = params[0]
    kwargs = {} 
    if len(params) > 1: 
        kwargs = params[1]
    kwargs['clobber'] = True
    
    dataclass = Data('data', cat_corr, **kwargs) 
    print dataclass.file_name
    dataclass.build() 

    return None
Exemplo n.º 2
0
                self.cosmo = cat.cosmo()

                return self.cosmo
            else: 
                # default fiducial cosmology (hardcoded)
                omega_m = 0.31 

        except KeyError: 
            omega_m = 0.31  # default 

        # survey cosmology 
        cosmo = {} 
        cosmo['omega_M_0'] = omega_m 
        cosmo['omega_lambda_0'] = 1.0 - omega_m 
        cosmo['h'] = 0.676
        cosmo = cosmos.distance.set_omega_k_0(cosmo) 
        self.cosmos = cosmo 

        return self.cosmos

if __name__ == '__main__':

    for i_mock in xrange(1,85): 
        for corr in ['true', 'upweight', 'photoz']:
            cat_corr = {
                    'catalog': {'name': 'nseries', 'n_mock': i_mock}, 
                    'correction': {'name': 'photoz'}
                    }
            corrclass = Data('data', cat_corr, clobber=True)
            corrclass.build()
Exemplo n.º 3
0
    def build(self): 
        """ Run FFT FORTRAN code to calculate FFT of data
        """
        
        catdict = (self.cat_corr)['catalog']
        corrdict = (self.cat_corr)['correction']
        specdict = (self.cat_corr)['spec'] 
        
        if not os.path.isfile(self.data_file):
            if self.type == 'data': 
                galdata = Data(self.cat_corr, **self.kwargs) 
            elif self.type == 'random': 
                galdata = Random(self.cat_corr, **self.kwargs) 
            galdata.build()

        #if 'quad' not in specdict.keys(): 
        #    raise KeyError(" 'quad' must be specified ") 
        #if not specdict['quad']:       # quadrupole or regular FFT code
        #    fft_type = 'fft'
        #else:  
        #    fft_type = 'quad_fft'
    
        if specdict['ell'] == 0: 
            fft_type = 'fft'
        else: 
            fft_type = 'quad_fft'       # (outdated naming convention but too lazy to fully change)

        codeclass = Fcode(fft_type, self.cat_corr) 
        fftcode = codeclass.code
        fftexe = codeclass.fexe()
        
        # code and exe modification time 
        fftcode_t_mod, fftexe_t_mod = codeclass.mod_time()

        if fftexe_t_mod < fftcode_t_mod: 
            codeclass.compile()
                
        fft_file = self.file() 

        if specdict['ell'] == 0:       # Monopole 
            
            # command line call 
            FFTcmd = codeclass.commandline_call(
                    DorR = self.type, 
                    datafile = self.data_file,
                    fftfile = self.file_name
                    ) 

            if 'clobber' not in (self.kwargs).keys(): 
                bool_clobber = False
            else: 
                bool_clobber = self.kwargs['clobber']

            if any([not os.path.isfile(self.file_name), bool_clobber]):
                print ''
                print '-----------------------'
                print 'Constructing '
                print self.file_name  
                print '-----------------------'
                print ''
                print FFTcmd
                print '-----------------------'

                subprocess.call(FFTcmd.split())
            else: 
                print ''
                print '-----------------------'
                print self.file_name  
                print 'Already Exists'
                print '-----------------------'
                print ''

        else:                           # others Quadrupole
            # command line call 
            FFTcmd = codeclass.commandline_call(
                    DorR = self.type, 
                    datafile = self.data_file,
                    fftfile = self.file_name
                    ) 

            if 'clobber' not in (self.kwargs).keys(): 
                bool_clobber = False
            else: 
                bool_clobber = self.kwargs['clobber']

            if any([not os.path.isfile(self.file_name), bool_clobber]):
                print ''
                print '-----------------------'
                print 'Constructing '
                print self.file_name  
                print '-----------------------'
                print ''
                print FFTcmd
                print '-----------------------'

                subprocess.call(FFTcmd.split())
            else: 
                print ''
                print '-----------------------'
                print self.file_name  
                print 'Already Exists'
                print '-----------------------'
                print ''

        return None