Exemple #1
0
def main():

    import grid
    import numpy as np
    from os import system,path
    import myclumpfinder as clump_finder
    reload(clump_finder)
    import mygeometry as myg
    reload(myg)
    from mycoords import make_velocity_axis
    import mymath
    reload(mymath)

    # define directory locations
    output_dir = '/d/bip3/ezbc/perseus/data/python_output/co_dispersion/'
    figure_dir = '/d/bip3/ezbc/perseus/figures/'
    av_dir = '/d/bip3/ezbc/perseus/data/av/'
    hi_dir = '/d/bip3/ezbc/perseus/data/galfa/'
    cfa_dir = '/d/bip3/ezbc/perseus/data/cfa/'
    core_dir = output_dir + 'core_arrays/'
    region_dir = '/d/bip3/ezbc/taurus/data/python_output/ds9_regions/'

    # load 2mass Av and GALFA HI images, on same grid
    cfa_data, cfa_header = load_fits(cfa_dir + \
                'perseus_cfa_cube_galfa_regrid.fits',
            return_header=True)

    #av_data += - 0.4 # subtracts background of 0.4 mags
    hi_data, hi_header = load_fits(hi_dir + \
                'perseus_galfa_cube_bin_3.7arcmin.fits',
            return_header = True)

    # make the velocity axis
    hi_velocity_axis = make_velocity_axis(hi_header)
    cfa_velocity_axis = make_velocity_axis(cfa_header)

    cfa_mom2 = mymath.calc_moment(cfa_data, moment = 2, spectral_axis = 0)

    # define core properties
    cores = {'L1495':
                {'center_wcs': [(4,14,0), (28, 11, 0)],
                 'map': None,
                 'threshold': 4.75,
                 'box_wcs': [(4,16,30), (27,44,30), (4,5,20), (28,28,33)]
                 },
             'L1495A':
                {'center_wcs': [(4,18,0), (28,23., 0)],
                 'map': None,
                 'threshold': 4.75,
                 'box_wcs': [(4,28,23),(28,12,50),(4,16,23),(29,46,5)],
                 },
             'B213':
                {'center_wcs': [(4, 19, 0), (27, 15,0)],
                 'map': None,
                 'threshold': 4.75,
                 'box_wcs': [(4,22,27), (26,45,47),(4,5,25),(27,18,48)],
                },
             'B220':
                {'center_wcs': [(4, 41, 0.), (26,7,0)],
                 'map': None,
                 'threshold': 7,
                 'box_wcs': [(4,47,49),(25,31,13),(4,40,37),(27,31,17)],
                 },
             'L1527':
                {'center_wcs': [(4, 39, 0.), (25,47, 0)],
                 'map': None,
                 'threshold': 7,
                 'box_wcs': [(4,40,13), (24,46,38), (4,34,35), (25,56,7)],
                 },
             'B215':
                {'center_wcs': [(4, 23, 0), (25, 3, 0)],
                 'map': None,
                 'threshold': 3,
                 'box_wcs': [(4,24,51), (22,36,7), (4,20,54), (25,26,31)],
                 },
             'L1524':
                {'center_wcs': [(4,29,0.), (24,31.,0)],
                 'map': None,
                 'threshold': 3,
                 'box_wcs': [(4,31,0), (22,4,6), (4,25,33), (25,0,55)],
                 }
                }

    cores = convert_core_coordinates(cores, hi_header)

    if True:
        hsd_limits =[0.1,300]
        hisd_limits = [2,20]
        av_limits =[0.01,100]
        nhi_limits = [2,20]

        cores = load_ds9_region(cores,
                filename_base = region_dir + 'taurus_av_boxes_',
                header = hi_header)

        # save cores for later
        if 0:
            mask = np.zeros((cfa_mom2.shape))
            for core in cores:
                print('Calculating for core %s' % core)

                av_limits = [0.01,100]

                # Grab the mask
                xy = cores[core]['box_center_pix']
                box_width = cores[core]['box_width']
                box_height = cores[core]['box_height']
                box_angle = cores[core]['box_angle']
                mask += myg.get_rectangular_mask(cfa_mom2,
                        xy[0], xy[1],
                        width = box_width,
                        height = box_height,
                        angle = box_angle)

                cores[core]['box_vertices'] = myg.get_rect(
                            xy[0], xy[1],
                            width = box_width,
                            height = box_height,
                            angle = box_angle,)

                indices = np.where(mask == 1)

            mask[mask > 1] = 1
            cfa_mom2[mask == 0] = np.nan

        # currently have variance, need dispersion
        cfa_mom2 = cfa_mom2**0.5


        # Plot
        plot_mom2_image(mom2_image = cfa_mom2,
                header = cfa_header,
                boxes = False,
                #limits=[128,37,308,206],
                title = r'Perseus: $\sigma_{\rm CO}$ map with core ' + \
                        'boxed-regions.',
                savedir = figure_dir,
                filename='perseus_co_veldisp_map.png',
                show=True)
