示例#1
0
    def build(self): 
        """ Calculate power/bispectrum of simulated/observed data catalog 
        """
        
        if 'clobber' not in (self.kwargs).keys(): 
            bool_clobber = False
        else: 
            bool_clobber = self.kwargs['clobber']

        codeclass = Fcode(self.type, self.cat_corr) 
        spec_code = codeclass.code
        spec_exe = codeclass.fexe()
        
        # code and exe modification time 
        speccode_t_mod, specexe_t_mod = codeclass.mod_time()

        if specexe_t_mod <= speccode_t_mod: 
            codeclass.compile()

        # fft files 
        if not os.path.isfile(self.datafft.file_name) or bool_clobber:
            self.datafft.build()

        if not os.path.isfile(self.randfft.file_name): 
            self.randfft.build()
        
        spec_cmd = codeclass.commandline_call(
                datafft = self.datafft.file_name, 
                randfft = self.randfft.file_name, 
                powerfile = self.file_name
                )
        print spec_cmd

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

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

        return None
示例#2
0
    def build(self): 
        """ Run FFT FORTRAN code to calculate FFT of data
        """
        specdict = (self.cat_corr)['spec'] 
        
        if not os.path.isfile(self.data_file):
            self.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 
示例#3
0
    def build(self): 
        """ Calculate power/bispectrum of simulated/observed data catalog 
        """
        
        if 'clobber' not in (self.kwargs).keys(): 
            bool_clobber = False
        else: 
            bool_clobber = self.kwargs['clobber']

        #if corrdict['name'] == 'fourier_tophat':
        #    if self.ell != 2: 
        #        raise ValueError

        #    true_cat_corr = {
        #            'catalog': catdict, 
        #            'correction': {'name': 'true'}
        #            }
        #    tr_gal = Data('data', true_cat_corr)

        #    fourier_tophat_Pk(self.cat_corr, self.file_name, tr_gal.file_name)
        #    return None

        codeclass = Fcode(self.type, self.cat_corr) 
        spec_code = codeclass.code
        spec_exe = codeclass.fexe()
        
        # code and exe modification time 
        speccode_t_mod, specexe_t_mod = codeclass.mod_time()

        if specexe_t_mod <= speccode_t_mod: 
            codeclass.compile()

        # fft files 
        datafft = Fft('data', self.cat_corr, **self.kwargs)
        if not os.path.isfile(datafft.file_name+'_0') or bool_clobber:
            datafft.build()

        randfft = Fft('random', self.cat_corr, **self.kwargs)
        if not os.path.isfile(randfft.file_name+'_0'): 
            randfft.build()
        
        spec_cmd = codeclass.commandline_call(
                datafft = datafft.file_name, 
                randfft = randfft.file_name, 
                powerfile = self.file_name
                )
        print spec_cmd

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

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

        return None