Skip to content

Commit 0a7a7c8

Browse files
authored
Scale cov incalcs (#53)
* fixes #52 scale covariance by dependent vars * don't need registry in layers * tested using `Uncertainties.wrap()` by comparing uncertainties for calculated zenith and azimuth
1 parent 5a87573 commit 0a7a7c8

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

carousel/core/calculations.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,12 @@ def calc_static(self, formula_reg, data_reg, out_reg, timestep):
276276
# split uncertainty and jacobian from return values
277277
cov, jac = retval[-2:]
278278
retval = retval[:-2]
279+
# scale covariance
280+
scale = np.asarray(
281+
[1 / r.m if isinstance(r, UREG.Quantity) else 1 / r
282+
for r in retval]
283+
) # use magnitudes if quantities
284+
cov = (np.swapaxes((cov.T * scale), 0, 1) * scale).T
279285
nret = len(retval) # number of return output
280286
for m in xrange(nret):
281287
a = returns[m] # name in output registry

carousel/core/layers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
import importlib
2929
import os
30-
from carousel.core import Registry
3130
from carousel.core.simulations import SimRegistry
3231
from carousel.core.data_sources import DataRegistry
3332
from carousel.core.formulas import FormulaRegistry

0 commit comments

Comments
 (0)