def main():
    ''' Executes script.
    '''

    # import external modules
    import pyfits as pf
    import numpy as np
    from mycoords import make_velocity_axis
    import mygeometry as myg
    reload(myg)

    # define directory locations
    output_dir = '/d/bip3/ezbc/taurus/data/python_output/nhi_av/'
    figure_dir = '/d/bip3/ezbc/taurus/figures/maps/'
    av_dir = '/d/bip3/ezbc/taurus/data/av/'
    hi_dir = '/d/bip3/ezbc/taurus/data/galfa/'
    core_dir = output_dir + 'core_arrays/'
    region_dir = '/d/bip3/ezbc/taurus/data/python_output/ds9_regions/'

    # Load hi fits file
    hi_image, hi_header = pf.getdata(hi_dir + \
            'taurus_galfa_cube_bin_3.7arcmin.fits', header=True)
    h = hi_header

    # Load av fits file
    av_image, av_header = pf.getdata(av_dir + 'taurus_av_k09_regrid.fits',
                                     header=True)

    # make velocity axis for hi cube
    velocity_axis = make_velocity_axis(hi_header)

    # create nhi image
    nhi_image = calculate_nhi(hi_cube=hi_image,
                              velocity_axis=velocity_axis,
                              velocity_range=[-100, 100])

    if False:
        # trim hi_image to av_image size
        nhi_image_trim = np.ma.array(nhi_image, mask=av_image != av_image)

        plot_nhi_image(nhi_image=nhi_image_trim,
                       header=hi_header,
                       contour_image=av_image,
                       contours=[5, 10, 15],
                       savedir=figure_dir,
                       filename='taurus_nhi_cores_map.png',
                       show=True)

    cores = {
        'L1495': {
            'center_wcs': [(4, 14, 0), (28, 11, 0)],
            'map': None,
            'threshold': 4.75,
            'box_wcs': [(4, 16, 30), (27, 44, 30), (4, 5, 20), (28, 28, 33)]
        },
        'L1495A': {
            'center_wcs': [(4, 18, 0), (28, 23., 0)],
            'map': None,
            'threshold': 4.75,
            'box_wcs': [(4, 28, 23), (28, 12, 50), (4, 16, 23), (29, 46, 5)],
        },
        'B213': {
            'center_wcs': [(4, 19, 0), (27, 15, 0)],
            'map': None,
            'threshold': 4.75,
            'box_wcs': [(4, 22, 27), (26, 45, 47), (4, 5, 25), (27, 18, 48)],
        },
        'B220': {
            'center_wcs': [(4, 41, 0.), (26, 7, 0)],
            'map': None,
            'threshold': 7,
            'box_wcs': [(4, 47, 49), (25, 31, 13), (4, 40, 37), (27, 31, 17)],
        },
        'L1527': {
            'center_wcs': [(4, 39, 0.), (25, 47, 0)],
            'map': None,
            'threshold': 7,
            'box_wcs': [(4, 40, 13), (24, 46, 38), (4, 34, 35), (25, 56, 7)],
        },
        'B215': {
            'center_wcs': [(4, 23, 0), (25, 3, 0)],
            'map': None,
            'threshold': 3,
            'box_wcs': [(4, 24, 51), (22, 36, 7), (4, 20, 54), (25, 26, 31)],
        },
        'L1524': {
            'center_wcs': [(4, 29, 0.), (24, 31., 0)],
            'map': None,
            'threshold': 3,
            'box_wcs': [(4, 31, 0), (22, 4, 6), (4, 25, 33), (25, 0, 55)],
        }
    }

    cores = convert_core_coordinates(cores, h)

    if False:
        nhi_image = np.zeros(nhi_image.shape)

        for core in cores:
            core_image = np.load(core_dir + core + '.npy')
            core_indices = np.where(core_image == core_image)
            nhi_image[core_indices] += core_image[core_indices]

        nhi_image_trim =np.ma.array(nhi_image, mask=((av_image != av_image) &\
                (nhi_image == 0)))

        nhi_image_trim[nhi_image_trim == 0] = np.NaN

        read_ds9_region(av_dir + 'taurus_av_boxes.reg')

        plot_nhi_image(nhi_image=nhi_image_trim,
                       header=hi_header,
                       savedir=figure_dir,
                       cores=cores,
                       filename='taurus_nhi_core_regions_map.png',
                       show=True)

    if True:
        cores = load_ds9_region(cores,
                                filename_base=region_dir + 'taurus_av_boxes_',
                                header=h)

        # Grab the mask
        mask = np.zeros((nhi_image.shape))
        for core in cores:
            xy = cores[core]['box_center_pix']
            box_width = cores[core]['box_width']
            box_height = cores[core]['box_height']
            box_angle = cores[core]['box_angle']
            mask += myg.get_rectangular_mask(nhi_image,
                                             xy[0],
                                             xy[1],
                                             width=box_width,
                                             height=box_height,
                                             angle=box_angle)

            cores[core]['box_vertices'] = myg.get_rect(
                xy[0],
                xy[1],
                width=box_width,
                height=box_height,
                angle=box_angle,
            )

        #print(cores[core]['box_vertices'])
        #print core, xy, box_width, box_height, box_angle

        mask[mask > 1] = 1

        #nhi_image[mask == 0] = np.nan

        # trim hi_image to av_image size
        nhi_image_trim = np.ma.array(nhi_image, mask=(av_image != av_image))

        # Plot
        figure_types = ['pdf', 'png']
        for figure_type in figure_types:
            plot_nhi_image(nhi_image=nhi_image_trim, header=hi_header,
                    contour_image=av_image, contours=[5,10,15],
                    boxes=True, cores = cores, limits=[128,37,308,206],
                    title='Taurus: N(HI) map with core boxed-regions.',
                    savedir=figure_dir, filename='taurus_nhi_cores_map.%s' % \
                            figure_type,
                    show=False)
