예제 #1
0
def loaddata():
    sl = [slice(None, None, None), slice(None, None, None)]
    if machine == 'chinook':
        homedir = '/Users/lokhorst/Eagle/'
    elif machine == 'coho':
        homedir = '/Users/deblokhorst/eagle/SlicesFromNastasha/'

    # Simulation snapnum 28 (z = 0), xy box size: 100Mpc, z slice width: 5Mpc,
    files_SF_28 = [
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen12.5__fromSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen17.5__fromSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen2.5__fromSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen7.5__fromSFR.npz'
    ]

    files_noSF_28 = [
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen12.5_noSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen17.5_noSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen2.5_noSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen7.5_noSFR.npz'
    ]

    # Load a 5Mpc slice of data
    print('data1 (' + files_noSF_28[0] + ')...')
    data1 = (np.load(files_noSF_28[0])['arr_0'])[sl]
    data1 = get_halpha_SB.imreduce(data1,
                                   round(factor),
                                   log=True,
                                   method='average')
    print('data11 (' + files_SF_28[0] + ')...')
    data11 = (np.load(files_SF_28[0])['arr_0'])[sl]
    data11 = get_halpha_SB.imreduce(data11,
                                    round(factor),
                                    log=True,
                                    method='average')
    print('5 Mpc slice...')
    data_5 = np.log10(10**data1 + 10**data11)
    print('delete data1, data11...')
    del data1
    del data11

    return data_5
예제 #2
0
def changeres(distance, resolution, data):
    pixscale = {
        '50Mpc': 0.237 / 1000. * (1. + 0.0115),
        '100Mpc': 0.477 / 1000. * (1. + 0.0235),
        '200Mpc': 0.928 / 1000. * (1. + 0.047),
        '500Mpc': 2.178 / 1000. * (1. + 0.12)
    }  ### Mpc / arcsec (comoving)
    simpixsize = 100. / 32000.  ### Mpc / pixel is resolution of raw data
    factor = round(pixscale[distance] * resolution / simpixsize)
    size = 32000.
    print("Will reduce resolution by a factor of %s." % factor)
    # LATER determine the current resolution of the data. FOR NOW assume current resolution is 100 Mpc/ 32000 pixels ~ 3 kpc/pixel

    # If the factors are not integer multiples of 32000., I'll trim the data first and then imreduce it
    if 32000. % ((factor)) != 0.:
        times_factor_fits_in = int(32000. / factor)
        newsize = times_factor_fits_in * factor
        print(
            "Before reducing resolution, the original data was trimmed to size %s."
            % newsize)
        datanew = data[0:int(newsize), 0:int(newsize)]
    else:
        datanew = data
        newsize = size

    return get_halpha_SB.imreduce(datanew,
                                  round(factor),
                                  log=True,
                                  method='average'), newsize, factor
def changeres(distance,resolution,data):
    print('changing the resolution of the data')
    simpixsize = 100./32000. ### Mpc / pixel is resolution of raw data 
    factor = round(pixscale[distance]*resolution/simpixsize)
    print('factor is %s'%factor)
    size = 32000.
    # LATER determine the current resolution of the data. FOR NOW assume current resolution is 100 Mpc/ 32000 pixels ~ 3 kpc/pixel

    # If the factors are not integer multiples of 32000., I'll trim the data first and then imreduce it
    if 32000.%((factor)) != 0.:
        times_factor_fits_in = int(32000./factor)
        newsize = times_factor_fits_in * factor
        print("Before reducing resolution, the original data was trimmed to size %s."%newsize)
        datanew = data[0:int(newsize),0:int(newsize)]
    else:
        datanew = data
        newsize = size

    return get_halpha_SB.imreduce(datanew, round(factor), log=True, method = 'average'), newsize, factor
예제 #4
0
def testplot():
    file_snapnum28_noSF = '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen12.5_noSFR.npz'
    sl = [slice(None, None, None), slice(None, None, None)]
    data = (np.load(file_snapnum28_noSF)['arr_0'])[sl]
    factor = 10
    data = get_halpha_SB.imreduce(data, factor, log=True, method='average')

    #logSBarray = np.arange(0,5,0.1)
    #Numarray = np.zeroes(len(logSBarray))
    #indexarray = np.arange(len(logSBarray))
    #for logSB,index in zip(logSBarray,indexarray):
    #    logNumarray[index] = len(logSBarray[logSBarray >= logSB and logSBarray < (logSB+0.1)])
    #plt.plot()

    hist, bin_edges = np.histogram(data, bins=50, range=[0., 5.], density=True)
    """
    From python documentation for numpy.histogram:
    density : bool, optional
    If False, the result will contain the number of samples in each bin. If True, the result is the value of the probability density function at the bin, 
    normalized such that the integral over the range is 1. Note that the sum of the histogram values will not be equal to 1 unless bins of unity width are chosen; 
    it is not a probability mass function.
    Overrides the normed keyword if given.
    """
    plt.hist(data, bins=50, range=[0., 5.], density=True)
bin by 7.584 resolution pixels    -----> ~8
bin by 15.264 resolution pixels   -----> ~15
bin by 29.696 resolution pixels   -----> ~30
bin by 69.696 resolution pixels   -----> ~70
"""

# Great, we round those so that the imreduce script will work (hopefully).
# We can load up the snapnum 28 full size.  It would probably be best to first show the plot with the full simulation (maybe 50 Mpc across in size since probably don't need the 100Mpc) with the Dragonfly FOV all shown on top.  Then individually replot for each distance only the Dragonfly FOV at that distance and binned appropriately.

# snapnum 28, z = 0, width = 5Mpc, centred at z = 12.5Mpc, no SFing included, 100Mpc box size, Halpha emission ---- just testing distances
file_snapnum28_noSF = '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen12.5_noSFR.npz'
sl = [slice(None, None, None), slice(None, None, None)]
data = (np.load(file_snapnum28_noSF)['arr_0'])[sl]

data_50 = get_halpha_SB.imreduce(data,
                                 int(round(factor_50Mpc)),
                                 log=True,
                                 method='average')
# For the other size FOV, the factors are not integer multiples of 32000., therefore I'll trim the data first and then imreduce it
#data_trim = data[0:30000,0:30000]
#data_100 = get_halpha_SB.imreduce(data_trim, int(round(factor_100Mpc)), log=True, method = 'average')
#data_trim = data[0:31800,0:31800]
#data_200 = get_halpha_SB.imreduce(data_trim, int(round(factor_200Mpc)), log=True, method = 'average')
#data_trim = data[0:31500,0:31500]
#data_1000 = get_halpha_SB.imreduce(data_trim, int(round(factor_1000Mpc)), log=True, method = 'average')

#  Full Plot  #
# Use data_50 because if don't bin at all, end up with some weird bright pixels that are not physical

xystarts = [38., 0.]
size = [30., 18.]
factor = int(round(factor_50Mpc))
예제 #6
0
def loaddata1(machine):

    SFing = False
    factor = 10
    sl = [slice(None, None, None), slice(None, None, None)]

    if machine == 'chinook':
        homedir = '/Users/lokhorst/Eagle/'
    elif machine == 'coho':
        homedir = 'Users/deblokhorst/SlicesfromNastasha/'

    # Simulation snapnum 27 (z = 0.1), xy box size: 100Mpc, z slice width: 5Mpc, zloc: 12.5Mpc
    files_SF_27 = [
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen12.5__fromSFR.npz',
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen17.5__fromSFR.npz',
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen2.5__fromSFR.npz',
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen7.5__fromSFR.npz'
    ]
    files_noSF_27 = [
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen12.5_noSFR.npz',
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen17.5_noSFR.npz',
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen2.5_noSFR.npz',
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen7.5_noSFR.npz'
    ]
    # Simulation snapnum 28 (z = 0), xy box size: 100Mpc, z slice width: 5Mpc,
    files_SF_28 = [
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen12.5__fromSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen17.5__fromSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen2.5__fromSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen7.5__fromSFR.npz'
    ]

    files_noSF_28 = [
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen12.5_noSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen17.5_noSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen2.5_noSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen7.5_noSFR.npz'
    ]

    #. let's just copy snapnum 28 data into the snapnum 27 filename so that I don't have to repeat all the following and probably mess stuff up

    files_noSF_27 = files_noSF_28
    snapnum = 28

    print('Load non-star-forming Halpha emission data...')
    print('data1 (' + files_noSF_27[0] + ')...')
    data1 = (np.load(files_noSF_27[0])['arr_0'])[sl]
    #print('data11 ('+files_SF_27[0]+')...')
    #data11 = (np.load(files_SF_27[0])['arr_0'])[sl]

    data1 = get_halpha_SB.imreduce(data1, factor, log=True, method='average')
    #data11 = get_halpha_SB.imreduce(data11, factor, log=True, method = 'average')

    print('5 Mpc slice...')
    data_5 = np.log10(10**data1)  #+10**data11)

    print('delete data1, data11...')
    del data1
    #del data11

    print('data2 (' + files_noSF_27[1] + ')...')
    data2 = (np.load(files_noSF_27[1])['arr_0'])[sl]
    #print('data22 ('+files_SF_27[1]+')...')
    #data22 = (np.load(files_SF_27[1])['arr_0'])[sl]

    data2 = get_halpha_SB.imreduce(data2, factor, log=True, method='average')
    #data22 = get_halpha_SB.imreduce(data22, factor, log=True, method = 'average')

    print('10 Mpc slice...')
    data_10 = np.log10(10**data_5 + 10**data2)  #+10**data22)

    print('delete data2, data22..')
    del data2
    #del data22

    print('data3 (' + files_noSF_27[2] + ')...')
    data3 = (np.load(files_noSF_27[2])['arr_0'])[sl]
    data3 = get_halpha_SB.imreduce(data3, factor, log=True, method='average')

    print('15 Mpc slice...')
    data_15 = np.log10(10**data_10 +
                       10**data3)  #+10**data11+10**data22+10**data33)

    del data3
    #print('data33 ('+files_SF_27[2]+')...')
    #data33 = (np.load(files_SF_27[2])['arr_0'])[sl]

    print('data4 (' + files_noSF_27[3] + ')...')
    data4 = (np.load(files_noSF_27[3])['arr_0'])[sl]
    data4 = get_halpha_SB.imreduce(data4, factor, log=True, method='average')

    print('20 Mpc slice...')
    data_20 = np.log10(
        10**data_15 +
        10**data4)  #+10**data11+10**data22+10**data33+10**data44)

    del data4

    #print('Load star-forming Halpha emission data')
    #print('data44 ('+files_SF_27[3]+')...')
    #data44 = (np.load(files_SF_27[3])['arr_0'])[sl]

    #print('Reduce all the data that we just loaded...')
    #data33 = get_halpha_SB.imreduce(data33, factor, log=True, method = 'average')
    #data44 = get_halpha_SB.imreduce(data44, factor, log=True, method = 'average')

    #print('Add slices together to create larger slices (also adding together the SFing and non-SFing data)..')

    return data_5, data_10, data_15, data_20
예제 #7
0
def loaddata(machine):
    factor = 10
    sl = [slice(None, None, None), slice(None, None, None)]

    if machine == 'chinook':
        homedir = '/Users/lokhorst/Eagle/'
    elif machine == 'coho':
        homedir = 'Users/deblokhorst/SlicesfromNastasha/'

    # Simulation snapnum 27 (z = 0.1), xy box size: 100Mpc, z slice width: 5Mpc, zloc: 12.5Mpc
    files_SF_27 = [
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen12.5__fromSFR.npz',
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen17.5__fromSFR.npz',
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen2.5__fromSFR.npz',
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen7.5__fromSFR.npz'
    ]
    files_noSF_27 = [
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen12.5_noSFR.npz',
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen17.5_noSFR.npz',
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen2.5_noSFR.npz',
        '/Users/lokhorst/Eagle/emission_halpha_L0100N1504_27_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen7.5_noSFR.npz'
    ]
    # Simulation snapnum 28 (z = 0), xy box size: 100Mpc, z slice width: 5Mpc,
    files_SF_28 = [
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen12.5__fromSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen17.5__fromSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen2.5__fromSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen7.5__fromSFR.npz'
    ]

    files_noSF_28 = [
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen12.5_noSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen17.5_noSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen2.5_noSFR.npz',
        homedir +
        'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen7.5_noSFR.npz'
    ]

    #. let's just copy snapnum 28 data into the snapnum 27 filename so that I don't have to repeat all the following and probably mess stuff up

    files_noSF_27 = files_noSF_28
    snapnum = 28

    #  For a 3nm filter width, that corresponds to a redshift slice of 20 Mpc
    data_20 = []  # log( photons / cm^2 / s / sr )
    ind = 0
    print(
        'Create data_20 (20Mpc wide slice) from 5Mpc slices at redshift of 0...'
    )
    for fname in files_SF_28 + files_noSF_28:
        ind = ind + 1
        print('loading data (' + fname + ')...')
        data = (np.load(fname)['arr_0'])[sl]
        data = get_halpha_SB.imreduce(data, factor, log=True, method='average')
        if data_20 == []:
            print('(1/%s) first addition to data_20...' %
                  (len(files_SF_28 + files_noSF_28)))
            data_20 = data
        else:
            print('(%s/%s) adding data to data_20...' %
                  (ind, len(files_SF_28 + files_noSF_28)))
            data_20 = np.log10(10**data_20 + 10**data)
            del data

    return data_20
예제 #8
0
# Read in data from snapshot 27
# print('Reading: '+files_noSF_27[0]+'...')
# data1 = (np.load(files_noSF_27[0])['arr_0'])[sl]
# data1 = get_halpha_SB.imreduce(data1, factor, log=True, method = 'average')
# print('Reading: '+files_SF_27[0]+'...')
# data11 = (np.load(files_SF_27[0])['arr_0'])[sl]
# data11 = get_halpha_SB.imreduce(data11, factor, log=True, method = 'average')
# print('5 Mpc slice...')
# data_27 = np.log10(10**data1+10**data11)
# print('delete %s...'%(files_noSF_27[0]))
# del data11

print('Reading: ' + files_noSF_28[0] + '...')
data2 = (np.load(files_noSF_28[0])['arr_0'])[sl]
data2 = get_halpha_SB.imreduce(data2, factor, log=True, method='average')
print('Reading: ' + files_SF_28[0] + '...')
data22 = (np.load(files_SF_28[0])['arr_0'])[sl]
data22 = get_halpha_SB.imreduce(data22, factor, log=True, method='average')
print('5 Mpc slice...')
data_28 = np.log10(10**data2 + 10**data22)
print('delete %s...' % (files_noSF_28[0]))
del data22

fig = plt.subplots(1, 1, figsize=[6, 5])
#plt.hist(data1.flatten(),bins=50,log='True',normed='True',histtype='step',label='noSF 27')
#plt.hist(data_27.flatten(),bins=50,log='True',normed='True',histtype='step',label='with SF 27')
plt.hist(data2.flatten(),
         bins=50,
         log='True',
         normed='True',