Exemple #1
0
def testOpenCat_sortBy():
    fname = 'testCat.csv'
    sortBy = 'z'
    catalog = catalogTools.cat(fname, sortBy=sortBy)
    #check if largest number is the first
    max_ok = catalog.df.z.iloc[0] == catalog.df.z.values.max()
    min_ok = catalog.df.z.iloc[-1] == catalog.df.z.values.min()
    assert max_ok and min_ok
Exemple #2
0
def testOpenCat_query():
    fname = 'testCat.csv'
    query = 'ra>30 and dec>0 and z>0.1'
    catalog = catalogTools.cat(fname, query=query)
    ra_query_ok = catalog.df.ra.min() > 30
    dec_query_ok = catalog.df.dec.min() > 0
    z_query_ok = catalog.df.z.min() > 0.1
    assert ra_query_ok and dec_query_ok and z_query_ok
Exemple #3
0
def splitCatalog(fname, howManyGroups, chunk):
    '''Splits the dataframe in fname, into howManyGroups and returns
    the chunk number chunk.'''
    print "Extracting chunk: %i/%i" % (chunk, howManyGroups)
    df = catalogTools.cat(fname=fname).df
    chunk_to_return = np.array_split(df, howManyGroups)[chunk]
    print(chunk_to_return.head())
    print(chunk_to_return.tail())
    return chunk_to_return
Exemple #4
0
        submap = submapTools.getSubmap_originalPixelization(
            theMap, ra, dec, 4 * photoringR_arcmin / 60.)  # noqa
        stamp = extractStamp(submap,
                             ra,
                             dec,
                             submapSemiWidthR_arcmin,
                             repixelize=params.REPIXELIZE,
                             reprojection=params.REPROJECT)
        dset[j, :, :] = np.array(stamp)
        if verbose:
            bar.update(j + 1)
    if verbose:
        bar.finish()
    f.close()


if howMany is not None:
    print "Processing only %i objects, use howMany=None full cat" % howMany
params = paramTools.params('params.ini')
mapfnames = {'submaps': params.FITS_FNAME, 'divmaps': params.DIVMAP_FNAME}

theMap = mapTools.openMap_remote(fname=mapfnames[dsetName])
df = catalogTools.cat(fname=params.CAT_FNAME, howMany=howMany).df

writeSubapsToFile(theMap,
                  df,
                  params.PHOTORINGR,
                  params,
                  dsetName=dsetName,
                  verbose=True)
Exemple #5
0
def howManyEntries():
    '''Opens the catalog pointed to in params.ini and returns its length
    are there.'''
    params = paramTools.params('params.ini')
    df = catalogTools.cat(fname=params.CAT_FNAME).df
    return len(df)
Exemple #6
0
def testOpenCat_howMany():
    fname = 'testCat.csv'
    howMany = 30
    catalog = catalogTools.cat(fname, howMany=howMany)
    assert len(catalog.df) == howMany
Exemple #7
0
def testOpenCat_NoArguments():
    fname = 'testCat.csv'
    catalog = catalogTools.cat(fname)
    assert len(catalog.df) > 10