Esempio n. 1
0
def main():
    args = parseargs()
    password = casda.get_opal_password(args.opal_password, args.password_file)

    # Change this to choose which environment to use, prod is the default
    # casda.use_at()

    start = time.time()
    if args.destination_directory is not None and not os.path.exists(
            args.destination_directory):
        os.makedirs(args.destination_directory)

    # Read the locations
    source_list = parse_sources_file(args.coord_list)

    # Do the work
    extract_spectra(source_list, args.radius, args.opal_username, password,
                    args.destination_directory)

    # Report
    end = time.time()
    print('#### Spectra generation completed at %s ####' %
          (time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end))))
    print('Full run took %.02f s' % (end - start))
    return 0
Esempio n. 2
0
def main():
    args = parseargs()
    password = casda.get_opal_password(args.opal_password, args.password_file)

    # Change this to choose which environment to use, prod is the default
    casda.use_at()

    start = time.time()
    if args.destination_directory is not None and not os.path.exists(
            args.destination_directory):
        os.makedirs(args.destination_directory)

    # Read cube dimensions
    cube_dim = get_dimensions(args.cubeid)
    # print("DIM=", cube_dim)

    # Generate random locations in the cutout
    pos_params, band_params = generate_random_cutouts(args, cube_dim)
    # print("POS=", pos_params)
    # print("BAND=", band_params)

    # Get access to the cube - sia call then datalink
    async_url, authenticated_id_token = casda.get_service_link_and_id(
        args.cubeid,
        args.opal_username,
        password,
        destination_dir=args.destination_directory)
    print(async_url, authenticated_id_token)

    # Create a job to retrieve the cutouts
    job_location = casda.create_async_soda_job([authenticated_id_token],
                                               soda_url=async_url)
    casda.add_params_to_async_job(job_location, 'POS', pos_params)
    casda.add_params_to_async_job(job_location, 'BAND', band_params)
    print('\n\n Job will have %d cutouts.\n\n' %
          (len(pos_params) * len(band_params)))

    # Run and time the job
    run_start = time.time()
    status = casda.run_async_job(job_location)
    run_end = time.time()
    print('Job finished with status %s in %.02f s\n\n' %
          (status, run_end - run_start))

    # Optionally download
    print("Job result available at ", casda.get_results_page(job_location))
    if args.download:
        casda.download_all(job_location, args.destination_directory)

    # Report
    end = time.time()
    print('#### Cutout processing completed at %s ####' %
          (time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end))))
    print('Job was processed in %.02f s' % (run_end - run_start))
    print('Full run took %.02f s' % (end - start))
    return 0
Esempio n. 3
0
def main():
    args = parseargs()
    password = casda.get_opal_password(args.opal_password, args.password_file)

    # Change this to choose which environment to use, prod is the default
    casda.use_at()

    start = time.time()
    if args.destination_directory is not None and not os.path.exists(args.destination_directory):
        os.makedirs(args.destination_directory)

    # Read cube dimensions
    cube_dim = get_dimensions(args.cubeid)
    # print("DIM=", cube_dim)

    # Generate random locations in the cutout
    pos_params, band_params = generate_random_cutouts(args, cube_dim)
    # print("POS=", pos_params)
    # print("BAND=", band_params)

    # Get access to the cube - sia call then datalink
    async_url, authenticated_id_token = casda.get_service_link_and_id(
        args.cubeid,
        args.opal_username,
        password,
        destination_dir=args.destination_directory)
    print (async_url, authenticated_id_token)

    # Create a job to retrieve the cutouts
    job_location = casda.create_async_soda_job([authenticated_id_token], soda_url=async_url)
    casda.add_params_to_async_job(job_location, 'POS', pos_params)
    casda.add_params_to_async_job(job_location, 'BAND', band_params)
    print ('\n\n Job will have %d cutouts.\n\n' % (len(pos_params)*len(band_params)))

    # Run and time the job
    run_start = time.time()
    status = casda.run_async_job(job_location)
    run_end = time.time()
    print('Job finished with status %s in %.02f s\n\n' % (status, run_end - run_start))

    # Optionally download
    print ("Job result available at ", casda.get_results_page(job_location))
    if args.download:
        casda.download_all(job_location, args.destination_directory)

    # Report
    end = time.time()
    print('#### Cutout processing completed at %s ####'
          % (time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end))))
    print('Job was processed in %.02f s' % (run_end - run_start))
    print('Full run took %.02f s' % (end - start))
    return 0
Esempio n. 4
0
def main():
    args = parseargs()
    password = casda.get_opal_password(args.opal_password, args.password_file)

    # 1) Create the destination directory
    destination_dir = args.destination_directory + "/"
    if not os.path.exists(destination_dir):
        os.makedirs(destination_dir)

    # Change this to choose which environment to use, prod is the default
    # casda.use_dev()

    return download_images(args.ra, args.dec, args.opal_username, password, destination_dir)
