anemone-core 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- anemone/__init__.py +26 -0
- anemone/experiment/__init__.py +1 -0
- anemone/experiment/experiment.py +53 -0
- anemone/forwards/__init__.py +1 -0
- anemone/forwards/forwards.py +755 -0
- anemone/inversion/__init__.py +3 -0
- anemone/inversion/inversion.py +785 -0
- anemone/inversion/models.py +266 -0
- anemone/physics/__init__.py +1 -0
- anemone/physics/physics.py +859 -0
- anemone/system/__init__.py +1 -0
- anemone/system/system.py +595 -0
- anemone/transforms/__init__.py +1 -0
- anemone/transforms/hankel_coefficients.py +212 -0
- anemone/transforms/transforms.py +449 -0
- anemone_core-0.1.0.dist-info/METADATA +65 -0
- anemone_core-0.1.0.dist-info/RECORD +20 -0
- anemone_core-0.1.0.dist-info/WHEEL +5 -0
- anemone_core-0.1.0.dist-info/licenses/LICENSE +8 -0
- anemone_core-0.1.0.dist-info/top_level.txt +1 -0
anemone/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import torch
|
|
2
|
+
|
|
3
|
+
class constants:
|
|
4
|
+
pi = torch.pi
|
|
5
|
+
twopi = 2*torch.pi
|
|
6
|
+
fourpi = 4*torch.pi
|
|
7
|
+
sqrt_twopi = (2*torch.pi)**(1./2.)
|
|
8
|
+
sqrt_pi = torch.pi**(1./2.)
|
|
9
|
+
mu0 = 4*torch.pi*1e-7
|
|
10
|
+
epsilon0 = 8.854187817e-12
|
|
11
|
+
log2 = 0.6931471805599453
|
|
12
|
+
|
|
13
|
+
default_dtype = 'double'
|
|
14
|
+
if default_dtype=='float':
|
|
15
|
+
torch.set_default_dtype(torch.float32)
|
|
16
|
+
elif default_dtype=='double':
|
|
17
|
+
torch.set_default_dtype(torch.float64)
|
|
18
|
+
|
|
19
|
+
def rdtype():
|
|
20
|
+
return torch.get_default_dtype()
|
|
21
|
+
|
|
22
|
+
def cdtype():
|
|
23
|
+
cfloat = rdtype()
|
|
24
|
+
if cfloat==torch.float32: return torch.complex64
|
|
25
|
+
elif cfloat==torch.float64: return torch.complex128
|
|
26
|
+
raise NotImplementedError(f"no complex type associated with current default float {cfloat}")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .experiment import *
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import torch
|
|
3
|
+
from .. import constants as c
|
|
4
|
+
from ..system import *
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def compute_relstd(t_gates, data_val, noise_slope_exponent=-0.5, noise_level_at_1ms=1e-8, current=1, relative_noise=0.03):
|
|
8
|
+
b = noise_level_at_1ms/(1e-3**noise_slope_exponent)
|
|
9
|
+
abs_noise = b*(t_gates**noise_slope_exponent)
|
|
10
|
+
y = data_val*current
|
|
11
|
+
std_rel = abs_noise/y.T
|
|
12
|
+
relstd_tot = torch.sqrt(std_rel**2 + relative_noise**2)
|
|
13
|
+
return relstd_tot.to(data_val.device).T
|
|
14
|
+
|
|
15
|
+
def plot_error_statistics(times, dbdt, dbdt_ref, ax=None, log_relerr=True, abs_color="C0", rel_color="C3", min_percentile=5., max_percentile=95., ok_relerr_lines=3.):
|
|
16
|
+
if ax is None:
|
|
17
|
+
from matplotlib.pyplot import subplots
|
|
18
|
+
fig,ax = subplots()
|
|
19
|
+
|
|
20
|
+
abserr = np.abs(dbdt - dbdt_ref)
|
|
21
|
+
relerr = 100*(dbdt - dbdt_ref) / np.abs(dbdt_ref)
|
|
22
|
+
|
|
23
|
+
ax2 = ax.twinx()
|
|
24
|
+
|
|
25
|
+
if log_relerr:
|
|
26
|
+
relerr = np.abs(relerr)
|
|
27
|
+
|
|
28
|
+
ax.plot(times, relerr.mean(0), '--', color=rel_color)
|
|
29
|
+
ax.plot(times, np.median(relerr, axis=0), '-', color=rel_color)
|
|
30
|
+
lb = np.percentile(relerr, min_percentile, axis=0)
|
|
31
|
+
ub = np.percentile(relerr, max_percentile, axis=0)
|
|
32
|
+
ax.fill_between(times, lb, ub, color=rel_color, alpha=0.2)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
ax2.loglog(times, abserr.mean(0), '--', color=abs_color)
|
|
36
|
+
ax2.loglog(times, np.median(abserr, axis=0), '-', color=abs_color)
|
|
37
|
+
lb = np.percentile(abserr, min_percentile, axis=0)
|
|
38
|
+
ub = np.percentile(abserr, max_percentile, axis=0)
|
|
39
|
+
ax2.fill_between(times, lb, ub, color=abs_color, alpha=0.2)
|
|
40
|
+
|
|
41
|
+
ax2.set_ylabel('Absolute Error [V/m$^2$]', color=abs_color)
|
|
42
|
+
ax.set_ylabel('Relative Error [%]', color=rel_color)
|
|
43
|
+
|
|
44
|
+
if log_relerr:
|
|
45
|
+
ax.set_yscale('log')
|
|
46
|
+
|
|
47
|
+
ax.grid(lw=0.5, which='both')
|
|
48
|
+
if ok_relerr_lines is not None:
|
|
49
|
+
ax.axhline( ok_relerr_lines, color='k', lw=2)
|
|
50
|
+
ax.axhline(-ok_relerr_lines, color='k', lw=2)
|
|
51
|
+
ax.set_xlabel('time [s]')
|
|
52
|
+
|
|
53
|
+
return ax,ax2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .forwards import *
|