IMAGE module¶
image is the pyvista module that implements some general image processing including basic image arithmetic, VISTA-style, and VISTA-style boxes
image functions:¶
- class pyvista.image.BOX(n=None, nr=None, nc=None, sr=1, sc=1, cr=None, cc=None, xr=None, yr=None)[source]¶
Defines BOX class
- set(xmin, xmax, ymin, ymax)[source]¶
Resets limits of a box
- Parameters
xmin – lower x value
xmax – higher x value
ymin – lower y value
ymax – higher xyvalue
- mean(data)[source]¶
Returns mean of data in box
- Args :
data : input data (Data or np.array)
- Returns
mean of data in box
- stdev(data)[source]¶
Returns standard deviation of data in box
- Args :
data : input data (Data or np.array)
- Returns
standard deviation of data in box
- iqr(data)[source]¶
Returns IQR data in box
- Args :
data : input data (Data or np.array)
- Returns
IQR of data in box
- max(data)[source]¶
Returns maximum of data in box
- Args :
data : input data (Data or np.array)
- Returns
maximum of data in box
- min(data)[source]¶
Returns minimum of data in box
- Args :
data : input data (Data or np.array)
- Returns
minimum of data in box
- pyvista.image.abx(data, box)[source]¶
Returns dictionary with image statistics in box.
- Args :
data : input data (Data or np.array) box : pyvista BOX
- Returns :
dictionary with image statistics : ‘mean’, ‘stdev’, ‘min’, ‘max’, ‘peakx’, ‘peaky’
- pyvista.image.gauss2d(X, amp, x0, y0, a, b, c, back, binned=False)[source]¶
Evaluate Gaussian 2D function
Form: amp*exp(-a(x-x0)**2 - b(x-x0)*(y-y0) - c(y-y0)**2) + const
- Parameters
X (arraylike [2,npts]) – x,y positions to evaluate at
amp (float) – coefficients of function
x0 (float) – coefficients of function
y0 (float) – coefficients of function
a (float) – coefficients of function
b (float) – coefficients of function
c (float) – coefficients of function
back (float) – coefficients of function
- pyvista.image.gh2d(X, gpars, hpars, back, binned=False)[source]¶
Evaluate Gauss-Hermite 2D function
Form: exp(-a(x-x0)**2 - b(x-x0)*(y-y0) - c(y-y0)**2) + const
- Parameters
X (arraylike [2,npts]) – x,y positions to evaluate at
x0 (float) – coefficients of function
y0 (float) – coefficients of function
a (float) – coefficients of function
b (float) – coefficients of function
c (float) – coefficients of function
back (float) – coefficients of function
- pyvista.image.fwxfwytheta2abc(xfwhm, yfwhm, theta)[source]¶
Convert xfwhm, yfwhm, theta to a,b,c for gauss2d
- pyvista.image.gfit2d(data, x0, y0, size=5, fwhm=3.0, sub=True, plot=None, fig=1, scale=1, pafixed=False, astropy=True, binned=False)[source]¶
Does gaussian fit to input data given initial xcen,ycen
- pyvista.image.ghfit2d_thread(pars)[source]¶
Wrapper for ghfit2d for multithreading, with just a single argument
- pyvista.image.ghfit2d(data, x0, y0, size=5, fwhm=3.0, nherm=6, sub=True, plot=None, fig=1, scale=1, pafixed=False, binned=False, p0=None, bounds=None)[source]¶
Does 2D Gauss-Hermite fit to input data given initial xcen,ycen
- pyvista.image.stretch(a, ncol=None, nrow=None)[source]¶
Stretches a 1D image into a 2D image along rows or columns
- pyvista.image.clip(hd, min=None, max=None, vmin=None, vmax=None, box=None)[source]¶
Clipping tasks: sets all values above or below input values to specified values
- Parameters
hd – input HDU
- Keyword Arguments
min= (float) – clip values below min
vmin= (float) – values to clip min values to. If min= is not given clips values <vmin to vmin
max= (float) – clip values above max
vmax= (float) – values to clip max values to. If max= is not given clips values >vmax to vmax
- pyvista.image.create(box=None, n=None, nr=None, nc=None, sr=1, sc=1, cr=None, cc=None, const=None)[source]¶
Creates a new HDU
- pyvista.image.sky(im, box=None, max=None, min=None, plot=None)[source]¶
Estimate sky value in an image by fitting parabola to peak of histogram
- Parameters
im (HDU or numpy array) – input image data
- Keyword Arguments
box= – only use values within specified box (default=None)
min= – ignore values below min in sky computation (default=None)
max= – ignore values above max in sky computation (default=None)
plot= – matplotlib axes to view histogram and fit (default=None)
- pyvista.image.xcorr(a, b, lags, medfilt=0, rad=3)[source]¶
Cross correlation function between two arrays, calculated at lags
- If input images have the same number of rows, then calculate a single
cross-correlation in columns
- If first image has one row, but the second has more, then calculate
a cross correlation for each row of the second images
- Parameters
a – array_like reference array
b – array_like array to calculate shifts for
lags – array_like x-corrlation lags to use
medfilt – int, default=0 size of median filter for arrays
- Returns :
fit peak of cross-correlation (quadratic fit) 1D cross-correlation function
- pyvista.image.xcorr2d(a, b, lags=None, xlags=None, ylags=None)[source]¶
Two-dimensional cross correlation
- Parameters
a – input Data frames
b – input Data frames
lags – array (1D) of x-corrlation lags
- Returns
(x,y) position of cross correlation peak from quadratic fit to x-correlation 2D cross correlation function
- pyvista.image.zap(hd, size, nsig=3, mask=False)[source]¶
Median filter array and replace values > nsig*uncertainty
- pyvista.image.minmax(data, mask=None, low=3, high=10)[source]¶
Return min,max scaling factors for input data using median, and MAD
- Parameters
img – input CCDData
low – number of MADs below median to return
high – number of MADs above median to retunr
- Returns
low and high scaling factors
- Return type
min,max
- pyvista.image.transform(im0, im, lines0, xlags=range(-11, 12), ylags=range(-17, 18), rad=2, scale=20, hard=None, reject=1)[source]¶
Get geometric transformation between images based on point sources
- Parameters
im0 (Data or array-like) – Reference image
im (Data or array-like) – Target image
lines0 (Table) – Table with reference object positions (‘x’ and ‘y’)
xlags (range) – Range of cross-correlation shifts to try, default is range(-11,12) and (-17,18)
ylags (range) – Range of cross-correlation shifts to try, default is range(-11,12) and (-17,18)
rad (float, default=2) – radius for automark
scale (integer, default=20) – scale for quiver plots
hard (None or char) – if char, make tranformation plots (’’ to display, otherwise save to specified file name)
- pyvista.image.seq(files, box=None, size=None, red=None)[source]¶
Create montage image from a sequence
- Parameters
files (array-like) – list of files to montage
box (box, default=None) – image.BOX to use to extract subregion
size (int, default=None) – if specified, extract region of given size around maximum pixel
red (Reducer, default=None) – imred.Reducer used to extract images, else use iio.imread