Skip to content
Snippets Groups Projects
Commit 02ca72cd authored by Antoine Berchet's avatar Antoine Berchet
Browse files

New transform pipe working with loadfromoutputs

parent ade9e3fd
No related branches found
No related tags found
1 merge request!28Fix issue with global domains and find_gridcells; speed up regrid for...
......@@ -121,6 +121,56 @@ def connect_pipes(self, all_transforms,
precursors[trid] = [new_id]
itransf += 1
# Read output files if necessary
ref_transforms = copy.deepcopy(all_transforms.attributes)
itransf = 0
for transform in ref_transforms:
transf = getattr(all_transforms, transform)
transf_mapper = mapper[transform]
precursors = transf_mapper["precursors"]
successors = transf_mapper["successors"]
itransf += 1
for trid in transf_mapper["outputs"]:
if transf_mapper["outputs"][trid].get("force_loadout", False):
# Adding a load transformation after the present one
yml_dict = {
"plugin": {
"name": "loadfromoutputs",
"version": "std",
"type": "transform",
},
"component": [trid[0]],
"parameter": [trid[1]],
}
new_transf, new_id = add_default(
all_transforms,
yml_dict,
position="index",
index=itransf,
mapper=mapper,
init=True,
inputs=all_inputs,
outputs=all_outputs,
backup_comps=backup_comps,
precursor=transform
)
itransf += 1
# Update successors of transform precursors
# to replace by current loadfromoutputs
for tr in successors[trid]:
itr = mapper[tr]["precursors"][trid].index(transform)
mapper[tr]["precursors"][trid][itr] = new_id
if trid not in mapper[new_id]["successors"]:
mapper[new_id]["successors"][trid] = []
mapper[new_id]["successors"][trid].append(tr)
# Update precursors of current transformation
# to the present dump2inputs
successors[trid] = [new_id]
# Add default transformation "fromcontrol" when no predecessor is available
ref_transforms = copy.deepcopy(all_transforms.attributes)
......@@ -129,6 +179,7 @@ def connect_pipes(self, all_transforms,
transf_mapper = mapper[transform]
precursors = transf_mapper["precursors"]
for trid in precursors:
# Skip if there are precursors
if precursors[trid]:
continue
......@@ -188,6 +239,7 @@ def connect_pipes(self, all_transforms,
transf_mapper = mapper[transform]
successors = transf_mapper["successors"]
for trid in successors:
# Skip if there are successors
if successors[trid]:
continue
......
......@@ -75,16 +75,8 @@ def do_transforms(
outputs = transf_mapper["inputs"]
precursors = transf_mapper["successors"]
successors = transf_mapper["precursors"]
tmp_datastore = transform_pipe.datastore.get(transform, {})
for inpt in inputs:
if inpt not in tmp_datastore:
tmp_datastore[inpt] = {}
for tr in precursors[inpt]:
tmp_datastore[inpt].update(
transform_pipe.datastore.get(tr, {}).get(inpt, {})
)
for outpt in outputs:
if outpt not in tmp_datastore:
tmp_datastore[outpt] = {}
......@@ -93,13 +85,23 @@ def do_transforms(
transform_pipe.datastore.get(tr, {}).get(outpt, {})
)
for inpt in inputs:
if inpt not in tmp_datastore:
tmp_datastore[inpt] = {}
for tr in precursors[inpt]:
tmp_datastore[inpt].update(
transform_pipe.datastore.get(tr, {}).get(inpt, {})
)
for inpt in inputs:
tmp_datastore[inpt].update(inputs[inpt])
if transform == "default_23":
print(__file__)
import code
code.interact(local=dict(locals(), **globals()))
# if transf.plugin.name == "loadfromoutputs" \
# and ("concs", "HCHO") in transf_mapper["inputs"]:
# print(tmp_datastore[("concs", "HCHO")]["data"])
# print(__file__)
# import code
# code.interact(local=dict(locals(), **globals()))
# Do the transform
......
......@@ -114,3 +114,4 @@ def adjoint(
param.obs_domain_init = True
datastore[tracer_id]["domain"] = param.domain
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment