You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

kite

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kite - pypi Package Compare versions

Comparing version
1.5.4
to
1.5.5
test/conftest.py
+2
-2

@@ -24,3 +24,3 @@ name: Build Wheels

- name: Build wheels
uses: pypa/cibuildwheel@v2.8.1
uses: pypa/cibuildwheel@v2.11.4
# to supply options, put them in 'env', like:

@@ -64,3 +64,3 @@ env:

- uses: pypa/gh-action-pypi-publish@v1.5.0
- uses: pypa/gh-action-pypi-publish@v1.6.2
with:

@@ -67,0 +67,0 @@ user: __token__

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v4.3.0
hooks:
- id: check-added-large-files
- id: check-yaml
- id: check-toml
- id: check-json
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: v2.2.2
hooks:
- id: codespell
args: [--write-changes, "-L ure,nd,ue,parms,Ue"]
args: [--write-changes, "-L ure,nd,ue,parms,Ue,lamda"]
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.11.4
hooks:

@@ -21,4 +23,4 @@ - id: isort

- repo: https://github.com/psf/black
rev: 22.6.0
rev: 22.12.0
hooks:
- id: black

@@ -16,3 +16,3 @@ .. _talpa:

The :mod:`~kite.SandboxScene` can hosts different types of displacement source by levering different processing engines, analytical and numerical. The different types of dispalcement source can be mixed within a single sandbox
The :mod:`~kite.SandboxScene` can hosts different types of displacement source by levering different processing engines, analytical and numerical. The different types of displacement source can be mixed within a single sandbox

@@ -19,0 +19,0 @@ 1. Okada Source

Metadata-Version: 2.1
Name: kite
Version: 1.5.4
Version: 1.5.5
Summary: InSAR unwrapped surface displacement processing for earthquake modelling.

@@ -18,3 +18,3 @@ Author-email: Marius Paul Isken <mi@gfz-potsdam.de>, Henriette Sudhaus <hsudhaus@ifg.uni-kiel.de>

Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: C

@@ -25,4 +25,5 @@ Classifier: Operating System :: POSIX

Description-Content-Type: text/markdown
Provides-Extra: formatting
Provides-Extra: gdal
Provides-Extra: development
Provides-Extra: tests
License-File: LICENSE.md

@@ -47,3 +48,11 @@

```
With additional gdal dependency, used for GeoTIFF (GACOS and LiCSAR):
```sh
pip install kite[gdal]
```
## Introduction
This framework is streamlining InSAR displacement processing routines for earthquake inversion through [Pyrocko](https://www.pyrocko.org) and Grond.

@@ -60,5 +69,6 @@

## Citation
Recommended citation for Kite
> Isken, Marius; Sudhaus, Henriette; Heimann, Sebastian; Steinberg, Andreas; Daout, Simon; Vasyura-Bathke, Hannes (2017): Kite - Software for Rapid Earthquake Source Optimisation from InSAR Surface Displacement. V. 0.1. GFZ Data Services. http://doi.org/10.5880/GFZ.2.1.2017.002
> Isken, Marius; Sudhaus, Henriette; Heimann, Sebastian; Steinberg, Andreas; Daout, Simon; Vasyura-Bathke, Hannes (2017): Kite - Software for Rapid Earthquake Source Optimisation from InSAR Surface Displacement. V. 0.1. GFZ Data Services. <http://doi.org/10.5880/GFZ.2.1.2017.002>

@@ -68,5 +78,7 @@ [![DOI](https://img.shields.io/badge/DOI-10.5880%2FGFZ.2.1.2017.002-blue.svg)](http://doi.org/10.5880/GFZ.2.1.2017.002)

# Documentation
Find the documentation at https://pyrocko.org/kite/docs/current/.
Find the documentation at <https://pyrocko.org/kite/docs/current/>.
## Short Example
```python

@@ -73,0 +85,0 @@ from kite import Scene

@@ -1,2 +0,2 @@

numpy>=1.22.0
numpy>=1.17.3
scipy>=1.8.0

@@ -9,7 +9,11 @@ PyQt5>=5.15.7

[formatting]
[development]
flake8
black
pre-commit
[gdal]
gdal>=3.5.0
[tests]
pytest

@@ -133,2 +133,3 @@ .coveralls.yml

test/common.py
test/conftest.py
test/covariance_ref.npy

@@ -135,0 +136,0 @@ test/test_covariance.py

@@ -1,2 +0,2 @@

import numpy as num
import numpy as np
from pyrocko.guts import Tuple

@@ -29,3 +29,3 @@ from scipy import stats

scene = self.scene
rstate = num.random.RandomState(123)
rstate = np.random.RandomState(123)

@@ -42,3 +42,3 @@ while True:

displacement = scene._displacement[rowmin:rowmax, colmin:colmax]
if num.any(displacement):
if np.any(displacement):
return llE, llN, urE, urN

@@ -60,3 +60,3 @@

mask = num.isfinite(displacement)
mask = np.isfinite(displacement)
elevation = elevation[mask]

@@ -63,0 +63,0 @@ displacement = displacement[mask]

@@ -5,3 +5,3 @@ #!/usr/bin/python

import numpy as num
import numpy as np
import scipy as sp

@@ -29,6 +29,6 @@

noise_regimes = [
(1.0 / 2000, num.inf),
(1.0 / 2000, np.inf),
(1.0 / 2000, 1.0 / 500),
(1.0 / 500, 1.0 / 10),
(0, num.inf),
(0, np.inf),
]

@@ -56,3 +56,3 @@

"""
return a * num.exp(-distance / b)
return a * np.exp(-distance / b)

@@ -83,3 +83,3 @@

"""
return a * num.exp(-distance / b) * num.cos((distance - c) / d)
return a * np.exp(-distance / b) * np.cos((distance - c) / d)

@@ -110,3 +110,3 @@

shape=(None,),
dtype=num.float,
dtype=float,
serialize_as="list",

@@ -143,3 +143,3 @@ optional=True,

covariance_matrix = Array.T(
dtype=num.float,
dtype=float,
optional=True,

@@ -271,3 +271,3 @@ serialize_as="base64",

def noise_coord(self, values):
self.config.noise_coord = num.array(values)
self.config.noise_coord = np.array(values)

@@ -324,3 +324,3 @@ @property

data = derampMatrix(trimMatrix(data))
data[num.isnan(data)] = 0.0
data[np.isnan(data)] = 0.0
self._noise_data = data

@@ -378,7 +378,7 @@ self._clear()

def costFunction(n):
nl = num.log2(n.length) / num.log2(lmax)
nl = np.log2(n.length) / np.log2(lmax)
ns = n.std / stdmax
return nl * (1.0 - ns) * (1.0 - n.nan_fraction)
fitness = num.array([costFunction(n) for n in node_selection])
fitness = np.array([costFunction(n) for n in node_selection])

@@ -388,3 +388,3 @@ self._log.debug(

)
node = node_selection[num.argmin(fitness)]
node = node_selection[np.argmin(fitness)]
return node

@@ -427,3 +427,3 @@

"""
if not isinstance(self.config.covariance_matrix, num.ndarray):
if not isinstance(self.config.covariance_matrix, np.ndarray):
self.config.covariance_matrix = self._calcCovarianceMatrix(method="full")

@@ -446,3 +446,3 @@ self.evChanged.notify()

distance only. Fast, use for intermediate steps only and
finallly use approach :attr:`~kite.Covariance.covariance_matrix`.
finally use approach :attr:`~kite.Covariance.covariance_matrix`.

@@ -463,3 +463,3 @@ :type: :class:`numpy.ndarray`,

"""
return num.linalg.inv(self.covariance_matrix)
return np.linalg.inv(self.covariance_matrix)

@@ -474,3 +474,3 @@ @property_cached

"""
incov = num.linalg.inv(self.covariance_matrix)
incov = np.linalg.inv(self.covariance_matrix)
return sp.linalg.sqrtm(incov)

@@ -488,6 +488,6 @@

try:
return num.linalg.inv(self.covariance_matrix_focal)
except num.linalg.LinAlgError as e:
return np.linalg.inv(self.covariance_matrix_focal)
except np.linalg.LinAlgError as e:
self._log.exception(e)
return num.eye(self.covariance_matrix_focal.shape[0])
return np.eye(self.covariance_matrix_focal.shape[0])

@@ -500,3 +500,3 @@ @property_cached

"""
return num.sum(self.weight_matrix, axis=1)
return np.sum(self.weight_matrix, axis=1)

@@ -510,3 +510,3 @@ @property_cached

"""
return num.sum(self.weight_matrix_focal, axis=1)
return np.sum(self.weight_matrix_focal, axis=1)

@@ -536,5 +536,5 @@ def _calcCovarianceMatrix(self, method="focal", nthreads=None):

coords = self.quadtree.leaf_focal_points_meter
dist_matrix = num.sqrt(
(coords[:, 0] - coords[:, 0, num.newaxis]) ** 2
+ (coords[:, 1] - coords[:, 1, num.newaxis]) ** 2
dist_matrix = np.sqrt(
(coords[:, 0] - coords[:, 0, np.newaxis]) ** 2
+ (coords[:, 1] - coords[:, 1, np.newaxis]) ** 2
)

@@ -551,9 +551,9 @@ cov_matrix = model(dist_matrix, *self.covariance_model)

variance += self.quadtree.leaf_mean_px_var
num.fill_diagonal(cov_matrix, variance)
np.fill_diagonal(cov_matrix, variance)
for nx, ny in num.nditer(num.triu_indices_from(dist_matrix)):
for nx, ny in np.nditer(np.triu_indices_from(dist_matrix)):
self._mapLeaves(nx, ny)
elif method == "full":
leaf_map = num.empty((len(self.quadtree.leaves), 4), dtype=num.uint32)
leaf_map = np.empty((len(self.quadtree.leaves), 4), dtype=np.uint32)
for nl, leaf in enumerate(self.quadtree.leaves):

@@ -584,3 +584,3 @@ leaf, _ = self._mapLeaves(nl, nl)

cov_matrix[
num.diag_indices_from(cov_matrix)
np.diag_indices_from(cov_matrix)
] += self.quadtree.leaf_mean_px_var

@@ -604,7 +604,7 @@

try:
chol_decomp = num.linalg.cholesky(matrix)
except num.linalg.linalg.LinAlgError:
chol_decomp = np.linalg.cholesky(matrix)
except np.linalg.linalg.LinAlgError:
pos_def = False
else:
pos_def = ~num.all(num.iscomplex(chol_decomp))
pos_def = ~np.all(np.iscomplex(chol_decomp))
finally:

@@ -617,3 +617,3 @@ if not pos_def:

def _leafFocalDistance(leaf1, leaf2):
return num.sqrt(
return np.sqrt(
(leaf1.focal_point[0] - leaf2.focal_point[0]) ** 2

@@ -666,3 +666,3 @@ + (leaf1.focal_point[1] - leaf2.focal_point[1]) ** 2

weight_mat = self.weight_matrix_focal
return num.mean(weight_mat, axis=0)[nl]
return np.mean(weight_mat, axis=0)[nl]

@@ -700,18 +700,18 @@ def syntheticNoise(

if rstate is None:
rstate = num.random.RandomState()
rstate = np.random.RandomState()
rfield = rstate.rand(nN, nE)
spec = num.fft.fft2(rfield)
spec = np.fft.fft2(rfield)
if not dEdN:
dE, dN = (self.scene.frame.dEmeter, self.scene.frame.dNmeter)
kE = num.fft.fftfreq(nE, dE)
kN = num.fft.fftfreq(nN, dN)
k_rad = num.sqrt(kN[:, num.newaxis] ** 2 + kE[num.newaxis, :] ** 2)
kE = np.fft.fftfreq(nE, dE)
kN = np.fft.fftfreq(nN, dN)
k_rad = np.sqrt(kN[:, np.newaxis] ** 2 + kE[np.newaxis, :] ** 2)
amp = num.zeros_like(k_rad)
amp = np.zeros_like(k_rad)
if not anisotropic:
noise_pspec, k, _, _, _, _ = self.powerspecNoise2D()
k_bin = num.insert(k + k[0] / 2, 0, 0)
k_bin = np.insert(k + k[0] / 2, 0, 0)

@@ -721,28 +721,28 @@ for i in range(k.size):

k_max = k_bin[i + 1]
r = num.logical_and(k_rad > k_min, k_rad <= k_max)
r = np.logical_and(k_rad > k_min, k_rad <= k_max)
if i == (k.size - 1):
r = k_rad > k_min
if not num.any(r):
if not np.any(r):
continue
amp[r] = noise_pspec[i]
amp[k_rad == 0.0] = self.variance
amp[k_rad > k.max()] = noise_pspec[num.argmax(k)]
amp = num.sqrt(amp * self.noise_data.size * num.pi * 4)
amp[k_rad > k.max()] = noise_pspec[np.argmax(k)]
amp = np.sqrt(amp * self.noise_data.size * np.pi * 4)
elif anisotropic:
interp_pspec, _, _, _, skE, skN = self.powerspecNoise3D()
kE = num.fft.fftshift(kE)
kN = num.fft.fftshift(kN)
make = num.logical_and(kE >= skE.min(), kE <= skE.max())
mkN = num.logical_and(kN >= skN.min(), kN <= skN.max())
mkRad = num.where( # noqa
k_rad < num.sqrt(kN[mkN].max() ** 2 + kE[make].max() ** 2)
kE = np.fft.fftshift(kE)
kN = np.fft.fftshift(kN)
make = np.logical_and(kE >= skE.min(), kE <= skE.max())
mkN = np.logical_and(kN >= skN.min(), kN <= skN.max())
mkRad = np.where( # noqa
k_rad < np.sqrt(kN[mkN].max() ** 2 + kE[make].max() ** 2)
)
res = interp_pspec(kN[mkN, num.newaxis], kE[num.newaxis, make], grid=True)
res = interp_pspec(kN[mkN, np.newaxis], kE[np.newaxis, make], grid=True)
amp = res
amp = num.fft.fftshift(amp)
amp = np.fft.fftshift(amp)
spec *= amp
noise = num.abs(num.fft.ifft2(spec))
noise -= num.mean(noise)
noise = np.abs(np.fft.ifft2(spec))
noise -= np.mean(noise)

@@ -752,3 +752,3 @@ # remove shape % 2 padding

def getQuadtreeNoise(self, rstate=None, gather=num.nanmedian):
def getQuadtreeNoise(self, rstate=None, gather=np.nanmedian):
"""Create noise for a :class:`~kite.quadtree.Quadtree`

@@ -760,3 +760,3 @@

:param gather: Function gathering leaf's noise realisation,
defaults to num.median.
defaults to np.median.
:type normalisation: callable, optional

@@ -771,4 +771,4 @@ :returns: Array of noise level at each quadtree leaf.

)
syn_noise[self.scene.displacement_mask] = num.nan
noise_quadtree_arr = num.full(qt.nleaves, num.nan)
syn_noise[self.scene.displacement_mask] = np.nan
noise_quadtree_arr = np.full(qt.nleaves, np.nan)

@@ -815,10 +815,10 @@ for il, lv in enumerate(qt.leaves):

