Ejemplo n.º 1
0
def get_cluster(config_file_arg):
    if io.file_exists(config_file_arg):
        cluster_obj = cluster.read_cluster_data(config_file_arg)
    else:
        config_file = cluster.get_cluster_config(config_file_arg)
        if config_file:
            cluster_obj = cluster.read_cluster_data(config_file)
        else:
            print("Error finding cluster configuration file. Try passing the full path to the file.")
            return
    return cluster_obj
Ejemplo n.º 2
0
def process_commandline_arguments(cluster_obj):
    print("Processing commandline arguments")
    args = get_arguments()
    cluster_obj = None
    if None not in [
            args.name, args.abundance, args.nH, args.redshift, args.obsids
    ]:
        ciao.initialize_cluster(name=args.name,
                                obsids=args.obsids,
                                abundance=args.abundance,
                                redshift=args.redshift,
                                nH=args.nH)
    if args.init_cluster:
        cluster_obj.initialize_cluster()
    if args.config_file != "":
        if io.file_exists(args.config_file):
            cluster_obj = cluster.read_cluster_data(args.config_file)
        else:
            config_file = cluster.get_cluster_config(args.config_file)
            if config_file:
                cluster_obj = cluster.read_cluster_data(config_file)
            else:
                print(
                    "Error finding cluster configuration file. Try passing the full path to the file."
                )
                return
        if args.find_sources:
            ciao.find_sources(cluster_obj, ecf=args.ecf, energy=args.energy)

    if args.cont:
        if cluster_obj is None:
            cluster_obj = config.current_cluster()
            if cluster_obj is None:
                print("Cannot find a current working cluster.")
                exit(-1)

        if args.parallel and cluster_obj.last_step_completed == '1':
            ciao.run_stage_2_parallel(cluster_obj, args)
        else:
            ciao.start_from_last(cluster_obj, args)

    return cluster_obj
Ejemplo n.º 3
0
def process_commandline_arguments(cluster_obj):
    print("Processing commandline arguments")
    args = get_arguments()
    cluster_obj = None
    if io.file_exists(args.batch_file):
        ciao.automated_cluster_init(args.batch_file)
    if None not in [args.name, args.abundance, args.nH, args.redshift, args.obsids]:
        ciao.initialize_cluster(name=args.name, obsids=args.obsids, abundance=args.abundance,
                                redshift=args.redshift, nH=args.nH)
    if args.init_cluster:
        cluster_obj.initialize_cluster()
    if args.config_file != "":
        if io.file_exists(args.config_file):
            cluster_obj = cluster.read_cluster_data(args.config_file)
        else:
            config_file = cluster.get_cluster_config(args.config_file)
            if config_file:
                cluster_obj = cluster.read_cluster_data(config_file)
            else:
                print("Error finding cluster configuration file. Try passing the full path to the file.")
                return
    if args.cont:
        if cluster_obj is None:
            cluster_obj = config.current_cluster()
            if cluster_obj is None:
                print("Cannot find a current working cluster.")
                exit(-1)
        print("Continuing {}.".format(cluster_obj.name))

        ciao.start_from_last(cluster_obj)
    if args.download_data:
        if 0 == cluster_obj.last_step_completed:
            cluster_obj.get_cluster_info_from_user()
        ciao.download_data(cluster_obj)
    if args.remove_sources:
        ciao.remove_sources(cluster_obj)
    return cluster_obj
Ejemplo n.º 4
0
            )
            print(log_string)
            log_file = "{super_comp_dir}/{p_name}_time.txt".format(
                super_comp_dir=cluster_obj.super_comp_dir,
                p_name=mp.current_process().name)
            io.write_contents_to_file(log_string, log_file, False)
            print("Manual garbage collection.")
            gc.collect()

    mp.Queue().put('Regions processed: {}'.format(len(regions_processed)))


if __name__ == '__main__':
    args = get_arguments()
    if args.cluster_config is not None:
        clstr = cluster.read_cluster_data(args.cluster_config)
        if args.cont:
            print("Continuing spectral fits")
            regions = clstr.unfinished_regions_to_fit(args.resolution)
            original = len(clstr.scale_map_regions_to_fit(args.resolution))
            print('{reg} of {orig} regions left to fit.'.format(
                reg=len(regions), orig=original))
        else:
            clstr.initialize_best_fits_file()
            clstr.initialize_worst_fits_file()
            clstr.initialize_all_fits_file()
            regions = clstr.scale_map_regions_to_fit(args.resolution)

        start_time = time.time()

        if args.parallel:
Ejemplo n.º 5
0
def change_current_cluster(cluster_config):
    new_cluster = cluster.read_cluster_data(cluster_config)
    config.set_current_cluster(new_cluster)
Ejemplo n.º 6
0
def current_cluster():
    if current_cluster_file() is not None:
        return cluster.read_cluster_data(current_cluster_file())
    else:
        return None