Пример #1
0
def search_CLASHcat(cluster,output='default',search_radius=0.08333,clobber=False,verbose=True):
    """

    --- INPUT ---
    cluster        (full) Name of cluster to search
    output         Name of output to generate
    search_radius  Radius to return objects in around cluster ra and dec (from clusterinfo())
    clobber        Overwrite outputfile if it already exists?
    verbose        Toggle verbosity

    --- EXAMPLE OF USE ---
    import MUSE_AOsetup as mao
    cluster   = 'MACS2129.4-0741'
    outputcat = mao.search_CLASHcat(cluster,verbose=True)


    """
    cluster_short = cluster.split('.')[0].lower()
    catalog = '/Users/kschmidt/work/catalogs/CLASHcatalogs/hlsp_clash_hst_ir_'+cluster_short+'_cat.txt.FITS'
    ra, dec = mao.clusterinfo()[cluster.upper()]['ra'], mao.clusterinfo()[cluster.upper()]['dec']
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    CLASH_hdu      = pyfits.open(catalog) # Load the FITS hdulist
    CLASH_dat      = CLASH_hdu[1].data
    CLASH_hdr      = CLASH_hdu[1].header

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    CLASH_IDall    = CLASH_dat['id']
    CLASH_RAall    = CLASH_dat['ra']
    CLASH_Decall   = CLASH_dat['dec']
    Nobj_CLASH     = len(CLASH_IDall)
    if verbose: print ' - Will find matches to the '+str(Nobj_CLASH)+' in \n   '+catalog
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    if output== 'default':
        outputfile = cluster_short.upper()+'_CLASHcatSearchOutput_rsearch'+\
                     str(search_radius).replace('.','p')+'.fits'
    else:
        outputfile = output
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    r_match  = np.sqrt( (np.cos(np.deg2rad(dec))*(CLASH_RAall-ra))**2.0 + (CLASH_Decall-dec)**2.0 )

    goodmatch = np.where(r_match <= search_radius)[0]
    if len(goodmatch) > 0:
        if verbose: print ' - Writing output to '+outputfile
        if (os.path.isfile(outputfile)) & (clobber==False): # check if file already exists
            if verbose: print '   WARNING: output file already exists. clobber=False so did not overwrite '
        else:
            if (os.path.isfile(outputfile)) & (clobber==True) & verbose:
                print '   Output file already exists but clobber=True so overwriting it'

            pyfits.writeto(outputfile, CLASH_dat[goodmatch], clobber=clobber)
    else:
        if verbose: print ' - WARNING No matches found within search_radius = '+str(search_radius)+\
                          ' No file returned'

    return outputfile
Пример #2
0
def get_extinctions4GLASSclusters(filter='F125W',valreturn='median',radius=1.7/60.,
                                  stepsize=[0.4/60.,0.4/60.],clusters='GLASS',verbose=True):
    """

    Using kbs.getAv_area to get extinction of GLASS clusters

    mao.get_extinctions4GLASSclusters()

    """
    if clusters == 'GLASS':
        cldic = mao.clusterinfo()
    elif clusters == 'others':
        cldic = {}
        cldic['bullet'] = {'ra':104.62958,'dec': -55.94694 , 'name':'Bullet'}
        cldic['A1689']  = {'ra':197.87292,'dec': -1.33806  , 'name':'A1689'}

    for key in cldic.keys():
        if verbose: print ' ---------------- Get extinction for '+cldic[key]['name']+' ----------------'
        if verbose == 'Full':
            vb_getAv_area = True
        else:
            vb_getAv_area = False
        A, EBV, grid = kbs.getAv_area(cldic[key]['ra'],cldic[key]['dec'],radius,stepsize=stepsize,
                                      valreturn=valreturn,filter=filter,verbose=vb_getAv_area)
        if verbose: print ' - The results is A, EBV, grid = ',A,',', EBV,',', grid,','
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Пример #3
0
def get_extinctions4GLASSclusters(filter='F125W',
                                  valreturn='median',
                                  radius=1.7 / 60.,
                                  stepsize=[0.4 / 60., 0.4 / 60.],
                                  clusters='GLASS',
                                  verbose=True):
    """

    Using kbs.getAv_area to get extinction of GLASS clusters

    mao.get_extinctions4GLASSclusters()

    """
    if clusters == 'GLASS':
        cldic = mao.clusterinfo()
    elif clusters == 'others':
        cldic = {}
        cldic['bullet'] = {'ra': 104.62958, 'dec': -55.94694, 'name': 'Bullet'}
        cldic['A1689'] = {'ra': 197.87292, 'dec': -1.33806, 'name': 'A1689'}

    for key in cldic.keys():
        if verbose:
            print ' ---------------- Get extinction for ' + cldic[key][
                'name'] + ' ----------------'
        if verbose == 'Full':
            vb_getAv_area = True
        else:
            vb_getAv_area = False
        A, EBV, grid = kbs.getAv_area(cldic[key]['ra'],
                                      cldic[key]['dec'],
                                      radius,
                                      stepsize=stepsize,
                                      valreturn=valreturn,
                                      filter=filter,
                                      verbose=vb_getAv_area)
        if verbose:
            print ' - The results is A, EBV, grid = ', A, ',', EBV, ',', grid, ','