def main():
    ''' Executes script.
    '''

    # import external modules
    import pyfits as pf
    import numpy as np
    from mycoords import make_velocity_axis
    import mygeometry as myg
    reload(myg)

    # define directory locations
    output_dir = '/d/bip3/ezbc/california/data/python_output/nhi_av/'
    figure_dir = '/d/bip3/ezbc/california/figures/'
    av_dir = '/d/bip3/ezbc/california/data/av/'
    hi_dir = '/d/bip3/ezbc/california/data/galfa/'
    core_dir = output_dir + 'core_arrays/'
    region_dir = '/d/bip3/ezbc/california/data/python_output/ds9_regions/'

    # Load hi fits file
    hi_image, hi_header = pf.getdata(hi_dir + \
            'california_galfa_cube_bin_3.7arcmin.fits', header=True)
    h = hi_header

    # Load av fits file
    av_image, av_header = pf.getdata(av_dir + \
                'california_planck_av_regrid.fits',
            header=True)

    # make velocity axis for hi cube
    velocity_axis = make_velocity_axis(hi_header)

    # create nhi image
    nhi_image = calculate_nhi(hi_cube=hi_image,
            velocity_axis=velocity_axis, velocity_range=[-100,100])

    if False:
        # trim hi_image to av_image size
        nhi_image_trim = np.ma.array(nhi_image, mask=av_image != av_image)

        plot_nhi_image(nhi_image=nhi_image_trim, header=hi_header,
                contour_image=av_image, contours=[5,10,15],
                savedir=figure_dir, filename='california_nhi_cores_map.png',
                show=True)

    # define core properties
    cores = {'L1482':
                {'center_wcs': [(4, 29, 41), (35, 48, 41)],
                 'map': None,
                 'threshold': None,
                 },
              'L1483':
                {'center_wcs': [(4, 34, 57), (36, 18, 12)],
                 'map': None,
                 'threshold': None,
                 },
              'L1478':
                {'center_wcs': [(4, 25, 7), (37, 13, 0)],
                 'map': None,
                 'threshold': None,
                 },
              'L1434':
                {'center_wcs': [(3, 50, 51), (35, 15, 10)],
                 'map': None,
                 'threshold': None,
                 },
              'L1503':
                {'center_wcs': [(4, 40, 27), (29, 57, 12)],
                 'map': None,
                 'threshold': None,
                 },
              'L1507':
                {'center_wcs': [(4, 42, 51), (29, 44, 47)],
                 'map': None,
                 'threshold': None,
                 },
                }

    cores = convert_core_coordinates(cores, h)

    if False:
        nhi_image = np.zeros(nhi_image.shape)

        for core in cores:
        	core_image = np.load(core_dir + core + '.npy')
        	core_indices = np.where(core_image == core_image)
        	nhi_image[core_indices] += core_image[core_indices]

        nhi_image_trim =np.ma.array(nhi_image, mask=((av_image != av_image) &\
                (nhi_image == 0)))

        nhi_image_trim[nhi_image_trim == 0] = np.NaN

        read_ds9_region(av_dir + 'california_av_boxes.reg')

        plot_nhi_image(nhi_image=nhi_image_trim, header=hi_header,
            savedir=figure_dir,
            cores=cores,
            filename='california_nhi_core_regions_map.png',
            show=True)

    if True:
        cores = load_ds9_region(cores,
                filename_base = region_dir + 'california_av_boxes_',
                header = h)

        # Grab the mask
        mask = np.zeros((nhi_image.shape))
        for core in cores:
        	xy = cores[core]['box_center_pix']
        	box_width = cores[core]['box_width']
        	box_height = cores[core]['box_height']
        	box_angle = cores[core]['box_angle']
        	mask += myg.get_rectangular_mask(nhi_image,
        	        xy[0], xy[1],
                    width = box_width,
                    height = box_height,
                    angle = box_angle)

        	cores[core]['box_vertices'] = myg.get_rect(
                        xy[0], xy[1],
                        width = box_width,
                        height = box_height,
                        angle = box_angle,)

        #print(cores[core]['box_vertices'])
        #print core, xy, box_width, box_height, box_angle

        mask[mask > 1] = 1

        #nhi_image[mask == 0] = np.nan

        # trim hi_image to av_image size
        nhi_image_trim = np.ma.array(nhi_image,
                mask = (av_image != av_image))

        # Plot
        plot_nhi_image(nhi_image=nhi_image_trim, header=hi_header,
                contour_image=av_image, contours=[3,6,10],
                boxes=True, cores = cores, #limits=[128,37,308,206],
                title='California: N(HI) map with core boxed-regions.',
                savedir=figure_dir, filename='california_nhi_cores_map.pdf',
                show=True)
