mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-15 12:03:42 +02:00
Bugfixes in dobs
This commit is contained in:
parent
c9789a34e6
commit
061ba6ecfa
1 changed files with 15 additions and 19 deletions
|
@ -575,17 +575,13 @@ def read_dobs(fname, noempty=False, full_output=False, gz=True, separator_insert
|
||||||
if not fname.endswith('.gz'):
|
if not fname.endswith('.gz'):
|
||||||
fname += '.gz'
|
fname += '.gz'
|
||||||
with gzip.open(fname, 'r') as fin:
|
with gzip.open(fname, 'r') as fin:
|
||||||
content = fin.read().decode('utf-8')
|
content = fin.read()
|
||||||
else:
|
else:
|
||||||
if fname.endswith('.gz'):
|
if fname.endswith('.gz'):
|
||||||
warnings.warn("Trying to read from %s without unzipping!" % fname, UserWarning)
|
warnings.warn("Trying to read from %s without unzipping!" % fname, UserWarning)
|
||||||
with open(fname, 'r', encoding='utf-8') as fin:
|
with open(fname, 'r') as fin:
|
||||||
content = fin.read()
|
content = fin.read()
|
||||||
|
|
||||||
# open and read gzipped xml file
|
|
||||||
infile = gzip.open(fname)
|
|
||||||
content = infile.read()
|
|
||||||
|
|
||||||
return import_dobs_string(content, noempty, full_output, separator_insertion=separator_insertion)
|
return import_dobs_string(content, noempty, full_output, separator_insertion=separator_insertion)
|
||||||
|
|
||||||
|
|
||||||
|
@ -779,31 +775,31 @@ def create_dobs_string(obsl, name, spec='dobs v1.0', origin='', symbol=[], who=N
|
||||||
|
|
||||||
allcov = {}
|
allcov = {}
|
||||||
for o in obsl:
|
for o in obsl:
|
||||||
for name in o.cov_names:
|
for cname in o.cov_names:
|
||||||
if name in allcov:
|
if cname in allcov:
|
||||||
if not np.array_equal(allcov[name], o.covobs[name].cov):
|
if not np.array_equal(allcov[cname], o.covobs[cname].cov):
|
||||||
raise Exception('Inconsistent covariance matrices for %s!' % (name))
|
raise Exception('Inconsistent covariance matrices for %s!' % (cname))
|
||||||
else:
|
else:
|
||||||
allcov[name] = o.covobs[name].cov
|
allcov[cname] = o.covobs[cname].cov
|
||||||
pd['cdata'] = []
|
pd['cdata'] = []
|
||||||
for name in cov_names:
|
for cname in cov_names:
|
||||||
cd = {}
|
cd = {}
|
||||||
cd['id'] = name
|
cd['id'] = cname
|
||||||
|
|
||||||
covd = {'id': 'cov'}
|
covd = {'id': 'cov'}
|
||||||
if allcov[name].shape == ():
|
if allcov[cname].shape == ():
|
||||||
ncov = 1
|
ncov = 1
|
||||||
covd['layout'] = '1 1 f'
|
covd['layout'] = '1 1 f'
|
||||||
covd['#data'] = '%1.14e' % (allcov[name])
|
covd['#data'] = '%1.14e' % (allcov[cname])
|
||||||
else:
|
else:
|
||||||
shape = allcov[name].shape
|
shape = allcov[cname].shape
|
||||||
assert (shape[0] == shape[1])
|
assert (shape[0] == shape[1])
|
||||||
ncov = shape[0]
|
ncov = shape[0]
|
||||||
covd['layout'] = '%d %d f' % (ncov, ncov)
|
covd['layout'] = '%d %d f' % (ncov, ncov)
|
||||||
ds = ''
|
ds = ''
|
||||||
for i in range(ncov):
|
for i in range(ncov):
|
||||||
for j in range(ncov):
|
for j in range(ncov):
|
||||||
val = allcov[name][i][j]
|
val = allcov[cname][i][j]
|
||||||
if val == 0:
|
if val == 0:
|
||||||
ds += '0 '
|
ds += '0 '
|
||||||
else:
|
else:
|
||||||
|
@ -816,8 +812,8 @@ def create_dobs_string(obsl, name, spec='dobs v1.0', origin='', symbol=[], who=N
|
||||||
ds = ''
|
ds = ''
|
||||||
for i in range(ncov):
|
for i in range(ncov):
|
||||||
for o in obsl:
|
for o in obsl:
|
||||||
if name in o.covobs:
|
if cname in o.covobs:
|
||||||
val = o.covobs[name].grad[i]
|
val = o.covobs[cname].grad[i]
|
||||||
if val != 0:
|
if val != 0:
|
||||||
ds += '%1.14e ' % (val)
|
ds += '%1.14e ' % (val)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue