In [12]:
import numpy as np
from astropy.io import fits
import os, sys
path = os.path.abspath('../library/')
if path not in sys.path:
    sys.path.append(path)
from cumhpx import delete_sources_below_maglim, do_likelihood, delete_magellanic_clouds, assign_cumhpx, transfer_cumhpx_structure, hpx_indices,highest_hpx_level_from_largest_cumhpx

In [2]:
#x = fits.getdata("../output/GDR2_207/GDR2_207_0.0025sampling.fits")
#x = delete_magellanic_clouds(x, True)

In [3]:
outputDir = '../output/mockcat_new_SFR_new_more_thick_0.00025_sampling_new_model_maglim'
fSample = 0.00025
outputFile = 'GDR2mock_20.7Gmag'
x = fits.getdata(outputDir + "/" + outputFile + '.fits')
nside_maglim = 128
print('GDR2mock')
x = delete_sources_below_maglim(x,nside_maglim,'g',True)
x = delete_sources_below_maglim(x,nside_maglim,'rp',True)
x = delete_magellanic_clouds(x)
print("GDR2")
nside = 128
data = fits.getdata("../output/GDR2_207/GDR2_207_cleaned_0.0025sampling.fits")
downsampling = fSample / 0.0025
if downsampling > 1:
    print('could not assess likelihood, because GDR2data only has sampling of 0.0025')
choice = np.random.choice(np.arange(len(data)), size = int(len(data)*downsampling), replace = False)
data = data[choice]
data = delete_sources_below_maglim(data,nside,'g',True)
# taking the maglims of rp does throw away many sources
data = delete_sources_below_maglim(data,nside,'rp',True)
# throw away magellanic clouds
data = delete_magellanic_clouds(data)


GDR2mock
nstar before cleaning: 656194
nstar after g-band cleaning: 528789
nstar before cleaning: 528789
nstar after rp-band cleaning: 388166
388166
after smc cut: 388034
after lmc cut: 387241
GDR2
nstar before cleaning: 313477
nstar after g-band cleaning: 276212
nstar before cleaning: 276212
nstar after rp-band cleaning: 232536
232536
after smc cut: 232197
after lmc cut: 229807

In [4]:
threshold=10000
data = assign_cumhpx(data, threshold)
#x = transfer_cumhpx_structure(data,x)

In [9]:
np.unique(data.cumhpx)


Out[9]:
array([  1,   2,   4,   6,   8,  12,  13,  14,  15,  24,  25,  27,  32,
        33,  34,  35,  42,  43,  48,  49,  50,  51,  54,  55,  56,  57,
        58,  59, 116, 117, 118, 119, 173, 174, 175, 176, 177, 178, 179,
       220, 221, 222, 223, 224, 225, 226, 227, 700, 701, 702, 703])

In [8]:
len(np.unique(data.hpx)) ## Therefore hpx are missing


Out[8]:
766

In [14]:
max_hpx_level = highest_hpx_level_from_largest_cumhpx(max(data.cumhpx))
scr_idx = hpx_indices(data.hpx,max_hpx_level)

In [17]:
np.diff(scr_idx)


