Ejemplo n.º 1
0
def _update_completed_things(current, max_num, thing):
    io.clear_line()
    io.write("{current} out of {max} {thing} complete.                                                         ".format(
        current=current,
        max=max_num,
        thing=thing
    ))
    io.flush()
Ejemplo n.º 2
0
def _source_free_region(counter, current, max_num):
    io.clear_line()
    io.write("Encountered a source-free region -- recalculating...{counter} - {current}/{max} complete".format(
        counter=counter,
        current=current,
        max=max_num
    ))
    io.flush()
Ejemplo n.º 3
0
def _update_completed_things(current, max_num, thing):
    io.move_cursor_left(1000)
    io.write("{current} out of {max} {thing} complete.".format(
        current=current,
        max=max_num,
        thing=thing
    ))
    io.flush()
Ejemplo n.º 4
0
def _update_effective_exposure_time(obsid, current_region, number_regions, time_elapsed):
    #io.clear_line()
    #io.write("{current_region} of {num_regions} complete. Time elapsed: {time}".format(
    print("ObsID {obsid} -\t{current_region} of {num_regions} complete. Time elapsed: {time}".format(
        obsid=obsid,
        current_region=current_region,
        num_regions=number_regions,
        time=time_elapsed
    ))
    io.flush()
Ejemplo n.º 5
0
def calculate_effective_time_for(observation: cluster.Observation):
    """This function returns 2 image maps, data and background, of the cluster representing the same area
     of the cluster the scale map represents. Each pixel of the map represents the effective time observed
     for each of the ACB regions. The effective observed time is essentially the integrated observing time
     for each acb region. This is value differs from a simple, area of region * exposure time as some parts
     of the region may be masked (i.e. a removed point source within the ACB region)."""
    print("Starting observation {obs}".format(obs=observation.id))
    start_time = time.time()
    scale_map = observation.cluster.scale_map

    nx = scale_map.shape[0]
    ny = scale_map.shape[1]

    effective_data_times = np.zeros(scale_map.shape)
    effective_background_times = np.zeros(scale_map.shape)

    if observation.acisI_nosrc_combined_mask.shape != scale_map.shape:
        observation.reproject_nosrc_combined_mask(observation.cluster.scale_map_file)

    if observation.acisI_combined_mask.shape != scale_map.shape:
        observation.reproject_combined_mask(observation.cluster.scale_map_file)



    high_energy_data = observation.acisI_high_energy_combined_image
    background = observation.backI_high_energy_combined_image
    sum_acis_high_energy = np.sum(high_energy_data)  # get the total counts in the high energy image
    sum_back_high_energy = np.sum(background)

    bg_to_data_ratio = sum_back_high_energy / sum_acis_high_energy

    source_subtracted_mask = observation.acisI_nosrc_combined_mask

    exposure_time = observation.acisI_high_energy_combined_image_header['EXPOSURE']

    indices = np.vstack(np.where(observation.acisI_combined_mask * scale_map > 0)).T

    total = len(indices)
    counter = 1

    for index in indices:
        x,y = index
        if counter % 5000 == 0:
            time_elapsed = time.strftime("%H h %M m %S s",
                                         time.gmtime(time.time() - start_time))
            print("ObsID {}\t {} of {} regions calculated. Time elapsed: {}. Avg {:2f} ms/region".format(
                observation.id,
                counter, total, time_elapsed, ((time.time() - start_time)/counter)*1000))
            io.flush()
        radius_map = generate_radius_map(x, y, nx, ny)
        circle_mask = radius_map <= scale_map[x, y]

        source_subtracted_area = np.sum(source_subtracted_mask[circle_mask])
        total_area = source_subtracted_mask[circle_mask].size
        fractional_area = source_subtracted_area / total_area

        fractional_exposure_time = fractional_area * exposure_time

        effective_data_times[x, y] = fractional_exposure_time
        effective_background_times[x, y] = fractional_exposure_time * bg_to_data_ratio
        counter += 1

    observation.effective_data_time = effective_data_times
    observation.effective_background_time = effective_background_times
    time_elapsed = time.strftime("%H hours %M minutes %S seconds.",
                                 time.gmtime(time.time() - start_time))
    print("ObsID {} complete. Time elapsed: {}".format(observation.id, time_elapsed))