y, g1true, g2true, g1int, g2int, cval, cval, evaluate.MFID, evaluate.MFID, outfile=subfile, noise_sigma=NOISE_SIGMA[obs_type]) os.close(fdsub) # Then evaluate Q_v qc[obs_type][itest, jc] = evaluate.q_variable( subfile, EXPERIMENT, obs_type, usebins=evaluate.USEBINS, truth_dir=TRUTH_DIR) os.remove(subfile) print "Test %4d / %4d (c = %.3e) Q_v = %.4f" % ( itest + 1, NTEST, cval, qc[obs_type][itest, jc]) print "Mean Q_v = "+str(qc[obs_type][:, jc].mean())+" for "+str(NTEST)+\ " sims (with c = "+str(cval)+", obs_type = "+str(obs_type)+")" print print "Saving pickled Q_v versus c dict to " + coutfile with open(coutfile, "wb") as fout: cPickle.dump(qc, fout) print else:
g1int, g2int, cval, cval, mval, mval, outfile=subfile, noise_sigma=NOISE_SIGMA) os.close(fdsub) # First estimate the absolute metric qabsl = evaluate.q_variable( subfile, experiment, obs_type, logger=None, usebins=usebins[0], poisson_weight=poisson[0], fractional_diff=False, truth_dir=truth_dir, sigma2_min=sigma2_min, normalization=evaluate.NORMALIZATION_VARIABLE_SPACE) print "%3d/%3d: Q_v_absl (c = %.4f, m = %.4f) = %.5e" % ( k + 1, NTEST, cval, mval, qabsl) # Then the fractional qfrac = evaluate.q_variable(subfile, experiment, obs_type, logger=None, usebins=usebins[0], poisson_weight=poisson[0], fractional_diff=True,
# Get the unitc term map_E_unitc = 2. * test_evaluate.make_unitc( EXPERIMENT, obs_type, truth_dir=TRUTH_DIR) # Loop over c values for jc, cval in enumerate(CVALS): # Build the submissions (includes inter-method and inter-bin correlations) map_E_field_subs = make_multiple_variable_submissions( NTEST, map_E_ref, map_E_unitc, cval, evaluate.MFID, cholesky) # Loop over submissions evaluating metric for itest in xrange(NTEST): fdsub, subfile = tempfile.mkstemp(suffix=".dat") os.close(fdsub) write_submission(map_E_field_subs[:, itest], outfile=subfile) qc[obs_type][itest, jc] = evaluate.q_variable( subfile, EXPERIMENT, obs_type, truth_dir=TRUTH_DIR) os.remove(subfile) print "mean(Q_v), std(Q_v) = "+str(qc[obs_type][:, jc].mean())+", "+\ str(qc[obs_type][:, jc].std())+" for "+str(NTEST)+" sims (with c = "+\ str(cval)+", obs_type = "+str(obs_type)+")" print print "Saving pickled Q_v versus c dict to "+coutfile with open(coutfile, "wb") as fout: cPickle.dump(qc, fout) print else: with open(coutfile, "rb") as fin: qc = cPickle.load(fin) # Test to see if moutfile is already made, if not make it, if so load it if not os.path.isfile(moutfile): for obs_type in ("ground", "space"):
# outfile=subfile, noise_sigma=NOISE_SIGMA) #q = evaluate.q_variable( # subfile, experiment, obs_type, logger=logger, usebins=usebins[0], # poisson_weight=poisson[0], fractional_diff=fractional[0]) #os.remove(subfile) #print "%3d/%3d: Q_v (c = %.4f, m = %.4f) = %.5e" % (1, NTEST, cval, mval, q) for k in range(NTEST): fdsub, subfile = tempfile.mkstemp(suffix=".dat") result = make_variable_submission( x, y, g1true, g2true, g1int, g2int, cval, cval, mval, mval, outfile=subfile, noise_sigma=NOISE_SIGMA) os.close(fdsub) # First estimate the absolute metric qabsl = evaluate.q_variable( subfile, experiment, obs_type, logger=None, usebins=usebins[0], poisson_weight=poisson[0], fractional_diff=False, truth_dir=truth_dir, sigma2_min=sigma2_min, normalization=evaluate.NORMALIZATION_VARIABLE_SPACE) print "%3d/%3d: Q_v_absl (c = %.4f, m = %.4f) = %.5e" % ( k + 1, NTEST, cval, mval, qabsl) # Then the fractional qfrac = evaluate.q_variable( subfile, experiment, obs_type, logger=None, usebins=usebins[0], poisson_weight=poisson[0], fractional_diff=True, truth_dir=truth_dir, sigma2_min=sigma2_min_bymc / 10., normalization=300. * 0.6492) print "%3d/%3d: Q_v_frac (c = %.4f, m = %.4f) = %.5e" % ( k + 1, NTEST, cval, mval, qfrac) # Then the sqrd qsqrd = evaluate.q_variable( subfile, experiment, obs_type, logger=None, usebins=usebins[0], poisson_weight=poisson[0], fractional_diff=False, squared_diff=True, truth_dir=truth_dir, sigma2_min=sigma2_min * 3.e-5,