Ejemplo n.º 1
0
def test_targets():
    test_data = \
"""#name  lon  lat  radius coord  
object_1 354.36 -63.26 1.0 CEL
object_2 19.45  -17.46 1.0 CEL
#object_3  18.94  -41.05  1.0  CEL
"""
    with open('targets.txt','w') as f:
        f.write(test_data)
    
    parser = ugali.utils.parser.Parser()
    parser.add_coords(targets=True)
    args = parser.parse_args(['-t','targets.txt'])

    np.testing.assert_array_almost_equal(args.coords['lon'],[316.311,156.487],
                                         decimal=3)
    np.testing.assert_array_almost_equal(args.coords['lat'],[-51.903,-78.575],
                                         decimal=3)
    np.testing.assert_array_almost_equal(args.coords['radius'],[1.0,1.0],
                                         decimal=3)
    os.remove('targets.txt')
    return args
Ejemplo n.º 2
0
def test_targets():
    test_data = \
"""#name  lon  lat  radius coord  
object_1 354.36 -63.26 1.0 CEL
object_2 19.45  -17.46 1.0 CEL
#object_3  18.94  -41.05  1.0  CEL
"""
    with open('targets.txt', 'w') as f:
        f.write(test_data)

    parser = ugali.utils.parser.Parser()
    parser.add_coords(targets=True)
    args = parser.parse_args(['-t', 'targets.txt'])

    np.testing.assert_array_almost_equal(args.coords['lon'],
                                         [316.311, 156.487],
                                         decimal=3)
    np.testing.assert_array_almost_equal(args.coords['lat'],
                                         [-51.903, -78.575],
                                         decimal=3)
    np.testing.assert_array_almost_equal(args.coords['radius'], [1.0, 1.0],
                                         decimal=3)
    os.remove('targets.txt')
    return args
Ejemplo n.º 3
0
#!/usr/bin/env python
import ugali.candidate.associate
import ugali.utils.parser
import numpy as np
from ugali.utils.projector import gal2cel,ang2const,ang2iau

#CATALOGS = ['McConnachie12','Rykoff14', 'Harris96', 'Corwen04', 'Nilson73', 'Webbink85', 'Kharchenko13', 'WEBDA14']
CATALOGS = ['McConnachie12', 'Harris96', 'Corwen04', 'Nilson73', 'Webbink85', 'Kharchenko13', 'Bica08', 'WEBDA14', 'ExtraDwarfs','ExtraClusters']

if __name__ == "__main__":
    import argparse
    description = "python script"
    parser = ugali.utils.parser.Parser(description=description)
    parser.add_coords(required=True,radius=True,targets=True)
    parser.add_argument('-n','--nnearest',default=1,type=int)
    opts = parser.parse_args()

    catalog = ugali.candidate.associate.SourceCatalog()
    for i in CATALOGS:
        catalog += ugali.candidate.associate.catalogFactory(i)

    for name,(glon,glat,radius) in zip(opts.names, opts.coords):
        ra,dec = gal2cel(glon,glat)
        iau = ang2iau(glon,glat)
        const = ang2const(glon,glat)[0]
        if radius <= 0: radius = None
    
        idx1,idx2,sep = catalog.match([glon],[glat],tol=radius,nnearest=opts.nnearest)
        match = catalog[idx2]

        if len(match) > 0:
Ejemplo n.º 4
0
import ugali.candidate.associate
import ugali.utils.parser
import numpy as np
from ugali.utils.projector import gal2cel, ang2const, ang2iau

#CATALOGS = ['McConnachie12','Rykoff14', 'Harris96', 'Corwen04', 'Nilson73', 'Webbink85', 'Kharchenko13', 'WEBDA14']
CATALOGS = [
    'McConnachie12', 'Harris96', 'Corwen04', 'Nilson73', 'Webbink85',
    'Kharchenko13', 'Bica08', 'WEBDA14', 'ExtraDwarfs', 'ExtraClusters'
]

if __name__ == "__main__":
    import argparse
    description = "python script"
    parser = ugali.utils.parser.Parser(description=description)
    parser.add_coords(required=True, radius=True, targets=True)
    parser.add_argument('-n', '--nnearest', default=1, type=int)
    opts = parser.parse_args()

    catalog = ugali.candidate.associate.SourceCatalog()
    for i in CATALOGS:
        catalog += ugali.candidate.associate.catalogFactory(i)

    for name, (glon, glat, radius) in zip(opts.names, opts.coords):
        ra, dec = gal2cel(glon, glat)
        iau = ang2iau(glon, glat)
        const = ang2const(glon, glat)[0]
        if radius <= 0: radius = None

        idx1, idx2, sep = catalog.match([glon], [glat],
                                        tol=radius,
Ejemplo n.º 5
0
                          clobber=True)

        fitsio.write(outfile,
                     dict(DISTANCE_MODULUS=self.distance_modulus_array.astype(
                         'f4', copy=False)),
                     extname='DISTANCE_MODULUS',
                     clobber=False)


if __name__ == "__main__":
    import ugali.utils.parser
    description = "Script for executing the likelihood scan."
    parser = ugali.utils.parser.Parser(description=description)
    parser.add_config()
    parser.add_argument('outfile',
                        metavar='outfile.fits',
                        help='Output fits file.')
    parser.add_debug()
    parser.add_verbose()
    parser.add_coords(required=True, radius=False)
    opts = parser.parse_args()

    if len(opts.coords) != 1:
        raise Exception('Must specify exactly one coordinate.')
    lon, lat, radius = opts.coords[0]

    grid = createGridSearch(opts.config, lon, lat)
    if not opts.debug:
        result = grid.search()
        grid.write(opts.outfile)
Ejemplo n.º 6
0
                                                 outfile,
                                                 distance_modulus_array=self.distance_modulus_array,
                                                 coordsys='NULL', ordering='NULL',
                                                 header_dict=header_dict)

############################################################
    
if __name__ == "__main__":
    import ugali.utils.parser
    description = "Script for executing the likelihood scan."
    parser = ugali.utils.parser.Parser(description=description)
    parser.add_config()
    parser.add_argument('outfile',metavar='outfile.fits',help='Output fits file.')
    parser.add_debug()
    parser.add_verbose()
    parser.add_coords(required=True,radius=False)
    opts = parser.parse_args()

    if len(opts.coords) != 1: 
        raise Exception('Must specify exactly one coordinate.')
    lon,lat,radius = opts.coords[0]

    grid = createGridSearch(opts.config,lon,lat)
    if not opts.debug:
        result = grid.search()
        grid.write(opts.outfile)


    ##print opts.coords
    #scan = Scan(opts.config,opts.coords)
    #if not opts.debug:
Ejemplo n.º 7
0
    mcmc = MCMC(config,loglike)
    if samples is not None:
        mcmc.load_samples(samples)

    return mcmc

if __name__ == "__main__":
    import ugali.utils.parser
    description = "Script for running MCMC followup"
    parser = ugali.utils.parser.Parser(description=description)
    parser.add_config()
    parser.add_debug()
    parser.add_verbose()
    #parser.add_coords(required=True)
    parser.add_coords()
    parser.add_name()
    parser.add_argument('--srcmdl',help='Source model file')
    parser.add_argument('--grid',action='store_true',help='Grid search for intial parameters')
    parser.add_argument('outfile',default=None,help="Output file name")
                        
    opts = parser.parse_args()

    if opts.coords is not None and len(opts.coords) != 1: 
        raise Exception('Must specify exactly one coordinate.')
    
    #try:
    #    # Initialize the MPI-based pool used for parallelization.
    #    from emcee.utils import MPIPool
    #    pool = MPIPool(loadbalance=True)
    #except (ImportError,ValueError) as e:
Ejemplo n.º 8
0
    mcmc = MCMC(config, loglike)
    if samples is not None:
        mcmc.load_samples(samples)

    return mcmc


if __name__ == "__main__":
    import ugali.utils.parser
    description = "Script for running MCMC followup"
    parser = ugali.utils.parser.Parser(description=description)
    parser.add_config()
    parser.add_debug()
    parser.add_verbose()
    #parser.add_coords(required=True)
    parser.add_coords()
    parser.add_name()
    parser.add_argument('--srcmdl', help='Source model file')
    parser.add_argument('--grid',
                        action='store_true',
                        help='Grid search for intial parameters')
    parser.add_argument('outfile', default=None, help="Output file name")

    opts = parser.parse_args()

    if opts.coords is not None and len(opts.coords) != 1:
        raise Exception('Must specify exactly one coordinate.')

    #try:
    #    # Initialize the MPI-based pool used for parallelization.
    #    from emcee.utils import MPIPool