qa.qacore

Quality analysis core functions

Functions

allclose(a, b[, rtol, atol]) Returns True if two arrays are element-wise equal within a tolerance.
any(a[, axis, out]) Test whether any array element along a given axis evaluates to True.
arange arange([start,] stop[, step,], dtype=None)
argmax(a[, axis]) Indices of the maximum values along an axis.
argsort(a[, axis, kind, order]) Returns the indices that would sort an array.
array array(object, dtype=None, copy=True, order=None, subok=False, ndmin=True)
asarray(a[, dtype, order]) Convert the input to an array.
atleast_1d(*arys) Convert inputs to arrays with at least one dimension.
barthann(M[, sym]) Return the M-point modified Bartlett-Hann window.
bartlett(M[, sym]) The M-point Bartlett window.
blackman(M[, sym]) The M-point Blackman window.
blackmanharris(M[, sym]) The M-point minimum 4-term Blackman-Harris window.
bohman(M[, sym]) The M-point Bohman window.
boxcar(M[, sym]) The M-point boxcar window.
chebwin(M, at[, sym]) Dolph-Chebyshev window.
cmplx_sort(p) sort roots based on magnitude.
compute_image_stats(image) Compute simple image statistics.
compute_radiometric_stats(image) Compute simple radiometric statistics.
concatenate concatenate((a1, a2, ...), axis=0)
convolve(in1, in2[, mode]) Convolve two N-dimensional arrays.
convolve2d(in1, in2[, mode, boundary, fillvalue]) Convolve two 2-dimensional arrays.
correlate(in1, in2[, mode]) Cross-correlate two N-dimensional arrays.
correlate2d(in1, in2[, mode, boundary, ...]) Cross-correlate two 2-dimensional arrays.
deconvolve(signal, divisor) Deconvolves divisor out of signal.
detrend(data[, axis, type, bp]) Remove linear trend along axis from data.
dot dot(a, b)
enl(image)
expand_dims(a, axis) Expand the shape of an array.
extract(condition, arr) Return the elements of an array that satisfy some condition.
extract_cuts(data[, axis, az_rotation_flag, ...]) It returns the data cuts.
factorial(n[, exact]) n! = special.gamma(n+1)
fft(x[, n, axis, overwrite_x])
fft2(x[, shape, axes, overwrite_x])
fftconvolve(in1, in2[, mode]) Convolve two N-dimensional arrays using FFT. See convolve.
fftn(x[, shape, axes, overwrite_x]) fftn(x, shape=None, axes=None, overwrite_x=0) -> y
filtfilt(b, a, x)
flattop(M[, sym]) The M-point Flat top window.
flipud(m) Flip array in the up/down direction.
gaussian(M, std[, sym]) Return a Gaussian window of length M with standard-deviation std.
general_gaussian(M, p, sig[, sym]) Return a window with a generalized Gaussian shape.
get_window(window, Nx[, fftbins]) Return a window of length Nx and type window.
hamming(M[, sym]) The M-point Hamming window.
hann(M[, sym]) The M-point Hanning window.
hanning(M[, sym]) The M-point Hanning window.
hilbert(x[, N]) Compute the analytic signal.
hilbert2(x[, N]) Compute the ‘2-D’ analytic signal of x of length N.
ifft(x[, n, axis, overwrite_x]) ifft(x, n=None, axis=-1, overwrite_x=0) -> y
ifft2(x[, shape, axes, overwrite_x]) ifft2(x, shape=None, axes=(-2,-1), overwrite_x=0) -> y
ifftn(x[, shape, axes, overwrite_x]) ifftn(x, s=None, axes=None, overwrite_x=0) -> y
ifftshift(x[, axes]) Inverse of fftshift.
interpolate2d(input_matrix[, ...]) Returns the input matrix interpolated by a factor.
invres(r, p, k[, tol, rtype]) Compute b(s) and a(s) from partial fraction expansion: r,p,k
invresz(r, p, k[, tol, rtype]) Compute b(z) and a(z) from partial fraction expansion: r,p,k
irf_shape_1d(input_array[, resolution]) Return the IRF Shape -6dB/-3dB and -10dB/-3dB.
irf_shape_2d(input_matrix[, resolution]) Return the IRF Shape -6dB/-3dB and -10dB/-3dB ratios along X and
iscomplexobj(x) Return True if x is a complex type or an array of complex numbers.
islr_1d(input_array[, resolution]) Return [ISLR, Main lobe energy, Side lobe energy].
islr_2d(input_matrix[, resolution]) Return the 2 dimensional - ISLR Integrated Side Lobe Ratio parameter.
isscalar(num) Returns True if the type of num is a scalar type.
kaiser(M, beta[, sym]) Return a Kaiser window of length M with shape parameter beta.
lfilter(b, a, x[, axis, zi]) Filter data along one-dimension with an IIR or FIR filter.
lfilter_zi(b, a)
lfiltic(b, a, y[, x]) Given a linear filter (b,a) and initial conditions on the output y and the input x, return the inital conditions on the state vector zi which is used by lfilter to generate the output given the input.
linspace(start, stop[, num, endpoint, retstep]) Return evenly spaced numbers over a specified interval.
local_maxima(input_array) Return the two arrays with the positions and corresponding values of the local maxima computed on the input array.
local_maxima_tpz(input_array[, max_index]) Return the 4 1d arrays with the positions and corresponding values of the local maxima on the left and on the right side of the absolute array maximum.
main_lobe_width(v[, factor, precision, kind]) Returns the main lobe width of the input array.
main_lobe_width2(v[, factor, precision, kind]) Returns the main lobe width of the input array.
matrix_squint_rotation(input_matrix[, ...]) Return the matrix anti-clockwise rotated according to the angle value.
matrix_squint_rotation2(input_matrix[, ...]) Return the matrix anti-clockwise rotated according to the angle value.
max(a[, axis, out]) Return the maximum along an axis.
mean(a[, axis, dtype, out]) Compute the arithmetic mean along the specified axis.
medfilt(volume[, kernel_size]) Perform a median filter on an N-dimensional array.
medfilt2d(input[, kernel_size]) Median filter two 2-dimensional arrays.
min(a[, axis, out]) Return the minimum along an axis.
nuttall(M[, sym]) A minimum 4-term Blackman-Harris window according to Nuttall.
ones(shape[, dtype, order]) Return a new array of given shape and type, filled with ones.
order_filter(a, domain, rank) Perform an order filter on an N-dimensional array.
parzen(M[, sym]) The M-point Parzen window.
poly(seq_of_zeros) Return polynomial coefficients given a sequence of roots.
polyadd(a1, a2) Returns sum of two polynomials.
polyder(p[, m]) Return the derivative of the specified order of a polynomial.
polydiv(u, v) Returns the quotient and remainder of polynomial division.
polymul(a1, a2) Returns product of two polynomials represented as sequences.
polysub(a1, a2) Returns difference from subtraction of two polynomials input as sequences.
polyval(p, x) Evaluate a polynomial at specific values.
power_balance(data[, fft_flag]) It estimates the central frequency of the input data spectrum.
power_balance2d(data[, axis, fft_flag]) It estimates the central frequency of the input data spectrum.
prod(a[, axis, dtype, out]) Return the product of array elements over a given axis.
product(a[, axis, dtype, out]) Return the product of array elements over a given axis.
pslr_1d(input_array[, resolution, sslr_flag]) Return a tuple with the left and right PSLR.
pslr_2d(input_matrix[, resolution]) Return a tuple with the left and right PSLR value per axis.
radiometric_res(image)
rank(a) Return the number of dimensions of an array.
ravel(a[, order]) Return a flattened array.
real(val) Return the real part of the elements of the array.
real_if_close(a[, tol]) If complex input returns a real array if complex parts are close to zero.
remez(numtaps, bands, desired[, weight, Hz, ...]) Calculate the minimax optimal filter using Remez exchange algorithm.
resample(x, num[, t, axis, window, freq_shift]) Resample to num samples using Fourier method along the given axis.
reshape(a, newshape[, order]) Gives a new shape to an array without changing its data.
residue(b, a[, tol, rtype]) Compute partial-fraction expansion of b(s) / a(s).
residuez(b, a[, tol, rtype]) Compute partial-fraction expansion of b(z) / a(z).
resolution1d(v[, precision, kind]) Returns the resolution of the input array.
resolution2d(input_matrix[, precision, kind]) Returns the resolution of the input matrix in x and y direction.
roots(p) Return the roots of a polynomial with coefficients given in p.
scipy_fft(x[, n, axis, overwrite_x]) Return discrete Fourier transform of arbitrary type sequence x.
scipy_fft2(x[, shape, axes, overwrite_x]) fft2(x, shape=None, axes=(-2,-1), overwrite_x=0) -> y
size(a[, axis]) Return the number of elements along a given axis.
slepian(M, width[, sym]) Return the M-point slepian window.
smooth_image(im)
sort(a[, axis, kind, order]) Return a sorted copy of an array.
sslr_1d(input_array[, resolution]) Return a tuple with the left and right SSLR value (respect of the absolute
sslr_2d(input_matrix[, resolution]) Return a tuple with the left and right SSLR value per axis.
sum(a[, axis, dtype, out]) Return the sum of array elements over a given axis.
take(a, indices[, axis, out, mode]) Take elements from an array along an axis.
target_measures(data[, az_rotation_flag, ...]) It computes all the target analisys parameters.
transpose(a[, axes]) Permute the dimensions of an array.
triang(M[, sym]) The M-point triangular window.
unique(x) Return the sorted, unique elements of an array or sequence.
unique_roots(p[, tol, rtype]) Determine the unique roots and their multiplicities in two lists
where where(condition, [x, y])
wiener(im[, mysize, noise]) Perform a Wiener filter on an N-dimensional array.
zeropadding1d(X, num[, shift]) Returns the num-length input array zero padded.
zeropadding2d(X, num[, axis, shift]) Returns the input 2-d array zero padded along the input axis.
zeros zeros(shape, dtype=float, order=’C’)

Classes

OrderedDict(*args, **kwds)
qa.qacore.compute_image_stats(image)

Compute simple image statistics.

Input :
  • image
Output :
  • a ordered dictionary containing: size, min, max, mean, stddev, coefficient of variation
qa.qacore.compute_radiometric_stats(image)

Compute simple radiometric statistics.

Input :
  • image
Output :
  • a ordered dictionary containing: radiometric resolution, enl
qa.qacore.enl(image)
qa.qacore.extract_cuts(data, axis=0, az_rotation_flag=False, rg_rotation_flag=False, az_rot_angle=None, rg_rot_angle=None)

It returns the data cuts.

Parameters :
  • data : 2d matrix

  • axis: it it specifies the axis along which the algorithm must be perfomed

    • axis == 0: zero padding along the columns (azimuth)
    • axis == 1: zero padding along the rows (range)
Output :(row cut, column cut) == (azimuth cut, range cut)
qa.qacore.fft(x, n=None, axis=-1, overwrite_x=0)
qa.qacore.fft2(x, shape=None, axes=(-2, -1), overwrite_x=0)
qa.qacore.interpolate2d(input_matrix, interpolation_factor=[, 8.0, 8.0], dc_range_coeff=None, dc_azimuth_coeff=None)

Returns the input matrix interpolated by a factor.

Parameters :
  • input_matrix: bidimensional matrix of values for the input waves form.
  • interpolation_factor: 2 element tuple which contains the interpolation factor along the X and Y axis
  • dc_range_coeff: normalized Doppler centroid shift in range
  • dc_azimuth_coeff: normalized Doppler centroid shift in azimuth

Note

the interpolation of the input matrix as result of the application of the Fourier (zero padding) 2D interpolation.

qa.qacore.irf_shape_1d(input_array, resolution=None)

Return the IRF Shape -6dB/-3dB and -10dB/-3dB.

Parameters :
  • input_array : 1-d array
  • resolution: (optional) in case it is not set, then it is computed.
Output :
  • [IRF Shape -6dB/-3dB, IRF Shape -10dB/-3dB]

Note

estimate the ratio of the resolution measured at two different attenuation levels of the main lobe. The output result is a tuple containing the IRF Shape -6dB/-3dB and -10dB/-3dB ratios. In case of unattended values of resolution, it returns None.

qa.qacore.irf_shape_2d(input_matrix, resolution=None)

Return the IRF Shape -6dB/-3dB and -10dB/-3dB ratios along X and Y axis around the absolute maximum value.

Parameters :
  • input_matrix : 2-d array
  • resolution: (optional) [res_X, res_Y]; in case it is not set, then it is computed.
Output :
  • [X axis IRF Shape -6dB/-3dB , X axis IRF Shape -10dB/-3dB, Y axis IRF Shape -6dB/-3dB , Y axis IRF Shape -10dB/-3dB]

Note

estimate the ratio of the resolution measured at two different attenuation levels of the main lobe. The output result is a tuple containing the IRF Shape -6dB/-3dB and -10dB/-3dB ratios along X and Y axis. In case of unattended values of resolution, it returns None.

qa.qacore.islr_1d(input_array, resolution=None)

Return [ISLR, Main lobe energy, Side lobe energy].

Parameters :
  • input_array : 1-d array
  • resolution: (optional) in case it is not set, then it is computed.
Output :
  • ISLR [dB]: Integrated Side Lobe Ratio

  • Main Lobe Energy: energy in [peak pos - res: peak pos + res]

  • Side Lobe Energy: energy in the side lobes commputed as the total energy

    defined in [peak pos - 10*res: peak pos + 10*res] minus the Main Lobe Energy

Note

compute the ratio of the energy in the side lobes (outside 2 resolution cells and within 20 resolution cells from the absolute maximum) to the energy of the main lobe. In case the input array dimension is not enough to compute the ISLR, the value is set to None.

qa.qacore.islr_2d(input_matrix, resolution=None)

Return the 2 dimensional - ISLR Integrated Side Lobe Ratio parameter.

Parameters :
  • input_matrix : 2-d array
  • resolution: (optional) [res_X, res_Y]; in case it is not set, then it is computed.
Output :
  • [ISLR_dB along X axis, ISLR_dB along Y axis, ISLR_dB 2-dimensional]

Note

compute the ratio of the energy in the side lobes (outside a box of 2x2 resolution cells and within a box of 20x20 resolution cells from the absolute maximum) to the energy of the main lobe. In case the input array dimension is not enough to compute the ISLR values, it returns None.

qa.qacore.local_maxima(input_array)

Return the two arrays with the positions and corresponding values of the local maxima computed on the input array.

Parameters :
  • input_array : 1-d array

Note

the function calculates the first derivative and the second derivative of the input array function. The local maxima are detected finding the zeros of the first derivative function with the correspondent value of the second derivative lower than zero. if (f’(x) == 0) and (f’‘(x)<0) then x = x_max

qa.qacore.local_maxima_tpz(input_array, max_index=None)

Return the 4 1d arrays with the positions and corresponding values of the local maxima on the left and on the right side of the absolute array maximum.

Parameters :
  • input_array : 1 dimension array
  • max_index : posizion of the absolute maximum value of the input array
Output :
  • left_maxima_indices: indices of the local maxima at the left side of the absolute maximum
  • left_local_maxima: values of the local maxima at the left side of the absolute maximum
  • right_maxima_indices: indices of the local maxima at the right side of the absolute maximum
  • right_local_maxima: values of the local maxima at the right side of the absolute maximum

Note

the function implements an iterative method to find out the local maxima.

qa.qacore.main_lobe_width(v, factor=0.5, precision=1000.0, kind='cubic')

Returns the main lobe width of the input array.

Parameters :
  • v: array (one dimensional only) of values for the input wave form.
  • factor: reduction factor to estimate the boundaries of the main lobe.
  • precision: precision of the measure.
  • kind: kind of interpolation.
Output :
  • main lobe width: scalar value.

Note

the main lobe width is computed considering as:: limit values = peak value * factor.

qa.qacore.main_lobe_width2(v, factor=0.5, precision=1000.0, kind=None)

Returns the main lobe width of the input array.

Parameters :
  • v: array (one dimensional only) of values for the input wave form.
  • factor: reduction factor to estimate the boundaries of the main lobe
  • precision: precision of the measure.
Output :
  • main lobe width: scalar value.

Note

the main lobe width is computed considering as:: limit values = peak value * factor.

qa.qacore.matrix_squint_rotation(input_matrix, angle=None, axis=1)

Return the matrix anti-clockwise rotated according to the angle value.

Parameters :
  • input_matrix : 2-d array

  • angle: the rotation angle in degrees (optional).

    In case it is not set, then it is computed*.

  • axis: axis to be consider for squint rotation

    ‘1’: range direction ‘0’: azimuth direction

Output :
  • the input matrix is anti-clockwise rotated according to the angle value

Note

in case the squint angle is not set, then it is computed by a fitting algorithm which aims to find the angle rotation introduced by the squint.

qa.qacore.matrix_squint_rotation2(input_matrix, angle=None, axis=1)

Return the matrix anti-clockwise rotated according to the angle value.

Parameters :
  • input_matrix : 2-d array

  • angle: the rotation angle in degrees (optional).

    In case it is not set, then it is computed*.

  • axis: axis to be consider for squint rotation

    ‘1’: range direction ‘0’: azimuth direction

Output :
  • the input matrix is anti-clockwise rotated according to the angle value

Note

in case the squint angle is not set, then it is computed by a fitting algorithm which aims to find the angle rotation introduced by the squint.

qa.qacore.power_balance(data, fft_flag=False)

It estimates the central frequency of the input data spectrum.

Parameters :

data : 1d array - it can be a time domain signal or a signal spectrum fft_flag : boolean value

  • True: the data input is already in fft domain (spectrum)
  • False: the dat input is a time domain signal
Output :The cetral frequency of the data spectrum expressed as sample index.
qa.qacore.power_balance2d(data, axis=0, fft_flag=False)

It estimates the central frequency of the input data spectrum.

Parameters :
  • data : 2d array - it can be a time domain signal or a signal spectrum

  • axis: it it specifies the axis along which the algorithm must be perfomed
    • axis == 0: zero padding along the columns (azimuth)
    • axis == 1: zero padding along the rows (range)
  • fft_flag : boolean value
    • True: the data input is already in fft domain (spectrum)
    • False: the dat input is a time domain signal
Output :The cetral frequency of the data spectrum expressed as sample index.
qa.qacore.pslr_1d(input_array, resolution=None, sslr_flag=False)

Return a tuple with the left and right PSLR.

Parameters :
  • input_array : 1-d array
  • resolution: (optional) in case it is not set, then it is computed
  • sslr_flag: if set to True, it computes the SSLR value instead of PSLR
Output :
  • [PSLR left side, PSLR right side]

Note

in case the PSLR can not be computed, the value is set to None. The definition of PSLR has been taken from document CSM-UGS-STD-SPE-0084-2.1 pg.43.

qa.qacore.pslr_2d(input_matrix, resolution=None)

Return a tuple with the left and right PSLR value per axis.

Parameters :
  • input_matrix : 2-d array

  • resolution: (optional) it should be an array of two elements -

    [X axis resolution, Y axis resolution]. In case it is not set, then it is computed

Output :
  • [X axis PSLR left, X axis PSLR right, Y axis PSLR left, Y axis PSLR right]

Note

the PSRL value is computed respect to the absolute maximum value of the input matrix, which must be bidimensional. In case the PSLR can not be computed, the value is set to None.

qa.qacore.radiometric_res(image)
qa.qacore.resample(x, num, t=None, axis=0, window=None, freq_shift=0)

Resample to num samples using Fourier method along the given axis.

Parameters :
  • x: input array (multidimensional)

  • num: output length of the resampled array along the given axis

  • t: see Notes (it’s forced to None if freq_shift != 0.0)

  • axis: axis along which the resampling operation is performed
    • axis == 0: zero padding along the columns (azimuth)
    • axis == 1: zero padding along the rows (range)
  • window: see Notes

  • freq_shift: normalized frequecy shift of the spectrum (not base band

    spectrum), it can be an array of shift positions.

Output :
  • array (multidimensional) resampled along the given axis

Note

the resampled signal starts at the same value of x but is sampled with a spacing of len(x) / num * (spacing of x). Because a Fourier method is used, the signal is assumed periodic.

Window controls a Fourier-domain window that tapers the Fourier spectrum before zero-padding to aleviate ringing in the resampled values for sampled signals you didn’t intend to be interpreted as band-limited.

If window is a string then use the named window. If window is a float, then it represents a value of beta for a kaiser window. If window is a tuple, then the first component is a string representing the window, and the next arguments are parameters for that window.

Possible windows are:

‘blackman’ (‘black’, ‘blk’) ‘hamming’ (‘hamm’, ‘ham’) ‘bartlett’ (‘bart’, ‘brt’) ‘hanning’ (‘hann’, ‘han’) ‘kaiser’ (‘ksr’) # requires parameter (beta) ‘gaussian’ (‘gauss’, ‘gss’) # requires parameter (std.) ‘general gauss’ (‘general’, ‘ggs’) # requires two parameters

(power, width)

The first sample of the returned vector is the same as the first sample of the input vector, the spacing between samples is changed from dx to

dx * len(x) / num

If t is not None, then it represents the old sample positions, and the new sample positions will be returned as well as the new samples.

qa.qacore.resolution1d(v, precision=1000.0, kind='cubic')

Returns the resolution of the input array.

Parameters :
  • v: array (one dimensional only) of values for the input waves form.

    The waveform must be passed as amplitude values. It can be a complex array.

  • kind: kind of interpolation

Output :
  • Resolution: scalar value

Note

the resolution is computed as the main lobe peak width at -3dB.

qa.qacore.resolution2d(input_matrix, precision=1000.0, kind='cubic')

Returns the resolution of the input matrix in x and y direction.

Parameters :
  • input_matrix: bidimensional matrix of values for the input waves form.

    The waveform must be passed as amplitude values. It can be a complex matrix.

  • precision: the required precision of the measure

  • kind: kind of interpolation

Output :
  • [resolution along X axis, resolution along Y axis]: a 2 element tuple.

Note

the resolution is computed as the main lobe peak width at -3dB along both X and Y axis.

qa.qacore.smooth_image(im)
qa.qacore.sslr_1d(input_array, resolution=None)

Return a tuple with the left and right SSLR value (respect of the absolute maximum of the input array).

Parameters :
  • input_array : 1-d array
  • resolution: (optional) in case it is not set, then it is computed
  • sslr_flag: if set to True, it computes the SSLR value instead of PSLR
Output :
  • [SSLR left side, SSLR right side]

Note

in case the SSLR can not be computed, the value is set to None.

qa.qacore.sslr_2d(input_matrix, resolution=None)

Return a tuple with the left and right SSLR value per axis.

Parameters :
  • input_matrix : 2-d array
  • resolution: (optional) it should be an array of two elements [X axis resolution, Y axis resolution]. In case it is not set, then it is computed.
Output :
  • [X axis PSLR left, X axis PSLR right, Y axis PSLR left, Y axis PSLR right]

Note

the PSRL value is computed respect to the absolute maximum value of the input matrix, which must be bidimensional. In case the PSLR can not be computed, the value is set to None.

qa.qacore.target_measures(data, az_rotation_flag=False, rg_rotation_flag=False, az_rot_angle=None, rg_rot_angle=None, interp_factor=1.0, ulbasepos=(0, 0), pixel_spacings=(None, None), incidence_angle=None, productType=None)

It computes all the target analisys parameters.

Parameters :
  • data : 2d matrix - input interpolated data
  • az_rotation_flag
  • rg_rotation_flag
  • az_rot_angle
  • rg_rot_angle
  • interp_factor
  • ulbasepos
  • pixel_spacings
  • incidence angle [deg]
  • productType
Output :
  • Quality analisys parameters
qa.qacore.zeropadding1d(X, num, shift=0.0)

Returns the num-length input array zero padded.

Parameters :
  • X: 1d array.
  • num: int output length of the X array
  • shift: normalized frequency shift of the spectrum

Note

the zero padding fills up the output array till reaching the length ‘num’. The zeros will be inserted in:

  • (N+1)/2 + shift*N from the left side
  • -(N-1)/2 + shift*N from the right side
qa.qacore.zeropadding2d(X, num, axis=1, shift=0.0)

Returns the input 2-d array zero padded along the input axis.

Parameters :
  • X: 2d array.

  • num: int output length of the X array along the input axis.

  • axis: int the axis along which to perform the zero padding [0,1].
    • axis == 0: zero padding along the columns (azimuth)
    • axis == 1: zero padding along the rows (range)
  • shift: array of normalized frequency shift of the spectrum; it can be

    a single value in case a costant shift is required.

Note

the zero padding fills up the output array till reaching the length ‘num’ along the specified axis: in case the axis == 0 then the zero padding is performed along the columns, i.e. the number of rows changes to num; in case the axis == 1 then the zero padding is performed along the rows, i.e. the number of columns changes to num.

Previous topic

qa.info

Next topic

qa.qa_resources

This Page