def calc_chi2(profs, nuparstore): chi2 = 0. off = 0 for pop in np.arange(gp.pops)+1: # nu with normalization to 1 in first bin nuparams = nuparstore[pop-1] Numodel = rho_param_INT_Rho(gp.xepol, nuparams) # [Msun/pc^2], on nipol bins # Numodel = rho_INT_Rho(gp.xipol, profs.get_nu(pop)) # [Msun/pc^2] Nudata = compare_nu(pop,True,False) # [Msun/pc^2] Nuerr = compare_nu(pop,True,True) # [Msun/pc^2] chi2_nu = chi2red(Numodel, Nudata, Nuerr, gp.dof) # [1] chi2 += chi2_nu # [1] sigdat = gp.dat.sigdat[pop] # [km/s] sigerr = gp.dat.sigerr[pop] # [km/s] chi2_sig = chi2red(profs.get_sig(pop), sigdat, sigerr, gp.dof) # [1] chi2 += chi2_sig # [1] print('profs: ', profs.get_nu(pop)[0],', data: ', Nudata[0]) print('chi2_nu, chi2_sig = ',chi2_nu,' ',chi2_sig) # TODO: check huge offset of Numodel (1000s Msun/pc^2) and Nudata (0.3 Msun/pc^2) if gp.usekappa: kapdat = gp.dat.kapdat[pop] # [1] kaperr = gp.dat.kaperr[pop] # [1] chi2_kap = chi2red(profs.get_kap(pop), kapdat, kaperr, gp.dof) # [1] chi2 += chi2_kap # [1] return chi2
def sig_kap_los(r0, pop, rho_param, nu_param, beta_param): surfden = rho_param_INT_Rho(r0, rho_param) # total surface density siglos2surf,kaplos4surf = ant_sigkaplos2surf(r0, beta_param,\ rho_param, nu_param) # takes [pc], [1*pc], [munit], [munit/pc^3], returns [(km/s)^2], [1] siglos2 = siglos2surf[:-3]/surfden # [(km/s)^2] siglos = np.sqrt(siglos2) # [km/s] if gp.usekappa: kaplos4 = kaplos4surf/surfden # takes [munit/pc^2 (km/s)^2], gives back [(km/s)^2] kaplos = kaplos4/(siglos2**2) # - 3.0 # subtract 3.0 for Gaussian distribution in Fisher version. else: kaplos = 3.*np.ones(len(siglos)) return siglos, kaplos # [km/s], [1]