Esempio n. 5
0
def main():
    args = parseargs()
    password = casda.get_opal_password(args.opal_password, args.password_file)

    # 1) Create the destination directory
    destination_dir = args.destination_directory + "/"
    if not os.path.exists(destination_dir):
        os.makedirs(destination_dir)

    # Change this to choose which environment to use, prod is the default
    #casda.use_at();

    return download_cutouts(args.scheduling_block_id, args.opal_username, password, destination_dir, int(args.num_channels),
                            args.data_product_type)
Esempio n. 6
0
def main():
    args = parseargs()
    password = casda.get_opal_password(args.opal_password, args.password_file)

    # 1) Create the destination directory
    destination_dir = args.destination_directory + "/"
    if not os.path.exists(destination_dir):
        os.makedirs(destination_dir)

    # Change this to choose which environment to use, prod is the default
    # casda.use_dev()

    return download_images(args.ra, args.dec, args.opal_username, password,
                           destination_dir)
Esempio n. 7
0
def main():
    args = parseargs()
    password = casda.get_opal_password(args.opal_password, args.password_file)

    # 1) Create the destination directory
    destination_dir = args.destination_directory + "/"
    if not os.path.exists(destination_dir):
        os.makedirs(destination_dir)

    # Change this to choose which environment to use, prod is the default
    # casda.use_at()

    catalogue_query = 'SELECT * FROM casda.continuum_component where first_sbid = {} and flux_peak > 500'.format(
        args.scheduling_block_id)

    return download_cutouts(args.scheduling_block_id, args.opal_username,
                            password, destination_dir, catalogue_query,
                            not args.full_files)
Esempio n. 8
0
def main():
    args = parseargs()
    password = casda.get_opal_password(args.opal_password, args.password_file)

    # 1) Create the destination directory
    destination_dir = args.destination_directory + "/"
    if not os.path.exists(destination_dir):
        os.makedirs(destination_dir)

    # Change this to choose which environment to use, prod is the default
    # casda.use_at()


    catalogue_query = 'SELECT * FROM casda.continuum_component where first_sbid = {} and flux_peak > 500'.format(
        args.scheduling_block_id)

    return download_cutouts(args.scheduling_block_id, args.opal_username, password, destination_dir, catalogue_query,
                            not args.full_files)
Esempio n. 9
0
def main():
    args = parseargs()
    password = casda.get_opal_password(args.opal_password, args.password_file)

    # Change this to choose which environment to use, prod is the default
    # casda.use_dev()

    destination_dir = args.destination_directory + "/" + str(args.image_id) + "/"  # directory where files will be saved

    # 1) Read in the list of sources
    print ("\n\n** Parsing the source list ...\n")
    source_list = parse_sources_file(args.source_list_file)
    print ("\n** Read %d sources...\n\n" % (len(source_list)))

    # 2) Create the destination directory
    if not os.path.exists(destination_dir):
        os.makedirs(destination_dir)

    # Do the work
    return produce_cutouts(source_list, args.image_id, args.opal_username, password, destination_dir)
Esempio n. 10
0
def main():
    args = parseargs()
    password = casda.get_opal_password(args.opal_password, args.password_file)

    # Change this to choose which environment to use, prod is the default
    # casda.use_dev()

    destination_dir = args.destination_directory + "/" + str(
        args.proj) + "/"  # directory where files will be saved

    # 1) Read in the list of sources
    print("\n\n** Parsing the source list ...\n")
    source_list = parse_sources_file(args.source_list_file)
    print("\n** Read %d sources...\n\n" % (len(source_list)))

    # 2) Create the destination directory
    if not os.path.exists(destination_dir):
        os.makedirs(destination_dir)

    # Do the work
    return produce_cutouts(source_list, args.proj, args.opal_username,
                           password, destination_dir, args.radius)
Esempio n. 11
0
def main():
    args = parseargs()
    password = casda.get_opal_password(args.opal_password, args.password_file)

    # Change this to choose which environment to use, prod is the default
    # casda.use_at()

    start = time.time()
    if args.destination_directory is not None and not os.path.exists(args.destination_directory):
        os.makedirs(args.destination_directory)

    # Read the locations
    source_list = parse_sources_file(args.coord_list)

    # Do the work
    extract_spectra(source_list, args.radius, args.opal_username, password, args.destination_directory)

    # Report
    end = time.time()
    print('#### Spectra generation completed at %s ####'
          % (time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end))))
    print('Full run took %.02f s' % (end - start))
    return 0