create_final_plots
The create_final_plots module generates plots and visualizations for the cube data. It includes functions for coordinate transformations, calculating impact parameters, fitting spectral templates, and visualizing data cubes.
- Functions:
scale_params: Converts redshift to plate scale in kpc per arcsec.
get_impact: Calculates the impact parameter between a quasar and a galaxy.
get_num_lines: Counts the active emission lines based on a model integer.
gauss_function: Computes the value of a Gaussian function.
galaxy: Generates a synthetic galaxy spectrum using Gaussian profiles for emission lines.
find_bottom_of_plot: Sets axis limits for a plot based on the data range.
add_ticks_to_plot: Adjusts plot limits and hides tick labels.
- Dependencies:
astropy: For cosmological calculations and WCS transformations.
matplotlib: For plotting and visualizations.
mpdaf: For handling data cubes.
numpy: For numerical operations.
json, os, sys, logging, struct: For file handling and system operations.
- postprocessing.create_final_plots.add_ticks_to_plot(plt: Axes, aw: float, px_py: float) Axes[source]
Adjusts the plot by setting limits, hiding tick labels, and inverting the y-axis.
- Parameters:
plt (matplotlib.pyplot.Axes) – The plot axes object to modify.
aw (float) – The center value for the x-axis limits.
px_py (float) – The center value for the y-axis limits.
- Returns:
The modified axes object.
- Return type:
matplotlib.pyplot.Axes
- postprocessing.create_final_plots.find_bottom_of_plot(ax: Axes, crval: float, crmax: float, data: ndarray) Axes[source]
Sets axis limits for a plot based on the data range.
- Parameters:
ax (matplotlib.Axes) – The plot axes.
crval (float) – Start value for the x-axis.
crmax (float) – Max value for the x-axis.
data (list or array-like) – Data to determine y-axis limits.
- Returns:
The modified axes.
- Return type:
matplotlib.Axes
- postprocessing.create_final_plots.fit_template(t, z, f, w)[source]
fits a series of galaxy model to a series of lines as indicated by the best match template
- Parameters:
t (int) – The galaxy template
z (float) – The redshift guess from FELINE
f (float) – The flux array from the median filtered data cube
w (float) – The wavelength array from the median filtered data cube
- Returns:
The fitted redshift for this galaxy model
- Return type:
new_z (float)
- postprocessing.create_final_plots.galaxy(w: float, *p: int) ndarray[source]
Generates a model galaxy spectrum by summing Gaussian profiles for each emission line. This function takes a wavelength array and parameters for each emission line, including the redshift, line width (sigma), and amplitude for each line, to construct a synthetic galaxy spectrum. The emission lines are modeled as Gaussian functions.
- Parameters:
w (float) – An array of wavelengths at which to evaluate the galaxy model.
p (tuple) – A tuple containing parameters for the galaxy model. The first element is the redshift (z), the second is the common line width (sigma) for all lines, followed by the amplitude of each emission line. The number of amplitudes provided should match the number of emission lines being modeled.
- Returns:
An array representing the synthetic galaxy spectrum at the wavelengths specified by w. This array has the same shape as w.
- Return type:
np.ndarray
- postprocessing.create_final_plots.gauss_function(x: float, a: float, x0: float, sigma: float) float[source]
Computes the value of a Gaussian function with given parameters.
- Parameters:
x (float) – The input value at which to evaluate the function.
a (float) – The amplitude of the Gaussian curve.
x0 (float) – The mean (center) of the Gaussian curve.
sigma (float) – The standard deviation of the Gaussian curve.
- Returns:
The value of the Gaussian function at x.
- Return type:
float
- postprocessing.create_final_plots.get_impact(QSO_X: float, QSO_Y: float, px: float, py: float, z: float) float[source]
Calculates the impact parameter, which is the projected distance between a quasar (QSO) and a galaxy in kiloparsecs (kpc), at the redshift of the galaxy.
- Parameters:
QSO_X (float) – The x-coordinate of the quasar in arcseconds.
QSO_Y (float) – The y-coordinate of the quasar in arcseconds.
px (float) – The x-coordinate of the galaxy in arcseconds.
py (float) – The y-coordinate of the galaxy in arcseconds.
z (float) – The redshift of the galaxy.
- Returns:
The impact parameter in kpc.
- Return type:
float
- postprocessing.create_final_plots.get_num_lines(toggle: int) int[source]
Counts the number of active lines (set bits) in the binary representation of the input integer. This can be used to determine the number of emission lines considered in a given model by examining the bits set in the model’s integer representation.
- Parameters:
toggle (int) – An integer where each bit represents the presence (1) or absence (0) of a specific emission line in the model.
- Returns:
The count of active emission lines represented by the set bits in the input integer.
- Return type:
int
- postprocessing.create_final_plots.scale_params(redshift: float) float[source]
Compute the plate scale at a given redshift.
The plate scale is the distance in kiloparsecs (kpc) that corresponds to an angular size of one arcminute at the given redshift. This function uses the cosmology model defined in the global variable cosmo.
- Parameters:
redshift (float) – The redshift at which to compute the plate scale.
- Returns:
The plate scale at the given redshift, in kpc per arcsec.
- Return type:
float
create_pdf
The create_pdf module handles PDF operations. It provides functionality for merging PDF files and cleaning up the data folder.
- Functions:
create_pdf_file: Merges all PDF files in the specified folder into one, named with the current timestamp.
remove_pdf_files: Deletes all individual PDF files to maintain an organized directory.
- Dependencies:
pypdf: For merging PDF files.
os: For file system operations.
datetime: For generating timestamps for the merged PDF.
project_path_config: For accessing project-specific path configurations.
detect_objects
The detect_objects module provides functionalities for converting between world and pixel coordinates, calculating Gaussian values, and detecting objects in astronomical images.
- Functions:
world_to_pix: Converts world coordinates (RA, Dec) to pixel coordinates.
pix_to_world: Converts pixel coordinates to world coordinates (RA, Dec).
print_lines: Returns catalog lines for a given toggle and redshift.
sort_catalog: Sorts the catalog based on a specific value.
write_to_file: Writes sorted catalog data to a file.
- Dependencies:
astropy: For WCS transformations.
matplotlib: For visualizations.
numpy, scipy: For numerical operations.
skimage: For object detection.
json, os, sys: For file operations.
- postprocessing.detect_objects.extract_arrays() tuple[source]
Extracts grid spacing values from the header of a binary file.
Reads the first 16 bytes of the file, unpacks the Z, X, and Y spacing values as floats, and returns them as integers along with the raw header.
- Returns:
- (dz, xd, yd, header)
dz, xd, yd (int): Spacing values from the header.
header (bytes): The raw 16-byte header.
- Return type:
tuple
- postprocessing.detect_objects.pix_to_world(coord: WCS, pix: tuple) tuple[source]
Convert pixel coordinates to world coordinates.
Given a tuple of pixel coordinates (x, y) and an astropy WCS object, this function calculates the corresponding world coordinates in right ascension (RA) and declination (Dec).
- Parameters:
coord (astropy.wcs.WCS) – The World Coordinate System object that defines the transformation between pixel and world coordinates.
pix (tuple) – A tuple containing the x and y pixel coordinates.
- Returns:
A tuple containing the RA and Dec in degrees.
- Return type:
tuple
- postprocessing.detect_objects.print_lines(toggle: int, z: float) list[source]
This function returns the lines of the catalog for the given toggle and redshift.
- Parameters:
toggle – Integer value representing the toggle.
z – Float value representing the redshift.
- Returns:
List of strings containing the lines of the catalog.
- Return type:
lines
- postprocessing.detect_objects.resize_filters(xd: int, yd: int) tuple[source]
Resizes filter arrays to the specified dimensions.
Reads a raw binary file, splits it into four arrays, and resizes each to the provided (xd, yd) dimensions.
- Returns:
- (plane, redshift, template, used)
plane, redshift, template, used (ndarray): Resized arrays.
- Return type:
tuple
- postprocessing.detect_objects.sort_catalog(catalog_lines: list) list[source]
This function sorts the catalog based on the 5th value in descending order.
- Parameters:
catalog_lines – List of strings containing the catalog data.
- Returns:
List of strings containing sorted catalog data.
- Return type:
sorted_catalog