Skip to content

Commit f5a8f73

Browse files
committed
Update: uncertainty of totals
1 parent c09a669 commit f5a8f73

File tree

2 files changed

+76
-3
lines changed

2 files changed

+76
-3
lines changed

kaleidoscope/config/config.random.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,66 @@
143143
10.0
144144
]
145145
},
146+
"atot_412": {
147+
"total": [
148+
"aph_412",
149+
"adg_412"
150+
],
151+
"clip": [
152+
0.0,
153+
10.0
154+
]
155+
},
156+
"atot_443": {
157+
"total": [
158+
"aph_443",
159+
"adg_443"
160+
],
161+
"clip": [
162+
0.0,
163+
10.0
164+
]
165+
},
166+
"atot_490": {
167+
"total": [
168+
"aph_490",
169+
"adg_490"
170+
],
171+
"clip": [
172+
0.0,
173+
10.0
174+
]
175+
},
176+
"atot_510": {
177+
"total": [
178+
"aph_510",
179+
"adg_510"
180+
],
181+
"clip": [
182+
0.0,
183+
10.0
184+
]
185+
},
186+
"atot_560": {
187+
"total": [
188+
"aph_560",
189+
"adg_560"
190+
],
191+
"clip": [
192+
0.0,
193+
10.0
194+
]
195+
},
196+
"atot_665": {
197+
"total": [
198+
"aph_665",
199+
"adg_665"
200+
],
201+
"clip": [
202+
0.0,
203+
10.0
204+
]
205+
},
146206
"kd_490": {
147207
"bias": "kd_490_bias",
148208
"rmsd": "kd_490_rmsd",

kaleidoscope/operators/randomizeop.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def run(self, source: Dataset) -> Dataset: # noqa: D102
9191
if v not in config or self._args.selector == 0:
9292
continue
9393
get_logger().info(f"starting graph for variable: {v}")
94-
self.randomize(target, v, x, config[v])
94+
self.randomize(source, target, v, x, config[v])
9595
get_logger().info(f"finished graph for variable: {v}")
9696
target.attrs["monte_carlo_software"] = __name__
9797
target.attrs["monte_carlo_software_version"] = __version__
@@ -110,6 +110,7 @@ def config(self) -> dict[str : dict[str:Any]]:
110110

111111
def randomize(
112112
self,
113+
source: Dataset,
113114
target: Dataset,
114115
v: str,
115116
x: DataArray,
@@ -123,7 +124,18 @@ def randomize(
123124
:param x: The data of the variable.
124125
:param config: The randomization configuration.
125126
"""
126-
if "uncertainty" in config:
127+
if "total" in config:
128+
s = None
129+
z = _decode(x.data, x.attrs)
130+
for ref in config["total"]:
131+
a = _decode(target[ref].data, target[ref].attrs)
132+
b = _decode(source[ref].data, source[ref].attrs)
133+
z = z + (a - b)
134+
if "clip" in config:
135+
z = da.clip(
136+
z, config["clip"][0], config["clip"][1]
137+
)
138+
elif "uncertainty" in config:
127139
s = self.seed(self.uuid(v))
128140
f = Randomize(m=x.ndim, dist=config["distribution"], seed=s)
129141
u = (
@@ -170,7 +182,8 @@ def randomize(
170182
],
171183
dtype=z.dtype,
172184
)
173-
target[v].attrs["seed"] = s
185+
if s is not None:
186+
target[v].attrs["seed"] = s
174187
if get_logger().is_enabled(Logging.DEBUG):
175188
get_logger().debug(f"seed: {s}")
176189
get_logger().debug(f"min: {da.nanmin(z).compute() :.3f}")

0 commit comments

Comments
 (0)