Skip to content

Commit 2cbd4e0

Browse files
committedNov 8, 2024
minor fixes
1 parent f27bbc8 commit 2cbd4e0

File tree

3 files changed

+24
-45
lines changed

3 files changed

+24
-45
lines changed
 

‎pyobs/core/error.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,11 @@ def covar(self):
332332

333333

334334
class errinfo:
335-
def __init__(self, Stau=1.5, k=0, W=None):
335+
def __init__(self, Stau=1.5, k=0, W=None, gamma_bias=True):
336336
self.Stau = Stau
337337
self.k = k
338338
self.W = W
339-
339+
self.gamma_bias = gamma_bias
340340

341341
def gamma_error(x, name, plot=False, pfile=None, einfo=None):
342342
if einfo is None:
@@ -349,7 +349,8 @@ def gamma_error(x, name, plot=False, pfile=None, einfo=None):
349349
v.set_opt(einfo.W)
350350

351351
if not v.ismf:
352-
# v.correct_gamma_bias()
352+
if einfo.gamma_bias:
353+
v.correct_gamma_bias()
353354
tau = v.tauint() * 0.5
354355
else:
355356
tau = v.tauint()
@@ -363,7 +364,7 @@ def covariance(x, name, W):
363364
cov = covar(x, name)
364365
cov.set_opt(W)
365366

366-
# if not cov.ismf:
367-
# cov.correct_gamma_bias()
367+
if not cov.ismf:
368+
cov.correct_gamma_bias()
368369

369370
return cov.covar()

‎tests/core/error.py

+12-40
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,18 @@
99
N=1000
1010
tau=0.0
1111

12-
rng = pyobs.random.generator(46)
13-
14-
data = rng.markov_chain(val,sig**2,tau,N)
15-
obsA = pyobs.observable()
16-
obsA.create('EnsA',data)
17-
18-
[a,da] = obsA.error()
19-
dda = obsA.error_of_error()
20-
assert abs(a-val) < da
21-
assert abs(da - sig) < dda
22-
print(f'Estimated error {da[0]:g} vs expeceted {sig:g}')
23-
24-
N=10000
25-
tau=0.0
26-
27-
data = rng.markov_chain(val,sig**2,tau,N)
28-
obsA = pyobs.observable()
29-
obsA.create('EnsA',data)
30-
31-
[a,da] = obsA.error()
32-
dda = obsA.error_of_error()
33-
assert abs(a-val) <da
34-
assert abs(da - sig) < dda
35-
print(f'Estimated error {da[0]:g} vs expeceted {sig:g}')
36-
37-
[a, da] = obsA.error(errinfo={'EnsA': pyobs.errinfo(W=0)})
38-
assert abs(a-val) < da
39-
40-
N=4000
41-
tau=4.0
42-
43-
data = rng.markov_chain(val,sig**2,tau,N)
44-
obsA = pyobs.observable()
45-
obsA.create('EnsA',data)
46-
47-
[a,da] = obsA.error()
48-
dda = obsA.error_of_error()
49-
assert abs(a-val) < da
50-
assert abs(da - sig) < dda
51-
print(f'Estimated error {da[0]:g} vs expeceted {sig:g}')
12+
rng = pyobs.random.generator(67)
13+
14+
for tau, N in zip([0.0,4.0],[10000,4000]):
15+
data = rng.markov_chain(val,sig**2,tau,N)
16+
obsA = pyobs.observable()
17+
obsA.create('EnsA',data)
18+
19+
[a,da] = obsA.error()
20+
dda = obsA.error_of_error()
21+
assert abs(a-val) < da
22+
assert abs(da - sig) < dda
23+
print(f'Estimated error {da[0]:g} vs expeceted {sig:g}')
5224

5325
_tau = obsA.tauint()
5426
assert abs(_tau['EnsA'][0]-tau) < 1.5*_tau['EnsA'][1]

‎tests/core/slice.py

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import numpy
33

44
pyobs.set_verbose('slice', True)
5+
pyobs.set_verbose('transform', True)
56

67
T=16
78
L=16
@@ -44,6 +45,11 @@
4445
assert numpy.all(abs(v0-v1) < 1e-12)
4546
assert numpy.all(abs(e0-e1) < 1e-12)
4647

48+
[v0, e0] = obs.error()
49+
[v1, e1] = obs[::-1,:].error()
50+
assert numpy.all(abs(v0[::-1,:]-v1) < 1e-12)
51+
assert numpy.all(abs(e0[::-1,:]-e1) < 1e-12)
52+
4753
pyobs.set_verbose('slice', False)
4854

4955
data = rng.markov_chain(1.23,0.01,tau,N)

0 commit comments

Comments
 (0)
Please sign in to comment.