skrbcr_casa_scripts package
Submodules
skrbcr_casa_scripts.Image module
- class Image(imagename: str = None, data: ndarray = None, width: int = None, height: int = None, center_ra: str = None, center_dec: str = None)
Bases:
object
Image class for my_tools
- get_fig_size() -> (<class 'int'>, <class 'int'>)
Returns size of the figure.
- Returns:
int, height: int)
- Return type:
(width
- convert_axes_unit(unit: str)
Converts the unit of the axes
- Parameters:
unit – The new unit.
- get_ticks(xtickspan: int, ytickspan: int, relative: bool, fmt: str)
Returns x and y ticks and tick labels.
- Parameters:
xtickspan (int) – Span of ticks of x-axis.
ytickspan (int) – Span of ticks of y-axis.
relative (bool) – If True, ticks are relative coordinates. If False, ticks are global coordinates.
fmt (str) – Format of tick labels.
- Returns:
xticks, xticks_label, yticks, yticks_label
skrbcr_casa_scripts.PlotConfig module
- class PlotConfig(savename: str | None = None, width: int | None = None, height: int | None = None, chan: int | None = None, title: str | None = None, cmap: str = 'jet', vmin: float | None = None, vmax: float | None = None, cbar: str = 'common', cbar_label: str | None = None, cbar_unit: str | None = None, cbeam: str = 'white', rescale: str = 'milli', cbarfmt: str = ':.2f', axesunit: str = 'arcsec', relative: bool = True, xtickspan: int = 2, ytickspan: int = 2, ticksfmt: str = ':.3f', show: bool = True, dpi: int = 300)
Bases:
object
General configuration for plot.
skrbcr_casa_scripts.azimuthal_cut module
- azimuthal_cut(img: Image, radius: float, inclination: float, pa: float, beam_factor: float = 0.5) tuple
Extract an azimuthal cut from an image using a deprojected elliptical annulus.
This implementation computes the deprojected radius for each pixel, given the inclination and position angle, and selects pixels that lie within an annulus defined by [radius_px - beam_size/2, radius_px + beam_size/2]. The azimuthal angle is computed in the deprojected frame.
- Parameters:
img (Image) – The Image object.
radius (float) – The radius in arcsec.
inclination (float) – The inclination angle in degrees.
pa (float) – The position angle in degrees.
beam_factor (float, optional) – Sampling size based on the beam size. Defaults to 0.5.
- Returns:
- A tuple of three numpy arrays:
The azimuthal angle (in degrees) bins.
The mean intensity in each bin.
The standard deviation of the intensity in each bin.
- Return type:
tuple
skrbcr_casa_scripts.detectpeak module
skrbcr_casa_scripts.imshow module
- draw_beam(ax: Axes, img: Image = None, beam: tuple = None, color: str = 'white') None
Draws the beam on the image.
- Parameters:
ax (plt.Axes) – The Axes object.
img (Image) – The Image object.
beam (tuple) – The beam parameters (beam_x, beam_y, beam_ang). If both img and beam are provided, beam will be used.
color (str) – The color of the beam. Default to ‘white’.
- imshow(ax: Axes, img: Image, config: PlotConfig = None)
Rasterizes an image on given Axes object with matplotlib from a CASA style image file.
- Parameters:
ax (plt.Axes) – The Axes object.
img (Image) – The Image object.
config (PlotConfig) – The PlotConfig object.
- Returns:
The AxesImage object.
- Return type:
matplotlib.image.AxesImage
- overlay_contour(ax: Axes, img_base: Image, img: Image, fill=False, nchan=None, **kwargs) None
Overlays contours on the image.
To plot with correct scaling, both Image objects should have incr_x and incr_y attributes.
- Parameters:
ax (plt.Axes) – The Axes object.
img_base (Image) – Image plotted as background (This should have been already plotted).
img (Image) – Image to be plotted as contours.
fill (bool) – If True, the contours will be filled. Default is False.
nchan (int) – The channel number to be plotted. If img is a cube, this should be specified.
**kwargs – Contour configuration keywords of matplotlib.pyplot.contour.
- lazy_raster(imagename: str, **kwargs) None
Rasterizes an image with matplotlib from a CASA style image file. With this function, you can get an pretty image with a few lines of code.
- Parameters:
imagename (str) – CASA style image file.
**kwargs – Plot configuration keywords. Please see PlotConfig for more details.
skrbcr_casa_scripts.imstat module
- imstat(imagename: str, uncertainty: float, width: int = None, height: int = None, unit: str = 'beam', region_mask: str = None, inverse_mask: bool = False)
Alternative version of imstat.
- Parameters:
imagename (str) – Name of the image.
uncertainty (float) – Flux uncertainty.
width (int, optional) – Width of the region to perform the calculations. Defaults to None.
height (int, optional) – Height of the region to perform the calculations. Defaults to None.
unit (str, optional) – Unit of area. Choices are ‘beam’ or ‘arcsec’. Defaults to ‘beam’.
region_mask (str, optional) – If specified, statistics are calculated using only the data within the mask. Defaults to None.
inverse_mask (bool, optional) – If True, the specified mask region is inverted. Defaults to False.
skrbcr_casa_scripts.matplotlib_helper module
- set_cbar(im: AxesImage, observable: str, unit: str, rescale: str, fmt: str, fmt_default: str) None
Sets the colorbar for the given figure and image axes.
- Parameters:
im (plt.image.AxesImage) – The image axes.
observable (str) – The observable being plotted.
unit (str) – The unit of the observable.
rescale (str) – The SI prefix to rescale the colorbar.
fmt (str) – The format string for the colorbar labels.
fmt_default (str) – The default format string for the colorbar labels.
- set_axes_options(ax: Axes, title: str, xlabel: str, ylabel: str, xticks, xticks_label, yticks, yticks_label)
skrbcr_casa_scripts.prepare_image module
- prepare_image(imagename: str, **kwargs) -> (<class 'skrbcr_casa_scripts.Image.Image'>, <class 'skrbcr_casa_scripts.PlotConfig.PlotConfig'>)
Prepares the Image object and updates the configuration with the image dimensions.
- Parameters:
imagename (str) – The name of the image file.
**kwargs – Additional keyword arguments to update the PlotConfig object.
- Returns:
A tuple containing the prepared Image object and the updated PlotConfig object.
- Return type:
tuple
skrbcr_casa_scripts.radial_cut module
- radial_cut(img: Image, azimuth: float, beam_factor: float = 0.5) tuple
Radial line cut of the image along the specified azimuth angle from the center.
- Parameters:
img (Image) – The Image object.
azimuth (float) – The azimuth angle in degrees.
beam_factor (float, optional) – Sampling size based on the beam size. Defaults to 0.5.
- Returns:
- A tuple of three numpy arrays:
The radial distance from the center.
The mean intensity.
The standard deviation of the intensity.
- Return type:
tuple
skrbcr_casa_scripts.utilities module
- get_si_prefix_symbol(prefix: str) str
Returns the SI prefix symbol for a given prefix string.
- Parameters:
prefix (str) – The SI prefix string.
- Returns:
The symbol associated with the given prefix.
- Return type:
str
- get_si_prefix_base10(prefix: str) float
Returns the base 10 multiplier for a given SI prefix string.
- Parameters:
prefix (str) – The SI prefix string.
- Returns:
The base 10 multiplier associated with the given prefix.
- Return type:
float
- get_pret_dir_name(dir: str) str
Returns the last component of a directory path without trailing slashes.
- Parameters:
dir (str) – The directory path.
- Returns:
The last component of the directory path.
- Return type:
str