'''Fit plane through the displacement data.
:returns: Mean of the displacement and slopes in easting coefficients of the fitted plane. The array hold ``[offset_e, offset_n, slope_e, slope_n]``. :rtype: :class:`numpy.ndarray` ''' scene = self.scene msk = num.isfinite(displacement) displacement = displacement[msk]
coords = scene.frame.coordinates[msk.flatten()]
# Add ones for the offset coords = num.hstack(( num.ones_like(coords), coords))
coeffs, res, _, _ = num.linalg.lstsq( coords, displacement, rcond=None)
return coeffs
assert isinstance(demean, bool) self.config.demean = demean self.update()
'''Fit a plane onto the displacement data and substract it
:param demean: Demean the displacement :type demean: bool :param inplace: Replace data of the scene (default: True) :type inplace: bool
:return: ``None`` if ``inplace=True`` else a new Scene :rtype: ``None`` or :class:`~kite.Scene` ''' self._log.debug('De-ramping scene') coeffs = self.get_ramp_coefficients(displacement) coords = self.scene.frame.coordinates
ramp = coeffs[2:] * coords if self.config.demean: ramp += coeffs[:2]
ramp = ramp.sum(axis=1).reshape(displacement.shape)
displacement -= ramp return displacement |