Пример #4
0
def run_all_GLASSclusters(search_radius=0.16666,printcommand=True,catalog=None,verbose=True):
    """
    Perform cone search and generate the object region files for all 10 GLASS clusters

    --- INPUT ---
    search_radius       radius around ra and dec to search [deg]
    printcommand        Print DS9 command instead of opening the files?

    --- EXAMPLE OF USE ---
    import MUSE_AOsetup as mao
    mao.run_all_GLASSclusters(0.16666)

    """
    search_catalog     = 'Guide Star Catalog v2 1'
    cluster_dic        = mao.clusterinfo()
    if verbose: print ' - Search catalog set ('+search_catalog+') and cluster info loaded '

    if verbose: print ' - Searching for objects within '+str(search_radius)+' degrees of the cluster '
    for key in cluster_dic.keys():
        cli            = cluster_dic[key]
        if verbose: print '========================='+cli['name']+'========================='
        # -------------------- SEARCH via VO --------------------
        search_result  = mao.perform_conesearch(cli['ra'],cli['dec'],search_radius,
                                                catalog=search_catalog,verbose=verbose)
        conesearchfile = '/Users/kschmidt/work/MUSE/call_PublicDeepFied/'+\
                         cli['name']+'_conesearch_'+search_catalog.replace(' ','_')+\
                         '_Rsearch_'+str(search_radius).replace('.','p')
        mao.save_conesearch(search_result,filename=conesearchfile,verbose=verbose)
        if os.path.isfile(conesearchfile+'.txt'):
            mao.create_objectDS9reg(conesearchfile+'.txt','ra','dec',['RMag','RMag','VMag'],verbose=verbose)

        # -------------------- SEARCH GSPC --------------------
        GSPC_search_radius = 1.0 #deg
        GSPCsearchfile = '/Users/kschmidt/work/MUSE/call_PublicDeepFied/'+\
                         cli['name']+'_GSPCv2p4search_Rsearch_'+str(GSPC_search_radius).replace('.','p')+'.fits'

        mao.search_GSPCv2p4(GSPCsearchfile,cli['ra'],cli['dec'],GSPC_search_radius,clobber=False,verbose=True)
        if os.path.isfile(GSPCsearchfile):
            mao.create_objectDS9reg(GSPCsearchfile,'RAJ2000','DEJ2000',['Rmag','Rmag','Vmag'],id_name='ID')

        # -------------------- SEARCH CLASH --------------------
        if ('A370' not in key) and ('A2744' not in key):
            outputcat = mao.search_CLASHcat(key,search_radius=search_radius,verbose=True)
            mao.create_objectDS9reg(outputcat,'ra','dec',['f606w_mag','f606w_mag','f606w_mag'],
                                    id_name='id',star_name='stel')

        # -------------------- SEARCH ROMAN --------------------
        outputcat = mao.search_ROMANcat(key,search_radius=search_radius,verbose=True)
        if outputcat != None:
            mao.create_objectDS9reg(outputcat,'RA','DEC',['V606','V606','V606'],id_name='ID')

    if printcommand:
        if verbose: print '\n\n - To open the fits files use the DS9 command:'
    mao.open_fits_and_regions('all',printcommand=printcommand,verbose=verbose)
