Пример #1
0
if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--config', help='CATCH configuration file.')
    parser.add_argument('--source',
                        default='observation',
                        help=('limit analysis to this data source '
                              '(default: show all data)'))
    parser.add_argument('--nside',
                        default=2048,
                        help=('Healpix nside parameter, default is 2048'
                              ' for 1.7 arcmin resolution'))
    parser.add_argument(
        '-o',
        default=None,
        help='output file name prefix, default based on --source')
    parser.add_argument('--format', default='png', help='plot file format')
    parser.add_argument('--dpi', type=int, default=200)
    args = parser.parse_args()

    prefix = args.source if args.o is None else args.o

    config = Config.from_file(args.config)
    with Catch.with_config(config) as catch:
        catch.source = args.source
        source_name = catch.source.__data_source_name__
        cov = make_sky_coverage_map(catch, args.nside)

    hp.write_map('.'.join((prefix, 'fits')), cov, overwrite=True)
    plot(cov, source_name)
    plt.savefig('.'.join((prefix, args.format)), dpi=args.dpi)
Пример #2
0
import argparse
from sqlalchemy.orm.session import make_transient
from catch import Catch, Config
from catch.model import NEATMauiGEODSS, NEATPalomarTricam, SkyMapper
from sbsearch.model import ObservationSpatialTerm
from sbsearch.logging import ProgressBar

parser = argparse.ArgumentParser()
parser.add_argument('source_config')
parser.add_argument('destination_config')
args = parser.parse_args()

src = Catch.with_config(Config.from_file(args.source_config))
dest = Catch.with_config(Config.from_file(args.destination_config))

# for this example, just copy the observation tables and the spatial index
for table in (NEATMauiGEODSS, NEATPalomarTricam, SkyMapper,
              ObservationSpatialTerm):
    n_obs = src.db.session.query(table).count()
    with ProgressBar(n_obs, src.logger, scale='log') as bar:
        n_obs = 0
        while True:
            rows = (
                src.db.session.query(table).offset(n_obs).limit(1000).all())
            if len(rows) == 0:
                break

            for row in rows:
                n_obs += 1
                bar.update()
                src.db.session.expunge(row)
Пример #3
0
from astropy.time import Time
from catch import Catch, Config
from catch.model import SkyMapper

# Find 65P in SkyMapper DR2
#
# Catch v0 result:
#
# * JD: 2457971.9152
# * Product ID: 20170806095706-22
# * https://api.skymapper.nci.org.au/public/siap/dr2/get_image?IMAGE=20170806095706-22&SIZE=0.08333333333333333&POS=237.22441,-23.40757&FORMAT=fits
#
# For CATCH with min_edge_length = 3e-4 rad, spatial index terms are:
# $9e8c1,9e8c1,9e8c4,9e8d,9e8c,9e9,9ec,$9e8c7,9e8c7,$9e8ea04,9e8ea04,9e8ea1,9e8ea4,9e8eb,9e8ec,9e8f,$9e8ea0c,9e8ea0c,$9e8ea74,9e8ea74,9e8ea7

config = Config.from_file('../catch.config', debug=True)
with Catch.with_config(config) as catch:
    catch.db.engine.echo = False  # set to true to see SQL statements

    expected = (catch.db.session.query(SkyMapper)
                .filter(SkyMapper.product_id == '20170806095706-22')
                .all())[0]

    # benchmark queries
    t = []

    # full survey search
    t.append(Time.now())
    job_id = uuid.uuid4()
    count = catch.query('65P', job_id, sources=['skymapper'], cached=False,
                        debug=True)