sofia_redux.toolkit: Shared Utilities for SOFIA Pipelines

The sofia_redux.toolkit package contains supporting algorithms and helper functions for SOFIA data reduction pipelines.

Submodules

Reference/API

sofia_redux.toolkit.convolve.base Module

Classes

ConvolveBase(*args[, error, mask, stats, ...])

Convolution class allowing error propagation.

Class Inheritance Diagram

digraph inheritance555cb6bce0 { bgcolor=transparent; rankdir=LR; size=""; "ConvolveBase" [URL="../../api/sofia_redux.toolkit.convolve.base.ConvolveBase.html#sofia_redux.toolkit.convolve.base.ConvolveBase",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Convolution class allowing error propagation."]; "Model" -> "ConvolveBase" [arrowsize=1.2,arrowtail=empty,dir=back,style="setlinewidth(0.5)"]; "Model" [URL="../../api/sofia_redux.toolkit.utilities.base.Model.html#sofia_redux.toolkit.utilities.base.Model",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base model Class for fitting N-dimensional data"]; }

sofia_redux.toolkit.convolve.kernel Module

Functions

apply_ndkernel(data, kernel[, axes, ...])

Apply a kernel over multiple features

convolve(*args[, error, mask, stats, ...])

Convolve an N-dimensional array with a user defined kernel or fixed box.

savitzky_golay(*args[, order, error, mask, ...])

Apply a least-squares (Savitzky-Golay) polynomial filter

Classes

KernelConvolve(*args[, error, mask, stats, ...])

Generic convolution with a kernel

BoxConvolve(*args[, error, mask, stats, ...])

Convolution with a box kernel (mean)

SavgolConvolve(*args[, error, mask, stats, ...])

Convolve using Savitzky-Golay filter

Class Inheritance Diagram

digraph inheritance7459f88665 { bgcolor=transparent; rankdir=LR; size=""; "BoxConvolve" [URL="../../api/sofia_redux.toolkit.convolve.kernel.BoxConvolve.html#sofia_redux.toolkit.convolve.kernel.BoxConvolve",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Convolution with a box kernel (mean)"]; "KernelConvolve" -> "BoxConvolve" [arrowsize=1.2,arrowtail=empty,dir=back,style="setlinewidth(0.5)"]; "ConvolveBase" [URL="../../api/sofia_redux.toolkit.convolve.base.ConvolveBase.html#sofia_redux.toolkit.convolve.base.ConvolveBase",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Convolution class allowing error propagation."]; "Model" -> "ConvolveBase" [arrowsize=1.2,arrowtail=empty,dir=back,style="setlinewidth(0.5)"]; "KernelConvolve" [URL="../../api/sofia_redux.toolkit.convolve.kernel.KernelConvolve.html#sofia_redux.toolkit.convolve.kernel.KernelConvolve",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Generic convolution with a kernel"]; "ConvolveBase" -> "KernelConvolve" [arrowsize=1.2,arrowtail=empty,dir=back,style="setlinewidth(0.5)"]; "Model" [URL="../../api/sofia_redux.toolkit.utilities.base.Model.html#sofia_redux.toolkit.utilities.base.Model",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base model Class for fitting N-dimensional data"]; "SavgolConvolve" [URL="../../api/sofia_redux.toolkit.convolve.kernel.SavgolConvolve.html#sofia_redux.toolkit.convolve.kernel.SavgolConvolve",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Convolve using Savitzky-Golay filter"]; "ConvolveBase" -> "SavgolConvolve" [arrowsize=1.2,arrowtail=empty,dir=back,style="setlinewidth(0.5)"]; }

sofia_redux.toolkit.convolve.filter Module

Functions

savgol(data, window[, order, axes, check, ...])

Apply Savitzky-Golay filter to an array of arbitrary features

savgol_windows(order, window, *samples[, scale])

Creates the correct windows for given order and samples

sobel(input_array[, kderiv, kperp, pnorm, ...])

Edge enhancement Sobel filter for n-dimensional images.

sofia_redux.toolkit.fitting.fitpeaks1d Module

Functions

parse_width_arg(model_class, width_arg)

Simple convenience lookup to get width parameter name for various models.

get_fitter(fitter_class[, robust, ...])

Creates the object fitting a model to data

dofit(fitter, model, x, y, **kwargs)

A simple wrapper to fit model to the data

box_convolve(model, box_class[, box_width, ...])

Convolve a model with a box (or another model)

get_search_model(peak_model[, box_class, ...])

Create the initial_search peak fitting model

initial_search(fitter, model, x, y[, ...])

Perform an initial search for peaks in the data

get_background_fit(fitter, peak_model, ...)

Return a background model with initialized parameters

get_final_model(peak_class, pinit[, ...])

Refine the initial fit and return a set of models

fitpeaks1d(x, y[, npeaks, xrange, ...])

Fit peaks (and optionally background) to a 1D set of data.

medabs_baseline(_, y)

Default data preparation for initial_search and baseline function.

guess_xy_mad(x, y)

Default peak guess function for initial_search.

sofia_redux.toolkit.fitting.polynomial Module

Functions

polyexp(order[, ndim, indexing])

Returns exponents for given polynomial orders in arbitrary dimensions.

polysys(samples, order[, exponents, error, ...])

Create a system of linear equations to solve n-D polynomials

linear_equation(design_matrix, values[, ...])

Create a system of linear equations

gaussj(alpha, beta[, invert, preserve])

Linear equation solution by Gauss-Jordan elimination and matrix inversion

poly1d(x, coeffs[, covar])

Evalulate polynomial coefficients at x

polynd(v, coefficients[, exponents, ...])

Evaluate a polynomial in multiple features

zero_order_fit(data[, error])

Calculate the zeroth order polynomial coefficients and covariance

linear_polyfit(samples, order[, exponents, ...])

Fit a polynomial to data samples using linear least-squares.

gaussj_polyfit(samples, order[, exponents, ...])

Fit a polynomial to data samples using Gauss-Jordan elimination.

nonlinear_polyfit(samples, order[, ...])

Solve for polynomial coefficients using non-linear least squares fit

polyfitnd(*args[, error, mask, covar, ...])

Fits polynomial coefficients to N-dimensional data.

linear_vector_lstsq(alpha, beta, matrix_out)

nonlinear_coefficients(matrix, data[, ...])

nonlinear_evaluate(matrix_in, data, matrix_out)

polyfit2d(x, y, z[, kx, ky, full])

Least squares polynomial fit to a surface

poly2d(x, y, coeffs)

Evaluate 2D polynomial coefficients

polyinterp2d(x, y, z, xout, yout[, kx, ky, ...])

Interpolate 2D data using polynomial regression (global)

Classes

Polyfit(*args[, error, mask, covar, stats, ...])

Fits and evaluates polynomials in N-dimensions.

Class Inheritance Diagram

digraph inheritance812590e9a1 { bgcolor=transparent; rankdir=LR; size=""; "Model" [URL="../../api/sofia_redux.toolkit.utilities.base.Model.html#sofia_redux.toolkit.utilities.base.Model",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base model Class for fitting N-dimensional data"]; "Polyfit" [URL="../../api/sofia_redux.toolkit.fitting.polynomial.Polyfit.html#sofia_redux.toolkit.fitting.polynomial.Polyfit",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Fits and evaluates polynomials in N-dimensions."]; "Model" -> "Polyfit" [arrowsize=1.2,arrowtail=empty,dir=back,style="setlinewidth(0.5)"]; }

sofia_redux.toolkit.image.adjust Module

Functions

shift(data, offset[, order, missing, ...])

Shift an image by the specified amount.

rotate(data, angle[, order, missing, ...])

Rotate an image.

frebin(data, shape[, total, order, ...])

Rebins an array to new shape

image_shift(data, shifts[, order, missing])

Shifts an image by x and y offsets

rotate90(image, direction)

Replicates IDL rotate function

unrotate90(image, direction)

Un-rotates an image using IDL style rotation types

register_image(image, reference[, upsample, ...])

Return the pixel offset between an image and a reference

upsampled_dft(data, upsampled_region_size[, ...])

Upsampled DFT by matrix multiplication.

sofia_redux.toolkit.image.coadd Module

Functions

coadd(hdr_list, data_list, var_list, exp_list)

Coadd total intensity or spectral images.

sofia_redux.toolkit.image.combine Module

Functions

combine_images(data[, variance, method, ...])

Combine input image arrays.

sofia_redux.toolkit.image.fill Module

Functions

clough_tocher_2dfunc(d, cin, cout, **kwargs)

spline_interp_2dfunc(d, cin, cout, **kwargs)

maskinterp(image[, func, mask, apstep, ...])

Interpolates over image using a mask.

image_naninterp(data)

Fills in NaN values in an image

polyclip(i, j, pol_x, pol_y[, area])

Clip a polygon to a square unit pixel

polyfillaa(px, py[, xrange, yrange, ...])

Finds all pixels at least partially inside a specified polygon

polygon_area(ppath)

Uses the shoelace method to calculate area of a polygon

polygon_weights(polygon[, xrange, yrange, ...])

Get pixel weights - depreciated by polyfillaa

sofia_redux.toolkit.image.resize Module

Functions

resize(image, output_shape[, order, mode, ...])

Replacement for skimage.resize.

sofia_redux.toolkit.image.smooth Module

Functions

quadfit(image)

Quick and simple cubic polynomial fit to surface - no checks

bicubic_coefficients(z, dx, dy, dxy, nx, ny)

Returns the coefficients necessary for bicubic interpolation.

bicubic_evaluate(z, dx, dy, dxy, xrange, ...)

Parameters:

fitplane(points)

Fit a plane to distribution of points.

fiterpolate(image, nx, ny)

Fits a smooth surface to data using J.

sofia_redux.toolkit.image.utilities Module

Functions

to_ndimage_mode(mode)

Convert from numpy.pad mode name to the corresponding ndimage mode.

fix_ndimage_mode(mode)

Allow translation of modes for scipy versions >= 1.6.0

clip_output(original, warped, mode, cval, clip)

Clip the array to the range of original values.

map_coordinates(data, coordinates[, order, ...])

A drop in replacement for ndimage.map_coordinates().

sofia_redux.toolkit.image.warp Module

Functions

warp_image(data, xin, yin, xout, yout[, ...])

Warp data using transformation defined by two sets of coordinates

polywarp(xi, yi, xo, yo[, order])

Performs polynomial spatial warping

polywarp_image(image, x0, y0, x1, y1[, ...])

Warp an image by mapping 2 coordinate sets with a polynomial transform.

is_homography_transform(transform, n_dimensions)

Check if a transform is homographic.

full_transform(coordinates, transform)

Apply a metric transform to the supplied coordinates.

warp_terms(terms, coefficients)

Apply coefficients to polynomial terms.

estimate_polynomial_transform(source, ...[, ...])

Estimate the polynomial transform for (x, y) coordinates.

warp_coordinates(coordinates, source, ...[, ...])

Apply the warping between two sets of coordinates to another.

warp_array_elements(source, destination, shape)

Warp the indices of an array with a given shape using a polynomial.

warp(data, source, destination[, order, ...])

Warp an n-dimensional image according to a given coordinate transform.

Classes

PolynomialTransform([source, destination, order])

Initialize a polynomial transform.

Class Inheritance Diagram

digraph inheritance2c28666683 { bgcolor=transparent; rankdir=LR; size=""; "ABC" [URL="https://docs.python.org/3/library/abc.html#abc.ABC",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Helper class that provides a standard way to create an ABC using"]; "PolynomialTransform" [URL="../../api/sofia_redux.toolkit.image.warp.PolynomialTransform.html#sofia_redux.toolkit.image.warp.PolynomialTransform",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "ABC" -> "PolynomialTransform" [arrowsize=1.2,arrowtail=empty,dir=back,style="setlinewidth(0.5)"]; }

sofia_redux.toolkit.interpolate.interpolate Module

Functions

line_shift(y, offset[, order, missing])

Shift an equally spaced array of data values by an offset

interpolate_nans(x, y, xout[, missing, ...])

Interpolate values containing NaNs

spline(x, y, xout[, sigma])

Perform cubic spline (tensioned) interpolation

sincinterp(x, y, xout[, dampfac, ksize, ...])

Perform a sinc interpolation on a data set

interp_1d_point(x, y, xout)

Perform linear interpolation at a single point.

interp_1d_point_with_error(x, y, error, xout)

Perform linear interpolation at a single point with error propagation.

interp_error_1d(x, error, xout[, cval])

Perform linear interpolation of errors

interp_error_nd(points, error, xi[, cval])

Propagate errors using Delaunay triangulation in N-dimensions

interp_error(points, error, xi[, cval])

Propagate errors using linear interpolation in N-dimensions

tabinv(array, xvals[, missing, fast])

Find the effective index of a function value in an ordered vector with NaN handling.

findidx(ix, ox[, left, right])

Finds the effective index of a function value in an ordered array.

Classes

Interpolate(*args[, method, cval, cubic, ...])

Fast interpolation on a regular grid

Class Inheritance Diagram

digraph inheritanceb8ee21f950 { bgcolor=transparent; rankdir=LR; size=""; "Interpolate" [URL="../../api/sofia_redux.toolkit.interpolate.interpolate.Interpolate.html#sofia_redux.toolkit.interpolate.interpolate.Interpolate",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Fast interpolation on a regular grid"]; }

sofia_redux.toolkit.resampling Package

Functions

apply_mask_to_set_arrays(mask, data, phi, ...)

Set certain arrays to a fixed size based on a mask array.

array_sum(mask)

Return the sum of an array.

calculate_adaptive_distance_weights_scaled(...)

Returns distance weights based on offsets and scaled adaptive weighting.

calculate_adaptive_distance_weights_shaped(...)

Returns distance weights based on offsets and shaped adaptive weighting.

calculate_distance_weights(coordinates, ...)

Returns a distance weighting based on coordinate offsets.

calculate_distance_weights_from_matrix(...)

Returns distance weights based on coordinate offsets and matrix operation.

calculate_fitting_weights(errors, weights[, ...])

Calculate the final weighting factor based on errors and other weights.

check_edge_with_box(coordinates, reference, ...)

Defines a hyperrectangle edge around a coordinate distribution.

check_edge_with_distribution(coordinates, ...)

Defines an edge based on statistical deviation from a sample distribution.

check_edge_with_ellipsoid(coordinates, ...)

Defines an ellipsoid edge around a coordinate distribution.

check_edge_with_range(coordinates, ...)

Defines an edge based on the range of coordinates in each dimension.

check_edges(coordinates, reference, mask, ...)

Determine whether a reference position is within a distribution "edge".

check_orders(orders, coordinates, reference)

Checks the sample distribution is suitable for a polynomial fit order.

check_orders_with_bounds(orders, ...[, ...])

Checks maximum order for sample coordinates bounding a reference.

check_orders_with_counts(orders, counts[, ...])

Checks maximum order based only on the number of samples.

check_orders_without_bounds(orders, coordinates)

Checks maximum order based on unique samples, irrespective of reference.

clean_image(image[, error, mask, window, ...])

Uses ResamplePolynomial to correct NaNs in image and/or supplied in mask.

convert_to_numba_list(thing)

Converts a Python iterable to a Numba list for use in jitted functions.

coordinate_covariance(coordinates[, mean, ...])

Calculate the covariance of a distribution.

coordinate_mean(coordinates[, mask])

Returns the mean coordinate of a distribution.

covariance_matrix_inverse(amat, phi, error, ...)

Calculates the inverse covariance matrix inverse of the fit coefficients.

derivative_mscp(coefficients, phi_samples, ...)

Return the weighted mean-square-cross-product (mscp) of sample derivatives.

distribution_variances(coordinates[, mean, ...])

Return variance at each coordinate based on coordinate distribution.

estimated_covariance_matrix_inverse(phi, ...)

Calculates covariance matrix inverse of fit coefficients from mean error.

evaluate_derivative(coefficients, phi_point, ...)

Calculates the derivative of a polynomial at a single point.

evaluate_derivatives(coefficients, ...)

Calculates the derivative of a polynomial at multiple points.

fasttrapz(y, x)

Fast 1-D integration using Trapezium method.

fit_phi_value(phi, coefficients)

Returns the dot product of phi and coefficients.

fit_phi_variance(phi, inv_covariance)

Calculates variance given the polynomial terms of a coordinate.

fit_residual(data, phi, coefficients)

Calculates the residual of a polynomial fit to data.

half_max_sigmoid(x[, x_half, k, a, c, q, b, v])

Evaluate a special case of the logistic function where f(x0) = 0.5.

logistic_curve(x[, x0, k, a, c, q, b, v])

Evaluate the generalized logistic function.

multiple_polynomial_terms(coordinates, exponents)

Derive polynomial terms for a coordinate set given polynomial exponents.

multivariate_gaussian(covariance, coordinates)

Return values of a multivariate Gaussian in K-dimensional coordinates.

no_fit_solution(set_index, point_index, ...)

Fill output arrays with set values on fit failure.

offset_variance(coordinates, reference[, ...])

Variance at reference coordinate derived from distribution uncertainty.

polynomial_derivative_map(exponents)

Creates a mapping from polynomial exponents to derivatives.

polynomial_exponents(order[, ndim, ...])

Define a set of polynomial exponents.

polynomial_terms(coordinates, exponents)

Derive polynomial terms given coordinates and polynomial exponents.

relative_density(sigma, counts, weight_sum)

Returns the relative density of samples compared to a uniform distribution.

resamp(coordinates, data, *locations[, ...])

ResamplePolynomial data using local polynomial fitting.

resampler(coordinates, data, *locations[, ...])

ResamplePolynomial data using local polynomial fitting.

scale_coordinates(coordinates, scale, offset)

Apply scaling factors and offsets to N-dimensional data.

scale_forward_scalar(coordinate, scale, offset)

Applies the function f(x) = (x - offset) / scale to a single coordinate.

scale_forward_vector(coordinates, scale, offset)

Applies the function f(x) = (x - offset) / scale to a coordinate array.

scale_reverse_scalar(coordinate, scale, offset)

Applies the function f(x) = (x * scale) + offset to a single coordinate.

scale_reverse_vector(coordinates, scale, offset)

Applies the function f(x) = (x * scale) + offset to a coordinate array.

scaled_adaptive_weight_matrices(sigma, ...)

Wrapper for scaled_adaptive_weight_matrix over multiple values.

scaled_adaptive_weight_matrix(sigma, rchi2)

Scales a Gaussian weighting kernel based on a prior fit.

shaped_adaptive_weight_matrices(sigma, ...)

Wrapper for shaped_adaptive_weight_matrix over multiple values.

shaped_adaptive_weight_matrix(sigma, rchi2, ...)

Shape and scale the weighting kernel based on a prior fit.

sigmoid(x[, factor, offset])

Evaluate a scaled and shifted logistic function.

single_polynomial_terms(coordinate, exponents)

Derive polynomial terms for a single coordinate given polynomial exponents.

solve_amat_beta(phi, data, weights)

Convenience function returning matrices suitable for linear algebra.

solve_coefficients(amat, beta)

Find least squares solution of Ax=B and rank of A.

solve_fit(window_coordinates, window_phi, ...)

Solve for a fit at a single coordinate.

solve_fits(sample_indices, ...[, is_covar, ...])

Solve all fits within one intersection block.

solve_inverse_covariance_matrices(phi, ...)

Inverse covariance matrices on fit coefficients from errors and residuals.

solve_mean_fit(data, error, weight[, ...])

Return the weighted mean of data, variance, and reduced chi-squared.

solve_polynomial_fit(phi_samples, phi_point, ...)

Derive a polynomial fit from samples, then calculate fit at single point.

solve_rchi2_from_error(residuals, weights, ...)

Return the reduced chi-squared given residuals and sample errors.

solve_rchi2_from_variance(residuals, ...[, ...])

Return the reduced chi-squared given residuals and constant variance.

sscp(matrix[, weight, normalize])

Calculate the sum-of-squares-and-cross-products of a matrix.

stretch_correction(rchi2, density, ...)

A sigmoid function used by the "shaped" adaptive resampling algorithm.

update_mask(weights, mask)

Updates a mask, setting False values where weights are zero or non-finite.

variance_from_offsets(offsets, covariance[, ...])

Determine the variance given offsets from the expected value.

weighted_fit_variance(residuals, weights[, ...])

Calculate variance of a fit from the residuals of the fit to data.

weighted_mean(data, weights[, weightsum])

Calculate the weighted mean of a data set.

weighted_mean_variance(variance, weights[, ...])

Calculated mean weighted variance.

weighted_variance(error, weights[, weightsum])

Utility function to calculate the biased weighted variance.

Classes

BaseGrid(*grid[, scale_factor, ...])

Define and initialize a resampling grid.

PolynomialTree(argument[, shape, ...])

Create a tree structure for use with the resampling algorithm.

Resample

alias of ResamplePolynomial

ResampleKernel(coordinates, data, kernel[, ...])

Class to resample data using kernel convolution.

ResamplePolynomial(coordinates, data[, ...])

Class to resample data using local polynomial fits.

Class Inheritance Diagram

digraph inheritance5eb099603a { bgcolor=transparent; rankdir=LR; size=""; "BaseGrid" [URL="../../api/sofia_redux.toolkit.resampling.BaseGrid.html#sofia_redux.toolkit.resampling.BaseGrid",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "BaseTree" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled"]; "PolynomialTree" [URL="../../api/sofia_redux.toolkit.resampling.PolynomialTree.html#sofia_redux.toolkit.resampling.PolynomialTree",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "BaseTree" -> "PolynomialTree" [arrowsize=1.2,arrowtail=empty,dir=back,style="setlinewidth(0.5)"]; "ResampleBase" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled"]; "ResampleKernel" [URL="../../api/sofia_redux.toolkit.resampling.ResampleKernel.html#sofia_redux.toolkit.resampling.ResampleKernel",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "ResampleBase" -> "ResampleKernel" [arrowsize=1.2,arrowtail=empty,dir=back,style="setlinewidth(0.5)"]; "ResamplePolynomial" [URL="../../api/sofia_redux.toolkit.resampling.ResamplePolynomial.html#sofia_redux.toolkit.resampling.ResamplePolynomial",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "ResampleBase" -> "ResamplePolynomial" [arrowsize=1.2,arrowtail=empty,dir=back,style="setlinewidth(0.5)"]; }

sofia_redux.toolkit.splines.spline Module

Classes

Spline(*args[, weights, limits, degrees, ...])

Initialize a Spline object.

Class Inheritance Diagram

digraph inheritancec6547c4ef9 { bgcolor=transparent; rankdir=LR; size=""; "Spline" [URL="../../api/sofia_redux.toolkit.splines.spline.Spline.html#sofia_redux.toolkit.splines.spline.Spline",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; }

sofia_redux.toolkit.splines.spline_utils Module

Functions

find_knots(coordinates, knots, ...)

Find the knot indices for an array of coordinates.

find_knot(coordinate, knots, ...[, ...])

Find the knot index for a single coordinate.

calculate_minimum_bandwidth(degrees, ...)

Calculate the minimum possible bandwidth given knots and spline degree.

flat_index_mapping(shape)

Return index slices for Numba flattened arrays.

create_ordering(indices[, size])

Given a list of indices, create an ordering structure for fast access.

check_input_arrays(values, coordinates, weights)

Check all input arrays.

givens_parameters(x, y)

Calculate the parameters of a Givens transformation.

givens_rotate(cos, sin, x, y)

Apply the Givens transformation to a value.

build_observation(coordinates, values, ...)

Build the spline observation matrices.

back_substitute(amat, beta, n_coefficients, ...)

Use back-substitution to solve a reduced row-echelon form matrix.

solve_rank_deficiency(amat, beta, ...)

Solve a rank-deficient row-echelon reduced form matrix.

solve_observation(amat, beta, ...)

Solve a row-echelon reduced linear system of equations Ax=B.

knot_fit(splines, coefficients, ...)

Calculate the spline fit at each knot location.

add_knot(knot_weights, knot_coords, ...)

Add a knot to the spline fit.

evaluate_bspline(knot_line, degree, x, ...)

Evaluate b-splines for given knots at a coordinate.

determine_smoothing_spline(knots, n_knots, ...)

Smooth the current solution to a specified level.

discontinuity_jumps(knot_line, n_knot, ...)

Calculates the discontinuity jumps.

rational_interp_zero(p1, f1, p2, f2, p3, f3)

Determines p where (u + p + v)/(p + w) = 0.

fit_point(coefficients, spline, ...)

Evaluate fitted value given a spline and coefficients.

perform_fit(coordinates, knots, ...)

Evaluate a given spline at multiple coordinates.

single_fit(coordinate, knots, coefficients, ...)

Return a fitted value at the given coordinate.

sofia_redux.toolkit.stats.stats Module

Functions

find_outliers(data[, threshold, keepnans, axis])

Determines the outliers in a distribution of data

meancomb(data[, variance, mask, rms, axis, ...])

(Robustly) averages arrays along arbitrary axes.

medcomb(data[, variance, mask, mad, axis, ...])

Combines a data set using median

moments(data[, threshold, mask, axis, get_mask])

Computes statistics on a data set avoiding deviant points if requested

robust_mask(data, threshold[, mask, axis, ...])

Computes a mask derived from data Median Absolute Deviation (MAD).

sofia_redux.toolkit.utilities.base Module

Classes

Model(*args[, error, mask, covar, stats, ...])

Base model Class for fitting N-dimensional data

Class Inheritance Diagram

digraph inheritanced18b721993 { bgcolor=transparent; rankdir=LR; size=""; "Model" [URL="../../api/sofia_redux.toolkit.utilities.base.Model.html#sofia_redux.toolkit.utilities.base.Model",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base model Class for fitting N-dimensional data"]; }

sofia_redux.toolkit.utilities.fits Module

Functions

hdinsert(header, key, value[, comment, ...])

Insert or replace a keyword and value in the header

add_history(header, msg[, prefix, refkey])

Add HISTORY message to a FITS header before the pipeline.

add_history_wrap(prefix)

Make a function to add HISTORY messages to a header, prefixed with a string.

robust_read(filename[, data_hdu, ...])

Retrieve the data and header from a FITS file

getheader(filename[, hdu, verbose])

Returns the header of a FITS file

getdata(filename[, hdu, verbose])

Returns the data from a FITS file

header_to_chararray(header)

Convert a FITS header to an array of strings

chararray_to_header(chararray)

Convert an array of strings to a FITS header

gethdul(filename[, verbose])

Returns the HDUList from a FITS file

write_hdul(hdul[, outdir, overwrite])

Write a HDULists to disk.

get_key_value(header, key[, default])

Get a key value from a header.

set_log_level(level)

Context manager to temporarily set the log level.

order_headers(headers)

Order headers based on contents.

merge_headers(headers, keyword_configuration)

Merge input headers.

sofia_redux.toolkit.utilities.func Module

Functions

robust_bool(value)

Check for 'truthy' values.

valid_num(value)

Check for valid numbers.

natural_sort(string_list[, reverse])

Returns list sorted in a human friendly manner

goodfile(filename[, read, write, execute, ...])

Check if a file exists, and optionally if it has the correct permissions.

date2seconds(datestring[, dformat])

Convert a header datestring to seconds

str_to_value(text)

Convert a string to an int or float.

slicer(array, axis, index[, ind])

Returns a slice of an array in arbitrary dimension.

setnumber(value[, minval, maxval, default, ...])

Sets a value to a valid number type

gaussian_model(x, x0, amplitude, fwhm, y0)

Gaussian model for curve_fit

to_array_shape(value, shape[, dtype])

Broadcast an array to the desired shape.

recursive_dict_update(original, new)

Recursively update a dictionary

stack(*samples[, copy])

faststack(*samples)

taylor(order, n)

Taylor expansion generator for Polynomial exponents

bytes_string(size_bytes)

Convert a number of bytes to a string with correct suffix

remove_sample_nans(samples, error[, mask])

Remove any samples containing NaNs from sample points

bitset(arr, bits[, skip_checks])

Return a byte array the same size as the input array.

julia_fractal(sy, sx[, c0, c1, iterations, ...])

Generate a 2-D Julia fractal image

nantrim(xin[, flag, trim, bounds])

Derive a mask to trim NaNs from an array

nansum(a[, axis, dtype, out, keepdims, missing])

Emulates the behaviour of np.nansum for NumPy versions <= 1.9.0.

sofia_redux.toolkit.utilities.multiprocessing Module

Functions

get_core_number([cores])

Returns the maximum number of CPU cores available

relative_cores(jobs)

Return the actual number of cores to use for a given number of jobs.

valid_relative_jobs(jobs)

Return a valid number of jobs in the range 1 <= jobs <= max_cores.

multitask(func, iterable, args, kwargs[, ...])

Process a series of tasks in serial, or in parallel using joblib.

pickle_object(obj, filename)

Pickle a object and save to the given filename.

unpickle_file(filename)

Unpickle a string argument if it is a file, and return the result.

pickle_list(object_list[, prefix, ...])

Pickle a list of objects to a temporary directory.

unpickle_list(pickle_files[, delete])

Restore pickle files to objects in-place.

in_main_thread()

Return whether the process is running in the main thread.

log_with_multi_handler(logger)

Context manager to temporarily log messages for unique processes/threads

log_for_multitask(logger)

Context manager to output log messages during multiprocessing.

purge_multitask_logs(log_directory, ...[, ...])

Remove all temporary logging files/directories and handle log records.

wrapped_with_logger(func, ...)

Return the results of the function in multitask and save log records.

log_records_to_pickle_file(logger, pickle_file)

Store the log records in a pickle file rather than emitting.

wrap_function(func, args[, kwargs, logger, ...])

Wrap a function for use with multitask().

Classes

MultitaskHandler()

A log handler for multitask.

Class Inheritance Diagram

digraph inheritance7a3b669de2 { bgcolor=transparent; rankdir=LR; size=""; "Filterer" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="A base class for loggers and handlers which allows them to share"]; "Handler" [URL="https://docs.python.org/3/library/logging.html#logging.Handler",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Handler instances dispatch logging events to specific destinations."]; "Filterer" -> "Handler" [arrowsize=1.2,arrowtail=empty,dir=back,style="setlinewidth(0.5)"]; "MultitaskHandler" [URL="../../api/sofia_redux.toolkit.utilities.multiprocessing.MultitaskHandler.html#sofia_redux.toolkit.utilities.multiprocessing.MultitaskHandler",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,margin=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A log handler for multitask."]; "Handler" -> "MultitaskHandler" [arrowsize=1.2,arrowtail=empty,dir=back,style="setlinewidth(0.5)"]; }