Given that we do not appear to have access to the Minerva sims, I'm going to compute covariances from the test boxes. I'm gonna start by computing a separate one for each HOD and Cosmology used, across realizations, and convince myself they don't vary much.


In [31]:
from pearce.mocks.kittens import TestBox
from pearce.mocks import tpcf_subregions
import numpy as np
from collections import OrderedDict
from time import time
from scipy.optimize import minimize_scalar

In [32]:
import matplotlib
#matplotlib.use('Agg')
from matplotlib import pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set()

In [33]:
nd = 1e-4
min_ptcl = 100
r_bins = np.logspace(-0.4, 1.6, 11)
logMmin_bounds = (12.0, 14.0)

In [34]:
r_bins


Out[34]:
array([  0.39810717,   0.63095734,   1.        ,   1.58489319,
         2.51188643,   3.98107171,   6.30957344,  10.        ,
        15.84893192,  25.11886432,  39.81071706])

In [35]:
hod_param_ranges =  OrderedDict({'sigma_logM': [0.05, 0.3], 'logM0': [13.1, 14.6], 'logM1': [13.1, 14.6], 'alpha': [0.8, 1.2]})

In [36]:
def make_LHC(ordered_params, N, seed = None):

    if seed is None:
        seed = int(time())
    np.random.seed(seed)

    points = []
    # by linspacing each parameter and shuffling, I ensure there is only one point in each row, in each dimension.
    for plow, phigh in ordered_params.itervalues():
        point = np.linspace(plow, phigh, num=N)
        np.random.shuffle(point)  # makes the cube random.
        points.append(point)
    return np.stack(points).T

In [37]:
def add_logMmin(hod_params, cat):

    hod_params['logMmin'] = 13.0 #initial guess
    #cat.populate(hod_params) #may be overkill, but will ensure params are written everywhere
    def func(logMmin, hod_params):
        hod_params.update({'logMmin':logMmin}) 
        return (cat.calc_analytic_nd(hod_params) - nd)**2

    #res = minimize_scalar(func, bounds = logMmin_bounds, args = (hod_params,), options = {'maxiter':100}, method = 'Bounded')

    # assuming this doens't fail
    #print 'logMmin', res.x
    hod_params['logMmin'] = 15.0#res.x

In [38]:
N = 10
LHC = make_LHC(hod_param_ranges, N)
hod_dicts = [dict(zip(hod_param_ranges.keys(), vals)) for vals in LHC]

In [39]:
from scipy.linalg import block_diag

In [40]:
-

In [6]:
out = [range(i) for i in xrange(4)]
import numpy as np
print np.hstack(out)
print out


[ 0.  0.  1.  0.  1.  2.]
[[], [0], [0, 1], [0, 1, 2]]

In [42]:
cov_mats = np.zeros((7,N, 5, 2*len(r_bins)-2, 2*len(r_bins)-2))

for boxno in xrange(7):
    for realization in xrange(5):
        cat = TestBox(boxno = boxno, realization = realization, system = 'sherlock')
        cat.load(1.0, HOD = str('zheng07'), particles = True, downsample_factor = 1e-2)
        for hod_idx, hod_params in enumerate(hod_dicts):
            add_logMmin(hod_params, cat)
            print hod_params

            cat.populate(hod_params)
            mat =  compute_full_jk(cat, r_bins)
            break
        break
    break


{'logM0': 14.266666666666666, 'sigma_logM': 0.16111111111111109, 'logM1': 13.266666666666666, 'logMmin': 15.0, 'alpha': 0.88888888888888895}
/home/users/swmclau2/.local/lib/python2.7/site-packages/pearce/mocks/cat.py:284: UserWarning: n_cores invalid. Changing from 100 to maximum 16.
  warnings.warn('n_cores invalid. Changing from %d to maximum %d.' % (n_cores, max_cores))
True True
45688 456880
[ 0.39810717  0.63095734] [ 1660.55949785  1660.55949785  1660.55949785] 16
True True

A
B
C
(27, 1)
[[ 80307.03467913]
 [ 87574.49373991]
 [ 80152.7864895 ]
 [ 79432.8560821 ]
 [ 93104.60567729]
 [ 80649.13922977]
 [ 74764.79373644]
 [ 74638.03740602]
 [ 74959.67096925]
 [ 80367.46370381]
 [ 74328.08542864]
 [ 74509.90219362]
 [ 80949.30825906]
 [ 75046.29755305]
 [ 75199.62617734]
 [ 75567.75156179]
 [ 75117.51993911]
 [ 75113.81871287]
 [ 86948.19024289]
 [ 75006.41648796]
 [ 74977.72228714]
 [ 75472.99314119]
 [ 75266.15865228]
 [ 75010.16231616]
 [ 80681.96755157]
 [ 80929.11224539]
 [ 75646.71477444]]

True True
45688 228440
[  0.63095734   1.           1.58489319   2.51188643   3.98107171
   6.30957344  10.          15.84893192  25.11886432  39.81071706] [ 1660.55949785  1660.55949785  1660.55949785] 16
True True