Out[17]:
array([  23,   20,   21,   33,   39,   72,   50,   73,   25,   28,   23,
         43,   45,   54,   58,  120,  106,  196,  133,  194,  361,  348,
        432,  310,  133,  269,  223,  325,  352,  229,  394,  199,   25,
         52,   37,   62,   77,  146,   98,  246,   65,  100,  122,  217,
        194,  357,  373,  639,  253,  278,  470,  450,  331,  159,  277,
        149,  602,  472,  514,  344,  189,  122,  182,   93,   39,   29,
         43,   43,   22,   22,   34,   16,   75,   60,   97,   50,   24,
         24,   35,   41,   18,   14,   27,   15,    8,   17,   14,   20,
         22,   20,   25,   27,   20,   15,   26,   12,  107,   52,  150,
         84,   51,   33,   68,   40,  165,  109,  204,  164,   80,   52,
        100,   94,   30,   27,   32,   31,   19,   21,   31,   23,   39,
         46,   98,   73,   33,   35,   75,   41,   46,   47,   27,   33,
         48,   50,   29,   35,   27,   25,   24,   25,   31,   28,   28,
         28,   57,   81,   43,   72,   78,   82,   61,   66,   30,   35,
         32,   38,   56,   62,   46,   55,   22,   20,   20,   18,   24,
         19,   30,   19,   16,   21,   15,   19,   15,   16,   22,   15,
         23,   25,   35,   24,   39,   52,   33,   47,   24,   35,   16,
         20,   32,   61,   43,   45,  159,  109,  329,  240,   94,   83,
        182,  187,  751,  566, 1939, 1108,  390,  338,  911,  850,   93,
         95,  138,  144,  120,  133,  205,  271,  324,  353,  786,  912,
        490,  529,  938,  664, 1873, 2020,  842,  975, 1147,  453,  992,
        600,  318,  305,  148,  125,  284,  243,  106,  112,  889,  818,
        599,  438,  750,  407,  394,  285,  237,  185,   97,   82,  125,
        134,   90,   89,   24,   23,   23,   12,   16,   20,   19,   22,
         31,   31,   28,   28,   24,   26,   22,   22,   22,   11,   26,
         23,   23,   33,   15,   16,   22,   21,   22,   21,   21,   29,
         22,   27,   47,   30,   42,   39,   26,   23,   28,   25,   57,
         56,   85,   62,   59,   62,   72,   56,   20,   27,   38,   22,
         28,   33,   30,   37,   49,   36,   48,   52,   42,   64,   49,
         93,   89,  138,   84,  122,  295,  641,  200,  398,   66,   89,
         42,   67,  135,  230,   99,  165,  544,  296,  519,  405,  178,
         87,  177,  109,  515,  500,  342,  395,  249,  106,  368,  152,
         28,   50,   33,   32,   80,  127,   76,  104,   21,   23,   38,
         23,   36,   91,   42,   70,  252,  413,  202,  337,  361,  215,
        355,  285,  145,  308,  145,  215,  407,  284,  343,  295,  109,
         98,   87,   65,   61,   59,   50,   36,   61,   57,   65,   45,
         31,   45,   33,   40,   49,   46,   30,   42,   54,   42,   39,
         25,   23,   33,   31,   13,   36,   31,   18,   14,   37,   31,
         39,   34,   39,   21,   19,   19,   49,   42,   48,   30,   21,
         31,   34,   24,   30,   24,   25,   25,   24,   24,   11,   22,
         21,   17,   20,   15,   14,    7,   10,   14, 3744, 3502, 2148,
       2677, 2308, 1360, 2672, 2670, 2527, 3093,  817, 1058, 2061, 1457,
        809,  805,  738,  441, 2001, 1023,  286,  233,  655,  467, 2320,
       2049,  827, 1002, 1780, 1291, 1507, 1797,  254,  253,  139,  146,
        283,  490,  198,  247,  103,   82,   59,   67,  113,  117,   80,
         85,  696,  989,  310,  358, 1269, 1406,  455,  617,  160,  194,
        106,  108,  225,  276,  145,  108,  110,   38,   49,   40,    0,
          0,    5,   29,    2,   42,   18,   43,   43,   30,   23,   24,
         22,   58,   47,   30,   57,   59,   44,   53,   33,   33,   34,
         38,   32,   35,   46,   37,   33,   23,   32,   24,   21,   17,
         13,   25,   25,   23,   25,   19,   19,   20,   23,   16,   15,
         18,   28,   15,   32,   36,   20,   29,   17,   17,   25,   17,
         28,   22,   21,   15,  172,  271,  107,  288,  607, 1705,  695,
       1633,    7,  250,   12,  228,  738, 1379,  648,  654, 2340, 1176,
       1324,  545,  476,  192,  268,  137,  921,  341,  554,  290,  158,
        110,  112,   93,   77,  208,  100,  228,  633,  526,  567,  797,
        117,  280,   96,  196,  548,  862,  467,  689,  561,  186,  581,
        231,  104,   69,   85,   71,  572,  225,  599,  329,  104,   62,
        138,   76,  230,  293,  386,  908,  445,  656, 1519, 2409, 1035,
       2238, 2518, 2202, 2224, 2014, 1604, 1254,  975, 1528, 2853, 2262,
       2061, 2636, 1822, 2087, 1562, 1326,  917,  584, 1357, 2423,  642,
        538, 2049, 1241, 1070,  522,  649,  432,  339,  218,  439,  251,
        184,  123,  171,  120,   89,   79,  334,  272,  140,  150,  255,
        257,  146,  149,  106,   92,   68,   65,   92,   79,   73,   59,
        118,   71,  123,   96,   48,   61,   64,   61,  169,  120,  276,
        167,   84,   61,  122,   84,   40,   46,   44,   54,   21,   29,
         34,   29,   58,   48,   66,   53,   39,   22,   57,   40,  355,
        205,  476,  294,  150,   92,  207,  131,  827,  468, 1645, 1389,
        380,  234,  971,  507,   94,   77,  123,  100,   58,   41,   69,
         76,  165,  127,  315,  207,  116,   91,  173,  114])

In [ ]: