astrohack.utils.algorithms
Functions
|
Tokenize a version number into an array of integers |
|
Check if data from a version needs to be patched according to a reference patch version |
|
Calculate the center pixel of the image given a cell and image size |
|
Find the nearest entry in array to that of value. |
|
Average visibilities in chunks with close enough frequencies |
|
Search algorithm to determine the maximal signal peak in the beam pattern. |
|
Gauss elimination solving of a system using numpy |
|
Least squares fitting of a system of linear equations |
|
Least squares fitting of a system of linear equations |
|
|
|
|
|
|
|
Computes an antenna offset to the array center |
|
Rotate geometrical delays from antenna reference frame to GMT reference frame |
|
|
|
Wraps phase to the -pi to pi interval |
|
Takes two axes and creates 2D representation of the image coordinates |
|
|
|
|
|
|
|
Use index information to get 1D data back onto a 2D grid. |
|
Compute a matrix of antenna position distances from antenna positions |
Module Contents
- tokenize_version_number(version_number)[source]
Tokenize a version number into an array of integers :param version_number: The astrohack number version to be tokenized
- Returns:
Tokenized version number in 3 element numpy array of integers
- data_from_version_needs_patch(version_to_check, patched_version)[source]
Check if data from a version needs to be patched according to a reference patch version :param version_to_check: The version that is being tested :param patched_version: Reference version at which the patch is no longer needed
- Returns:
True if the checked version is from before the patch False elsewise
- calc_coords(image_size, cell_size)[source]
Calculate the center pixel of the image given a cell and image size
- Parameters:
image_size (np.ndarray) – image size
cell_size (np.ndarray) – cell size
- Returns:
center pixel location in coordinates x, y
- Return type:
float, float
- find_nearest(array, value)[source]
Find the nearest entry in array to that of value.
- Parameters:
array (numpy.array) – _description_
value (float) – _description_
- Returns:
index, array value
- Return type:
int, float
- chunked_average(data, weight, avg_map, avg_freq)[source]
Average visibilities in chunks with close enough frequencies :param data: Visibility data :param weight: Visibility weights :param avg_map: mapping of channels to average :param avg_freq: new frequency ranges
Returns: Chunked average of visibilities and weights
- find_peak_beam_value(data, height=0.5, scaling=0.5)[source]
Search algorithm to determine the maximal signal peak in the beam pattern.
- Parameters:
data (numpy.ndarray) – beam data grid
height (float, optional) – Peak threshold. Looks for the maximum peak in data and uses a percentage of this peak to determine a threshold for other peaks. Defaults to 0.5.
scaling (float, optional) – scaling factor for beam data cropping. Defaults to 0.5.
- Returns:
peak maximum value
- Return type:
float
- gauss_elimination(system, vector)[source]
Gauss elimination solving of a system using numpy :param system: System matrix to be solved :param vector: Vector that represents the right hand side of the system
Returns: The solved system
- least_squares(system, vector, return_sigma=False)[source]
Least squares fitting of a system of linear equations The variances are simplified as the diagonal of the covariances :param system: System matrix to be solved :param vector: Vector that represents the right hand side of the system :param return_sigma: Return sigma value
Returns: The solved system, the variances of the system solution and the sum of the residuals
- least_squares_jit(system, vector)[source]
Least squares fitting of a system of linear equations The variances are simplified as the diagonal of the covariances :param system: System matrix to be solved :param vector: Vector that represents the right hand side of the system
Returns: The solved system, the variances of the system solution and the sum of the residuals
- calculate_optimal_grid_parameters(pnt_map_dict, antenna_name, telescope_diameter, chan_freq, ddi)[source]
- compute_antenna_relative_off(antenna, tel_lon, tel_lat, tel_rad, scaling=1.0)[source]
Computes an antenna offset to the array center :param antenna: Antenna information dictionary :param tel_lon: array center longitude :param tel_lat: array center latitude :param tel_rad: array center’s distance to the center of the earth :param scaling: scale factor
Returns: Offset to the east, Offset to the North, elevation offset and distance to array center
- rotate_to_gmt(positions, errors, longitude)[source]
Rotate geometrical delays from antenna reference frame to GMT reference frame :param positions: geometrical delays :param errors: geometrical delay errors :param longitude: Antenna longitude
Returns: Rotated geometrical delays and associated errors
- phase_wrapping(phase)[source]
Wraps phase to the -pi to pi interval :param phase: phase to be wrapped
Returns: Phase wrapped to the -pi to pi interval
- create_coordinate_images(x_axis, y_axis, create_polar_coordinates=False)[source]
Takes two axes and creates 2D representation of the image coordinates :param x_axis: X axis :param y_axis: Y axis :param create_polar_coordinates: Also create polar coordinates images?
- Returns:
x_mesh and y_mesh, plus radius_mesh and polar_angle_mesh if create_polar_coordinates
- arm_shadow_masking(inmask, x_mesh, y_mesh, radius_mesh, minradius, maxradius, width, angle)[source]
- regrid_data_onto_2d_grid(x_axis, y_axis, linear_array, grid_idx)[source]
Use index information to get 1D data back onto a 2D grid. :param x_axis: X axis of the data on the 2 D grid :param y_axis: Y axis of the data on the 2 D grid :param linear_array: Linearized masked array :param grid_idx: Linearized 2 D indexes onto the original grid
Returns: Data regridded onto a 2D array