def main():
    ''' Executes script.
    '''

    # import external modules
    import pyfits as pf
    import numpy as np
    from mycoords import make_velocity_axis
    import mygeometry as myg
    reload(myg)

    # define directory locations
    output_dir = '/d/bip3/ezbc/perseus/data/python_output/nhi_av/'
    figure_dir = '/d/bip3/ezbc/perseus/figures/'
    av_dir = '/d/bip3/ezbc/perseus/data/av/'
    hi_dir = '/d/bip3/ezbc/perseus/data/galfa/'
    core_dir = output_dir + 'core_arrays/'
    region_dir = '/d/bip3/ezbc/perseus/data/python_output/ds9_regions/'

    # Load hi fits file
    hi_image, hi_header = pf.getdata(hi_dir + \
            'perseus_galfa_cube_bin_3.7arcmin.fits', header=True)
    h = hi_header

    # Load av fits file
    av_image, av_header = \
    pf.getdata('/d/bip3/ezbc/perseus/data/2mass/perseus_av_2mass_galfa_regrid.fits',
            header=True)

    # make velocity axis for hi cube
    velocity_axis = make_velocity_axis(hi_header)

    # create nhi image
    nhi_image = calculate_nhi(hi_cube=hi_image,
            velocity_axis=velocity_axis, velocity_range=[-100,100])

    if False:
        # trim hi_image to av_image size
        nhi_image_trim = np.ma.array(nhi_image, mask=av_image != av_image)

        plot_nhi_image(nhi_image=nhi_image_trim, header=hi_header,
                contour_image=av_image, contours=[5,10,15],
                savedir=figure_dir, filename='perseus_nhi_cores_map.png',
                show=True)

    cores = {'IC348':
                {'center_wcs': [(3, 44, 0), (32, 8, 0)],
                 'map': None,
                 'threshold': None,
                 'box_wcs': [(3,46,13), (26,3,24), (3,43,4), (32,25,41)],
                 },
             'NGC1333':
                {'center_wcs': [(3, 29, 11), (31, 16, 53)],
                 'map': None,
                 'threshold': None,
                 'box_wcs': None,
                 },
             'B4':
                {'center_wcs': [(3, 45, 50), (31, 42, 0)],
                 'map': None,
                 'threshold': None,
                 'box_wcs': None,
                 },
             'B5':
                {'center_wcs': [(3, 47, 34), (32, 48, 17)],
                 'map': None,
                 'threshold': None,
                 'box_wcs': None,
                 },
             #'':
             #   {'center_wcs': [],
             #    'map': None,
             #    'threshold': None,
             #    'box_wcs': None,
             #    },
            }

    cores = convert_core_coordinates(cores, h)

    if False:
        nhi_image = np.zeros(nhi_image.shape)

        for core in cores:
        	core_image = np.load(core_dir + core + '.npy')
        	core_indices = np.where(core_image == core_image)
        	nhi_image[core_indices] += core_image[core_indices]

        nhi_image_trim =np.ma.array(nhi_image, mask=((av_image != av_image) &\
                (nhi_image == 0)))

        nhi_image_trim[nhi_image_trim == 0] = np.NaN

        read_ds9_region(av_dir + 'perseus_av_boxes.reg')

        plot_nhi_image(nhi_image=nhi_image_trim, header=hi_header,
            savedir=figure_dir,
            cores=cores,
            filename='perseus_nhi_core_regions_map.png',
            show=True)

    if True:
        cores = load_ds9_region(cores,
                filename_base = region_dir + 'perseus_av_boxes_',
                header = h)

        # Grab the mask
        mask = np.zeros((nhi_image.shape))
        for core in cores:
        	xy = cores[core]['box_center_pix']
        	box_width = cores[core]['box_width']
        	box_height = cores[core]['box_height']
        	box_angle = cores[core]['box_angle']
        	mask += myg.get_rectangular_mask(nhi_image,
        	        xy[0], xy[1],
                    width = box_width,
                    height = box_height,
                    angle = box_angle)

        	cores[core]['box_vertices'] = myg.get_rect(
                        xy[0], xy[1],
                        width = box_width,
                        height = box_height,
                        angle = box_angle,)

        #print(cores[core]['box_vertices'])
        #print core, xy, box_width, box_height, box_angle

        mask[mask > 1] = 1

        #nhi_image[mask == 0] = np.nan

        # trim hi_image to av_image size
        nhi_image_trim = np.ma.array(nhi_image,
                mask = (av_image != av_image))

        # Plot
        figure_types = ['pdf', 'png']
        for figure_type in figure_types:
            plot_nhi_image(nhi_image=nhi_image_trim,
                    header=hi_header,
                    contour_image=av_image,
                    contours=[2.5,5,8],
                    boxes=True,
                    cores = cores,
                    limits=[47,128,231,222,],
                    title='Perseus: N(HI) map with core boxed-regions.',
                    savedir=figure_dir,
                    filename='perseus_nhi_cores_map.%s' % figure_type,
                    show=False)