A
B
C
(27, 9)
[[  2.73638103e+04   1.90450064e+04   6.90339277e+03   1.65587586e+03
    1.32019487e+02   2.07884262e+01   8.72280610e+00   3.32741246e+00
    1.01741160e+00]
 [  2.88961901e+04   1.86078879e+04   6.90165010e+03   1.67418783e+03
    1.34116947e+02   2.09344985e+01   8.70848492e+00   3.38784670e+00
    1.03592487e+00]
 [  2.87408255e+04   1.79525915e+04   6.77949810e+03   1.64358759e+03
    1.31698845e+02   2.10671575e+01   9.05588504e+00   3.36976826e+00
    1.05228303e+00]
 [  2.72571268e+04   1.81095208e+04   6.80330239e+03   1.64143482e+03
    1.28068755e+02   2.09122665e+01   8.65458534e+00   3.29874867e+00
    1.06343746e+00]
 [  2.85356021e+04   1.83600210e+04   6.72671395e+03   1.62005034e+03
    1.29815178e+02   2.08401293e+01   8.75775131e+00   3.30387629e+00
    1.04024184e+00]
 [  2.75548149e+04   1.85781460e+04   6.73731275e+03   1.66752014e+03
    1.33605584e+02   2.11173636e+01   8.81823175e+00   3.38797122e+00
    1.03770442e+00]
 [  2.73315188e+04   1.83887176e+04   6.82502922e+03   1.65018219e+03
    1.31459385e+02   2.09501918e+01   8.73966378e+00   3.32906997e+00
    1.05950787e+00]
 [  2.73402406e+04   1.84115839e+04   6.76483712e+03   1.66019013e+03
    1.31651256e+02   2.07403658e+01   8.83407134e+00   3.30831835e+00
    1.04093193e+00]
 [  2.87093294e+04   1.87837879e+04   6.88178516e+03   1.65425864e+03
    1.33992962e+02   2.12011114e+01   8.82054864e+00   3.38412621e+00
    1.05461016e+00]
 [  2.86553105e+04   1.94014474e+04   6.87402692e+03   1.67421300e+03
    1.34154621e+02   2.14105595e+01   8.65266496e+00   3.30690499e+00
    1.03358565e+00]
 [  2.86089076e+04   1.86713492e+04   6.97026566e+03   1.65559464e+03
    1.30647573e+02   2.11171702e+01   8.83687760e+00   3.33945645e+00
    1.06429013e+00]
 [  2.86000120e+04   1.81771357e+04   6.85385485e+03   1.66250603e+03
    1.30053375e+02   2.07605275e+01   8.69185090e+00   3.19033467e+00
    9.95756260e-01]
 [  2.89097370e+04   1.83273029e+04   6.99844946e+03   1.67044769e+03
    1.34807001e+02   2.11996348e+01   8.81309601e+00   3.41582640e+00
    1.02521552e+00]
 [  2.74865959e+04   1.84380583e+04   6.90048761e+03   1.66645676e+03
    1.32840785e+02   2.10569366e+01   8.77423056e+00   3.31820550e+00
    1.05260094e+00]
 [  3.17212207e+04   1.91473740e+04   6.79619889e+03   1.68402024e+03
    1.31270648e+02   2.07576360e+01   8.83811359e+00   3.40834920e+00
    1.05106485e+00]
 [  2.76828400e+04   1.94676706e+04   6.81616503e+03   1.65097766e+03
    1.30162349e+02   2.09253168e+01   8.60984287e+00   3.24733012e+00
    1.05995610e+00]
 [  3.14339910e+04   1.93233775e+04   6.82597590e+03   1.68236392e+03
    1.34381885e+02   2.11155506e+01   8.81236231e+00   3.32602544e+00
    1.04069775e+00]
 [  2.87870804e+04   1.85872773e+04   6.89909284e+03   1.67374703e+03
    1.30027025e+02   2.07206730e+01   8.85269647e+00   3.39156233e+00
    1.05749187e+00]
 [  3.01578195e+04   1.91423850e+04   6.86156347e+03   1.64081526e+03
    1.26001368e+02   2.05871935e+01   8.86980782e+00   3.47946616e+00
    1.08350016e+00]
 [  2.87589239e+04   1.91620728e+04   6.82701237e+03   1.67459753e+03
    1.32704123e+02   2.05638983e+01   8.62248432e+00   3.39949889e+00
    1.05613161e+00]
 [  2.74725726e+04   1.82543778e+04   6.99457061e+03   1.67331407e+03
    1.33025484e+02   2.09314150e+01   8.81517952e+00   3.36123082e+00
    1.05056885e+00]
 [  2.75294208e+04   1.85573900e+04   6.77810747e+03   1.63887817e+03
    1.32037371e+02   2.06272431e+01   8.75622801e+00   3.40829563e+00
    1.03731991e+00]
 [  2.74731568e+04   1.85393209e+04   6.87329889e+03   1.67347506e+03
    1.34020195e+02   2.08725918e+01   8.81519970e+00   3.30806814e+00
    1.03754942e+00]
 [  3.01781186e+04   1.85741089e+04   6.96090981e+03   1.64622883e+03
    1.32445555e+02   2.06074748e+01   8.67817999e+00   3.40617720e+00
    1.03467746e+00]
 [  2.86666944e+04   1.84587479e+04   6.91631471e+03   1.66243708e+03
    1.30778093e+02   2.06817260e+01   8.98142644e+00   3.42768462e+00
    1.03691200e+00]
 [  3.02236212e+04   1.86381480e+04   6.81990359e+03   1.66442893e+03
    1.33273620e+02   2.11179668e+01   8.73080389e+00   3.40779057e+00
    1.05708859e+00]
 [  2.75824712e+04   1.91975392e+04   6.85186841e+03   1.67432722e+03
    1.33299421e+02   2.03481809e+01   8.75607491e+00   3.37147038e+00
    1.04137070e+00]]


In [44]:
plt.imshow(np.log10(mat) )


Out[44]:
<matplotlib.image.AxesImage at 0x7f5fc9f36dd0>

In [ ]: