def plot3():
     """
     12 plots (eight like plot2), plus also zoomins on filaments for each distance.
     """
     f, ((ax1, ax2, ax3, ax4),(ax11, ax22, ax33, ax44),(ax111, ax222, ax333, ax444)) = plt.subplots(3, 4, figsize = (10.5, 10.))
     
     for distance,axistop,axismid,axisbot in zip(['50Mpc','100Mpc','200Mpc','500Mpc'],[ax1,ax2,ax3,ax4],[ax11,ax22,ax33,ax44],[ax111,ax222,ax333,ax444]):
         data_tuple = data_dict[distance]
         factor = data_tuple[2]; newsize = data_tuple[1]; data = data_tuple[0]; resolution = 100.
     
         xystarts = [x_center-x_FOV[distance]/2.,y_center-y_FOV[distance]/2.]
         size     = [x_FOV[distance], y_FOV[distance]]
     
         x1 = ((x_center-x_FOV[distance]/2.)/100.*(newsize/factor))
         x2 = ((x_center+x_FOV[distance]/2.)/100.*(newsize/factor))
         y1 = ((y_center-y_FOV[distance]/2.)/100.*(newsize/factor))
         y2 = ((y_center+y_FOV[distance]/2.)/100.*(newsize/factor))
         data_FOV = data[int(x1):int(x2),int(y1):int(y2)]
     
         get_halpha_SB.makemap(data_FOV,size,axistop,xystarts = xystarts)
     
         label = 'Mock observation at '+distance; exptime=10**7*3600.; map='bone'
         plotit_general(data_FOV,size,xystarts,axismid,float(exptime), map, float(resolution), label = label)
         
         # do the zoom-ins:                
         xzoomin = np.array([47.4,48.2])/100.*(newsize/factor)
         yzoomin = np.array([11.2,12.4])/100.*(newsize/factor)
         data_zoomin = data[int(xzoomin[0]):int(xzoomin[1]),int(yzoomin[0]):int(yzoomin[1])]
         
         xystarts = [47.4,11.2]
         size = [1.0,1.2]
         
         label = 'Mock observation at '+distance; exptime=10**7*3600.; map='bone'
         plotit_general(data_zoomin,size,xystarts,axisbot,float(exptime), map, float(resolution), label = label)
 def plot2():
     """
     Only eight plots, half raw EAGLE at different distances and half mock obs at different distances
     """
     f, ((ax1, ax2, ax3, ax4),(ax11, ax22, ax33, ax44)) = plt.subplots(2, 4, figsize = (15.5, 15.))
 
     for distance,axistop,axisbot in zip(['50Mpc','100Mpc','200Mpc','500Mpc'],[ax1,ax2,ax3,ax4],[ax11,ax22,ax33,ax44]):
         data_tuple = data_dict[distance]
         factor = data_tuple[2]; newsize = data_tuple[1]; data = data_tuple[0]; resolution = 100.
     
         xystarts = [x_center-x_FOV[distance]/2.,y_center-y_FOV[distance]/2.]
         size     = [x_FOV[distance], y_FOV[distance]]
     
         x1 = ((x_center-x_FOV[distance]/2.)/100.*(newsize/factor))
         x2 = ((x_center+x_FOV[distance]/2.)/100.*(newsize/factor))
         y1 = ((y_center-y_FOV[distance]/2.)/100.*(newsize/factor))
         y2 = ((y_center+y_FOV[distance]/2.)/100.*(newsize/factor))
         data_FOV = data[int(x1):int(x2),int(y1):int(y2)]
     
         get_halpha_SB.makemap(data_FOV,size,axistop,xystarts = xystarts)
     
         label = 'Mock observation at '+distance; exptime=10**5*3600.; map='bone'
         plotit_general(data_FOV,size,xystarts,axisbot,float(exptime), map, float(resolution), label = label)
         
         # put little boxes where zoomins are pulling out
         xystarts = [47.4,11.2]
         size = [1.0,1.2]
         axisbot.plot([47.4,47.4,47.4+1.0,47.4+1.0,47.4],[11.2,11.2+1.2,11.2+1.2,11.2,11.2],'r-')
         
         axisbot.set_xlim((x_center-x_FOV[distance]/2.),(x_center-x_FOV[distance]/2.)+x_FOV[distance])
         axisbot.set_ylim((y_center-y_FOV[distance]/2.),(y_center-y_FOV[distance]/2.)+y_FOV[distance])
示例#3
0
def testplot():
    # plot them all together
    f, ((ax1, ax2, ax3, ax4)) = plt.subplots(1, 4, figsize=(15.5, 15.))

    for distance, data, axis in zip([
            '50Mpc', '100Mpc', '200Mpc', '500Mpc'
    ], [data_50_100_FOV, data_100_100_FOV, data_200_100_FOV, data_500_100_FOV],
                                    [ax1, ax2, ax3, ax4]):
        xystarts = [
            x_center - x_FOV[distance] / 2., y_center - y_FOV[distance] / 2.
        ]
        size = [x_FOV[distance], y_FOV[distance]]
        get_halpha_SB.makemap(data, size, axis, xystarts=xystarts)
def plotit_general(data, size, xystarts, ax1, exptime, mymap='gist_gray', res=100, label=''):
    
    data_obs = HalphaSBplot_addnoise.addnoise(data,resolution,exptime=exptime,CMOS=True)
    
    # Plot the subtracted noiseadded data
    #fig = plt.figure(figsize = (9.5, 5.))
    #ax1 = plt.subplot(111)
    
    # Plot the data nicely
    median = np.median(data_obs);
    sig = np.sqrt(median)
    
    mymax = median + 40*sig
    mymin = median - 5*sig
    
    SBdata_clipped = data_obs
    SBdata_clipped[SBdata_clipped < mymin] = mymin
    SBdata_clipped[SBdata_clipped > mymax] = mymax
    SBdata_clipped = SBdata_clipped - mymin

    get_halpha_SB.makemap(np.log10(SBdata_clipped**0.5),size,ax1,xystarts=xystarts,colmap=mymap,label=label,colorbar=False)
#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))
fig = plt.figure(figsize=(16.5, 15.))
ax1 = plt.subplot(111)
get_halpha_SB.makemap(
    data_50[(38. / 100. * (32000. / factor)):(68. / 100. * (32000. / factor)),
            (0. / 100. * (32000. / factor)):(18. / 100. * (32000. / factor))],
    size,
    ax1,
    xystarts=xystarts)

# Plot the FOV of dragonfly on top
# snapnum 28:
scale_50 = 0.206  #kpc/"  ## at z = 0.01 (about 50 Mpc)
scale_100 = 0.467  #kpc/"  ## at z = 0.023 (about 100 Mpc)
scale_200 = 0.928  #kpc/"  ## at z = 0.047. (about 200 Mpc)
scale_1000 = 2.178  #kpc/" ## at z = 0.12 (about 1000 Mpc)

x_angFOV = 3. * 60. * 60.  # "
y_angFOV = 2. * 60. * 60.  # "
x_FOV_50 = x_angFOV * scale_50 / 1000.  # Mpc
y_FOV_50 = y_angFOV * scale_50 / 1000.  # Mpc
x_FOV_100 = x_angFOV * scale_100 / 1000.  # Mpc
示例#6
0
    data_5, data_10, data_15, data_20 = loaddata1('chinook')

    if verbose:
        print('Plot an example region (20 Mpc box)...')

    # Plotting parameters
    save = False
    plotDragonflyFOV = True
    xystarts = [40., 0.]
    size = 20.

    fig = plt.figure(figsize=(16.5, 15.))
    ax1 = plt.subplot(111)
    get_halpha_SB.makemap(data_5[(40. / 100. * 3200.):(60. / 100. * 3200.),
                                 0:(20. / 100. * 3200.)],
                          size,
                          ax1,
                          xystarts=xystarts)

    if verbose:
        print(
            'Plot the regions... (slightly shifted for the different snapnums)'
        )

    if snapnum == 27:
        # Pick out regions along the filaments in the map (snapnum 27)
        ax1.plot([53, 53, 56, 56, 53], [9.2, 10, 8.5, 7.7, 9.2],
                 color='r',
                 label='Region 3')
        ax1.plot(np.array([46.2, 47.2, 48.2, 47.2, 46.2]),
                 [14, 14, 10, 10, 14],
示例#7
0
    # exposure time
    exptime = 60. * 60. * 10**5  # seconds  (10^5 hours)

    # load data and calculate signal in exposure time
    data_20 = loaddata(machine)
    totsignal = np.log10(10**data_20 * exptime)  # log( photons / cm^2 /sr )

    print('Plotting without the noise added, small region (20 Mpc box)...')
    # Plotting parameters
    xystarts = [40., 0.]
    size = 20.
    fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(10, 10))
    get_halpha_SB.makemap(
        totsignal[(xystarts[0] / 100. * 3200.):((xystarts[0] + size) / 100. *
                                                3200.),
                  (xystarts[1] / 100. * 3200.):((xystarts[1] + size) / 100. *
                                                3200.)],
        size,
        ax1,
        xystarts=xystarts)
    ax1.set_title('sky signal, no noise')

    # calculate the number of detected electrons
    # how much are we going to bin?  100" square, so that is
    binpix_size = 100.  # arcsec

    numpixel = round((binpix_size / pix_size)**2)
    detsignal = np.log10(10**totsignal * QE_old * tau_l * tau_f * area_lens *
                         ang_size_pixel * numpixel)
    print(
        'The total detected signal per pixel (taking into account transmittance of the lens, quantum efficiency, and the pixel size) is %s.'
        % detsignal)