def main():
    ''' Executes script.
    '''

    # import external modules
    import pyfits as pf
    import numpy as np
    from mycoords import make_velocity_axis
    import mygeometry as myg
    reload(myg)

    # define directory locations
    output_dir = '/d/bip3/ezbc/taurus/data/python_output/nhi_av/'
    figure_dir = '/d/bip3/ezbc/taurus/figures/maps/'
    av_dir = '/d/bip3/ezbc/taurus/data/av/'
    hi_dir = '/d/bip3/ezbc/taurus/data/hi/'
    core_dir = output_dir + 'core_arrays/'
    region_dir = '/d/bip3/ezbc/taurus/data/python_output/ds9_regions/'

    # Load hi fits file
    hi_image, hi_header = pf.getdata(hi_dir + \
            'taurus_hi_galfa_cube_regrid_planckres.fits', header=True)
    h = hi_header

    # Load av fits file
    av_image, av_header = pf.getdata(av_dir + \
                'taurus_av_planck_5arcmin.fits',
            header=True)

    # make velocity axis for hi cube
    velocity_axis = make_velocity_axis(hi_header)

    # create nhi image
    nhi_image = calculate_nhi(hi_cube=hi_image,
            velocity_axis=velocity_axis, velocity_range=[-16.53,28.83])

    if False:
        # trim hi_image to av_image size
        nhi_image_trim = np.ma.array(nhi_image, mask=av_image != av_image)

        plot_nhi_image(nhi_image=nhi_image_trim, header=hi_header,
                contour_image=av_image, contours=[5,10,15],
                savedir=figure_dir, filename='taurus_nhi_cores_map.png',
                show=True)

    cores = {'L1495':
                {'center_wcs': [(4,14,0), (28, 11, 0)],
                 'map': None,
                 'threshold': 4.75,
                 'box_wcs': [(4,16,30), (27,44,30), (4,5,20), (28,28,33)]
                 },
             'L1495A':
                {'center_wcs': [(4,18,0), (28,23., 0)],
                 'map': None,
                 'threshold': 4.75,
                 'box_wcs': [(4,28,23),(28,12,50),(4,16,23),(29,46,5)],
                 },
             'B213':
                {'center_wcs': [(4, 19, 0), (27, 15,0)],
                 'map': None,
                 'threshold': 4.75,
                 'box_wcs': [(4,22,27), (26,45,47),(4,5,25),(27,18,48)],
                },
             'B220':
                {'center_wcs': [(4, 41, 0.), (26,7,0)],
                 'map': None,
                 'threshold': 7,
                 'box_wcs': [(4,47,49),(25,31,13),(4,40,37),(27,31,17)],
                 },
             'L1527':
                {'center_wcs': [(4, 39, 0.), (25,47, 0)],
                 'map': None,
                 'threshold': 7,
                 'box_wcs': [(4,40,13), (24,46,38), (4,34,35), (25,56,7)],
                 },
             'B215':
                {'center_wcs': [(4, 23, 0), (25, 3, 0)],
                 'map': None,
                 'threshold': 3,
                 'box_wcs': [(4,24,51), (22,36,7), (4,20,54), (25,26,31)],
                 },
             'L1524':
                {'center_wcs': [(4,29,0.), (24,31.,0)],
                 'map': None,
                 'threshold': 3,
                 'box_wcs': [(4,31,0), (22,4,6), (4,25,33), (25,0,55)],
                 }
                }

    cores = convert_core_coordinates(cores, h)

    if False:
        nhi_image = np.zeros(nhi_image.shape)

        for core in cores:
        	core_image = np.load(core_dir + core + '.npy')
        	core_indices = np.where(core_image == core_image)
        	nhi_image[core_indices] += core_image[core_indices]

        nhi_image_trim =np.ma.array(nhi_image, mask=((av_image != av_image) &\
                (nhi_image == 0)))

        nhi_image_trim[nhi_image_trim == 0] = np.NaN

        read_ds9_region(av_dir + 'taurus_av_boxes.reg')

        plot_nhi_image(nhi_image=nhi_image_trim, header=hi_header,
            savedir=figure_dir,
            cores=cores,
            filename='taurus_nhi_core_regions_map.png',
            show=True)

    if True:
        cores = load_ds9_region(cores,
                filename_base = region_dir + 'taurus_av_boxes_',
                header = h)

        # Grab the mask
        mask = np.zeros((nhi_image.shape))
        for core in cores:
        	xy = cores[core]['box_center_pix']
        	box_width = cores[core]['box_width']
        	box_height = cores[core]['box_height']
        	box_angle = cores[core]['box_angle']
        	mask += myg.get_rectangular_mask(nhi_image,
        	        xy[0], xy[1],
                    width = box_width,
                    height = box_height,
                    angle = box_angle)

        	cores[core]['box_vertices'] = myg.get_rect(
                        xy[0], xy[1],
                        width = box_width,
                        height = box_height,
                        angle = box_angle,)

        mask[mask > 1] = 1

        # trim hi_image to av_image size
        nhi_image_trim = np.ma.array(nhi_image,
                mask = ((av_image != av_image) & \
                        (av_image > 1.0)))
        av_image_trim = np.ma.array(av_image,
                mask = ((nhi_image != nhi_image) & \
                        (av_image > 1.0)))

        nhi_image_trim = np.copy(nhi_image)
        nhi_image_trim[av_image > 1.] = np.nan
        av_image_trim = np.copy(av_image)
        av_image_trim[av_image > 1.] = np.nan

        # Plot
        figure_types = ['png',]
        for figure_type in figure_types:
            # N(HI) alone
            plot_nhi_image(nhi_image=nhi_image_trim, header=hi_header,
                    contour_image=av_image, contours=[5,10,15],
                    boxes=True, cores = cores,
                    limits=[50,37,200,160],
                    savedir=figure_dir,
                    filename='taurus_nhi_cores_map.%s' % \
                            figure_type,
                    show=0)

            # N(HI) + Av
            plot_nhi_image(nhi_image=nhi_image_trim, header=hi_header,
                    av_image=av_image_trim,
                    #boxes=True, cores = cores,
                    limits=[50,37,200,160],
                    savedir=figure_dir,
                    filename='taurus_nhi_av_map.%s' % \
                            figure_type,
                    show=0)