API Documentation
Subpackages
- pykoala.corrections package
- Submodules
- pykoala.corrections.astrometry module
- pykoala.corrections.atmospheric_corrections module
- pykoala.corrections.correction module
- pykoala.corrections.flux_calibration module
- pykoala.corrections.sky module
- pykoala.corrections.throughput module
- pykoala.corrections.wavelength module
- Module contents
- pykoala.exceptions package
- pykoala.instruments package
- pykoala.plotting package
- pykoala.register package
Submodules
pykoala.ancillary module
Utility functions.
Many of them are partially implemented. They were in the old, non-modular version of PyKOALA and have not been included in the current modular scheme.
- pykoala.ancillary.detect_edge(rss)[source]
Detect the edges of a RSS. Returns the minimum and maximum wavelength that determine the maximum interval with valid (i.e. no masked) data in all the spaxels.
- Parameters
rss (RSS object.)
- Returns
min_w (float) – The lowest value (in units of the RSS wavelength) with valid data in all spaxels.
min_index (int) – Index of min_w in the RSS wavelength variable.
max_w (float) – The higher value (in units of the RSS wavelength) with valid data in all spaxels.
max_index (int) – Index of max_w in the RSS wavelength variable.
- pykoala.ancillary.update_wcs_coords(wcs, ra_dec_val=None, ra_dec_offset=None)[source]
Update the celestial reference values of a WCS.
Update the celestial coordinates of a WCS using new central values of RA and DEC or relative offsets expressed in degree.
- Parameters
- wcs (asteropy.wcs.WCS) – Target WCS to update.
- ra_dec_val (list or tupla, default=None) – New CRVAL of RA and DEC.
- ra_dec_offset (list or tupla, default=None) – Relative offset that will be applyied to CRVAL of RA and DEC axis. If ra_dec_val is privided, this will be ignored.
- Returns
- correct_wcs – A copy of the original WCS with the reference values updated.
- Return type
astropy.wcs.WCS
- pykoala.ancillary.running_mean(x, n_window)[source]
This function calculates the running mean of an array.
- Parameters
x ((n,) np.ndarray) – This is the given array.
n_window (Int) – Number of neighbours for computing the running mean.
- Returns
running_mean_x – Running mean array.
- Return type
(n - n_window,) np.ndarray
- pykoala.ancillary.flux_conserving_interpolation(new_wavelength, wavelength, spectra, **interp_args)[source]
Flux-conserving linear interpolation.
Linear interpolation of a spectrum \(I_\lambda(\labmda)\) as a function of wavelength \(\lambda\), ensuring that the integrated flux math:: F(lambda_a, lambda_b) = int_{lambda_a}^{lambda_b} I_lambda(labmda) dlambda$
is conserved for any \((\lambda_a, \lambda_b)\).
np.nan values become zero.
- Parameters
new_wavelength (ndarray) – New values of the x coordinate (wavelength) \(\lambda_{new}\).
wavelength (ndarray) – Old values of the x coordinate (wavelength) \(\lambda\).
spectra (ndarray) – Old values of the y coordinate (spectrum) \(I_\lambda(\labmda)\).
**interp_args (dict, optional) – Additional parameters to be passed to np.interp
- Returns
Interpolated spectra \(I_\lambda(\labmda_{new})\).
- Return type
ndarray
Notes
The function computes the cumulative flux with np.nancumsum, calls np.interp, and differentiates back.
- pykoala.ancillary.centre_of_mass(w, x, y)[source]
Compute the centre of mass of a given image. :Parameters: * w (np.ndarray(float)) – (n,) weights computing the centre of mass.
x (np.ndarray(float)) – (n,) Coordinates corresponding to the x-axis (columns).
y (np.ndarray(float)) – (n,) Coordinates corresponding to the y-axis (rows).
- Returns
x_com (float)
y_com (float)
- pykoala.ancillary.growth_curve_2d(image, x0=None, y0=None)[source]
Compute the curve of growth of an array f with respect to a given point (x0, y0).
- Parameters
image (np.ndarray) – 2D array
x0 (float) – Origin of coordinates in pixels along the x-axis (columns).
y0 (float) – Origin of coordinates in pixels along the y-axis (rows).
- Returns
r2 (np.ndarray) – Vector containing the square radius with respect to (x0, y0).
growth_curve (np.ndarray) – Curve of growth centered at (x0, y0).
- pykoala.ancillary.interpolate_image_nonfinite(image)[source]
Use scipy.interpolate.NearestNDInterpolator to replace NaN values.
- Parameters
- image ((np.ndarray)) – 2D array to be interpolated
Returnrs
——–
- interpolated_image ((np.ndarray))
- pykoala.ancillary.vac_to_air(vac_wl)[source]
Convert wavelength in vacuum to air using Morton (1991, ApJS, 77, 119).
- Parameters
- vac_wl (np.ndarray) – Vector of vacuum wavelengths in Angstrom.
- Returns
- air_wl – Vector of air wavelengths in Angstrom
- Return type
np.ndarray
- pykoala.ancillary.smooth_spectrum(wlm, s, wave_min=0, wave_max=0, step=50, exclude_wlm=[[0, 0]], order=7, weight_fit_median=0.5, plot=False, verbose=False, fig_size=12)[source]
THIS IS NOT EXACTLY THE SAME THING THAT applying signal.medfilter()
This needs to be checked, updated, and combine (if needed) with task fit_smooth_spectrum. The task gets the median value in steps of “step”, gets an interpolated spectrum, and fits a 7-order polynomy.
It returns fit_median + fit_median_interpolated (each multiplied by their weights).
Tasks that use this: get_telluric_correction
- pykoala.ancillary.in_rectangle(pos, rectangle_pos)[source]
Check if a point lies in the perimeter of a rectangle.
- pykoala.ancillary.pixel_in_circle(pixel_pos, pixel_size, circle_pos, circle_radius)[source]
Compute the area of a pixel within a circle.
- Parameters
- pixel_pos (tuple) – Position of the lower left corner of the pixel
- pixel_size (float) – Size of the pixel.
- circle_pos (tuple) – Position of the circle centre
- circle_raidus (float) – Radius of the circle.
- Returns
- area_pixel – Area of the pixel contained within the circle
- area_fraction – Fration of the circle area that overlaps with the pixel.
- pykoala.ancillary.cumulative_1d_sky(r2, sky_brightness)[source]
1D cumulative sky brightness. F_sky = 4*pi*r2 * B_sky
- Parameters
r2 (np.array(float)) – Square radius from origin.
sky_brightness (float) – Sky surface brightness.
- Returns
cumulative_sky_brightness – Cumulative sky brightness.
- Return type
np.array(float)
- pykoala.ancillary.cumulative_1d_moffat(r2, l_star, alpha2, beta)[source]
Cumulative Moffat ligth profile.
- Parameters
r2 (np.array(float)) – Square radius with respect to the profile centre.
l_star (float) – Total luminosity integrating from 0 to inf.
alpha2 (float) – Characteristic square radius.
beta (float) – Power-low slope
- Returns
cum_moffat_prof – Cumulative Moffat profile
- Return type
np.array(float)
- pykoala.ancillary.cumulative_1d_moffat_sky(r2, l_star, alpha2, beta, sky_brightness)[source]
Combined model of cumulative_1d_moffat and cumulative_1d_sky.
- pykoala.ancillary.fit_moffat(r2_growth_curve, f_growth_curve, f_guess, r2_half_light, r_max, plot=False)[source]
Fits a Moffat profile to a flux growth curve as a function of radius squared, cutting at to r_max (in units of the half-light radius), provided an initial guess of the total flux and half-light radius squared.
# TODO :Parameters: * r2_growth_curve (TYPE) – DESCRIPTION.
F_growth_curve (TYPE) – DESCRIPTION.
F_guess (TYPE) – DESCRIPTION.
r2_half_light (TYPE) – DESCRIPTION.
r_max (TYPE) – DESCRIPTION.
plot (Boolean, optional) – If True generates and shows the plots. The default is False.
- Returns
fit – DESCRIPTION.
- Return type
TYPE
pykoala.cubing module
pykoala.data_container module
pykoala.rss module
Module contents
- pykoala.vprint(msg, *args, **kwargs)[source]
Convenience function for using with the pykoala generic logger.
- class pykoala.VerboseMixin[source]
Bases:
object- property logger
- property verbose
Abstract property for the verbosity of the correction.