Пример #5
0
def search_ROMANcat(cluster,output='default',search_radius=0.08333,clobber=False,verbose=True):
    """

    --- INPUT ---
    cluster        (full) Name of cluster to search
    output         Name of output to generate
    search_radius  Radius to return objects in around cluster ra and dec (from clusterinfo())
    clobber        Overwrite outputfile if it already exists?
    verbose        Toggle verbosity

    --- EXAMPLE OF USE ---
    import MUSE_AOsetup as mao
    cluster   = 'a2744'
    outputcat = mao.search_ROMANcat(cluster,verbose=True)

    """
    cluster_short = cluster.split('.')[0].lower()

    if cluster_short == 'a2744':
        catfile = '/Users/kschmidt/work/GitHub/GLASS/ROMAN_CATALOGS/A2744/A2744_CLUSTER.cat'
    elif cluster_short == 'macs0416':
        catfile = '/Users/kschmidt/work/GitHub/GLASS/ROMAN_CATALOGS/M0416/M0416_CLUSTER.cat'
    elif cluster_short == 'macs1149':
        #coordfile = '/Users/kschmidt/work/GitHub/GLASS/ROMAN_CATALOGS/M1149/outcord.1007_HST.dat'
        #catfile   = '/Users/kschmidt/work/GitHub/GLASS/ROMAN_CATALOGS/M1149/outmag.1007_HST.dat'
        catfile    = '/Users/kschmidt/work/catalogs/ROMANphotocat_M1149combcat.cat'
    else:
        print ' WARNING No ROMAN catalog exists for the cluster '+cluster+'. Nothing returned.'
        return None
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    outpath     = '/Users/kschmidt/work/catalogs/'
    fitscatalog = f2a.ascii2fits(catfile,asciinames=True,skip_header=0,outpath=outpath,verbose=verbose)
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ROMAN_hdu      = pyfits.open(fitscatalog) # Load the FITS hdulist
    ROMAN_dat      = ROMAN_hdu[1].data
    ROMAN_IDall    = ROMAN_dat['ID']
    ROMAN_RAall    = ROMAN_dat['RA']
    ROMAN_Decall   = ROMAN_dat['DEC']
    Nobj_ROMAN     = len(ROMAN_IDall)
    if verbose: print ' - Will find matches to the '+str(Nobj_ROMAN)+' in \n   '+catfile
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ra, dec = mao.clusterinfo()[cluster.upper()]['ra'], mao.clusterinfo()[cluster.upper()]['dec']
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    if output== 'default':
        outputfile = cluster_short.upper()+'_ROMANcatSearchOutput_rsearch'+\
                     str(search_radius).replace('.','p')+'.fits'
    else:
        outputfile = output
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    r_match  = np.sqrt( (np.cos(np.deg2rad(dec))*(ROMAN_RAall-ra))**2.0 + (ROMAN_Decall-dec)**2.0 )

    goodmatch = np.where(r_match <= search_radius)[0]
    if len(goodmatch) > 0:
        if verbose: print ' - Writing output to '+outputfile
        if (os.path.isfile(outputfile)) & (clobber==False): # check if file already exists
            if verbose: print '   WARNING: output file already exists. clobber=False so did not overwrite '
        else:
            if (os.path.isfile(outputfile)) & (clobber==True) & verbose:
                print '   Output file already exists but clobber=True so overwriting it'

            pyfits.writeto(outputfile, ROMAN_dat[goodmatch], clobber=clobber)
    else:
        if verbose: print ' - WARNING No matches found within search_radius = '+str(search_radius)+\
                          ' No file returned'

    return outputfile
Пример #6
0
def run_all_GLASSclusters(search_radius=0.16666,
                          printcommand=True,
                          catalog=None,
                          verbose=True):
    """
    Perform cone search and generate the object region files for all 10 GLASS clusters

    --- INPUT ---
    search_radius       radius around ra and dec to search [deg]
    printcommand        Print DS9 command instead of opening the files?

    --- EXAMPLE OF USE ---
    import MUSE_AOsetup as mao
    mao.run_all_GLASSclusters(0.16666)

    """
    search_catalog = 'Guide Star Catalog v2 1'
    cluster_dic = mao.clusterinfo()
    if verbose:
        print ' - Search catalog set (' + search_catalog + ') and cluster info loaded '

    if verbose:
        print ' - Searching for objects within ' + str(
            search_radius) + ' degrees of the cluster '
    for key in cluster_dic.keys():
        cli = cluster_dic[key]
        if verbose:
            print '=========================' + cli[
                'name'] + '========================='
        # -------------------- SEARCH via VO --------------------
        search_result = mao.perform_conesearch(cli['ra'],
                                               cli['dec'],
                                               search_radius,
                                               catalog=search_catalog,
                                               verbose=verbose)
        conesearchfile = '/Users/kschmidt/work/MUSE/call_PublicDeepFied/'+\
                         cli['name']+'_conesearch_'+search_catalog.replace(' ','_')+\
                         '_Rsearch_'+str(search_radius).replace('.','p')
        mao.save_conesearch(search_result,
                            filename=conesearchfile,
                            verbose=verbose)
        if os.path.isfile(conesearchfile + '.txt'):
            mao.create_objectDS9reg(conesearchfile + '.txt',
                                    'ra',
                                    'dec', ['RMag', 'RMag', 'VMag'],
                                    verbose=verbose)

        # -------------------- SEARCH GSPC --------------------
        GSPC_search_radius = 1.0  #deg
        GSPCsearchfile = '/Users/kschmidt/work/MUSE/call_PublicDeepFied/'+\
                         cli['name']+'_GSPCv2p4search_Rsearch_'+str(GSPC_search_radius).replace('.','p')+'.fits'

        mao.search_GSPCv2p4(GSPCsearchfile,
                            cli['ra'],
                            cli['dec'],
                            GSPC_search_radius,
                            clobber=False,
                            verbose=True)
        if os.path.isfile(GSPCsearchfile):
            mao.create_objectDS9reg(GSPCsearchfile,
                                    'RAJ2000',
                                    'DEJ2000', ['Rmag', 'Rmag', 'Vmag'],
                                    id_name='ID')

        # -------------------- SEARCH CLASH --------------------
        if ('A370' not in key) and ('A2744' not in key):
            outputcat = mao.search_CLASHcat(key,
                                            search_radius=search_radius,
                                            verbose=True)
            mao.create_objectDS9reg(outputcat,
                                    'ra',
                                    'dec',
                                    ['f606w_mag', 'f606w_mag', 'f606w_mag'],
                                    id_name='id',
                                    star_name='stel')

        # -------------------- SEARCH ROMAN --------------------
        outputcat = mao.search_ROMANcat(key,
                                        search_radius=search_radius,
                                        verbose=True)
        if outputcat != None:
            mao.create_objectDS9reg(outputcat,
                                    'RA',
                                    'DEC', ['V606', 'V606', 'V606'],
                                    id_name='ID')

    if printcommand:
        if verbose: print '\n\n - To open the fits files use the DS9 command:'
    mao.open_fits_and_regions('all',
                              printcommand=printcommand,
                              verbose=verbose)
Пример #7
0
def search_ROMANcat(cluster,
                    output='default',
                    search_radius=0.08333,
                    clobber=False,
                    verbose=True):
    """

    --- INPUT ---
    cluster        (full) Name of cluster to search
    output         Name of output to generate
    search_radius  Radius to return objects in around cluster ra and dec (from clusterinfo())
    clobber        Overwrite outputfile if it already exists?
    verbose        Toggle verbosity

    --- EXAMPLE OF USE ---
    import MUSE_AOsetup as mao
    cluster   = 'a2744'
    outputcat = mao.search_ROMANcat(cluster,verbose=True)

    """
    cluster_short = cluster.split('.')[0].lower()

    if cluster_short == 'a2744':
        catfile = '/Users/kschmidt/work/GitHub/GLASS/ROMAN_CATALOGS/A2744/A2744_CLUSTER.cat'
    elif cluster_short == 'macs0416':
        catfile = '/Users/kschmidt/work/GitHub/GLASS/ROMAN_CATALOGS/M0416/M0416_CLUSTER.cat'
    elif cluster_short == 'macs1149':
        #coordfile = '/Users/kschmidt/work/GitHub/GLASS/ROMAN_CATALOGS/M1149/outcord.1007_HST.dat'
        #catfile   = '/Users/kschmidt/work/GitHub/GLASS/ROMAN_CATALOGS/M1149/outmag.1007_HST.dat'
        catfile = '/Users/kschmidt/work/catalogs/ROMANphotocat_M1149combcat.cat'
    else:
        print ' WARNING No ROMAN catalog exists for the cluster ' + cluster + '. Nothing returned.'
        return None
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    outpath = '/Users/kschmidt/work/catalogs/'
    fitscatalog = f2a.ascii2fits(catfile,
                                 asciinames=True,
                                 skip_header=0,
                                 outpath=outpath,
                                 verbose=verbose)
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ROMAN_hdu = pyfits.open(fitscatalog)  # Load the FITS hdulist
    ROMAN_dat = ROMAN_hdu[1].data
    ROMAN_IDall = ROMAN_dat['ID']
    ROMAN_RAall = ROMAN_dat['RA']
    ROMAN_Decall = ROMAN_dat['DEC']
    Nobj_ROMAN = len(ROMAN_IDall)
    if verbose:
        print ' - Will find matches to the ' + str(
            Nobj_ROMAN) + ' in \n   ' + catfile
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ra, dec = mao.clusterinfo()[cluster.upper()]['ra'], mao.clusterinfo()[
        cluster.upper()]['dec']
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    if output == 'default':
        outputfile = cluster_short.upper()+'_ROMANcatSearchOutput_rsearch'+\
                     str(search_radius).replace('.','p')+'.fits'
    else:
        outputfile = output
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    r_match = np.sqrt((np.cos(np.deg2rad(dec)) * (ROMAN_RAall - ra))**2.0 +
                      (ROMAN_Decall - dec)**2.0)

    goodmatch = np.where(r_match <= search_radius)[0]
    if len(goodmatch) > 0:
        if verbose: print ' - Writing output to ' + outputfile
        if (os.path.isfile(outputfile)) & (
                clobber == False):  # check if file already exists
            if verbose:
                print '   WARNING: output file already exists. clobber=False so did not overwrite '
        else:
            if (os.path.isfile(outputfile)) & (clobber == True) & verbose:
                print '   Output file already exists but clobber=True so overwriting it'

            pyfits.writeto(outputfile, ROMAN_dat[goodmatch], clobber=clobber)
    else:
        if verbose:            print ' - WARNING No matches found within search_radius = '+str(search_radius)+\
                  ' No file returned'

    return outputfile
Пример #8
0
def search_CLASHcat(cluster,
                    output='default',
                    search_radius=0.08333,
                    clobber=False,
                    verbose=True):
    """

    --- INPUT ---
    cluster        (full) Name of cluster to search
    output         Name of output to generate
    search_radius  Radius to return objects in around cluster ra and dec (from clusterinfo())
    clobber        Overwrite outputfile if it already exists?
    verbose        Toggle verbosity

    --- EXAMPLE OF USE ---
    import MUSE_AOsetup as mao
    cluster   = 'MACS2129.4-0741'
    outputcat = mao.search_CLASHcat(cluster,verbose=True)


    """
    cluster_short = cluster.split('.')[0].lower()
    catalog = '/Users/kschmidt/work/catalogs/CLASHcatalogs/hlsp_clash_hst_ir_' + cluster_short + '_cat.txt.FITS'
    ra, dec = mao.clusterinfo()[cluster.upper()]['ra'], mao.clusterinfo()[
        cluster.upper()]['dec']
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    CLASH_hdu = pyfits.open(catalog)  # Load the FITS hdulist
    CLASH_dat = CLASH_hdu[1].data
    CLASH_hdr = CLASH_hdu[1].header

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    CLASH_IDall = CLASH_dat['id']
    CLASH_RAall = CLASH_dat['ra']
    CLASH_Decall = CLASH_dat['dec']
    Nobj_CLASH = len(CLASH_IDall)
    if verbose:
        print ' - Will find matches to the ' + str(
            Nobj_CLASH) + ' in \n   ' + catalog
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    if output == 'default':
        outputfile = cluster_short.upper()+'_CLASHcatSearchOutput_rsearch'+\
                     str(search_radius).replace('.','p')+'.fits'
    else:
        outputfile = output
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    r_match = np.sqrt((np.cos(np.deg2rad(dec)) * (CLASH_RAall - ra))**2.0 +
                      (CLASH_Decall - dec)**2.0)

    goodmatch = np.where(r_match <= search_radius)[0]
    if len(goodmatch) > 0:
        if verbose: print ' - Writing output to ' + outputfile
        if (os.path.isfile(outputfile)) & (
                clobber == False):  # check if file already exists
            if verbose:
                print '   WARNING: output file already exists. clobber=False so did not overwrite '
        else:
            if (os.path.isfile(outputfile)) & (clobber == True) & verbose:
                print '   Output file already exists but clobber=True so overwriting it'

            pyfits.writeto(outputfile, CLASH_dat[goodmatch], clobber=clobber)
    else:
        if verbose:            print ' - WARNING No matches found within search_radius = '+str(search_radius)+\
                  ' No file returned'

    return outputfile