hop.tiling package¶
Submodules¶
hop.tiling.tiling_functions module¶
- hop.tiling.tiling_functions.calculate_completeness_stats(df_targets, N_targets_per_Hector_field, completion_fraction_to_calculate=0.95, verbose=True)[source]¶
Given a set of tiles, calculate some stats about the efficiency to get to a given completeness fraction
- Parameters
df_targets (dataframe) – a dataframe with a row for each target. Must have a column ‘Tile_number’
N_targets_per_Hector_field (dict) – The numnber of hexabundles we can place on galaxy targets
completeness_fraction_to_calculate (float, default=0.95) – calculate the efficiency to reach this completeness fraction. This is defined as actual number of tiles used / minimum number of tiles possible)
verbose (bool, default=True) – print efficiency stats or not.
- hop.tiling.tiling_functions.check_if_in_fov(df, xcen, ycen, inner_radius, outer_radius)[source]¶
Return a binary mask if points are within a circular field of view of radius R
- Parameters
df (dataframe) – A dataframe of targets. Must have columns ‘RA’ and ‘DEC’
xcen (float) – x (or RA) coordinate of centre
ycen (float) – y (or DEC) coordinate of centre
radius (float) – radius of circle in degrees
- hop.tiling.tiling_functions.find_clashes(df1, df2, proximity)[source]¶
Given some proximity, find objects in two dataframes which will clash
- Parameters
df1 (dataframe) – Dataframe of targets. Must have columns ‘RA’ and ‘DEC’
df2 (dataframe) – Dataframe of targets. Must have columns ‘RA’ and ‘DEC’
proximity (float) – Smallest distance which two objects can come before clashing. Measured in arcseconds
- hop.tiling.tiling_functions.find_great_circle_distance(uu, vv)[source]¶
The great circle distance between vectors uu=[RA, Dec] and vv=[RA, Dec] Note that RA and Dec must be in degrees. We then convert them to radians, calcualte the distance and return that distance in degrees.
- hop.tiling.tiling_functions.find_nearest(x, y, grid)[source]¶
Find the nearest grid point to each target (at coordinates (x, y))
- Parameters
x (array_like) – A list of target x coordinates
y (array_like) – A list of target y coordinates
grid (2D array) – A two dimensional array of grid coordinates to test against. Columns are x (grid[:, 0]) and y (grid[:, 1])
- hop.tiling.tiling_functions.get_best_tile_centre_dengreedy(master_df, targets_df, outer_FOV_radius, inner_FoV_radius, n_xx_yy=100)[source]¶
Given a set of x, y coordinates, find the position to place the tile according to Aaron’s Dengreedy algorithm
- Parameters
master_df (dataframe) – A dataframe of all target galaxies, irrespective of whether they’ve been tiled alread. Must have columns ‘RA’, ‘DEC’
targets_df (dataframe) – A dataframe of target galaxies which have not yet been tiled. Must have columns ‘RA’, ‘DEC’
n_xx_yy (int, optional) – Number of grid points along each direction. The size of the grid is n_xx_yy**2, and needs to fit in memory in one go! So don’t make this too large…
- hop.tiling.tiling_functions.get_best_tile_centre_greedy(targets_df, outer_FOV_radius, inner_FoV_radius, priorities, n_xx_yy=100)[source]¶
Given a set of x, y coordinates, find the position which would cover the most targets if we placed a field of view there.
- Parameters
targets_df (dataframe) – A dataframe of target galaxies which have not yet been tiled. Must have columns ‘RA’ and ‘DEC’
n_xx_yy (int, optional) – Number of grid points along each direction. The size of the grid is n_xx_yy**2, and needs to fit in memory in one go! So don’t make this too large…
Priorities (list) – A priority value for each galaxy. If none is given, assume equal priorties for all targets
- hop.tiling.tiling_functions.make_best_tile(df_targets, df_guide_stars, df_standard_stars, proximity, tiling_parameters, tiling_type, use_galaxy_priorities=True, selection_type='most_clashing', fill_spares_with_repeats=False, df_skies=None)[source]¶
Put all the above functions togther and make a tile. Note that this function __doesn’t__ update any tiling flags in the overall database. This should be done afterwards, so that we can integrate things with the Hector configuration code- the 19 best targets we pick might not actually be tile-able, so we don’t want to mark things as tiled if the config code needs to select backups.
- Parameters
df_targets (dataframe) – A dataframe of galaxy targets. Must include columns ‘RA’, ‘DEC’, “PRIORITY” and “TILED”
df_guide_stars (dataframe) – A dataframe of galaxy targets. Must include columns ‘RA’, ‘DEC’ and “r_mag”
df_standard_stars (dataframe) – A dataframe of standard stars. Must include columns ‘RA’, ‘DEC’ and ‘priority’
tiling_parameters (dict) – A dictionary containing the various parameters to do with the tiling. So far, necessary keys are ‘Hector_FOV_radius’, ‘proximity’, ‘Nsel’, ‘Nsel_guides’ and ‘Nsel_standards’
- Returns
The original df_targets dataframe
A dataframe containing the targets for this tile
A dataframe containing the guides for this tile
A dataframe containing the standard stars for this tile
The tile RA
The tile Dec
- hop.tiling.tiling_functions.noclash(df1, df2, proximity)[source]¶
Take two dataframes, find those which are within some proximity of each other and then return the first dataframe as is, the SECOND dataframe without the clashing elements, and the number of elements which clash. Useful for selecting guide stars which don’t clash with targets in a tile.
- Parameters
df1 (dataframe) – Dataframe of targets. Must have columns ‘RA’ and ‘DEC’
df2 (dataframe) – Dataframe of targets. Must have columns ‘RA’ and ‘DEC’
proximity (float) – Smallest distance which two objects can come before clashing. Measured in arcseconds
- hop.tiling.tiling_functions.plot_survey_completeness_and_tile_positions(tile_positions, df_targets, tiling_parameters, fig=None, ax=None, completion_fraction_to_calculate=0.95, verbose=True)[source]¶
Make an overall plot of the survey completeness and the positions of each tile.
- Parameters
tile_positions (list) – A two component list. First element is a list of RA values of the tile centres, second component is a list of Dec values of the tile centres.
tiling_parameters (dict) – A dictionary of tiling parameters. Must have a ‘Hector_FOV_radius’ key
- hop.tiling.tiling_functions.plot_tile(tile_df, guide_df, standards_df, catalogue_df, tile_RA, tile_Dec, tile_outer_radius, tile_inner_radius, tile_number, proximity, fig=None, ax=None)[source]¶
Make a plot of an individual tile.
- Parameters
tile_df (dataframe) – Dataframe of a tile to plot
guide_df (dataframe) – Dataframe of guide stars from this tile
standards_df (dataframe) – Dataframe of standard stars from this tile
catalogue_df (dataframe) – Dataframe of the entire field, to plot as background
tile_RA (float) – RA of the centre of this tile
tile_Dec (float) – Dec of the centre of this tile
tile_outer_radius (float) – Outer Radius of the FoV (in degrees)
tile_inner_radius (float) – Inner Radius of the FoV (in degrees)
tile_number (int) – Number of the tile
proximity (float) – Radius of the tile
fig (optional) – An exisiting Figure/Axis object to plot on
ax (optional) – An exisiting Figure/Axis object to plot on
- hop.tiling.tiling_functions.save_guide_text_file(outfolder, out_name, guide_stars_for_tile, tile_RA, tile_Dec, tiling_parameters, guide_columns_in_order)[source]¶
Save a text file of things to be observed with Hector guide bundles (i.e. guides). The second line of this text file __must__ be the tile RA and DEC seperated by a space.
- hop.tiling.tiling_functions.save_tile_outputs(outfolder, df_targets, tile_df, guide_stars_for_tile, standard_stars_for_tile, tile_RA, tile_Dec, tiling_parameters, tile_number, columns_in_order, guide_columns_in_order, plot=True, tile_out_name=None, guide_out_name=None)[source]¶
- Save the outputs from a single tile. These are:
A text file called tile_{i}.fld, which contains things to be observed the Hector science bundles. This has columns ID, RA, DEC, mag, type (where type is 1 for a galaxy target and 0 for a standard star) and isel (which is a bit like the priority they should be targeted in). The targets are sorted by priority!
A text file called guide_tile_{i}.fld, which contains guide stars (observed with the Hector guide bundles). This has columns RA, DEC, mag
A plot of the field with the Nsel best targets selected by this code. Note that this may not resemble the final tile selected by the configuration code!
Note that we also make two new columns called “MagnetX_noDC” and “MagnetY_noDC” which correspond to the xy positions of the galaxies on the Hector plate in microns from the centre. These have NOT been corrected for the optical distortions- that’s done by the “DistortionCorrection” code, which happens after each time has been saved. These outputs will be bundled together in a single folder, which contains subfolders ‘Tiles’ and ‘Plots’
- Parameters
outfolder (str) – Location for the output files
df_targets (dataframe) – Dataframe of all targets. This is used for plotting
tile_df (dataframe) – Dataframe of targets for a single tile
guide_stars_for_tile (dataframe) – Dataframe of guide stars for a single tile
standard_stars_for_tile (dataframe) – Dataframe of standard stars for a single tile
tile_RA (float) – RA of tile centre
tile_DEC (float) – DEC of tile centre
parameters (tiling) – Dictionary of tiling parameters
tile_number (int) – Number of the tile
plot (bool, optional) – Whether to save a plot of the tile. Default is True
- hop.tiling.tiling_functions.save_tile_text_file(outfolder, out_name, tile_df, standard_stars_for_tile, tile_RA, tile_Dec, tiling_parameters, columns_in_order)[source]¶
Save a text file of things to be observed with Hector science bundles (i.e. targets and standards). The second line of this text file __must__ be the tile RA and DEC seperated by a space.
- hop.tiling.tiling_functions.select_stars_for_tile(star_df, tile_df, proximity, Nsel, star_type)[source]¶
Given a tile of targets, select Nsel worth of stars by selecting stars which don’t clash with any of our targets. The returned stars are sorted by either their priority (for standard stars) or their R-band magnitude (for guide stars)
- Parameters
star_df (dataframe) – a dataframe of stars (guide or standard). Must have columns “RA”, “DEC” and either “priority” or “r_mag” (see below)
tile_df (dataframe) – a dataframe containing Nsel targets, created from using ‘unpick’. Must have columns “RA” amd “DEC”
proximity (float) – distance between two adjacent bundles, in arcseconds.
Nsel (int) – Return this many stars for each tile.
star_type (string) – One of either “standards” or “guides”. Selects whether we sort the star dataframe by “priority” (for standards) or “r_mag” (for guides)
- hop.tiling.tiling_functions.select_targets(all_targets_df, proximity, Nsel, priorities, selection_type='most_clashing', fill_spares_with_repeats=False)[source]¶
Given a dataframe of targets, select Nsel galaxies to observe. These can’t be nearer to each other than ‘proximity’. Return a dataframe of just the new tile we’ve made.
- Parameters
df (dataframe) – A dataframe of targets. Must have columns “RA”, “DEC”, “PRIORITY” (i.e. priority), “COMPLETED” (i.e. tiled before this current iteration).
proximity (float) – Smallest distance between two targets (in arcseconds)
Nsel (int) – Number of targets to select in each tile