Description¶
There are currently 11 main modules in dlnpyutils. They are described in detail below.
utils¶
The utils module has many of the general purpose functions.
size(): Returns the number of elements.
mad(): median absolute deviation of array.
minmax(): minimum and maximum of an array.
where(): Wrapper around numpy.where() to be more like IDL-like.
stat(): many useful statistics of an array
strlen(): number of characters in a string array or list
strip(): strip whitespace from string array or list
strjoin(): combine string arrays or scalars
strsplit(): split string arrays
pathjoin(): join two pathname components
first_el(): return the first element of an array or list
grep(): grep on a string array
readlines(): read a file into a string array
writelines(): write a string array to a file
remove_indices(): remove certain indices from an array
numlines(): return the number of lines in a file
basiclogger(): return a basic logger to the screen and optionally a file
remove(): delete multiple files and allow for non-existence
exists(): Check if a list of files exists.
lt(): takes the lesser of x or limit
gt(): takes the greater of x or limit
limit(): require x to be within upper and lower limits
valrange(): returns range of values.
signs(): Return the sign of input. Return +1.0 for 0.0.
scale(): Maps an array onto a new scale given two values on the old and new scales.
scale_vector(): Scale a vector to minrange and maxrange.
quadratic_bisector(): Calculate the axis of symmetric or bisector of parabola.
quadratic_coefficients(): Calculate the quadratic coefficients from the three points.
wtmean(): Calculate weighted mean and error.
mediqrslope(): Calculate robust slope from median of first quartile and points in the 3+4th quartile and median of 4th quartile and points in the 1+2nd quartile. The median is then found of all the slopes.
iqrslope(): Calculate robust slope from median of first quartile and last quartile of points.
medslope(): Calculate robust slope from median of first half and last half of points.
wtslope(): Calculate weighted slope and error.
robust_slope(): Calculate robust weighted slope.
wtmedian(): Weighted median by sorting the weighted values and finding the point of half the total weights.
iqrstdev(): Use the interquartile range to estimate the standard deviation robustly.
sigclipmean(): Sigma-clipped mean.
gausswtmean(): Compute weighted mean using a Gaussian with center of the median and sigma of the MAD.
gmean(): Compute geometric mean.
skewquartile(): Measure the skewness robustly based on quartiles.
skewgauss(): Return a skewed Gaussian.
gaussian(): Return 1-D Gaussian.
gaussbin(): Return 1-D binned Gaussian.
gaussfit(): fit a 1-D Gaussian to X/Y data.
voigt(): Return the Voigt line shape at x with Lorentzian component HWHM gamma and Gaussian sigma.
voigtfit(): Fit a Voigt profile to data.
voigtarea(): Compute area of Voigt profile.
poly(): evaluate a polynomial function of a variable
poly_fit(): Fit a polynomial to X/Y data.
slope(): derivative or slope of an array
smooth(): Boxcar smooth an array.
gsmooth(): Gaussian smooth an array or image.
savol(): Savitzky-Golay smoothing of data.
rebin(): Rebin data.
roi_cut(): Use cuts in a 2D plane to select points from arrays.
create_index(): Create an index of array values like reverse indices.
match(): Function to match values in two vectors.
interp(): Interpolate with extrapolation.
concatenate(): Concatenate two or more numpy structured arrays (or list of them).
addcatcols(): Add new columns to an existing numpty structured array catalog.
clicker(): Click on a plot and return the coordinates.
add_elements(): Add more elements to a catalog.
ellipsecoords(): Create coordinates of an ellipse.
closest(): Find value in array closest to an input scalar.
sexig2ten(): Convert sexigesimal to decimal.
fread(): Read the values in a string into variables using a format string.
randf(): Pick random floats between low and high (inclusive).
isnumber(): Returns True if string is a number or float.
coords¶
The coords module has coordinate-related tools.
rotsph(): Convert coordinates into a new coordinate system given the coordinates of the pole and the “ascending node”.
rotsphcen(): Convert coordinates into a new coordinate system given the coordinates of the origin of the new equator.
doPolygonsOverlap(): Returns True if two polygons are overlapping.
xmatch(): Cross-match angular values between RA1/DEC1 and RA2/DEC2.
dist(): Calculate Euclidian distance between two sets of points.
sphdist(): Calculate the angular distance between two sets of points.
lbd2xyz(): Convert from LON, LAT and DISTANCE to galactocentric cartesian coordinates.
xyz2lbd(): Convert galactocentric X/Y/Z coordinates to l,b,dist.
bindata¶
The bindata module is a variant of the scipy.stats.binned_statistic module. It adds the “mad” and “percentile” statistics.
binned_statistic(): Compute a binned statistic for one or more sets of data.
astro¶
Various astronomy-related tools and functions.
airtovac(): Convert air wavelengths to vacuum wavelengths.
vactoair(): Convert vacuum wavelengths to air wavelengths.
vgsr2vhelio(): Convert Galactocentric velocies to heliocentric.
vgsr2vlsr(): Convert Galactocentric velocies to Local Standard of Rest velocities.
galaxy_model(): Model of the proper motions and radial velocites of a simple disk galaxy.
job_daemon¶
The job_daemon module has the capability to ask as a simple python job manager.
job_daemon(): Run a set of python “jobs” simultaneously.
plotting¶
A set of utility plotting functions.
zscaling(): Calculate good min/max scaling values for a data set.
hist2d(): Plot 2D histogram of data (similar to plt.hist2d).
display(): Display an image (similar to plt.imshow).
plot(): Line or scatter plot of data.
db¶
Some tools to interact with with a sqlite3 or PostgresQL database.
writecat(): Write a catalog to a database table.
createindex(): Create an index on a column.
analyzetable(): Run “analyze” on a table.
query(): Run a query on a table.
spec¶
Some spectral processing and analysis tools.
trace(): Trace the spectrum. Spectral dimension is assumed to be on the horizontal axis.
boxcar(): Boxcar extract the spectrum.
linefit(): Fit Gaussian profile to data with center and sigma fixed
extract(): Extract a spectrum.
emissionlines(): Measure the emission lines in an arc lamp spectrum.
continuum(): Derive the continuum of a spectrum.
robust¶
A collection of robust statistics functions transflated from the AstroIDL User’s Library.
biweight_mean(): Calculate the mean of a data set using bisquare weighting.
mean(): Robust estimator of the mean of a data set. Based on the resistant_mean function from the AstroIDL User’s Library.
mode(): Robust estimator of the mode of a data set using the half-sample mode.
std(): Robust estimator of the standard deviation of a data set. Based on the robust_sigma function from the AstroIDL User’s Library.
checkfit(): Determine the quality of a fit and biweights.
linefit(): Outlier resistance two-variable linear regression function.
polyfit(): Outlier resistance two-variable polynomial function fitter.
ladfit¶
The ladfit module has some robust functions for estimating a linear model.
ladfit(): Fits the paired data {X(i), Y(i)} to the linear model, y = A + Bx, using a “robust” least absolute deviation method.
minpack¶
The minpack, least_squares, and trf module is a variant of the scipy.optimize.least_squares module but with some modifications to curve_fit to
allow for more user inputs.
curve_fit(): General purpose curve fitting of data.