MODEL_AGNfitter.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:AGNfitter 作者: GabrielaCR 项目源码 文件源码
def filters1( model_nus, model_fluxes, filterdict, z ):    

    """
    Projects the model SEDs into the filter curves of each photometric band.

    ##input:
    - model_nus: template frequencies [log10(nu)]
    - model_fluxes: template fluxes [F_nu]
    - filterdict: dictionary with all band filter curves' information.
                  To change this, add one band and filter curve, etc,
                  look at DICTIONARIES_AGNfitter.py
    - z: redshift

    ##output:
    - bands [log10(nu)]
    - Filtered fluxes at these bands [F_nu]
    """

    bands, files_dict, lambdas_dict, factors_dict = filterdict
    filtered_model_Fnus = []


    # Costumize model frequencies and fluxes [F_nu]
    # to same units as filter curves (to wavelengths [angstrom] and F_lambda)
    model_lambdas = nu2lambda_angstrom(model_nus) * (1+z)
    model_lambdas =  model_lambdas[::-1]
    model_fluxes_nu =  model_fluxes[::-1]
    model_fluxes_lambda = fluxnu_2_fluxlambda(model_fluxes_nu, model_lambdas) 
    mod2filter_interpol = interp1d(model_lambdas, model_fluxes_lambda, kind = 'nearest', bounds_error=False, fill_value=0.)            

    # For filter curve at each band. 
    # (Vectorised integration was not possible -> different filter-curve-arrays' sizes)
    for iband in bands:

        # Read filter curves info for each data point 
        # (wavelengths [angstrom] and factors [non])
        lambdas_filter = np.array(lambdas_dict[iband])
        factors_filter = np.array(factors_dict[iband])
        iband_angst = nu2lambda_angstrom(iband)

        # Interpolate the model fluxes to 
        #the exact wavelengths of filter curves
        modelfluxes_at_filterlambdas = mod2filter_interpol(lambdas_filter)
        # Compute the flux ratios, equivalent to the filtered fluxes: 
        # F = int(model)/int(filter)
        integral_model = trapz(modelfluxes_at_filterlambdas*factors_filter, x= lambdas_filter)
        integral_filter = trapz(factors_filter, x= lambdas_filter)     
        filtered_modelF_lambda = (integral_model/integral_filter)

        # Convert all from lambda, F_lambda  to Fnu and nu    
        filtered_modelFnu_atfilter_i = fluxlambda_2_fluxnu(filtered_modelF_lambda, iband_angst)
        filtered_model_Fnus.append(filtered_modelFnu_atfilter_i)

    return bands, np.array(filtered_model_Fnus)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号