flip.covariance.cov_utils¶
Attributes¶
Functions¶
|
The compute_sep function computes the separation between all pairs of objects in a catalog. |
|
The compute_i_j function takes in a number of nodes N and a sequence number seq. |
|
The compute_i_j_cross_matrix function takes in the number of vertices, Nv, and a sequence of numbers |
|
The compute_phi function computes the angle between the line of sight and |
|
The angle_separation function computes the angle between two points on a sphere. |
|
|
|
The return_full_cov function takes in a 1D array of covariance values and returns the full covariance matrix. |
|
|
|
The return_full_cov_cross function takes in a covariance matrix and the number of objects in each band. |
The return_correlation_matrix function takes a covariance matrix as input and returns the correlation matrix. |
|
|
The save_matrix function takes a matrix and saves it to the current directory as a .npy file. |
|
The open_matrix function takes in a string as an argument and returns the matrix that is saved under that name. |
|
The generator_need function checks if the coordinates_density and coordinates_velocity inputs are provided. |
|
The check_generator_need function is used to check if the generator_need function |
Module Contents¶
- flip.covariance.cov_utils.log¶
- flip.covariance.cov_utils.compute_sep(ra, dec, comoving_distance, los_definition='bisector', size_batch=10000)[source]¶
The compute_sep function computes the separation between all pairs of objects in a catalog.
- Parameters:
ra – Store the right ascension of each object
dec – Compute the angular separation between two objects
comoving_distance – Calculate the separation between two objects
size_batch – Control the number of objects that are processed at a time
:param : Set the number of objects in a batch
- Returns:
The separation, the perpendicular component of the separation, and
- flip.covariance.cov_utils.compute_i_j(N, seq)[source]¶
The compute_i_j function takes in a number of nodes N and a sequence number seq. It returns the i, j indices for the upper triangular matrix that correspond to the given sequence number. The function is used to convert between an indexing scheme that uses integers from 0 to (N^2 - N)/2 - 1 and one that uses i,j indices where i = 0,…,N-2 and j = i+ 1,…,N-2.
- Parameters:
N – Determine the size of the matrix
seq – Find the row and column of the element in a matrix
- Returns:
The row and column of the lower triangle matrix
- flip.covariance.cov_utils.compute_i_j_cross_matrix(Nv, seq)[source]¶
The compute_i_j_cross_matrix function takes in the number of vertices, Nv, and a sequence of numbers and returns two arrays. The first array is an array containing the row indices for each element in the sequence. The second array contains column indices for each element in the sequence.
- Parameters:
Nv – Determine the number of vertices in a given face
seq – Create the i and j arrays
- Returns:
The indices of the cross-terms in the matrix
- flip.covariance.cov_utils.compute_phi(ra_0, ra_1, dec_0, dec_1, r_0, r_1, los_definition)[source]¶
The compute_phi function computes the angle between the line of sight and the separation vector. The line of sight is defined as either:
- Parameters:
ra_0 – Compute the x_0, y_0 and z_0 coordinates of a galaxy
ra_1 – Compute the phi angle
dec_0 – Compute the z_0 parameter in radec2cart function
dec_1 – Compute the phi angle
r_0 – Compute the distance between two points
r_1 – Compute the distance between two points in the sky
los_definition – Define the line of sight
- Returns:
The angle between the line of sight and the separation vector
- flip.covariance.cov_utils.angle_separation(ra_0, ra_1, dec_0, dec_1, r_0, r_1, los_definition='bisector')[source]¶
The angle_separation function computes the angle between two points on a sphere.
- Parameters:
ra_0 – Set the right ascension of the first galaxy
ra_1 – Calculate the angle between two points in the sky
dec_0 – Define the declination of the first galaxy
dec_1 – Calculate the cosine of theta
r_0 – Compute the distance between two points
r_1 – Compute the distance between two points in space
los_definition – Define the line of sight
:param : Define the line of sight
- Returns:
The separation between two points in
- flip.covariance.cov_utils.return_full_cov(cov)[source]¶
The return_full_cov function takes in a 1D array of covariance values and returns the full covariance matrix. The first value in the input array is assumed to be the variance, and all other values are assumed to be non-diagonal covariance terms. The function then creates an empty square matrix with dimensions equal to the number of objects (calculated from cov_array size), fills it with zeros, adds diagonal elements (variance) using numpy’s eye function, and finally fills in upper triangle elements (non-diagonal covariances) using numpy’s triu_indices function
- Parameters:
cov – Store the covariance matrix of a multivariate normal distribution
- Returns:
A full covariance matrix from a vector of covariances
- flip.covariance.cov_utils.return_full_cov_cross(cov, number_objects_g, number_objects_v)[source]¶
The return_full_cov_cross function takes in a covariance matrix and the number of objects in each band. It then reshapes the covariance matrix into a full cross-covariance matrix, which is returned.
- Parameters:
cov – Reshape the covariance matrix
number_objects_g – Reshape the covariance matrix into a full covariance matrix
number_objects_v – Reshape the covariance matrix into a full covariance matrix
- Returns:
The full covariance matrix
- flip.covariance.cov_utils.return_correlation_matrix(cov)[source]¶
The return_correlation_matrix function takes a covariance matrix as input and returns the correlation matrix. The correlation matrix is calculated by dividing each element of the covariance matrix by the product of its row’s standard deviation and column’s standard deviation.
- Parameters:
cov – Calculate the correlation matrix
- Returns:
The correlation matrix
- flip.covariance.cov_utils.save_matrix(matrix, name)[source]¶
The save_matrix function takes a matrix and saves it to the current directory as a .npy file.
- Parameters:
matrix – Save the matrix to a file
name – Save the matrix with a name
- Returns:
The name of the file that was saved
- flip.covariance.cov_utils.open_matrix(name)[source]¶
The open_matrix function takes in a string as an argument and returns the matrix that is saved under that name.
- Parameters:
name – Specify the name of the matrix to be loaded
- Returns:
A matrix
- flip.covariance.cov_utils.generator_need(coordinates_density=None, coordinates_velocity=None)[source]¶
The generator_need function checks if the coordinates_density and coordinates_velocity inputs are provided. If they are not, it raises a ValueError exception.
- Parameters:
coordinates_density – Generate the density covariance matrix
coordinates_velocity – Generate the covariance matrix of the velocity field
:param : Check if the coordinates are provided or not
- Returns:
A list of the coordinates that are needed to proceed with covariance generation
- flip.covariance.cov_utils.check_generator_need(model_type, coordinates_density, coordinates_velocity)[source]¶
The check_generator_need function is used to check if the generator_need function is called with the correct arguments. The model type determines which coordinates are needed, and these are passed as arguments to generator_need.
- Parameters:
model_type – Determine if the density, velocity or full model is being used
coordinates_density – Check if the density coordinates are needed
coordinates_velocity – Determine whether the velocity model is needed
- Returns:
A boolean