# noise = squareMatrix(noise)
shift = num.fft.fftshift
shift = np.fft.fftshift
spectrum = shift(num.fft.fft2(noise, axes=(0, 1), norm=None))
power_spec = (num.abs(spectrum) / spectrum.size) ** 2
spectrum = shift(np.fft.fft2(noise, axes=(0, 1), norm=None))
power_spec = (np.abs(spectrum) / spectrum.size) ** 2
kE = shift(num.fft.fftfreq(power_spec.shape[1], d=self.quadtree.frame.dEmeter))
kN = shift(num.fft.fftfreq(power_spec.shape[0], d=self.quadtree.frame.dNmeter))
k_rad = num.sqrt(kN[:, num.newaxis] ** 2 + kE[num.newaxis, :] ** 2)
kE = shift(np.fft.fftfreq(power_spec.shape[1], d=self.quadtree.frame.dEmeter))
kN = shift(np.fft.fftfreq(power_spec.shape[0], d=self.quadtree.frame.dNmeter))
k_rad = np.sqrt(kN[:, np.newaxis] ** 2 + kE[np.newaxis, :] ** 2)
power_spec[k_rad == 0.0] = 0.0

@@ -829,23 +829,23 @@

# def power1d(k):
# theta = num.linspace(-num.pi, num.pi, ndeg, False)
# power = num.empty_like(k)
# theta = np.linspace(-np.pi, np.pi, ndeg, False)
# power = np.empty_like(k)
# for i in range(k.size):
# kE = num.cos(theta) * k[i]
# kN = num.sin(theta) * k[i]
# power[i] = num.median(power_interp.ev(kN, kE)) * k[i]\
# * num.pi * 4
# kE = np.cos(theta) * k[i]
# kN = np.sin(theta) * k[i]
# power[i] = np.median(power_interp.ev(kN, kE)) * k[i]\
# * np.pi * 4
# return power
def power1d(k):
theta = num.linspace(-num.pi, num.pi, ndeg, False)
power = num.empty_like(k)
theta = np.linspace(-np.pi, np.pi, ndeg, False)
power = np.empty_like(k)
cos_theta = num.cos(theta)
sin_theta = num.sin(theta)
cos_theta = np.cos(theta)
sin_theta = np.sin(theta)
for i in range(k.size):
kE = cos_theta * k[i]
kN = sin_theta * k[i]
power[i] = num.mean(power_interp.ev(kN, kE))
power[i] = np.mean(power_interp.ev(kN, kE))
power *= 2 * num.pi
power *= 2 * np.pi
return power

@@ -855,11 +855,11 @@

"""Mean 2D Power works!"""
theta = num.linspace(-num.pi, num.pi, ndeg, False)
power = num.empty_like(k)
theta = np.linspace(-np.pi, np.pi, ndeg, False)
power = np.empty_like(k)
cos_theta = num.cos(theta)
sin_theta = num.sin(theta)
cos_theta = np.cos(theta)
sin_theta = np.sin(theta)
for i in range(k.size):
kE = sin_theta * k[i]
kN = cos_theta * k[i]
power[i] = num.median(power_interp.ev(kN, kE))
power[i] = np.median(power_interp.ev(kN, kE))
# Median is more stable than the mean here

@@ -878,4 +878,4 @@

k_rad = num.sqrt(kN[:, num.newaxis] ** 2 + kE[num.newaxis, :] ** 2)
k = num.linspace(k_rad[k_rad > 0].min(), k_rad.max(), nk)
k_rad = np.sqrt(kN[:, np.newaxis] ** 2 + kE[np.newaxis, :] ** 2)
k = np.linspace(k_rad[k_rad > 0].min(), k_rad.max(), nk)
dk = 1.0 / (k[1] - k[0]) / (2 * nk)

@@ -937,3 +937,3 @@ return power(k), k, dk, spectrum, kE, kN

d = num.arange(1, power_spec.size + 1) * dk
d = np.arange(1, power_spec.size + 1) * dk
cov = self._powerCosineTransform(power_spec)

@@ -956,3 +956,3 @@

max_distance = min(abs(grdE.min() - grdE.max()), abs(grdN.min() - grdN.max()))
dist_bins = num.linspace(0, max_distance, nbins + 1)
dist_bins = np.linspace(0, max_distance, nbins + 1)

@@ -963,3 +963,3 @@ grdE = grdE.ravel()

# Select random coordinates
rstate = num.random.RandomState(noise_data.size)
rstate = np.random.RandomState(noise_data.size)
rand_idx = rstate.randint(0, noise_data.size, (2, npairs))

@@ -969,3 +969,3 @@ idx0 = rand_idx[0, :]

distances = num.sqrt(
distances = np.sqrt(
(grdN[idx0] - grdN[idx1]) ** 2 + (grdE[idx0] - grdE[idx1]) ** 2

@@ -977,7 +977,7 @@ )

bins = num.digitize(distances, dist_bins, right=True)
bins = np.digitize(distances, dist_bins, right=True)
bin_distances = dist_bins[1:] - dist_bins[1] / 2
covariance = num.full_like(bin_distances, fill_value=num.nan)
variance = num.full_like(bin_distances, fill_value=num.nan)
covariance = np.full_like(bin_distances, fill_value=np.nan)
variance = np.full_like(bin_distances, fill_value=np.nan)

@@ -987,13 +987,13 @@ for ib in range(nbins):

if selection.sum() != 0:
covariance[ib] = num.nanmean(cov_all[selection])
variance[ib] = num.nanmean(vario_all[selection]) / 2
covariance[ib] = np.nanmean(cov_all[selection])
variance[ib] = np.nanmean(vario_all[selection]) / 2
self._structure_spatial = (
variance[~num.isnan(variance)],
bin_distances[~num.isnan(variance)],
variance[~np.isnan(variance)],
bin_distances[~np.isnan(variance)],
)
covariance[0] = num.nan
covariance[0] = np.nan
return (
covariance[~num.isnan(covariance)],
bin_distances[~num.isnan(covariance)],
covariance[~np.isnan(covariance)],
bin_distances[~np.isnan(covariance)],
)

@@ -1031,9 +1031,9 @@

if self.config.model_function == "exponential":
coeff = (num.mean(covariance), num.mean(distance))
coeff = (np.mean(covariance), np.mean(distance))
elif self.config.model_function == "exponential_cosine":
coeff = (
num.mean(covariance),
num.mean(distance),
num.mean(distance) * -0.1,
np.mean(covariance),
np.mean(distance),
np.mean(distance) * -0.1,
0.1,

@@ -1082,3 +1082,3 @@ )

return num.sqrt(num.mean((cov - cov_mod) ** 2))
return np.sqrt(np.mean((cov - cov_mod) ** 2))

@@ -1099,9 +1099,9 @@ @property_cached

power_spec, k, dk, _, _, _ = self.powerspecNoise1D()
d = num.arange(1, power_spec.size + 1) * dk
d = np.arange(1, power_spec.size + 1) * dk
def structure_spectral(power_spec, d, k):
struc_func = num.zeros_like(k)
struc_func = np.zeros_like(k)
for i, d in enumerate(d):
for ik, tk in enumerate(k):
# struc_func[i] += (1. - num.cos(tk*d))*power_spec[ik]
# struc_func[i] += (1. - np.cos(tk*d))*power_spec[ik]
struc_func[i] += (1.0 - sp.special.j0(tk * d)) * power_spec[ik]

@@ -1155,3 +1155,3 @@ struc_func *= 2.0 / 1

last_20p = -int(structure_spatial.size * 0.2)
self.config.variance = float(num.mean(structure_spatial[(last_20p):]))
self.config.variance = float(np.mean(structure_spatial[(last_20p):]))

@@ -1165,4 +1165,4 @@ elif self.config.variance is None and self.config.sampling_method == "spectral":

# print(spectrum.size)
# print(num.mean(ps[-int(ps.size/9.):-1]))
var = num.median(ps[-int(ps.size / 9.0) :]) + ma
# print(np.mean(ps[-int(ps.size/9.):-1]))
var = np.median(ps[-int(ps.size / 9.0) :]) + ma
self.config.variance = float(var)

@@ -1186,3 +1186,3 @@

header += ", ".join([l.id for l in self.quadtree.leaves])
num.savetxt(filename, self.weight_matrix, header=header)
np.savetxt(filename, self.weight_matrix, header=header)

@@ -1189,0 +1189,0 @@ def get_state_hash(self):

@@ -1,2 +0,2 @@

import numpy as num
import numpy as np
from pyrocko.guts import Bool

@@ -28,3 +28,3 @@

scene = self.scene
msk = num.isfinite(displacement)
msk = np.isfinite(displacement)
displacement = displacement[msk]

@@ -35,5 +35,5 @@

# Add ones for the offset
coords = num.hstack((num.ones_like(coords), coords))
coords = np.hstack((np.ones_like(coords), coords))
coeffs, res, _, _ = num.linalg.lstsq(coords, displacement, rcond=None)
coeffs, res, _, _ = np.linalg.lstsq(coords, displacement, rcond=None)

@@ -40,0 +40,0 @@ return coeffs

@@ -7,3 +7,3 @@ import logging

import numpy as num
import numpy as np
from pyrocko.guts import Bool, List

@@ -88,9 +88,9 @@

idx_rows = row_offset + (num.arange(rows) * dLat // -self.dLat)
idx_cols = col_offset + (num.arange(cols) * dLon // self.dLon)
idx_rows = row_offset + (np.arange(rows) * dLat // -self.dLat)
idx_cols = col_offset + (np.arange(cols) * dLon // self.dLon)
idx_rows = num.repeat(idx_rows, cols).astype(num.intp)
idx_cols = num.tile(idx_cols, rows).astype(num.intp)
idx_rows = np.repeat(idx_rows, cols).astype(np.intp)
idx_cols = np.tile(idx_cols, rows).astype(np.intp)
return num.flipud(self.data[idx_rows, idx_cols].reshape(rows, cols))
return np.flipud(self.data[idx_rows, idx_cols].reshape(rows, cols))

@@ -120,3 +120,3 @@ @classmethod

data = num.memmap(filename, dtype=num.float32, mode="r", shape=(rows, cols))
data = np.memmap(filename, dtype=np.float32, mode="r", shape=(rows, cols))

@@ -217,5 +217,5 @@ return cls(filename, time, data, ulLat, ulLon, dLat, dLon)

correction = self.get_correction()
correction *= 1.0 / num.sin(self.scene.phi)
correction *= 1.0 / np.sin(self.scene.phi)
displacement -= correction
return displacement

@@ -5,3 +5,3 @@ import logging

import matplotlib.pyplot as plt
import numpy as num
import numpy as np
from matplotlib.image import AxesImage

@@ -88,3 +88,3 @@

if self._data is None:
return num.zeros((50, 50))
return np.zeros((50, 50))
return self._data

@@ -155,4 +155,4 @@

"""
vmax = num.nanmax(self.data)
vmin = num.nanmin(self.data)
vmax = np.nanmax(self.data)
vmin = np.nanmin(self.data)
self.colormap_limits = (vmin, vmax)

@@ -256,3 +256,3 @@

def plot(self, component="displacement", **kwargs):
"""Plots any component fom Scene
"""Plots any component from Scene
The following components are recognizes

@@ -458,7 +458,7 @@

cov, d = self._covariance.getCovariance()
var = num.empty_like(d)
var = np.empty_like(d)
var.fill(self.variance)
ax.plot(d, cov)
# d_interp = num.linspace(d.min(), d.max()+10000., num=50)
# d_interp = np.linspace(d.min(), d.max()+10000., num=50)
# ax.plot(d_interp, self._covariance.covariance(d_interp),

@@ -481,3 +481,3 @@ # label='Interpolated', ls='--')

ax.imshow(
num.flipud(noise_data),
np.flipud(noise_data),
aspect="equal",

@@ -493,3 +493,3 @@ extent=(0, noise_coord[2], 0, noise_coord[3]),

svar, d = self._covariance.structure_spatial
var = num.empty_like(d)
var = np.empty_like(d)
var.fill(self.variance)

@@ -515,4 +515,4 @@ ax.plot(d, svar)

# power_spec_x = num.mean(f_spec, axis=1)
# power_spec_y = num.mean(f_spec, axis=0)
# power_spec_x = np.mean(f_spec, axis=1)
# power_spec_y = np.mean(f_spec, axis=0)

@@ -546,3 +546,3 @@ # ax.plot(k_x[k_x > 0], power_spec_x[k_x > 0], label='$k_x$')

def selectRegime(k, d1, d2):
return num.logical_and(((1.0) / k) > d1, ((1.0) / k) < d2)
return np.logical_and(((1.0) / k) > d1, ((1.0) / k) < d2)

@@ -558,3 +558,3 @@ def curve_fit(k, p_spec):

check_finite=True,
bounds=(-num.inf, num.inf),
bounds=(-np.inf, np.inf),
method=None,

@@ -567,3 +567,3 @@ jac=None,

cov = sp.fftpack.dct(ps, type=2, n=None, axis=-1, norm="ortho")
d = num.arange(1, k[k > 0].size + 1) * self.scene.frame.dE
d = np.arange(1, k[k > 0].size + 1) * self.scene.frame.dE
return cov, d

@@ -573,3 +573,3 @@

# Regimes accord. to Hanssen, 2001
reg1 = selectRegime(k_x, 2000.0, num.inf)
reg1 = selectRegime(k_x, 2000.0, np.inf)
reg2 = selectRegime(k_x, 500.0, 2000.0)

@@ -602,4 +602,4 @@ reg3 = selectRegime(k_x, 10.0, 500.0)

self.noise_data = self._covariance.noise_data
clim_max = num.nanmax(self.noise_data)
clim_min = num.nanmin(self.noise_data)
clim_max = np.nanmax(self.noise_data)
clim_min = np.nanmin(self.noise_data)
self.clim = min(abs(clim_max), abs(clim_min))

@@ -634,3 +634,3 @@ self.fig = plt.figure(figsize=(6.692, 3.149))

im = ax.imshow(
num.flipud(self.noise_data),
np.flipud(self.noise_data),
aspect="equal",

@@ -648,3 +648,3 @@ extent=(0, noise_coord[2], 0, noise_coord[3]),

def plotSynthNoise(self, ax):
noise_shape = num.shape(self.noise_data)
noise_shape = np.shape(self.noise_data)
noise_data = self._covariance.syntheticNoise(noise_shape)

@@ -654,3 +654,3 @@ noise_coord = self._covariance.noise_coord

im = ax.imshow(
num.flipud(noise_data),
np.flipud(noise_data),
aspect="equal",

@@ -657,0 +657,0 @@ extent=(0, noise_coord[2], 0, noise_coord[3]),

import time
from hashlib import sha1
import numpy as num
import numpy as np
from pyrocko import guts

@@ -51,3 +51,3 @@ from pyrocko import orthodrome as od

"""
return float(num.sum(self.displacement_mask)) / self.displacement.size
return float(np.sum(self.displacement_mask)) / self.displacement.size

@@ -63,3 +63,3 @@ @property_cached

"""
return float(num.nanmean(self.displacement))
return float(np.nanmean(self.displacement))

@@ -71,3 +71,3 @@ @property_cached

"""
return float(num.nanmedian(self.displacement))
return float(np.nanmedian(self.displacement))

@@ -79,3 +79,3 @@ @property_cached

"""
return float(num.nanstd(self.displacement))
return float(np.nanstd(self.displacement))

@@ -87,3 +87,3 @@ @property_cached

"""
return float(num.nanvar(self.displacement))
return float(np.nanvar(self.displacement))

@@ -96,3 +96,3 @@ @property_cached

if self.displacement_px_var is not None:
return float(num.nanmean(self.displacement_px_var))
return float(np.nanmean(self.displacement_px_var))
return None

@@ -105,3 +105,3 @@

"""
return float(num.nanstd(self.displacement - self.median))
return float(np.nanstd(self.displacement - self.median))

@@ -113,3 +113,3 @@ @property_cached

"""
return float(num.nanstd(self.displacement - self.mean))
return float(np.nanstd(self.displacement - self.mean))

@@ -122,3 +122,3 @@ @property_cached

"""
return float(num.nanstd(derampMatrix(self.displacement)))
return float(np.nanstd(derampMatrix(self.displacement)))

@@ -139,4 +139,4 @@ @property

"""
E = float(num.mean(self.gridE.compressed()) + self.frame.dE / 2)
N = float(num.mean(self.gridN.compressed()) + self.frame.dN / 2)
E = float(np.mean(self.gridE.compressed()) + self.frame.dE / 2)
N = float(np.mean(self.gridN.compressed()) + self.frame.dN / 2)
return E, N

@@ -149,4 +149,4 @@

"""
E = float(num.mean(self.gridEmeter.compressed() + self.frame.dEmeter / 2))
N = float(num.mean(self.gridNmeter.compressed() + self.frame.dNmeter / 2))
E = float(np.mean(self.gridEmeter.compressed() + self.frame.dEmeter / 2))
N = float(np.mean(self.gridNmeter.compressed() + self.frame.dNmeter / 2))
return E, N

@@ -167,4 +167,4 @@

"""
return num.ma.masked_array(
self.displacement, self.displacement_mask, fill_value=num.nan
return np.ma.masked_array(
self.displacement, self.displacement_mask, fill_value=np.nan
)

@@ -182,3 +182,3 @@

"""
return num.isnan(self.displacement)
return np.isnan(self.displacement)

@@ -200,3 +200,3 @@ @property_cached

phi = self.scene.phi[self._slice_rows, self._slice_cols]
return num.nanmedian(phi[~self.displacement_mask])
return np.nanmedian(phi[~self.displacement_mask])

@@ -209,3 +209,3 @@ @property_cached

theta = self.scene.theta[self._slice_rows, self._slice_cols]
return num.nanmedian(theta[~self.displacement_mask])
return np.nanmedian(theta[~self.displacement_mask])

@@ -215,3 +215,3 @@ @property

unitE = self.scene.los_rotation_factors[self._slice_rows, self._slice_cols, 1]
return num.nanmedian(unitE[~self.displacement_mask])
return np.nanmedian(unitE[~self.displacement_mask])

@@ -221,3 +221,3 @@ @property

unitN = self.scene.los_rotation_factors[self._slice_rows, self._slice_cols, 2]
return num.nanmedian(unitN[~self.displacement_mask])
return np.nanmedian(unitN[~self.displacement_mask])

@@ -227,3 +227,3 @@ @property

unitU = self.scene.los_rotation_factors[self._slice_rows, self._slice_cols, 0]
return num.nanmedian(unitU[~self.displacement_mask])
return np.nanmedian(unitU[~self.displacement_mask])

@@ -352,3 +352,3 @@ @property_cached

)
if n.displacement.size == 0 or num.all(n.displacement_mask):
if n.displacement.size == 0 or np.all(n.displacement_mask):
continue

@@ -472,5 +472,5 @@ yield n

# Cached matrices
self._leaf_matrix_means = num.empty_like(self.displacement)
self._leaf_matrix_medians = num.empty_like(self.displacement)
self._leaf_matrix_weights = num.empty_like(self.displacement)
self._leaf_matrix_means = np.empty_like(self.displacement)
self._leaf_matrix_medians = np.empty_like(self.displacement)
self._leaf_matrix_weights = np.empty_like(self.displacement)

@@ -572,3 +572,3 @@ self._log = scene._log.getChild("Quadtree")

npx = max(self.frame.cols, self.frame.rows)
return int(2 ** round(num.log(npx / 64)))
return int(2 ** round(np.log(npx / 64)))

@@ -624,3 +624,3 @@ def _initTree(self):

"""Initial epsilon for virgin tree creation"""
return num.nanstd(self.displacement)
return np.nanstd(self.displacement)

@@ -787,3 +787,3 @@ @property_cached

if self.scene.displacement_px_var is not None:
return num.array([lf.mean_px_var for lf in self.leaves])
return np.array([lf.mean_px_var for lf in self.leaves])
return None

@@ -798,3 +798,3 @@

"""
return num.array([lf.mean for lf in self.leaves])
return np.array([lf.mean for lf in self.leaves])

@@ -808,7 +808,7 @@ @property_cached

"""
return num.array([lf.median for lf in self.leaves])
return np.array([lf.median for lf in self.leaves])
@property
def _leaf_focal_points(self):
return num.array([lf._focal_point for lf in self.leaves])
return np.array([lf._focal_point for lf in self.leaves])

@@ -821,3 +821,3 @@ @property

"""
return num.array([lf.focal_point for lf in self.leaves])
return np.array([lf.focal_point for lf in self.leaves])

@@ -830,3 +830,3 @@ @property

"""
return num.array([lf.focal_point_meter for lf in self.leaves])
return np.array([lf.focal_point_meter for lf in self.leaves])

@@ -845,7 +845,7 @@ @property

"""
distances = num.empty((self.nleaves, 3))
distances = np.empty((self.nleaves, 3))
center = self.center_point
distances[:, 0] = self.leaf_focal_points[:, 0] - center[0]
distances[:, 1] = self.leaf_focal_points[:, 1] - center[1]
distances[:, 2] = num.sqrt(distances[:, 1] ** 2 + distances[:, 1] ** 2)
distances[:, 2] = np.sqrt(distances[:, 1] ** 2 + distances[:, 1] ** 2)
return distances

@@ -867,3 +867,3 @@

"""
return num.array([lf.phi for lf in self.leaves])
return np.array([lf.phi for lf in self.leaves])

@@ -876,3 +876,3 @@ @property

"""
return num.array([lf.theta for lf in self.leaves])
return np.array([lf.theta for lf in self.leaves])

@@ -887,6 +887,6 @@ @property_cached

"""
los_factors = num.empty((self.nleaves, 3))
los_factors[:, 0] = num.sin(self.leaf_thetas)
los_factors[:, 1] = num.cos(self.leaf_thetas) * num.cos(self.leaf_phis)
los_factors[:, 2] = num.cos(self.leaf_thetas) * num.sin(self.leaf_phis)
los_factors = np.empty((self.nleaves, 3))
los_factors[:, 0] = np.sin(self.leaf_thetas)
los_factors[:, 1] = np.cos(self.leaf_thetas) * np.cos(self.leaf_phis)
los_factors[:, 2] = np.cos(self.leaf_thetas) * np.sin(self.leaf_phis)
return los_factors

@@ -926,6 +926,6 @@

array.fill(num.nan)
array.fill(np.nan)
for lf in self.leaves:
array[lf._slice_rows, lf._slice_cols] = self._norm_methods[method](lf)
array[self.scene.displacement_mask] = num.nan
array[self.scene.displacement_mask] = np.nan
return array

@@ -935,3 +935,3 @@

def center_point(self):
return num.median(self.leaf_focal_points, axis=0)
return np.median(self.leaf_focal_points, axis=0)

@@ -959,6 +959,6 @@ @property

"""
if num.all(num.isnan(self.leaf_matrix_means)):
return num.inf
return num.sqrt(
num.nanmean((self.scene.displacement - self.leaf_matrix_means) ** 2)
if np.all(np.isnan(self.leaf_matrix_means)):
return np.inf
return np.sqrt(
np.nanmean((self.scene.displacement - self.leaf_matrix_means) ** 2)
)

@@ -969,6 +969,6 @@

self._base_nodes = []
init_length = num.power(
2, num.ceil(num.log(num.min(self.displacement.shape)) / num.log(2))
init_length = np.power(
2, np.ceil(np.log(np.min(self.displacement.shape)) / np.log(2))
)
nx, ny = num.ceil(num.array(self.displacement.shape) / init_length)
nx, ny = np.ceil(np.array(self.displacement.shape) / init_length)
self._log.debug("Creating %d base nodes", nx * ny)

@@ -1058,3 +1058,3 @@

coords = num.array(
coords = np.array(
[(llN, llE), (llN, urE), (urN, urE), (urN, llE), (llN, llE)]

@@ -1065,3 +1065,3 @@ )

coords = od.ne_to_latlon(self.frame.llLat, self.frame.llLon, *coords.T)
coords = num.array(coords).T
coords = np.array(coords).T

@@ -1105,5 +1105,5 @@ coords = coords[:, [1, 0]].tolist()

for e in num.linspace(0.1, 0.00005, num=30):
for e in np.linspace(0.1, 0.00005, num=30):
sc.quadtree.epsilon = e
# qp = Plot2DQuadTree(qt, cmap='spectral')
# qp.plot()
import time
from os import path as op
import numpy as num
import numpy as np
from pyrocko import guts

@@ -16,4 +16,4 @@ from pyrocko.guts import Int, List, Object, String

km = 1e3
d2r = num.pi / 180.0
r2d = 180.0 / num.pi
d2r = np.pi / 180.0
r2d = 180.0 / np.pi

@@ -77,9 +77,9 @@

self._north = num.zeros((self.rows, self.cols))
self._east = num.zeros_like(self._north)
self._down = num.zeros_like(self._north)
self._north = np.zeros((self.rows, self.cols))
self._east = np.zeros_like(self._north)
self._down = np.zeros_like(self._north)
self.theta = num.zeros_like(self._north)
self.phi = num.zeros_like(self._north)
self.theta.fill(num.pi / 2)
self.theta = np.zeros_like(self._north)
self.phi = np.zeros_like(self._north)
self.theta.fill(np.pi / 2)
self.phi.fill(0.0)

@@ -110,4 +110,4 @@

self.theta = num.full_like(self.theta, theta * r2d)
self.phi = num.full_like(self.phi, phi * r2d)
self.theta = np.full_like(self.theta, theta * r2d)
self.phi = np.full_like(self.phi, phi * r2d)
self.frame.updateExtent()

@@ -152,3 +152,3 @@

"""Maximum horizontal displacement"""
return num.sqrt(self._north**2 + self._east**2).max()
return np.sqrt(self._north**2 + self._east**2).max()

@@ -197,8 +197,8 @@ def addSource(self, source):

if result is None:
result = num.zeros(
result = np.zeros(
self.frame.npixel,
dtype=[
("north", num.float64),
("east", num.float64),
("down", num.float64),
("north", float),
("east", float),
("down", float),
],

@@ -310,3 +310,3 @@ )

if self.reference:
arr[self.reference.scene.displacement_mask] = num.nan
arr[self.reference.scene.displacement_mask] = np.nan

@@ -374,8 +374,8 @@ self.displacement = None

model_result = num.zeros(
model_result = np.zeros(
coordinates.shape[0],
dtype=[
("north", num.float64),
("east", num.float64),
("down", num.float64),
("north", float),
("east", float),
("down", float),
],

@@ -393,3 +393,3 @@ )

mf = (
num.sum(num.abs(quadtree.leaf_medians - model_displacement) ** p) ** 1.0
np.sum(np.abs(quadtree.leaf_medians - model_displacement) ** p) ** 1.0
/ p

@@ -443,10 +443,12 @@ )

def r(lo, hi):
return float(num.random.randint(lo, high=hi, size=1))
return float(np.random.randint(lo, high=hi, size=1))
for s in range(nsources):
for isrc in range(nsources):
length = r(5000, 15000)
sandbox_scene.addSource(
OkadaSource(
easting=r(length, sandbox_scene.frame.E.max() - length),
northing=r(length, sandbox_scene.frame.N.max() - length),
easting=r(sandbox_scene.frame.E.min(), sandbox_scene.frame.E.max()),
northing=r(
sandbox_scene.frame.N.min(), sandbox_scene.frame.N.max()
),
depth=r(0, 8000),

@@ -453,0 +455,0 @@ strike=r(0, 360),

@@ -7,3 +7,3 @@ import glob

import numpy as num
import numpy as np
import scipy.io

@@ -25,3 +25,3 @@ import utm

d2r = num.pi / 180.0
d2r = np.pi / 180.0
km = 1e3

@@ -175,5 +175,5 @@ op = os.path

if io_k in mat_k:
container[io_k] = num.rot90(mat[mat_k])
container[io_k] = np.rot90(mat[mat_k])
elif "ig_" in mat_k:
container.displacement = num.rot90(mat[mat_k])
container.displacement = np.rot90(mat[mat_k])
elif "xx" in mat_k:

@@ -192,6 +192,6 @@ utm_e = mat[mat_k].flatten()

if len(theta0) == 1:
container.theta = num.ones(num.shape(container.displacement)) * theta0
container.theta = np.ones(np.shape(container.displacement)) * theta0
if len(theta0) == 1:
container.phi = num.ones(num.shape(container.displacement)) * phi0
container.phi = np.ones(np.shape(container.displacement)) * phi0

@@ -206,6 +206,6 @@ if utm_zone is None:

if not (num.all(utm_e) or num.all(utm_n)):
if not (np.all(utm_e) or np.all(utm_n)):
self._log.warning("Could not find referencing UTM vectors in .mat file!")
utm_e = num.linspace(100000, 110000, container.displacement.shape[0])
utm_n = num.linspace(1100000, 1110000, container.displacement.shape[1])
utm_e = np.linspace(100000, 110000, container.displacement.shape[0])
utm_n = np.linspace(1100000, 1110000, container.displacement.shape[1])

@@ -216,4 +216,4 @@ if utm_e.min() < 1e4 or utm_n.min() < 1e4:

container.frame.dE = num.abs(utm_e[1] - utm_e[0])
container.frame.dN = num.abs(utm_n[1] - utm_n[0])
container.frame.dE = np.abs(utm_e[1] - utm_e[0])
container.frame.dN = np.abs(utm_n[1] - utm_n[0])
try:

@@ -300,3 +300,3 @@ container.frame.llLat, container.frame.llLon = utm.to_latlon(

if not log:
self._log.info("Found parameter file %s" % file)
self._log.info("Found parameter file %s", file)
return params

@@ -307,5 +307,5 @@

def _getSLCParameters(self, path):
required_params = ["radar_frequency"]
required_params = ("nlines",)
path = op.dirname(op.realpath(path))
par_files = glob.glob("%s/*slc.par" % path)
par_files = glob.glob(f"{path}/*par")

@@ -316,8 +316,8 @@ for file in par_files:

if check_required(required_params, params):
self._log.info("Found SLC parameter file %s" % file)
self._log.info("Found SLC parameter file %s", file)
return params
raise ImportError(
"Could not find SLC parameter file *.slc.par"
" with parameters %s" % required_params
"Could not find SLC parameter file *.par"
f" with parameters {required_params}"
)

@@ -349,3 +349,3 @@

self._log.info("Loading LOS %s from %s" % (pattern, filename))
return num.memmap(filename, mode="r", dtype=">f4")
return np.memmap(filename, mode="r", dtype=">f4")

@@ -369,4 +369,4 @@ def read(self, filename, **kwargs):

params_slc = self._getSLCParameters(par_file)
except ImportError as e:
raise e
except ImportError as exc:
raise exc

@@ -377,14 +377,14 @@ fill = None

nlines = int(params["nlines"])
radar_frequency = float(params_slc.get("radar_frequency", None))
radar_frequency = float(params_slc.get("radar_frequency", 5.405e9)) # Sentinel1
displ = num.fromfile(filename, dtype=">f4")
displ = np.fromfile(filename, dtype=">f4")
# Resize array if last line is not scanned completely
if (displ.size % ncols) != 0:
fill = num.empty(ncols - displ.size % ncols)
fill.fill(num.nan)
displ = num.append(displ, fill)
fill = np.empty(ncols - displ.size % ncols)
fill.fill(np.nan)
displ = np.append(displ, fill)
displ = displ.reshape(nlines, ncols)
displ[displ == -0.0] = num.nan
displ = num.flipud(displ)
displ[displ == -0.0] = np.nan
displ = np.flipud(displ)

@@ -398,3 +398,3 @@ if radar_frequency is not None:

wavelength = util.C / radar_frequency
displ /= -4 * num.pi
displ /= -4 * np.pi
displ *= wavelength

@@ -413,12 +413,12 @@

if isinstance(phi, num.ndarray):
if isinstance(phi, np.ndarray):
phi = phi.reshape(nlines, ncols)
phi = num.flipud(phi)
if isinstance(theta, num.ndarray):
phi = np.flipud(phi)
if isinstance(theta, np.ndarray):
theta = theta.reshape(nlines, ncols)
theta = num.flipud(theta)
theta = np.flipud(theta)
if fill is not None:
theta = num.append(theta, fill)
phi = num.append(phi, fill)
theta = np.append(theta, fill)
phi = np.append(phi, fill)

@@ -460,4 +460,4 @@ container = self.container

utm_e = num.linspace(utm_corn_e, utm_corn_eo, displ.shape[1])
utm_n = num.linspace(utm_corn_n, utm_corn_no, displ.shape[0])
utm_e = np.linspace(utm_corn_e, utm_corn_eo, displ.shape[1])
utm_n = np.linspace(utm_corn_n, utm_corn_no, displ.shape[0])

@@ -591,11 +591,11 @@ llLat, llLon = utm.to_latlon(

look = num.mean(num.array([look_ref1, look_ref2, look_ref3, look_ref4]))
look = np.mean(np.array([look_ref1, look_ref2, look_ref3, look_ref4]))
data = num.memmap(filename, dtype="<f4")
data = np.memmap(filename, dtype="<f4")
data = data.reshape(nlines, ncols * 2)
displ = data[:, ncols:]
displ = num.flipud(displ)
displ[displ == -0.0] = num.nan
displ = displ / (4.0 * num.pi) * wavelength
displ = np.flipud(displ)
displ[displ == -0.0] = np.nan
displ = displ / (4.0 * np.pi) * wavelength

@@ -610,4 +610,4 @@ z_scale = par.get("Z_SCALE", 1.0)

container.displacement = displ
container.theta = num.deg2rad(90.0 - look)
container.phi = num.deg2rad(-heading + 180.0)
container.theta = np.deg2rad(90.0 - look)
container.phi = np.deg2rad(-heading + 180.0)

@@ -764,4 +764,4 @@ container.meta.title = par.get("TITLE", "None")

coord_lat = isce_xml.getProperty("coordinate2")
container.frame.dN = num.abs(coord_lat["delta"])
container.frame.dE = num.abs(coord_lon["delta"])
container.frame.dN = np.abs(coord_lat["delta"])
container.frame.dE = np.abs(coord_lon["delta"])

@@ -775,18 +775,18 @@ nlon = int(coord_lon["size"])

displ = num.memmap(self._getDisplacementFile(path), dtype="<f4").reshape(
displ = np.memmap(self._getDisplacementFile(path), dtype="<f4").reshape(
nlat, nlon * 2
)[:, nlon:]
displ = num.flipud(displ)
displ[displ == 0.0] = num.nan
displ = np.flipud(displ)
displ[displ == 0.0] = np.nan
container.displacement = displ
los_file = self._getLOSFile(path)
los_data = num.fromfile(los_file, dtype="<f4").reshape(nlat * 2, nlon)
los_data = np.fromfile(los_file, dtype="<f4").reshape(nlat * 2, nlon)
theta = num.flipud(los_data[0::2, :])
phi = num.flipud(los_data[1::2, :])
theta = np.flipud(los_data[0::2, :])
phi = np.flipud(los_data[1::2, :])
def los_is_degree():
return num.abs(theta).max() > num.pi or num.abs(phi).max() > num.pi
return np.abs(theta).max() > np.pi or np.abs(phi).max() > np.pi

@@ -799,4 +799,4 @@ if not los_is_degree():

phi[phi == 0.0] = num.nan
theta[theta == 0.0] = num.nan
phi[phi == 0.0] = np.nan
theta[theta == 0.0] = np.nan

@@ -806,4 +806,4 @@ phi *= d2r

phi = num.pi / 2 + phi
theta = num.pi / 2 - theta
phi = np.pi / 2 + phi
theta = np.pi / 2 - theta

@@ -870,3 +870,3 @@ container.phi = phi

def read(self, path, **kwargs):
from scipy.io import netcdf
from scipy.io import netcdf_file

@@ -876,3 +876,3 @@ path = op.abspath(path)

grd = netcdf.netcdf_file(self._getDisplacementFile(path), mode="r", version=2)
grd = netcdf_file(self._getDisplacementFile(path), mode="r", version=2)
displ = grd.variables["z"][:].copy()

@@ -895,3 +895,3 @@ container.displacement = displ

try:
los = num.memmap(self._getLOSFile(path), dtype="<f4")
los = np.memmap(self._getLOSFile(path), dtype="<f4")
e = los[3::6].copy().reshape(shape)

@@ -901,5 +901,5 @@ n = los[4::6].copy().reshape(shape)

phi = num.arctan(n / e)
theta = num.arcsin(u)
# phi[n < 0] += num.pi
phi = np.arctan(n / e)
theta = np.arcsin(u)
# phi[n < 0] += np.pi

@@ -911,3 +911,3 @@ container.phi = phi

self._log.warning("Defaulting theta to pi/2 and phi to 0.")
container.theta = num.pi / 2
container.theta = np.pi / 2
container.phi = 0.0

@@ -935,4 +935,4 @@ return container

self._log.debug("Loading %s" % filename)
return num.flipud(
num.fromfile(filename, dtype=num.float32).reshape(
return np.flipud(
np.fromfile(filename, dtype=np.float32).reshape(
(header.lines, header.samples)

@@ -946,12 +946,12 @@ )

if not theta_file:
theta = num.full_like(displacement, 0.0)
theta = np.full_like(displacement, 0.0)
else:
theta = load_data(theta_file)
theta = num.deg2rad(theta)
theta = np.deg2rad(theta)
if not phi_file:
phi = num.full_like(displacement, num.pi / 2)
phi = np.full_like(displacement, np.pi / 2)
else:
phi = load_data(phi_file)
phi = num.pi / 2 - num.rad2deg(phi)
phi = np.pi / 2 - np.rad2deg(phi)

@@ -1070,5 +1070,5 @@ container = self.container

array = band.ReadAsArray()
array[array == band.GetNoDataValue()] = num.nan
array[array == band.GetNoDataValue()] = np.nan
return num.flipud(array)
return np.flipud(array)

@@ -1091,3 +1091,3 @@ def read(self, filename, **kwargs):

displacement = self._readBandData(dataset)
c.displacement = -displacement / (4 * num.pi) * LAMBDA_SENTINEL
c.displacement = -displacement / (4 * np.pi) * LAMBDA_SENTINEL

@@ -1107,12 +1107,12 @@ try:

un = num.sin(d2r * incident) * num.cos(d2r * heading)
ue = num.sin(d2r * incident) * num.sin(d2r * heading)
uz = num.cos(d2r * incident)
un = np.sin(d2r * incident) * np.cos(d2r * heading)
ue = np.sin(d2r * incident) * np.sin(d2r * heading)
uz = np.cos(d2r * incident)
los_n = num.full_like(c.displacement, un)
los_e = num.full_like(c.displacement, ue)
los_u = num.full_like(c.displacement, uz)
los_n = np.full_like(c.displacement, un)
los_e = np.full_like(c.displacement, ue)
los_u = np.full_like(c.displacement, uz)
c.phi = num.arctan2(los_n, los_e)
c.theta = num.arcsin(los_u)
c.phi = np.arctan2(los_n, los_e)
c.theta = np.arcsin(los_u)

@@ -1157,6 +1157,6 @@ c.meta.title = dataset.GetDescription()

array = band.ReadAsArray()
if array.dtype != num.int16 and array.dtype != num.int:
array[array == band.GetNoDataValue()] = num.nan
if array.dtype != np.int16 and array.dtype != np.int:
array[array == band.GetNoDataValue()] = np.nan
return num.flipud(array)
return np.flipud(array)

@@ -1193,5 +1193,5 @@ @staticmethod

conn_mask = self._readBandData(conn_comp) # Mask from snaphu
displacement *= num.where(conn_mask, 1.0, num.nan)
displacement *= np.where(conn_mask, 1.0, np.nan)
c.displacement = displacement / (4 * num.pi) * LAMBDA_SENTINEL
c.displacement = displacement / (4 * np.pi) * LAMBDA_SENTINEL

@@ -1201,3 +1201,3 @@ inc_angle = self._dataset_from_dir(op.join(folder, "incidenceAngle"))

c.theta = num.pi / 2 - self._readBandData(inc_angle) * d2r
c.theta = np.pi / 2 - self._readBandData(inc_angle) * d2r
c.phi = self._readBandData(azi_angle) * d2r

@@ -1339,3 +1339,3 @@

self._log.info("Loading LOS %s from %s" % (pattern, filename))
return num.memmap(filename, mode="r", dtype=">f4")
return np.memmap(filename, mode="r", dtype=">f4")

@@ -1361,3 +1361,3 @@ def read(self, filename, **kwargs):

heading_par = float(params.get("centre_heading", None))
displ = num.fromfile(filename, dtype=">f4")
displ = np.fromfile(filename, dtype=">f4")

@@ -1367,9 +1367,9 @@ # Resize array if last line is not scanned completely

if (displ.size % ncols) != 0:
fill = num.empty(ncols - displ.size % ncols)
fill.fill(num.nan)
displ = num.append(displ, fill)
fill = np.empty(ncols - displ.size % ncols)
fill.fill(np.nan)
displ = np.append(displ, fill)
displ = displ.reshape(nlines, ncols)
displ[displ == -0.0] = num.nan
displ = num.flipud(displ)
displ[displ == -0.0] = np.nan
displ = np.flipud(displ)

@@ -1383,3 +1383,3 @@ if radar_frequency and "_dsp_" not in par_file:

wavelength = util.C / radar_frequency
displ /= -4 * num.pi
displ /= -4 * np.pi
displ *= wavelength

@@ -1398,8 +1398,8 @@

if fill:
inc_angle = num.append(inc_angle, fill)
inc_angle[inc_angle == 0.0] = num.nan
inc_angle = np.append(inc_angle, fill)
inc_angle[inc_angle == 0.0] = np.nan
phi = num.full_like(displ, (180.0 - heading_par))
phi = np.full_like(displ, (180.0 - heading_par))
theta = 90.0 - inc_angle.reshape(displ.shape)
theta = num.flipud(theta)
theta = np.flipud(theta)

@@ -1444,4 +1444,4 @@ c = self.container

utm_e = num.linspace(utm_corn_e, utm_corn_eo, displ.shape[1])
utm_n = num.linspace(utm_corn_n, utm_corn_no, displ.shape[0])
utm_e = np.linspace(utm_corn_e, utm_corn_eo, displ.shape[1])
utm_n = np.linspace(utm_corn_n, utm_corn_no, displ.shape[0])

@@ -1448,0 +1448,0 @@ llLat, llLon = utm.to_latlon(

import matplotlib.pyplot as plt
import numpy as num
import numpy as np
from matplotlib.path import Path

@@ -33,4 +33,4 @@ from pyrocko.guts import Bool, Dict

f = self.scene.frame
cols, rows = num.meshgrid(range(f.cols), range(f.rows))
self._points = num.vstack((cols.ravel(), rows.ravel())).T
cols, rows = np.meshgrid(range(f.cols), range(f.rows))
self._points = np.vstack((cols.ravel(), rows.ravel())).T
return self._points

@@ -77,3 +77,3 @@

mask = num.full((sc.frame.rows, sc.frame.cols), False)
mask = np.full((sc.frame.rows, sc.frame.cols), False)
for vertices in self.config.polygons.values():

@@ -83,3 +83,3 @@ p = Path(vertices)

displacement[mask] = num.nan
displacement[mask] = np.nan
return displacement
#!/bin/python
import numpy as num
import numpy as np
from pyrocko.guts import Float, Int, Object

@@ -65,5 +65,5 @@ from scipy import ndimage

sx, sy = sc.displacement.shape
gx, gy = num.ogrid[0:sx, 0:sy]
gx, gy = np.ogrid[0:sx, 0:sy]
regions = sy / factor * (gx / factor) + gy / factor
indices = num.arange(regions.max() + 1)
indices = np.arange(regions.max() + 1)

@@ -70,0 +70,0 @@ def block_downsample(arr):

from datetime import datetime
import numpy as num
import numpy as np

@@ -75,3 +75,3 @@ from .scene import BaseScene, Scene

def displacement_mask(self):
return ~num.isfinite(self.displacement)
return ~np.isfinite(self.displacement)

@@ -84,3 +84,3 @@ @displacement.setter

times = self.times
time = times[num.abs(num.array(times) - timestamp).argmin()]
time = times[np.abs(np.array(times) - timestamp).argmin()]
return time, self._scenes[time]

@@ -87,0 +87,0 @@

@@ -9,3 +9,3 @@ #!/usr/bin/env python3

import numpy as num
import numpy as np
import utm

@@ -42,3 +42,3 @@ from pyrocko.dataset.topo import srtmgl3

def _setDataNumpy(obj, variable, value):
if isinstance(value, num.ndarray):
if isinstance(value, np.ndarray):
return obj.__setattr__(variable, value)

@@ -226,11 +226,11 @@ else:

def E(self):
return num.arange(self.cols) * self.dE
return np.arange(self.cols) * self.dE
@property_cached
def Emeter(self):
return num.arange(self.cols) * self.dEmeter
return np.arange(self.cols) * self.dEmeter
@property_cached
def N(self):
return num.arange(self.rows) * self.dN
return np.arange(self.rows) * self.dN

@@ -247,3 +247,3 @@ @property

def Nmeter(self):
return num.arange(self.rows) * self.dNmeter
return np.arange(self.rows) * self.dNmeter

@@ -257,5 +257,5 @@ @property_cached

"""
valid_data = num.isnan(self._scene.displacement)
gridE = num.repeat(self.E[num.newaxis, :], self.rows, axis=0)
return num.ma.masked_array(gridE, valid_data, fill_value=num.nan)
valid_data = np.isnan(self._scene.displacement)
gridE = np.repeat(self.E[np.newaxis, :], self.rows, axis=0)
return np.ma.masked_array(gridE, valid_data, fill_value=np.nan)

@@ -269,5 +269,5 @@ @property_cached

"""
valid_data = num.isnan(self._scene.displacement)
gridN = num.repeat(self.N[:, num.newaxis], self.cols, axis=1)
return num.ma.masked_array(gridN, valid_data, fill_value=num.nan)
valid_data = np.isnan(self._scene.displacement)
gridN = np.repeat(self.N[:, np.newaxis], self.cols, axis=1)
return np.ma.masked_array(gridN, valid_data, fill_value=np.nan)

@@ -289,8 +289,8 @@ def _calculateMeterGrid(self):

valid_data = num.isnan(self._scene.displacement)
gridE = num.ma.masked_array(
gridE.reshape(self.gridE.shape), valid_data, fill_value=num.nan
valid_data = np.isnan(self._scene.displacement)
gridE = np.ma.masked_array(
gridE.reshape(self.gridE.shape), valid_data, fill_value=np.nan
)
gridN = num.ma.masked_array(
gridN.reshape(self.gridN.shape), valid_data, fill_value=num.nan
gridN = np.ma.masked_array(
gridN.reshape(self.gridN.shape), valid_data, fill_value=np.nan
)

@@ -321,9 +321,9 @@ self._meter_grid = (gridE, gridN)

"""
coords = num.empty((self.rows * self.cols, 2))
coords[:, 0] = num.repeat(self.E[num.newaxis, :], self.rows, axis=0).flatten()
coords[:, 1] = num.repeat(self.N[:, num.newaxis], self.cols, axis=1).flatten()
coords = np.empty((self.rows * self.cols, 2))
coords[:, 0] = np.repeat(self.E[np.newaxis, :], self.rows, axis=0).flatten()
coords[:, 1] = np.repeat(self.N[:, np.newaxis], self.cols, axis=1).flatten()
if self.isMeter():
coords = ne_to_latlon(self.llLat, self.llLon, *coords.T)
coords = num.array(coords).T
coords = np.array(coords).T

@@ -343,8 +343,8 @@ else:

"""
coords = num.empty((self.rows * self.cols, 2))
coords[:, 0] = num.repeat(
self.Emeter[num.newaxis, :], self.rows, axis=0
coords = np.empty((self.rows * self.cols, 2))
coords[:, 0] = np.repeat(
self.Emeter[np.newaxis, :], self.rows, axis=0
).flatten()
coords[:, 1] = num.repeat(
self.Nmeter[:, num.newaxis], self.cols, axis=1
coords[:, 1] = np.repeat(
self.Nmeter[:, np.newaxis], self.cols, axis=1
).flatten()

@@ -543,3 +543,3 @@ return coords

"""
return ~num.isfinite(self.displacement)
return ~np.isfinite(self.displacement)

@@ -616,3 +616,3 @@ @property

"""
return num.rad2deg(self.theta)
return np.rad2deg(self.theta)

@@ -627,3 +627,3 @@ @property_cached

"""
return num.rad2deg(self.phi)
return np.rad2deg(self.phi)

@@ -651,6 +651,6 @@ @property_cached

if self._los_factors is None:
self._los_factors = num.empty((self.theta.shape[0], self.theta.shape[1], 3))
self._los_factors[:, :, 0] = num.sin(self.theta)
self._los_factors[:, :, 1] = num.cos(self.theta) * num.cos(self.phi)
self._los_factors[:, :, 2] = num.cos(self.theta) * num.sin(self.phi)
self._los_factors = np.empty((self.theta.shape[0], self.theta.shape[1], 3))
self._los_factors[:, :, 0] = np.sin(self.theta)
self._los_factors[:, :, 1] = np.cos(self.theta) * np.cos(self.phi)
self._los_factors[:, :, 2] = np.cos(self.theta) * np.sin(self.phi)
return self._los_factors

@@ -677,4 +677,4 @@

if interpolation == "nearest_neighbor":
iy = num.rint((lats - tile.ymin) / tile.dy).astype(num.intp)
ix = num.rint((lons - tile.xmin) / tile.dx).astype(num.intp)
iy = np.rint((lats - tile.ymin) / tile.dy).astype(np.intp)
ix = np.rint((lons - tile.xmin) / tile.dx).astype(np.intp)

@@ -906,3 +906,3 @@ elevation = tile.data[(iy, ix)]

num.savez("%s.npz" % (filename), *[getattr(self, arr) for arr in components])
np.savez("%s.npz" % (filename), *[getattr(self, arr) for arr in components])

@@ -934,3 +934,3 @@ self.gacos.save(op.dirname(op.abspath(filename)))

try:
data = num.load("%s.npz" % basename)
data = np.load("%s.npz" % basename)
displacement = data["arr_0"]

@@ -1088,3 +1088,3 @@ theta = data["arr_1"]

rand_state = num.random.RandomState(seed=kwargs.pop("seed", None))
rand_state = np.random.RandomState(seed=kwargs.pop("seed", None))
scene.displacement = (rand_state.rand(nx, ny) - 0.5) * 2

@@ -1102,15 +1102,15 @@

E, N = num.meshgrid(scene.frame.E, scene.frame.N)
displ = num.zeros_like(E)
E, N = np.meshgrid(scene.frame.E, scene.frame.N)
displ = np.zeros_like(E)
kE = num.random.rand(3) * kE
kN = num.random.rand(3) * kN
kE = np.random.rand(3) * kE
kN = np.random.rand(3) * kN
for ke in kE:
phase = num.random.randn(1)[0]
displ += num.sin(ke * E + phase)
phase = np.random.randn(1)[0]
displ += np.sin(ke * E + phase)
for kn in kN:
phase = num.random.randn(1)[0]
displ += num.sin(kn * N + phase)
displ -= num.mean(displ)
phase = np.random.randn(1)[0]
displ += np.sin(kn * N + phase)
displ -= np.mean(displ)

@@ -1139,10 +1139,10 @@ scene.displacement = displ * amplitude

rfield = num.random.rand(nE, nN)
spec = num.fft.fft2(rfield)
rfield = np.random.rand(nE, nN)
spec = np.fft.fft2(rfield)
kE = num.fft.fftfreq(nE, dE)
kN = num.fft.fftfreq(nN, dN)
k_rad = num.sqrt(kN[:, num.newaxis] ** 2 + kE[num.newaxis, :] ** 2)
kE = np.fft.fftfreq(nE, dE)
kN = np.fft.fftfreq(nN, dN)
k_rad = np.sqrt(kN[:, np.newaxis] ** 2 + kE[np.newaxis, :] ** 2)
regime = num.array(regime)
regime = np.array(regime)
k0 = 0.0

@@ -1152,7 +1152,7 @@ k1 = regime[0] * k_rad.max()

r0 = num.logical_and(k_rad > k0, k_rad < k1)
r1 = num.logical_and(k_rad >= k1, k_rad < k2)
r0 = np.logical_and(k_rad > k0, k_rad < k1)
r1 = np.logical_and(k_rad >= k1, k_rad < k2)
r2 = k_rad >= k2
beta = num.array(beta)
beta = np.array(beta)
# From Hanssen (2001)

@@ -1174,3 +1174,3 @@ # beta+1 is used as beta, since, the power exponent

amp = num.zeros_like(k_rad)
amp = np.zeros_like(k_rad)
amp[r0] = k_rad[r0] ** -beta[0]

@@ -1187,5 +1187,5 @@ amp[r0] /= amp[r0].max()

spec *= amplitude * num.sqrt(amp)
disp = num.abs(num.fft.ifft2(spec))
disp -= num.mean(disp)
spec *= amplitude * np.sqrt(amp)
disp = np.abs(np.fft.ifft2(spec))
disp -= np.mean(disp)

@@ -1196,3 +1196,3 @@ scene.displacement = disp

def addNoise(self, noise_amplitude=1.0, seed=None):
rand = num.random.RandomState(seed)
rand = np.random.RandomState(seed)
noise = rand.randn(*self.displacement.shape) * noise_amplitude

@@ -1207,7 +1207,7 @@ self.displacement += noise

scene.frame.dLon = 5e-4
# scene.frame.E = num.arange(nE) * 50.
# scene.frame.N = num.arange(nN) * 50.
scene.theta = num.repeat(num.linspace(0.8, 0.85, nE), nN).reshape((nE, nN))
scene.phi = num.rot90(scene.theta)
scene.displacement = num.zeros((nE, nN))
# scene.frame.E = np.arange(nE) * 50.
# scene.frame.N = np.arange(nN) * 50.
scene.theta = np.repeat(np.linspace(0.8, 0.85, nE), nN).reshape((nE, nN))
scene.phi = np.rot90(scene.theta)
scene.displacement = np.zeros((nE, nN))
return scene

@@ -1223,5 +1223,5 @@

y0 = y.min() + abs(y.max() - y.min()) / 2
X, Y = num.meshgrid(x, y)
X, Y = np.meshgrid(x, y)
gauss_anomaly = amplitude * num.exp(
gauss_anomaly = amplitude * np.exp(
-(((X - x0) ** 2 / 2 * sigma_x**2) + (Y - y0) ** 2 / 2 * sigma_y**2)

@@ -1228,0 +1228,0 @@ )

@@ -1,2 +0,2 @@

import numpy as num
import numpy as np
from pyrocko import orthodrome as od

@@ -7,4 +7,4 @@ from pyrocko.guts import Float, Object

d2r = num.pi / 180.0
r2d = 180.0 / num.pi
d2r = np.pi / 180.0
r2d = 180.0 / np.pi
km = 1e3

@@ -62,7 +62,7 @@

def outline(self):
coords = num.empty((4, 2))
coords = np.empty((4, 2))
c_strike = num.cos(self.strike * d2r)
s_strike = num.sin(self.strike * d2r)
c_dip = num.cos(self.dip * d2r)
c_strike = np.cos(self.strike * d2r)
s_strike = np.sin(self.strike * d2r)
c_dip = np.cos(self.dip * d2r)

@@ -131,7 +131,7 @@ coords[0, 0] = s_strike * self.length / 2

result = {
"displacement.n": num.array(),
"displacement.e": num.array(),
"displacement.d": num.array(),
"displacement.n": np.array(),
"displacement.e": np.array(),
"displacement.d": np.array(),
"processor_profile": ProcessorProfile(),
}
return result
import logging
import time
import numpy as num
import numpy as np

@@ -28,23 +28,23 @@ """Ellispoidal Cavity Model (ECM), triaxial elipsoidal deformation source.

d2r = num.pi / 180.0
r2d = 180.0 / num.pi
sqrt = num.sqrt
pi = num.pi
d2r = np.pi / 180.0
r2d = 180.0 / np.pi
sqrt = np.sqrt
pi = np.pi
def cosd(deg):
return num.cos(deg * d2r)
return np.cos(deg * d2r)
def sind(deg):
return num.sin(deg * d2r)
return np.sin(deg * d2r)
def strike_dip(rot_mat, idx):
Vstrike = num.array([-rot_mat[1, idx], rot_mat[0, idx], 0.0])
Vstrike = Vstrike / num.linalg.norm(Vstrike)
strike = num.arctan2(Vstrike[0], Vstrike[1]) * r2d
if num.isnan(strike):
Vstrike = np.array([-rot_mat[1, idx], rot_mat[0, idx], 0.0])
Vstrike = Vstrike / np.linalg.norm(Vstrike)
strike = np.arctan2(Vstrike[0], Vstrike[1]) * r2d
if np.isnan(strike):
strike = 0.0
dip = num.arccos(rot_mat[2, idx]) * r2d
dip = np.arccos(rot_mat[2, idx]) * r2d
return strike, dip

@@ -54,9 +54,9 @@

def rotation_matrix(rotx, roty, rotz):
Rx = num.matrix(
Rx = np.matrix(
[[1.0, 0.0, 0.0], [0.0, cosd(rotx), sind(rotx)], [0.0, -sind(rotx), cosd(rotx)]]
)
Ry = num.matrix(
Ry = np.matrix(
[[cosd(roty), 0.0, -sind(roty)], [0.0, 1.0, 0.0], [sind(roty), 0.0, cosd(roty)]]
)
Rz = num.matrix(
Rz = np.matrix(
[[cosd(rotz), sind(rotz), 0.0], [-sind(rotz), cosd(rotz), 0.0], [0.0, 0.0, 1.0]]

@@ -99,5 +99,5 @@ )

Ue = num.zeros(ncoords)
Un = num.zeros(ncoords)
Uv = num.zeros(ncoords)
Ue = np.zeros(ncoords)
Un = np.zeros(ncoords)
Uv = np.zeros(ncoords)

@@ -111,3 +111,3 @@ coords_shifted = coords.copy()

for icomp, comp in enumerate([dVx, dVy, dVz]):
if num.all(comp):
if np.all(comp):
t0 = time.time()

@@ -181,7 +181,7 @@ strike, dip = strike_dip(rot_mat, icomp)

a_arr = num.array([ax, ay, az])
ia_sort = num.argsort(a_arr)[::-1]
a_arr = np.array([ax, ay, az])
ia_sort = np.argsort(a_arr)[::-1]
shape_tensor = shapeTensor(*a_arr[ia_sort], nu=nu)
# Transform strain
eT = -num.linalg.inv(shape_tensor) * P * num.ones((3, 1)) / 3.0 / K
eT = -np.linalg.inv(shape_tensor) * P * np.ones((3, 1)) / 3.0 / K
sT = (2 * mu * eT) + lamda * eT.sum()

@@ -203,5 +203,5 @@ V = 4.0 / 3 * pi * ax * ay * az

Ue = num.zeros(ncoords)
Un = num.zeros(ncoords)
Uv = num.zeros(ncoords)
Ue = np.zeros(ncoords)
Un = np.zeros(ncoords)
Uv = np.zeros(ncoords)

@@ -214,3 +214,3 @@ coords_shifted = coords.copy()

for icomp, comp in enumerate([dVx, dVy, dVz]):
if num.all(comp):
if np.all(comp):
t0 = time.time()

@@ -236,3 +236,3 @@ strike, dip = strike_dip(rot_mat, icomp)

if a1 == 0.0 and a2 == 0.0 and a3 == 0:
return num.zeros((3, 3)).view(num.matrix)
return np.zeros((3, 3)).view(np.matrix)

@@ -289,3 +289,3 @@ # General case: triaxial ellipsoid

/ (a1**2 - a3**2) ** 1.5
* (num.arccos(a3 / a1) - a3 / a1 * sqrt(1.0 - a3**2 / a1**2))
* (np.arccos(a3 / a1) - a3 / a1 * sqrt(1.0 - a3**2 / a1**2))
)

@@ -314,3 +314,3 @@ I2 = I1

/ (a1**2 - a3**2) ** 1.5
* (a1 / a3 * sqrt(a1**2 / a3**2 - 1) - num.arccosh(a1 / a3))
* (a1 / a3 * sqrt(a1**2 / a3**2 - 1) - np.arccosh(a1 / a3))
)

@@ -375,3 +375,3 @@ I3 = I2

return num.matrix(
return np.matrix(
[

@@ -389,3 +389,3 @@ [S1111 - 1, S1122, S1133],

raise ArithmeticError("x, y and z values must be positive!")
elif num.count_nonzero([x, y, z]) < 2:
elif np.count_nonzero([x, y, z]) < 2:
raise ArithmeticError("At most one of the x, y and z values can be zero!")

@@ -466,6 +466,6 @@

beta = strike - 90.0
rot_mat = num.matrix([[cosd(beta), -sind(beta)], [sind(beta), cosd(beta)]])
rot_mat = np.matrix([[cosd(beta), -sind(beta)], [sind(beta), cosd(beta)]])
r_beta = rot_mat * coords_shifted.conj().T
x = r_beta[0, :].view(num.ndarray).ravel()
y = r_beta[1, :].view(num.ndarray).ravel()
x = r_beta[0, :].view(np.ndarray).ravel()
y = r_beta[1, :].view(np.ndarray).ravel()

@@ -486,3 +486,3 @@ r = (x**2 + y**2 + z0**2) ** 0.5

# Note: For a PDF M0 = dV*mu!
u = num.empty((ncoords, 3))
u = np.empty((ncoords, 3))

@@ -493,3 +493,3 @@ u[:, 0] = x

u *= (3.0 * q**2 / r**5)[:, num.newaxis]
u *= (3.0 * q**2 / r**5)[:, np.newaxis]
u[:, 0] -= I3 * sind(dip) ** 2

@@ -502,4 +502,4 @@ u[:, 1] -= I1 * sind(dip) ** 2

return (
r_beta[0, :].view(num.ndarray).ravel(), # ue
r_beta[1, :].view(num.ndarray).ravel(), # un
r_beta[0, :].view(np.ndarray).ravel(), # ue
r_beta[1, :].view(np.ndarray).ravel(), # un
u[:, 2],

@@ -533,5 +533,5 @@ ) # uv

X, Y = num.meshgrid(num.arange(nrows), num.arange(ncols))
X, Y = np.meshgrid(np.arange(nrows), np.arange(ncols))
coords = num.empty((nrows * ncols, 2))
coords = np.empty((nrows * ncols, 2))
coords[:, 0] = X.ravel()

@@ -538,0 +538,0 @@ coords[:, 1] = Y.ravel()

@@ -1,2 +0,2 @@

import numpy as num
import numpy as np
import pyrocko.orthodrome as od

@@ -8,4 +8,4 @@ from pyrocko.guts import Float

d2r = num.pi / 180.0
r2d = 180.0 / num.pi
d2r = np.pi / 180.0
r2d = 180.0 / np.pi
km = 1e3

@@ -47,3 +47,3 @@

K = self.lamda + 2 * self.mu / 3 # Bulk Modulus
V = 4.0 / 3 * num.pi * self.length_x * self.length_y * self.length_z
V = 4.0 / 3 * np.pi * self.length_x * self.length_y * self.length_z
V = (self.cavity_pressure * V) / K

@@ -132,5 +132,5 @@ return V

"processor_profile": dict(),
"displacement.e": num.zeros(sandbox.frame.npixel),
"displacement.n": num.zeros(sandbox.frame.npixel),
"displacement.d": num.zeros(sandbox.frame.npixel),
"displacement.e": np.zeros(sandbox.frame.npixel),
"displacement.n": np.zeros(sandbox.frame.npixel),
"displacement.d": np.zeros(sandbox.frame.npixel),
}

@@ -137,0 +137,0 @@

@@ -1,2 +0,2 @@

import numpy as num
import numpy as np
from pyrocko import orthodrome as od

@@ -9,4 +9,4 @@ from pyrocko.guts import Bool, Float, List

d2r = num.pi / 180.0
r2d = 180.0 / num.pi
d2r = np.pi / 180.0
r2d = 180.0 / np.pi
km = 1e3

@@ -58,7 +58,7 @@

"""
return 2.0 / 3 * num.log10(self.seismic_moment * 1e7) - 10.7
return 2.0 / 3 * np.log10(self.seismic_moment * 1e7) - 10.7
def dislocSource(self, dsrc=None):
if dsrc is None:
dsrc = num.empty(10)
dsrc = np.empty(10)

@@ -77,4 +77,4 @@ dip = self.dip

ss_slip = num.cos(self.rake * d2r) * self.slip
ds_slip = num.sin(self.rake * d2r) * self.slip
ss_slip = np.cos(self.rake * d2r) * self.slip
ds_slip = np.sin(self.rake * d2r) * self.slip
# print '{:<13}{}\n{:<13}{}'.format(

@@ -93,3 +93,3 @@ # 'strike_slip', ss_slip, 'dip_slip', ds_slip)

def getParametersArray(self):
return num.array([self.__getattribute__(p) for p in self.parameters])
return np.array([self.__getattribute__(p) for p in self.parameters])

@@ -157,3 +157,3 @@ def setParametersArray(self, parameter_arr):

"width": 15.0 * length**0.66,
"strike": num.arccos(dN / length) * r2d,
"strike": np.arccos(dN / length) * r2d,
"slip": 45.0,

@@ -175,3 +175,3 @@ "rake": 90.0,

"width": 15.0 * length**0.66,
"strike": num.arccos(dN / length) * r2d,
"strike": np.arccos(dN / length) * r2d,
}

@@ -235,3 +235,3 @@

def dislocSource(self):
return num.array([seg.dislocSource() for seg in self.segments if seg.enabled])
return np.array([seg.dislocSource() for seg in self.segments if seg.enabled])

@@ -246,5 +246,5 @@

"processor_profile": dict(),
"displacement.n": num.zeros(sandbox.frame.npixel),
"displacement.e": num.zeros(sandbox.frame.npixel),
"displacement.d": num.zeros(sandbox.frame.npixel),
"displacement.n": np.zeros(sandbox.frame.npixel),
"displacement.e": np.zeros(sandbox.frame.npixel),
"displacement.d": np.zeros(sandbox.frame.npixel),
}

@@ -257,9 +257,9 @@

nsources = len(nu_sources)
src_arr = num.vstack([src.dislocSource() for src in nu_sources])
src_arr = np.vstack([src.dislocSource() for src in nu_sources])
north_shifts, east_shifts = od.latlon_to_ne_numpy(
num.repeat(sandbox.frame.llLat, nsources),
num.repeat(sandbox.frame.llLon, nsources),
num.array([src.lat for src in nu_sources]),
num.array([src.lon for src in nu_sources]),
np.repeat(sandbox.frame.llLat, nsources),
np.repeat(sandbox.frame.llLon, nsources),
np.array([src.lat for src in nu_sources]),
np.array([src.lon for src in nu_sources]),
)

@@ -266,0 +266,0 @@

@@ -1,2 +0,2 @@

import numpy as num
import numpy as np
from pyrocko import gf

@@ -7,4 +7,4 @@ from pyrocko.guts import Float, Int, String

d2r = num.pi / 180.0
r2d = 180.0 / num.pi
d2r = np.pi / 180.0
r2d = 180.0 / np.pi
km = 1e3

@@ -245,5 +245,5 @@ km3 = 1e9

"processor_profile": dict(),
"displacement.n": num.zeros(sandbox.frame.npixel),
"displacement.e": num.zeros(sandbox.frame.npixel),
"displacement.d": num.zeros(sandbox.frame.npixel),
"displacement.n": np.zeros(sandbox.frame.npixel),
"displacement.e": np.zeros(sandbox.frame.npixel),
"displacement.d": np.zeros(sandbox.frame.npixel),
}

@@ -254,4 +254,4 @@

target = gf.StaticTarget(
lats=num.full(sandbox.frame.npixel, sandbox.frame.llLat),
lons=num.full(sandbox.frame.npixel, sandbox.frame.llLon),
lats=np.full(sandbox.frame.npixel, sandbox.frame.llLat),
lons=np.full(sandbox.frame.npixel, sandbox.frame.llLon),
east_shifts=coords[:, 0],

@@ -258,0 +258,0 @@ north_shifts=coords[:, 1],

from os import path
import numpy as num
import numpy as np
import pyqtgraph as pg

@@ -15,3 +15,3 @@ import pyqtgraph.parametertree.parameterTypes as pTypes

d2r = num.pi / 180.0
d2r = np.pi / 180.0

@@ -101,8 +101,8 @@

def orientArrow(self):
phi = num.nanmedian(self.model.scene.phi)
theta = num.nanmedian(self.model.scene.theta)
phi = np.nanmedian(self.model.scene.phi)
theta = np.nanmedian(self.model.scene.theta)
angle = 180.0 - num.rad2deg(phi)
angle = 180.0 - np.rad2deg(phi)
theta_f = theta / (num.pi / 2)
theta_f = theta / (np.pi / 2)

@@ -153,3 +153,3 @@ tipAngle = 30.0 + theta_f * 20.0

"north": 0.0,
"value": num.nan,
"value": np.nan,
"measure": self.component.title(),

@@ -217,5 +217,5 @@ "vlength": "03",

size_ramp = 10
ramp = num.linspace(-1, 1, size_ramp)[::-1]
ramp = np.linspace(-1, 1, size_ramp)[::-1]
ramp_x = num.tile(ramp, size_ramp).reshape(size_ramp, size_ramp)
ramp_x = np.tile(ramp, size_ramp).reshape(size_ramp, size_ramp)
ramp_y = ramp_x.T

@@ -225,3 +225,3 @@ ramp = ramp_x + ramp_y

ramp = ramp / ramp.max() * contrast
# ramp = num.array([[-1, -.5, 0], [0, .5, 1.]]) * contrast
# ramp = np.array([[-1, -.5, 0], [0, .5, 1.]]) * contrast
# convolution of two 2-dimensional arrays

@@ -236,7 +236,7 @@

percentile2 = num.quantile(shad, 0.02)
percentile98 = num.quantile(shad, 0.98)
percentile2 = np.quantile(shad, 0.02)
percentile98 = np.quantile(shad, 0.98)
shad = num.where(shad > percentile98, percentile98, shad)
shad = num.where(shad < percentile2, percentile2, shad)
shad = np.where(shad > percentile98, percentile98, shad)
shad = np.where(shad < percentile2, percentile2, shad)
shad -= shad.min()

@@ -304,3 +304,3 @@ shad /= shad.max()

return self._data
# return self._data # num.nan_to_num(_data)
# return self._data # np.nan_to_num(_data)

@@ -339,3 +339,3 @@ @QtCore.pyqtSlot()

self.hint["length"] = (
"03" if num.isnan(self.hint["value"]) else self.hint["vlength"]
"03" if np.isnan(self.hint["value"]) else self.hint["vlength"]
)

@@ -377,4 +377,4 @@ self.hint_text.setText(self.hint_text.text_template.format(**self.hint))

max_range = num.nanmax(num.abs(self._plot.data))
if max_range is not num.nan:
max_range = np.nanmax(np.abs(self._plot.data))
if max_range is not np.nan:
self.vb.setYRange(-max_range, max_range)

@@ -418,5 +418,5 @@

relevant_data = num.abs(self._plot.data[num.isfinite(self._plot.data)])
if num.any(relevant_data):
lvl_max = num.quantile(relevant_data, 0.999)
relevant_data = np.abs(self._plot.data[np.isfinite(self._plot.data)])
if np.any(relevant_data):
lvl_max = np.quantile(relevant_data, 0.999)
else:

@@ -433,3 +433,3 @@ lvl_max = 1.0

self.gradient.restoreState(cmap)
self.setLevels(num.nanmin(self._plot.data), num.nanmax(self._plot.data))
self.setLevels(np.nanmin(self._plot.data), np.nanmax(self._plot.data))

@@ -436,0 +436,0 @@ def isoCurveControl(self):

@@ -1,2 +0,2 @@

import numpy as num
import numpy as np
import pyqtgraph as pg

@@ -105,4 +105,4 @@ import pyqtgraph.parametertree.parameterTypes as pTypes

# data = self.roi.getArrayRegion(self.image.image, self.image)
# data[data == 0.] = num.nan
# if num.all(num.isnan(data)):
# data[data == 0.] = np.nan
# if np.all(np.isnan(data)):
# return

@@ -157,3 +157,3 @@

slope, intercept = aps.get_correlation()
elev = num.array([elevation.min(), elevation.max()])
elev = np.array([elevation.min(), elevation.max()])
model = elev * slope + intercept

@@ -160,0 +160,0 @@

from collections import OrderedDict
import numpy as num
import numpy as np
import pyqtgraph as pg

@@ -174,4 +174,4 @@ import pyqtgraph.parametertree.parameterTypes as pTypes

data = scene.displacement[slice_N, slice_E]
data[data == 0.0] = num.nan
if num.all(num.isnan(data)):
data[data == 0.0] = np.nan
if np.all(np.isnan(data)):
return

@@ -370,3 +370,3 @@

struct, dist = covariance.getStructure()
self.structure.setData(dist[num.isfinite(struct)], struct[num.isfinite(struct)])
self.structure.setData(dist[np.isfinite(struct)], struct[np.isfinite(struct)])
self.variance.setValue(covariance.variance)

@@ -402,3 +402,3 @@

data = covariance.noise_data.copy()
data[data == 0.0] = num.nan
data[data == 0.0] = np.nan
return data

@@ -590,3 +590,3 @@

self.hint = {"leaf1": 0, "leaf2": 0, "weight": num.nan}
self.hint = {"leaf1": 0, "leaf2": 0, "weight": np.nan}

@@ -593,0 +593,0 @@ self.hint_text.template = (

#!/usr/bin/python2
from collections import OrderedDict
import numpy as num
import numpy as np
import pyqtgraph as pg

@@ -138,3 +138,3 @@ import pyqtgraph.parametertree.parameterTypes as pTypes

vertices = num.array([(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)])
vertices = np.array([(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)])
vertices[:, 0] *= frame.cols / 6

@@ -237,6 +237,6 @@ vertices[:, 1] *= frame.rows / 6

transect = num.ndarray((0))
transect = np.ndarray((0))
length = 0
for line in self.poly_line.segments:
transect = num.append(
transect = np.append(
transect, line.getArrayRegion(self.plot.image.image, self.plot.image)

@@ -247,5 +247,5 @@ )

# interpolate over NaNs
nans, x = num.isnan(transect), lambda z: z.nonzero()[0]
transect[nans] = num.interp(x(nans), x(~nans), transect[~nans])
length = num.linspace(0, length, transect.size)
nans, x = np.isnan(transect), lambda z: z.nonzero()[0]
transect[nans] = np.interp(x(nans), x(~nans), transect[~nans])
length = np.linspace(0, length, transect.size)

@@ -269,5 +269,5 @@ self.trans_plot.setData(length, transect)

self.parameters = {
"min value": lambda plot: num.nanmin(plot.data),
"max value": lambda plot: num.nanmax(plot.data),
"mean value": lambda plot: num.nanmean(plot.data),
"min value": lambda plot: np.nanmin(plot.data),
"max value": lambda plot: np.nanmax(plot.data),
"mean value": lambda plot: np.nanmean(plot.data),
}

@@ -274,0 +274,0 @@

@@ -1,2 +0,2 @@

import numpy as num
import numpy as np
import pyqtgraph as pg

@@ -9,3 +9,3 @@ from PyQt5 import QtCore, QtGui, QtWidgets

d2r = num.pi / 180.0
d2r = np.pi / 180.0

@@ -323,4 +323,4 @@

nx = int(num.sqrt(nvectors) * float(w) / h)
ny = int(num.sqrt(nvectors) * float(h) / w)
nx = int(np.sqrt(nvectors) * float(w) / h)
ny = int(np.sqrt(nvectors) * float(h) / w)
dx = float(w) / nx

@@ -355,4 +355,4 @@ dy = float(h) / ny

or (pE < 0 or pN < 0)
or num.isnan(mat_E[pE, pN])
or num.isnan(mat_N[pE, pN])
or np.isnan(mat_E[pE, pN])
or np.isnan(mat_N[pE, pN])
):

@@ -422,9 +422,9 @@ dE = 0.0

head_p1 = self.p2 - QtCore.QPointF(
num.sin(d * d2r + num.pi / 3) * arrow_length,
num.cos(d * d2r + num.pi / 3) * arrow_length,
np.sin(d * d2r + np.pi / 3) * arrow_length,
np.cos(d * d2r + np.pi / 3) * arrow_length,
)
head_p2 = self.p2 - QtCore.QPointF(
num.sin(d * d2r + num.pi - num.pi / 3) * arrow_length,
num.cos(d * d2r + num.pi - num.pi / 3) * arrow_length,
np.sin(d * d2r + np.pi - np.pi / 3) * arrow_length,
np.cos(d * d2r + np.pi - np.pi / 3) * arrow_length,
)

@@ -474,4 +474,4 @@

for plot in self.plots:
plt_min = num.nanmin(plot.data)
plt_max = num.nanmax(plot.data)
plt_min = np.nanmin(plot.data)
plt_max = np.nanmax(plot.data)
lvl_max = lvl_max if plt_max < lvl_max else plt_max

@@ -478,0 +478,0 @@ lvl_min = lvl_min if plt_min > lvl_min else plt_min

@@ -1,2 +0,2 @@

import numpy as num
import numpy as np
import pyqtgraph as pg

@@ -9,4 +9,4 @@ from PyQt5 import QtCore, QtWidgets

d2r = num.pi / 180.0
r2d = 180.0 / num.pi
d2r = np.pi / 180.0
r2d = 180.0 / np.pi

@@ -57,4 +57,4 @@

northing = float(self.pos().y() + num.cos(strike * d2r) * length / 2)
easting = float(self.pos().x() + num.sin(strike * d2r) * length / 2)
northing = float(self.pos().y() + np.cos(strike * d2r) * length / 2)
easting = float(self.pos().x() + np.sin(strike * d2r) * length / 2)

@@ -61,0 +61,0 @@ north_shift, east_shift = self.source.getSandboxOffset()

@@ -1,2 +0,2 @@

import numpy as num
import numpy as np

@@ -7,4 +7,4 @@ from kite.sources import EllipsoidSource, PointCompoundSource

d2r = num.pi / 180.0
r2d = 180.0 / num.pi
d2r = np.pi / 180.0
r2d = 180.0 / np.pi

@@ -11,0 +11,0 @@

@@ -1,2 +0,2 @@

import numpy as num
import numpy as np

@@ -7,4 +7,4 @@ from kite.sources import OkadaSource

d2r = num.pi / 180.0
r2d = 180.0 / num.pi
d2r = np.pi / 180.0
r2d = 180.0 / np.pi

@@ -11,0 +11,0 @@

import os
import numpy as num
import numpy as np
from PyQt5 import QtCore, QtGui

@@ -17,4 +17,4 @@

d2r = num.pi / 180.0
r2d = 180.0 / num.pi
d2r = np.pi / 180.0
r2d = 180.0 / np.pi

@@ -166,4 +166,4 @@

params = self.delegate.getSourceParameters()
exponent = num.log10(
num.max([v for k, v in params.items() if k in self.scaling_params])
exponent = np.log10(
np.max([v for k, v in params.items() if k in self.scaling_params])
)

@@ -279,4 +279,4 @@ scale = float("1e%d" % int(exponent))

return (
sdx * num.sin(rangle) + sdy * num.cos(rangle),
sdx * num.cos(rangle) - sdy * num.sin(rangle),
sdx * np.sin(rangle) + sdy * np.cos(rangle),
sdx * np.cos(rangle) - sdy * np.sin(rangle),
)

@@ -399,4 +399,4 @@

return (
sdx * num.sin(rangle) + sdy * num.cos(rangle),
sdx * num.cos(rangle) - sdy * num.sin(rangle),
sdx * np.sin(rangle) + sdy * np.cos(rangle),
sdx * np.cos(rangle) - sdy * np.sin(rangle),
)

@@ -494,4 +494,4 @@

params = self.delegate.getSourceParameters()
exponent = num.log10(
num.max([abs(v) for k, v in params.items() if k in self.scaling_params])
exponent = np.log10(
np.max([abs(v) for k, v in params.items() if k in self.scaling_params])
)

@@ -547,4 +547,4 @@ scale = float("1e%d" % int(exponent))

return (
sdx * num.sin(rangle) + sdy * num.cos(rangle),
sdx * num.cos(rangle) - sdy * num.sin(rangle),
sdx * np.sin(rangle) + sdy * np.cos(rangle),
sdx * np.cos(rangle) - sdy * np.sin(rangle),
)

@@ -551,0 +551,0 @@

@@ -1,2 +0,2 @@

import numpy as num
import numpy as np
from PyQt5 import QtCore, QtWidgets

@@ -79,4 +79,4 @@

model = self.sandbox.model
phi = num.deg2rad(self.spinlos_phi.value())
theta = num.deg2rad(self.spinlos_theta.value())
phi = np.deg2rad(self.spinlos_phi.value())
theta = np.deg2rad(self.spinlos_theta.value())

@@ -83,0 +83,0 @@ @QtCore.pyqtSlot()

#!/bin/python
import numpy as num
import numpy as np
import scipy as sp

@@ -11,4 +11,4 @@

return mat
min_a = num.argmin(mat.shape)
max_a = num.argmax(mat.shape)
min_a = np.argmin(mat.shape)
max_a = np.argmax(mat.shape)

@@ -21,3 +21,3 @@ width = mat.shape[max_a] - mat.shape[min_a]

padding = ((0, 0), (0, width))
return num.pad(mat, pad_width=padding, mode="constant", constant_values=0.0)
return np.pad(mat, pad_width=padding, mode="constant", constant_values=0.0)

@@ -31,14 +31,14 @@

raise TypeError("Displacement has to be 2-dim array")
mx = num.nanmedian(displ, axis=0)
my = num.nanmedian(displ, axis=1)
mx = np.nanmedian(displ, axis=0)
my = np.nanmedian(displ, axis=1)
ix = num.arange(mx.size)
iy = num.arange(my.size)
dx, cx, _, _, _ = sp.stats.linregress(ix[~num.isnan(mx)], mx[~num.isnan(mx)])
dy, cy, _, _, _ = sp.stats.linregress(iy[~num.isnan(my)], my[~num.isnan(my)])
ix = np.arange(mx.size)
iy = np.arange(my.size)
dx, cx, _, _, _ = sp.stats.linregress(ix[~np.isnan(mx)], mx[~np.isnan(mx)])
dy, cy, _, _, _ = sp.stats.linregress(iy[~np.isnan(my)], my[~np.isnan(my)])
rx = ix * dx
ry = iy * dy
data = displ - (rx[num.newaxis, :] + ry[:, num.newaxis])
data -= num.nanmean(data)
data = displ - (rx[np.newaxis, :] + ry[:, np.newaxis])
data -= np.nanmean(data)
return data

@@ -55,3 +55,3 @@

# form a relative coordinate grid
c_grid = num.mgrid[0 : displ.shape[0], 0 : displ.shape[1]]
c_grid = np.mgrid[0 : displ.shape[0], 0 : displ.shape[1]]

@@ -64,8 +64,8 @@ # separate and flatten coordinate grid into x and y vectors for each !point

# reduce vectors taking out all NaN's
displ_nonan = displ_f[num.isfinite(displ_f)]
ix = ix[num.isfinite(displ_f)]
iy = iy[num.isfinite(displ_f)]
displ_nonan = displ_f[np.isfinite(displ_f)]
ix = ix[np.isfinite(displ_f)]
iy = iy[np.isfinite(displ_f)]
# form kernel/design derampMatrix (c, x, y)
GT = num.matrix([num.ones(len(ix)), ix, iy])
GT = np.matrix([np.ones(len(ix)), ix, iy])
G = GT.T

@@ -83,6 +83,6 @@

ramp_nonan = ramp_paras * GT
ramp_f = num.multiply(displ_f, 0.0)
ramp_f = np.multiply(displ_f, 0.0)
# insert ramp values in full vectors
num.place(ramp_f, num.isfinite(displ_f), num.array(ramp_nonan).flatten())
np.place(ramp_f, np.isfinite(displ_f), np.array(ramp_nonan).flatten())
ramp_f = ramp_f.reshape(displ.shape[0], displ.shape[1])

@@ -98,3 +98,3 @@

if num.all(num.isnan(displ)):
if np.all(np.isnan(displ)):
raise ValueError("Displacement is all NaN.")

@@ -105,3 +105,3 @@

for r in range(displ.shape[0]):
if not num.all(num.isnan(displ[r, :])):
if not np.all(np.isnan(displ[r, :])):
if r1 is False:

@@ -111,3 +111,3 @@ r1 = r

for c in range(displ.shape[1]):
if not num.all(num.isnan(displ[:, c])):
if not np.all(np.isnan(displ[:, c])):
if c1 is False:

@@ -125,5 +125,5 @@ c1 = c

R1 = 6371009.0
d2r = num.deg2rad
sin = num.sin
cos = num.cos
d2r = np.deg2rad
sin = np.sin
cos = np.cos
a = (

@@ -133,3 +133,3 @@ sin(d2r(alat - blat) / 2) ** 2

)
c = 2.0 * num.arctan2(num.sqrt(a), num.sqrt(1.0 - a))
c = 2.0 * np.arctan2(np.sqrt(a), np.sqrt(1.0 - a))
return R1 * c

@@ -160,7 +160,7 @@

# number of floating points:
mn = num.nanmin(data)
mx = num.nanmax(data)
if not num.isfinite(mx) or num.isfinite(mn):
mn = np.nanmin(data)
mx = np.nanmax(data)
if not np.isfinite(mx) or np.isfinite(mn):
return 3, 6
precision = int(round(num.log10((100.0 / (mx - mn)))))
precision = int(round(np.log10((100.0 / (mx - mn)))))
if precision < 0:

@@ -174,5 +174,5 @@ precision = 0

def formatScalar(v, ndigits=7):
if num.isinf(v):
if np.isinf(v):
return "inf"
elif num.isnan(v):
elif np.isnan(v):
return "nan"

@@ -186,3 +186,3 @@

p = num.ceil(num.log10(num.abs(v)))
p = np.ceil(np.log10(np.abs(v)))
if p <= 0.0:

@@ -189,0 +189,0 @@ f = {"d": 1, "f": ndigits - 1}

@@ -5,3 +5,3 @@ import logging

import numpy as num
import numpy as np
import pyrocko.orthodrome as od

@@ -16,4 +16,4 @@ import shapefile

d2r = num.pi / 180.0
r2d = 180.0 / num.pi
d2r = np.pi / 180.0
r2d = 180.0 / np.pi

@@ -60,9 +60,9 @@

data.ps_mean_v = num.zeros(npoints)
data.ps_mean_var = num.zeros(npoints)
los_n = num.zeros(npoints)
los_e = num.zeros(npoints)
los_u = num.zeros(npoints)
data.ps_mean_v = np.zeros(npoints)
data.ps_mean_var = np.zeros(npoints)
los_n = np.zeros(npoints)
los_e = np.zeros(npoints)
los_u = np.zeros(npoints)
coords = num.zeros((npoints, 2))
coords = np.zeros((npoints, 2))

@@ -83,4 +83,4 @@ for isr, sr in enumerate(shp.iterShapeRecords()):

data.phi = num.arctan2(los_n, los_e)
data.theta = num.arcsin(los_u)
data.phi = np.arctan2(los_n, los_e)
data.theta = np.arcsin(los_u)

@@ -87,0 +87,0 @@ data.easts = coords[:, 0]

@@ -6,3 +6,3 @@ import glob

import numpy as num
import numpy as np
import pyrocko.orthodrome as od

@@ -23,4 +23,4 @@ from scipy import interpolate, io, stats

d2r = num.pi / 180.0
r2d = 180.0 / num.pi
d2r = np.pi / 180.0
r2d = 180.0 / np.pi

@@ -73,11 +73,11 @@

data = DataStruct()
data.ll_coords = num.asarray(ps2_mat["ll0"])
data.radar_coords = num.asarray(ps2_mat["ij"])
data.ps_mean_v = num.asarray(ps_plot_mat["ph_disp"]).ravel()
data.ll_coords = np.asarray(ps2_mat["ll0"])
data.radar_coords = np.asarray(ps2_mat["ij"])
data.ps_mean_v = np.asarray(ps_plot_mat["ph_disp"]).ravel()
geo_coords = num.asarray(ps2_mat["lonlat"])
geo_coords = np.asarray(ps2_mat["lonlat"])
data.lons = geo_coords[0, :]
data.lats = geo_coords[1, :]
days = num.asarray(ps2_mat["day"])
days = np.asarray(ps2_mat["day"])
data.tmin = timedelta(days=days.min() - 366.25) + datetime(1, 1, 1)

@@ -89,3 +89,3 @@ data.tmax = timedelta(days=days.max() - 366.25) + datetime(1, 1, 1)

mv2_mat = h5py.File(fn_mv2, "r")
data.ps_mean_std = num.asarray(mv2_mat["mean_v_std"]).ravel()
data.ps_mean_std = np.asarray(mv2_mat["mean_v_std"]).ravel()

@@ -96,6 +96,6 @@ with open(fn_len) as rl, open(fn_width) as rw:

data.look_angles = num.loadtxt(fn_look_angle)[::2]
data.look_angles = np.loadtxt(fn_look_angle)[::2]
heading = float(num.asarray(params_mat["heading"]))
if num.isnan(heading):
heading = float(np.asarray(params_mat["heading"]))
if np.isnan(heading):
raise ValueError("Heading information in parms.mat is missing!")

@@ -154,13 +154,13 @@

"Binned radar coordinate ranges: length %d - %d; width %d - %d",
num.nanmin(data.bin_radar_i),
num.nanmax(data.bin_radar_i),
num.nanmin(data.bin_radar_j),
num.nanmax(data.bin_radar_j),
np.nanmin(data.bin_radar_i),
np.nanmax(data.bin_radar_i),
np.nanmin(data.bin_radar_j),
np.nanmax(data.bin_radar_j),
)
width_coords = num.linspace(0, data.px_width, 50)
len_coords = num.linspace(0, data.px_length, 50)
coords = num.asarray(num.meshgrid(width_coords, len_coords)).reshape(2, 2500)
width_coords = np.linspace(0, data.px_width, 50)
len_coords = np.linspace(0, data.px_length, 50)
coords = np.asarray(np.meshgrid(width_coords, len_coords)).reshape(2, 2500)
radar_coords = num.vstack(
radar_coords = np.vstack(
[

@@ -252,7 +252,7 @@ data.bin_radar_j.ravel() - data.radar_coords[0].min(),

phi_angle = -data.heading * d2r + num.pi
if phi_angle > num.pi:
phi_angle -= 2 * num.pi
data.bin_phi = num.full_like(data.bin_theta, phi_angle)
data.bin_phi[num.isnan(data.bin_theta)] = num.nan
phi_angle = -data.heading * d2r + np.pi
if phi_angle > np.pi:
phi_angle -= 2 * np.pi
data.bin_phi = np.full_like(data.bin_theta, phi_angle)
data.bin_phi[np.isnan(data.bin_theta)] = np.nan

@@ -259,0 +259,0 @@ log.debug("Setting up the Kite Scene")

Metadata-Version: 2.1
Name: kite
Version: 1.5.4
Version: 1.5.5
Summary: InSAR unwrapped surface displacement processing for earthquake modelling.

@@ -18,3 +18,3 @@ Author-email: Marius Paul Isken <mi@gfz-potsdam.de>, Henriette Sudhaus <hsudhaus@ifg.uni-kiel.de>

Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: C

@@ -25,4 +25,5 @@ Classifier: Operating System :: POSIX

Description-Content-Type: text/markdown
Provides-Extra: formatting
Provides-Extra: gdal
Provides-Extra: development
Provides-Extra: tests
License-File: LICENSE.md

@@ -47,3 +48,11 @@

```
With additional gdal dependency, used for GeoTIFF (GACOS and LiCSAR):
```sh
pip install kite[gdal]
```
## Introduction
This framework is streamlining InSAR displacement processing routines for earthquake inversion through [Pyrocko](https://www.pyrocko.org) and Grond.

@@ -60,5 +69,6 @@

## Citation
Recommended citation for Kite
> Isken, Marius; Sudhaus, Henriette; Heimann, Sebastian; Steinberg, Andreas; Daout, Simon; Vasyura-Bathke, Hannes (2017): Kite - Software for Rapid Earthquake Source Optimisation from InSAR Surface Displacement. V. 0.1. GFZ Data Services. http://doi.org/10.5880/GFZ.2.1.2017.002
> Isken, Marius; Sudhaus, Henriette; Heimann, Sebastian; Steinberg, Andreas; Daout, Simon; Vasyura-Bathke, Hannes (2017): Kite - Software for Rapid Earthquake Source Optimisation from InSAR Surface Displacement. V. 0.1. GFZ Data Services. <http://doi.org/10.5880/GFZ.2.1.2017.002>

@@ -68,5 +78,7 @@ [![DOI](https://img.shields.io/badge/DOI-10.5880%2FGFZ.2.1.2017.002-blue.svg)](http://doi.org/10.5880/GFZ.2.1.2017.002)

# Documentation
Find the documentation at https://pyrocko.org/kite/docs/current/.
Find the documentation at <https://pyrocko.org/kite/docs/current/>.
## Short Example
```python

@@ -73,0 +85,0 @@ from kite import Scene

[build-system]
requires = ["setuptools >= 61.0.0", "oldest-supported-numpy", "setuptools_scm[toml]>=6.2"]
requires = ["wheel", "setuptools >= 61.0.0", "oldest-supported-numpy", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

@@ -27,3 +27,3 @@

"Topic :: Scientific/Engineering :: Visualization",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.7",
"Programming Language :: C",

@@ -34,3 +34,3 @@ "Operating System :: POSIX",

dependencies = [
"numpy>=1.22.0",
"numpy>=1.17.3",
"scipy>=1.8.0",

@@ -50,4 +50,5 @@ "PyQt5>=5.15.7",

[project.optional-dependencies]
formatting = ["flake8", "black"]
gdal = ["gdal>=3.5.0"]
development = ["flake8", "black", "pre-commit"]
tests = ["pytest"]

@@ -54,0 +55,0 @@ [project.scripts]

@@ -18,3 +18,11 @@ # Kite

```
With additional gdal dependency, used for GeoTIFF (GACOS and LiCSAR):
```sh
pip install kite[gdal]
```
## Introduction
This framework is streamlining InSAR displacement processing routines for earthquake inversion through [Pyrocko](https://www.pyrocko.org) and Grond.

@@ -31,5 +39,6 @@

## Citation
Recommended citation for Kite
> Isken, Marius; Sudhaus, Henriette; Heimann, Sebastian; Steinberg, Andreas; Daout, Simon; Vasyura-Bathke, Hannes (2017): Kite - Software for Rapid Earthquake Source Optimisation from InSAR Surface Displacement. V. 0.1. GFZ Data Services. http://doi.org/10.5880/GFZ.2.1.2017.002
> Isken, Marius; Sudhaus, Henriette; Heimann, Sebastian; Steinberg, Andreas; Daout, Simon; Vasyura-Bathke, Hannes (2017): Kite - Software for Rapid Earthquake Source Optimisation from InSAR Surface Displacement. V. 0.1. GFZ Data Services. <http://doi.org/10.5880/GFZ.2.1.2017.002>

@@ -39,5 +48,7 @@ [![DOI](https://img.shields.io/badge/DOI-10.5880%2FGFZ.2.1.2017.002-blue.svg)](http://doi.org/10.5880/GFZ.2.1.2017.002)

# Documentation
Find the documentation at https://pyrocko.org/kite/docs/current/.
Find the documentation at <https://pyrocko.org/kite/docs/current/>.
## Short Example
```python

@@ -44,0 +55,0 @@ from kite import Scene

@@ -11,3 +11,3 @@ import logging

data_uri = "http://data.pyrocko.org/testing/kite/"
data_uri = "https://data.pyrocko.org/testing/kite/"
data_dir = op.join(op.dirname(op.abspath(__file__)), "data/")

@@ -19,3 +19,3 @@

class DownloadError(Exception):
pass
...

@@ -27,3 +27,3 @@

except OSError:
pass
...

@@ -65,3 +65,5 @@

if dl_bytes != fsize:
raise DownloadError("Download incomplete!")
raise DownloadError(
f"Download {url} incomplete! Got {fsize} bytes, expected {dl_bytes}"
)
logger.info("Download completed.")

@@ -68,0 +70,0 @@ return fn_local

@@ -5,3 +5,3 @@ #!/usr/bin/env python3

import matplotlib.pyplot as plt
import numpy as num
import numpy as np

@@ -33,3 +33,3 @@ from kite import Scene

for _, c2 in d:
num.testing.assert_allclose(c1, c2, rtol=200, atol=2e3, verbose=True)
np.testing.assert_allclose(c1, c2, rtol=200, atol=2e3, verbose=True)

@@ -41,3 +41,3 @@ def test_synthetic_noise(self):

def test_quadtree_noise(self):
rstate = num.random.RandomState()
rstate = np.random.RandomState()
self.sc.covariance.getQuadtreeNoise(rstate=rstate)

@@ -61,8 +61,2 @@

res = calc_exp()
ref = num.load("test/covariance_ref.npy")
# calc_exp_cos()
num.testing.assert_array_equal(ref, res)
print(benchmark)
@benchmark

@@ -90,3 +84,3 @@ def _test_covariance_single_thread(self):

for i, (title, mat) in enumerate(d):
print("%s Max %f" % ((title, num.nanmax(mat)), mat.shape))
print("%s Max %f" % ((title, np.nanmax(mat)), mat.shape))
fig.axes[i].imshow(mat)

@@ -103,3 +97,3 @@ fig.axes[i].set_title(title)

cov, dist = c.covariance_spatial
# assert num.all(num.isfinite(cov))
# assert np.all(np.isfinite(cov))

@@ -106,0 +100,0 @@ for i in range(10):

@@ -1,2 +0,2 @@

import numpy as num
import numpy as np

@@ -7,4 +7,4 @@ from kite import Scene

def test_deramp():
c = num.arange(20, dtype=num.float)
E, N = num.meshgrid(c, c)
c = np.arange(20, dtype=float)
E, N = np.meshgrid(c, c)

@@ -14,5 +14,2 @@ displ = (-3 + 5.4 * E) + (10 + 2.5 * N)

sc.displacement_deramp(demean=True, inplace=True)
coeffs = sc.get_ramp_coefficients()
num.testing.assert_almost_equal(coeffs, num.zeros_like(coeffs))
coeffs = sc.deramp.get_ramp_coefficients(sc.displacement)
import matplotlib.pyplot as plt
import pytest

@@ -6,2 +7,3 @@ from kite.gacos import GACOSCorrection

@pytest.skip(reason="data is local")
def test_gacos():

@@ -8,0 +10,0 @@ corr = GACOSCorrection()

@@ -8,3 +8,3 @@ from __future__ import absolute_import

import numpy as num
import numpy as np

@@ -54,5 +54,5 @@ from kite import Scene

num.testing.assert_equal(sc1.displacement, sc2.displacement)
num.testing.assert_equal(sc1.phi, sc2.phi)
num.testing.assert_equal(sc1.theta, sc2.theta)
np.testing.assert_equal(sc1.displacement, sc2.displacement)
np.testing.assert_equal(sc1.phi, sc2.phi)
np.testing.assert_equal(sc1.theta, sc2.theta)

@@ -64,3 +64,3 @@ f.__name__ = "test_import_%s" % fmt

for fmt, fns in filenames.iteritems():
for fmt, fns in filenames.items():
setattr(SceneIOTest, "test_import_%s" % fmt, _create_test_func(fmt, *fns))
import logging
import time
import numpy as num
import numpy as np

@@ -50,17 +50,1 @@ from kite.quadtree import QuadNode

stack.add_scene(scene, timestamp=ts)
def test_set_scene():
stack.set_scene(stack.times[-1])
def test_set_scene_to():
tmin = min(stack.times)
tmax = max(stack.times)
times = num.linspace(tmin, tmax, 30)
for ts in times:
stack.set_scene_to(ts)
spool(stack)

@@ -5,3 +5,3 @@ #!/bin/python

import numpy as num
import numpy as np

@@ -22,3 +22,3 @@ from kite import Scene, TestScene

sc.frame.spacing = "degree"
sc.displacement = num.zeros((500, 500))
sc.displacement = np.zeros((500, 500))

@@ -42,3 +42,2 @@ return sc

self.sc = TestScene.createGauss()
self.sc.setLogLevel("ERROR")
self.sc.quadtree.epsilon = 0.02

@@ -49,13 +48,13 @@ self.sc.covariance.subsampling = 24

qt = self.sc.quadtree
for e in num.linspace(0.118, 0.2, num=30):
for e in np.linspace(0.118, 0.2, num=30):
qt.epsilon = e
for nan in num.linspace(0.1, 1.0, num=30):
for nan in np.linspace(0.1, 1.0, num=30):
qt.nan_allowed = nan
for s in num.linspace(100, 4000, num=30):
for s in np.linspace(100, 4000, num=30):
qt.tile_size_min = s
qt.tile_size_max = 5000
for s in num.linspace(200, 4000, num=30):
for s in np.linspace(200, 4000, num=30):
qt.tile_size_min = 20

@@ -62,0 +61,0 @@ qt.tile_size_max = s

import unittest
import numpy as num
import numpy as np

@@ -43,5 +43,5 @@ from kite import SandboxScene

X, Y = num.meshgrid(num.arange(nrows), num.arange(ncols))
X, Y = np.meshgrid(np.arange(nrows), np.arange(ncols))
coords = num.empty((nrows * ncols, 2))
coords = np.empty((nrows * ncols, 2))
coords[:, 0] = X.ravel()

@@ -70,3 +70,3 @@ coords[:, 1] = Y.ravel()

X, Y = num.meshgrid(num.linspace(-7.0, 7.0, 701), num.linspace(-5.0, 5.0, 501))
X, Y = np.meshgrid(np.linspace(-7.0, 7.0, 701), np.linspace(-5.0, 5.0, 501))
x0 = 0.5

@@ -88,3 +88,3 @@ y0 = -0.25

coords = num.empty((X.size, 2))
coords = np.empty((X.size, 2))
coords[:, 0] = X.ravel()

@@ -109,4 +109,4 @@ coords[:, 1] = Y.ravel()

num.testing.assert_equal(X, mat["X"])
num.testing.assert_equal(Y, mat["Y"])
np.testing.assert_equal(X, mat["X"])
np.testing.assert_equal(Y, mat["Y"])

@@ -116,3 +116,3 @@ for pym, comp in zip([ue, un, uv], ["ue", "un", "uv"]):

# print([pym.min(), pym.max()], [m.min(), m.max()])
num.testing.assert_allclose(pym, m, rtol=1e-11)
np.testing.assert_allclose(pym, m, rtol=1e-11)

@@ -124,3 +124,3 @@ self._plot_displacement(uv)

def r(lo, hi):
return num.random.randint(lo, high=hi, size=1).astype(num.float)
return np.random.randint(lo, high=hi, size=1).astype(float)

@@ -144,3 +144,3 @@ ms = SandboxScene()

X, Y = num.meshgrid(num.linspace(-7.0, 7.0, 701), num.linspace(-5.0, 5.0, 501))
X, Y = np.meshgrid(np.linspace(-7.0, 7.0, 701), np.linspace(-5.0, 5.0, 501))
x0 = 0.5

@@ -160,3 +160,3 @@ y0 = -0.25

coords = num.empty((X.size, 2))
coords = np.empty((X.size, 2))
coords[:, 0] = X.ravel()

@@ -181,4 +181,4 @@ coords[:, 1] = Y.ravel()

num.testing.assert_equal(X, mat["X"])
num.testing.assert_equal(Y, mat["Y"])
np.testing.assert_equal(X, mat["X"])
np.testing.assert_equal(Y, mat["Y"])

@@ -188,3 +188,3 @@ for pym, comp in zip([ue, un, uv], ["ue", "un", "uv"]):

# print([pym.min(), pym.max()], [m.min(), m.max()])
num.testing.assert_allclose(pym, m, rtol=1e-9)
np.testing.assert_allclose(pym, m, rtol=1e-9)

@@ -196,3 +196,3 @@ self._plot_displacement(mat["uv"])

def r(lo, hi):
return num.random.randint(lo, high=hi, size=1).astype(num.float)
return np.random.randint(lo, high=hi, size=1).astype(float)

@@ -223,3 +223,3 @@ ms = SandboxScene()

ax.imshow(
num.flipud(ms.down),
np.flipud(ms.down),
aspect="equal",

@@ -226,0 +226,0 @@ extent=[0, ms.frame.E.max(), 0, ms.frame.N.max()],

@@ -5,3 +5,3 @@ import shutil

import numpy as num
import numpy as np

@@ -23,6 +23,4 @@ from kite import SandboxScene, TestSandboxScene

self.tmpdir = tempfile.mkdtemp(prefix="kite")
print(self.tmpdir)
def tearDown(self):
return
shutil.rmtree(self.tmpdir)

@@ -33,16 +31,20 @@

def r(lo, hi):
return num.random.randint(lo, high=hi, size=1).astype(num.float)
def random_int(low, high):
return np.random.randint(low, high, size=1).astype(float)
for s in xrange(nsources):
length = r(5000, 15000)
for s in range(nsources):
length = random_int(5000, 15000)
self.ms.addSource(
OkadaSource(
easting=r(0.0, self.ms.frame.E.max()), # ok
northing=r(0.0, self.ms.frame.N.max()), # ok
depth=r(0, 8000), # ok
strike=r(0, 360), # ok
dip=r(0, 170),
slip=r(1, 5), # ok
rake=r(0, 180),
easting=random_int(
self.ms.frame.E.min(), self.ms.frame.E.max()
), # ok
northing=random_int(
self.ms.frame.N.min(), self.ms.frame.N.max()
), # ok
depth=random_int(0, 8000), # ok
strike=random_int(0, 360), # ok
dip=random_int(0, 170),
slip=random_int(1, 5), # ok
rake=random_int(0, 180),
length=length,

@@ -82,3 +84,3 @@ width=15.0 * length**0.66,

ax.imshow(
num.flipud(ms.down),
np.flipud(ms.down),
aspect="equal",

@@ -92,3 +94,3 @@ extent=[0, ms.frame.E.max(), 0, ms.frame.N.max()],

if isinstance(src, OkadaPath):
nodes = num.array(src.nodes)
nodes = np.array(src.nodes)
ax.scatter(nodes[:, 0], nodes[:, 1], color="r")

@@ -95,0 +97,0 @@ plt.show()

@@ -5,3 +5,3 @@ import shutil

import numpy as num
import numpy as np

@@ -38,3 +38,3 @@ from kite import SandboxScene, TestSandboxScene # noqa

def r(lo, hi):
return num.random.randint(lo, high=hi, size=1).astype(num.float)
return np.random.randint(lo, high=hi, size=1).astype(float)

@@ -64,5 +64,5 @@ for s in range(nsources):

def r(lo, hi):
return num.random.randint(lo, high=hi, size=1).astype(num.float)
return np.random.randint(lo, high=hi, size=1).astype(float)
for s in xrange(nsources):
for s in range(nsources):
self.ms.addSource(

@@ -83,5 +83,5 @@ PyrockoMomentTensor(

def r(lo, hi):
return num.random.randint(lo, high=hi, size=1).astype(num.float)
return np.random.randint(lo, high=hi, size=1).astype(float)
for s in xrange(nsources):
for s in range(nsources):
self.ms.addSource(

@@ -102,5 +102,5 @@ PyrockoDoubleCouple(

def r(lo, hi):
return num.random.randint(lo, high=hi, size=1).astype(num.float)
return np.random.randint(lo, high=hi, size=1).astype(float)
for s in xrange(nsources):
for s in range(nsources):
diameter = r(5000, 15000)

@@ -136,3 +136,3 @@ self.ms.addSource(

ax.imshow(
num.flipud(ms.north),
np.flipud(ms.north),
aspect="equal",

@@ -139,0 +139,0 @@ extent=[0, ms.frame.E.max(), 0, ms.frame.N.max()],

@@ -1,2 +0,2 @@

import numpy as num
import numpy as np

@@ -7,3 +7,3 @@ from kite import util

def test_trim_matrix():
arr = num.full((100, 100), num.nan)
arr = np.full((100, 100), np.nan)

@@ -16,3 +16,3 @@ arr[-1, -1] = 1.0

arr[num.diag_indices_from(arr)] = 1.0
arr[np.diag_indices_from(arr)] = 1.0
assert util.trimMatrix(arr).shape == arr.shape