示例#8
0
    def maskgalaxies_infilament(resolution, distance):
        # load the full 100Mpc x 100Mpc box size data first
        data_tuple = (np.load('data_%s_%sarcsec.npz' %
                              (distance, resolution))['arr_0'])
        factor = data_tuple[2]
        newsize = data_tuple[1]
        data = data_tuple[0]

        # select out a region around the filament 1
        xmin = np.min(xbox_1) - 1.
        xmax = np.max(xbox_1) + 1.
        ymin = np.min(ybox_1) - 1.
        ymax = np.max(ybox_1) + 1.
        xystarts = [
            xmin - pixscale[distance] * resolution / 2.,
            ymin - pixscale[distance] * resolution / 2.
        ]  ###
        size = [xmax - xmin, ymax - ymin]
        data_aroundfilament1 = data[(xmin / 100. *
                                     (newsize / factor)):(xmax / 100. *
                                                          (newsize / factor)),
                                    (ymin / 100. *
                                     (newsize / factor)):(ymax / 100. *
                                                          (newsize / factor))]

        if plotchecks:
            fig = plt.figure(figsize=[5, 5])
            axis = plt.subplot(111)
            get_halpha_SB.makemap(data_aroundfilament1,
                                  size,
                                  axis,
                                  xystarts=xystarts)
            plt.show()

        # load the galaxy catalogue
        zmin = 10.
        zmax = 15.
        xgal, ygal, mgal, rhgas, rhstar = searchgals(xmin, xmax, ymin, ymax,
                                                     zmin, zmax)

        if plotchecks:
            fig = plt.figure(figsize=[5, 5])
            axis = plt.subplot(111)
            get_halpha_SB.makemap(data_aroundfilament1,
                                  size,
                                  axis,
                                  xystarts=xystarts)
            plotgals(xgal, ygal, rhgas, rhstar, axis)
            plt.show()

        # mask the galaxies in the EAGLE data
        data_masked = maskgals2(
            xgal, ygal, rhgas, data, [0, 0], [100., 100.],
            distance)  # using the full 100Mpcx100Mpc data for the next steps

        if plotchecks:
            fig = plt.figure(figsize=[5, 10])
            axis = plt.subplot(121)
            get_halpha_SB.makemap(
                data_masked[(xmin / 100. *
                             (newsize / factor)):(xmax / 100. *
                                                  (newsize / factor)),
                            (ymin / 100. *
                             (newsize / factor)):(ymax / 100. *
                                                  (newsize / factor))],
                size,
                axis,
                xystarts=xystarts)
            plotgals(xgal, ygal, rhgas, rhstar, axis)

            axis2 = plt.subplot(122)
            get_halpha_SB.makemap(
                data[(xmin / 100. * (newsize / factor)):(xmax / 100. *
                                                         (newsize / factor)),
                     (ymin / 100. * (newsize / factor)):(ymax / 100. *
                                                         (newsize / factor))],
                size,
                axis2,
                xystarts=xystarts)
            plotgals(xgal, ygal, rhgas, rhstar, axis2)
            plt.show()

        # select out the filament region
        xboxes, yboxes = define_filament_boxes(data_masked)
        xfull, yfull = get_halpha_SB.indices_region(xboxes[boxnum].astype(int),
                                                    yboxes[boxnum].astype(int))
        SBdata = extractdata(xfull, yfull, data_masked)

        if plotchecks:
            SBdata_notmasked = np.load('SBdata_%sarcsec.npz' %
                                       resolution)['arr_0']
            fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8.5, 7.))
            map = 'viridis'
            get_halpha_SB.makemapfilament(SBdata_notmasked,
                                          ax1,
                                          colmap=map,
                                          labelaxes=True)
            get_halpha_SB.makemapfilament(SBdata,
                                          ax2,
                                          colmap=map,
                                          labelaxes=True)
            plt.show()

        np.savez('SBdata_%sarcsec_%s_masked.npz' % (resolution, distance))

        return SBdata
        fname = 'emission_halpha_L0100N1504_28_test2_SmAb_C2Sm_32000pix_5.000000slice_zcen12.5_'+resolution+'.npz'
        if os.path.isfile(fname):
            print("data exists, loading %s now..."%fname)
            sl = [slice(None,None,None), slice(None,None,None)]
            data = (np.load(fname)['arr_0'])[sl]
        else:
            print("data not saved, loading from original files now...")
            data = loaddata()
            np.savez(fname,data)
            
        xystarts = [38.,0.]
        size     = [30.,18.]
        #factor = int(round(factor_50Mpc))
        fig = plt.figure(figsize = (6.5, 5.))
        ax1 = plt.subplot(111)
        get_halpha_SB.makemap(data[(38./100.*(32000./factor)):(68./100.*(32000./factor)),(0./100.*(32000./factor)):(18./100.*(32000./factor))],size,ax1,xystarts = xystarts)
        
        ax1.set_xlim(38.,68.)
        ax1.set_ylim(0.,18.)
        
        for distance in ['50Mpc','100Mpc','200Mpc','500Mpc']:
            ax1.plot([x_center-x_FOV[distance]/2.,x_center+x_FOV[distance]/2.,x_center+x_FOV[distance]/2.,x_center-x_FOV[distance]/2.,x_center-x_FOV[distance]/2.],
                     [y_center+y_FOV[distance]/2.,y_center+y_FOV[distance]/2.,y_center-y_FOV[distance]/2.,y_center-y_FOV[distance]/2.,y_center+y_FOV[distance]/2.],color='gray')
            #ax1.text(x_center-x_FOV[distance]/2.,y_center+y_FOV[distance]/2.,distance+' away')
            ax1.text(x_center-x_FOV[distance]/2.,y_center,distance+' away',rotation='vertical',va='center')
        plt.show()
    
    elif allFOVs:
        print("congrats, you picked allFOVs!  These are the all the same resolution, different distances plots.")

        # load the data: