示例#1
0
文件: atable.py 项目: chbrandt/booq
def describe(table):
    from booq.utils import stats
    sts_list = []
    for col in table.colnames():
        sts = stats.basic( table[col] )
        sts_list.append( sts )
    return sts_list
示例#2
0
文件: xmatch.py 项目: chbrandt/booq
def gc_serial(A_coord, B_coord, radius):
    '''
    '''
    from astropy.coordinates import search_around_sky

    def assert_input(A_coord, B_coord, radius):
        from astropy.coordinates import SkyCoord
        from astropy.units import Quantity
        assert isinstance(A_coord,SkyCoord), "Was expecting an ~astropy.coordinates.SkyCoord instance for 'A_coord'."
        assert isinstance(B_coord,SkyCoord), "Was expecting an ~astropy.coordinates.SkyCoord instance for 'B_coord'."
        assert isinstance(radius,Quantity), "Was expecting an ~astropy.units.Quantity instance for 'radius'"
    assert_input(A_coord, B_coord, radius)
    
    logging.info("Searching B_coord {1} objects, {0} neighbors.".format(len(B_coord),len(A_coord)))
    _prau = A_coord.ra.unit
    _pdecu = A_coord.dec.unit
    _nrau = B_coord.ra.unit
    _ndecu = B_coord.dec.unit
    logging.debug("Unit of coordinates being matched: ({0},{1}) and ({2},{3})".format(_prau,_pdecu,_nrau,_ndecu))

    match_A_gc_idx, match_B_gc_idx, match_gc_sep, _d3d = search_around_sky(A_coord, B_coord, radius)

    from booq.utils import stats
    _sts = stats.basic(match_gc_sep.value)
    logging.info("Basic stats of distances between matchings: {}".format(_sts))

    assert len(match_A_gc_idx) == len(match_B_gc_idx)

    return (match_A_gc_idx, match_B_gc_idx, match_gc_sep)
示例#3
0
文件: xmatch.py 项目: chbrandt/booq
def nn_serial(A_coord, B_coord):
    """
    Nearest-Neighbor search

    Input:
     - A_coord : ~astropy.coordinates.SkyCoord
            reference catalog (catalog "A")
     - B_coord : ~astropy.coordinates.SkyCoord
            matching catalog (catalog "B")

    Output:
     - tuple with ~numpy.ndarray , ~astropy.units.Quantity
            array of respective (to 'A_coord') index entries in 'B_coord'
            , array of respective pair distances
    """

    from astropy.coordinates import SkyCoord
    assert isinstance(A_coord,SkyCoord), "Was expecting a ~astropy.coordinates.SkyCoord instance."
    assert isinstance(B_coord,SkyCoord), "Was expecting a ~astropy.coordinates.SkyCoord instance."

    logging.info("Searching among {0} neighbors, {1} reference objects.".format(len(B_coord),len(A_coord)))
    _prau = A_coord.ra.unit
    _pdecu = A_coord.dec.unit
    _nrau = B_coord.ra.unit
    _ndecu = B_coord.dec.unit
    logging.debug("Unit of coordinates being matched: ({0},{1}) and ({2},{3})".format(_prau,_pdecu,_nrau,_ndecu))

    from astropy.coordinates import match_coordinates_sky
    match_A_nn_idx, match_A_nn_sep, _d3d = match_coordinates_sky(A_coord,B_coord)

    from booq.utils import stats
    _sts = stats.basic(match_A_nn_sep.value)
    logging.info("Basic stats of distances between matchings: {}".format(_sts))

    assert len(match_A_nn_idx) == len(A_coord)
    assert match_A_nn_idx.max() < len(B_coord)

    return (match_A_nn_idx, match_A_nn_sep)