def RUN_AGNfitter_onesource( line, data_obj, modelsdict):
    """
    Main function for fitting a single source in line 'line'.
    """
    
    mc = MCMC_settings()
    out = OUTPUT_settings()

    data = DATA(data_obj,line)
    data.DICTS(filters, Modelsdict)

    P = parspace.Pdict (data)  # Dictionary with all parameter space especifications.
                                # From PARAMETERSPACE_AGNfitter.py

    print ''
    print 'Fitting sources from catalog: ', data.catalog 
    print '- Sourceline: ', line
    print '- Sourcename: ', data.name


    t1= time.time()

    MCMC_AGNfitter.main(data, P, mc)        
    PLOTandWRITE_AGNfitter.main(data,  P,  out)


    print '_____________________________________________________'
    print 'For this fit %.2g min elapsed'% ((time.time() - t1)/60.)
    return
Esempio n. 2
0
def RUN_AGNfitter_onesource( line, data_obj, models):
    """
    Main function for fitting a single source in line 'line'.
    """
    
    mc = MCMC_settings()
    out = OUTPUT_settings()
    data = DATA(data_obj,line)
    data.DICTS(filters, Modelsdict)

    P = parspace.Pdict (data)  # Dictionary with all parameter space especifications.
                                # From PARAMETERSPACE_AGNfitter.py

    print ''
    print '________________________'      
    print 'Fitting sources from catalog: ', data.catalog 
    print '- Sourceline: ', line
    print '- Sourcename: ', data.name

    t1= time.time()

    MCMC_AGNfitter.main(data, P, mc)        
    PLOTandWRITE_AGNfitter.main(data,  P,  out, models)


    print '_____________________________________________________'
    print 'For this fit %.2g min elapsed'% ((time.time() - t1)/60.)
    return
Esempio n. 3
0
def RUN_AGNfitter_onesource_independent(cat, line, data_obj, filtersz, clobbermodel=False):
    """
    Main function for fitting a single source in line 'line' and create it's modelsdict independently.
    """
    
    mc = MCMC_settings()
    out = OUTPUT_settings()

    data = DATA(data_obj,line)

    print ''
    print 'Fitting sources from catalog: ', data.catalog 
    print '- Sourceline: ', line
    print '- Sourcename: ', data.name


    ## 0. CONSTRUCT DICTIONARY for this redshift
    t0= time.time()

    # needs a list/array of z
    filtersz['dict_zarray'] = [data.z]

    # save the dictionary for this source in the OUTPUT folder for this source
    # create this source output folder if it doesn't exist
    if not os.path.lexists(cat['output_folder'] +'/'+str(data.name)):
        os.system('mkdir -p ' + cat['output_folder'] +'/'+str(data.name))
    dictz = cat['output_folder'] +'/'+str(data.name) +'/MODELSDICT_' + str(data.name) 
    # remove this source modelsdict if it already exists and we want to remove it
    if clobbermodel and os.path.lexists(dictz):
        os.system('rm -rf '+dictz)
        print "removing source model dictionary "+dictz
      
    if not os.path.lexists(dictz):
        zdict = MODELSDICT(dictz, cat['path'], filtersz)
        Modelsdictz = zdict.build(save=False)
        print '_____________________________________________________'
        print 'For this dictionary creation %.2g min elapsed'% ((time.time() - t0)/60.)
    else:
        Modelsdictz = cPickle.load(file(dictz, 'rb')) 

    data.DICTS(filtersz, Modelsdictz)


    P = parspace.Pdict (data)   # Dictionary with all parameter space especifications.
                                # From PARAMETERSPACE_AGNfitter.py

    t1= time.time()

    MCMC_AGNfitter.main(data, P, mc)        
    print 'fitting took %.2g min'% ((time.time() - t1)/60.)
    
    t2= time.time()
    PLOTandWRITE_AGNfitter.main(data,  P,  out)
    print 'plotting took %.2g min '% ((time.time() - t2)/60.)


    print '_____________________________________________________'
    print 'Processing this source took %.2g min '% ((time.time() - t0)/60.)
    return
Esempio n. 4
0
def RUN_AGNfitter_onesource_independent( line, data_obj, filtersz, models, clobbermodel=False):
    """
    Main function for fitting a single source in line and create it's modelsdict independently.
    """
    
    mc = MCMC_settings()
    out = OUTPUT_settings()
    data = DATA(data_obj,line)

    print ''
    print '________________________'    
    print 'Fitting sources from catalog: ', data.catalog 
    print '- Sourceline: ', line
    print '- Sourcename: ', data.name


    ## 0. CONSTRUCT DICTIONARY for this redshift
    t0= time.time()

    ## needs a list/array of z
    filtersz['dict_zarray'] = [data.z]

    ## save the dictionary for this source in the OUTPUT folder for this source
    ## create this source output folder if it doesn't exist
    if not os.path.lexists(cat['output_folder']+str(data.name)):
        os.system('mkdir -p ' + cat['output_folder'] +str(data.name))
    dictz = cat['output_folder'] +str(data.name) +'/MODELSDICT_' + str(data.name) 
    ## remove this source modelsdict if it already exists and we want to remove it
    if clobbermodel and os.path.lexists(dictz):
        os.system('rm -rf '+dictz)
        print "removing source model dictionary "+dictz
      
    if not os.path.lexists(dictz):
        zdict = MODELSDICT(dictz, cat['path'], filtersz, models)
        zdict.build()
        f = open(zdict.filename, 'wb')
        cPickle.dump(zdict, f, protocol=2)
        f.close()
        print '_____________________________________________________'
        print 'For this dictionary creation %.2g min elapsed'% ((time.time() - t0)/60.)
    else:
        zdict = cPickle.load(file(dictz, 'rb'))
    Modelsdictz = zdict.MD

    data.DICTS(filtersz, Modelsdictz)

    P = parspace.Pdict (data)   # Dictionary with all parameter space especifications.
                                # From PARAMETERSPACE_AGNfitter.py

    t1= time.time()

    MCMC_AGNfitter.main(data, P, mc)        
    PLOTandWRITE_AGNfitter.main(data,  P,  out, models)


    print '_____________________________________________________'
    print 'For this fit %.2g min elapsed'% ((time.time() - t1)/60.)
    return