當前位置: 首頁>>代碼示例>>Python>>正文


Python JLA_library.computeOffsets方法代碼示例

本文整理匯總了Python中JLA_library.computeOffsets方法的典型用法代碼示例。如果您正苦於以下問題:Python JLA_library.computeOffsets方法的具體用法?Python JLA_library.computeOffsets怎麽用?Python JLA_library.computeOffsets使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在JLA_library的用法示例。


在下文中一共展示了JLA_library.computeOffsets方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: compute_Ccal

# 需要導入模塊: import JLA_library [as 別名]
# 或者: from JLA_library import computeOffsets [as 別名]

#.........這裏部分代碼省略.........
    # ------------- Create an area to work in -----------------------
    workArea = JLA.get_full_path(options.workArea)
    try:
        os.mkdir(workArea)
    except:
        pass

    # -----------   The lightcurve fitting --------------------------

    firstSN=True
    
    log=open('log.txt','w')

    for i,SN in enumerate(SNeList):
        J=[]
        try:
            os.mkdir(workArea+'/'+SN['id'])
        except:
            pass

        #firstModel=True
        print 'Examining SN #%d %s' % (i+1,SN['id'])

        # Set up the number of processes
        pool = mp.Pool(processes=int(options.processes))
        # runSALT is the program that does the lightcurve fitting
        results = [pool.apply(runSALT, args=(SALTpath,
                                             SALTmodel,
                                             salt_prefix,
                                             SN['lc'],
                                             SN['id'])) for SALTmodel in SALTmodels]
        for result in results[1:]:
            # The first model is the unperturbed model
            dM,dX,dC=JLA.computeOffsets(results[0],result)
            J.extend([dM,dX,dC])
        pool.close() # This prevents to many open files

        if firstSN:
            J_new=numpy.array(J).reshape(nSALTmodels,3).T
            firstSN=False
        else:
            J_new=numpy.concatenate((J_new,numpy.array(J).reshape(nSALTmodels,3).T),axis=0)

        log.write('%d rows %d columns\n' % (J_new.shape[0],J_new.shape[1]))

    log.close()

    # Compute the new covariance matrix J . Cal . J.T produces a 3 * n_SN by 3 * n_SN matrix
    # J=jacobian

    J_smoothed=numpy.array(J_new)*0.0
    J=J_new

    # We need to concatenate the different samples ...
    
    if options.Plot:
        try:
            os.mkdir('figures')
        except:
            pass               

    nPoints={'SNLS':11,'SDSS':11,'nearby':11,'high-z':11,'DES':11} 
    #sampleList=['nearby','DES']
    sampleList=params['smoothList'].split(',')
    if options.smoothed:
        # We smooth the Jacobian 
開發者ID:dessn,項目名稱:Covariance,代碼行數:70,代碼來源:jla_compute_Ccal.py


注:本文中的JLA_library.computeOffsets方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。