Commit c95977cd authored by Antoine Berchet's avatar Antoine Berchet
Browse files

Fix LMDZ

parent cc4dff7a
......@@ -54,13 +54,12 @@ def adjoint(
for comp, spec in zip(components_in, inputs):
file_fwd_data = \
ddi.strftime(
"{}/chain/isotopes/{}_fwd_obsvect_{}_{}_%Y%m%d%H%M.nc".format(
"{}/chain/conc2ratio/{}_fwd_obsvect_{}_{}_%Y%m%d%H%M.nc".format(
transform.model.adj_refdir, transform.orig_name, comp, spec))
ds = read_datastore(
file_fwd_data, reorder=False,
col2dump=[("metadata", "parameter"), ("metadata", "parameter_ref"),
("maindata", "spec"), ("maindata", "incr")])
datastore_in[(comp, spec)][di].loc[:, ("metadata", "parameter")] = \
ds[("metadata", "parameter")].values
datastore_in[(comp, spec)][di].loc[:, ("metadata", "parameter_ref")] = \
......
......@@ -41,7 +41,7 @@ def forward(
for comp, spec in zip(components_in, inputs):
file_fwd_data = \
ddi.strftime(
"{}/../chain/isotopes/{}_fwd_obsvect_{}_{}_%Y%m%d%H%M.nc"
"{}/../chain/conc2ratio/{}_fwd_obsvect_{}_{}_%Y%m%d%H%M.nc"
.format(runsubdir, transform.orig_name, comp, spec))
dump_datastore(
datastore_in[(comp, spec)][di],
......@@ -108,5 +108,5 @@ def forward(
if mode == "tl":
dfout_ref.loc[:, ("maindata", "incr")] = \
spec_sim.loc[mask_spec, "incr"]
spec_sims.loc[mask_spec, "incr"]
......@@ -45,7 +45,7 @@ def adjoint(
# Fet fwd data
file_fwd_dataset = ddi.strftime(
"{}/chain/{}_fwd_%Y%m%d%H%M.nc".format(
"{}/chain/ratio2conc/{}_fwd_%Y%m%d%H%M.nc".format(
transform.model.adj_refdir, transform.orig_name))
fwd_dataset = xr.open_dataset(file_fwd_dataset)
......
......@@ -2,6 +2,8 @@ import numpy as np
import pandas as pd
import copy
import xarray as xr
import os
from .....utils.path import init_dir
def forward(
......@@ -56,13 +58,18 @@ def forward(
for sign in inputs[:-1]}
# Save signature and data for later use by adjoint
dump_dir = "{}/../chain/ratio2conc/".format(runsubdir, transform.orig_name)
if not os.path.isdir(dump_dir):
init_dir(dump_dir)
file_fwd_dataset = ddi.strftime(
"{}/../chain/{}_fwd_%Y%m%d%H%M.nc"
"{}/../chain/ratio2conc/{}_fwd_%Y%m%d%H%M.nc"
.format(runsubdir, transform.orig_name))
fwd_dataset = spec_data.to_dataset(name="spec")
for sign in inputs[:-1]:
fwd_dataset[sign] = signatures[sign]
fwd_dataset.to_netcdf(file_fwd_dataset)
# Compute fwd spec
......
......@@ -317,7 +317,11 @@ def read_datastore(
# Keep only some variables
keys = copy.deepcopy(list(ds.keys()))
for k in keys:
if k not in col2dump + coord2dump:
tokeep = [
col == (group, k) if type(col) == tuple
else col == k for col in col2dump + coord2dump]
if sum(tokeep) == 0:
del ds[k]
keys = list(ds.coords.keys()) + list(ds.dims.keys())
......
......@@ -26,6 +26,10 @@ def test_integration_adjtltest(lmdz_config_fwd, settings):
# Fetch coniguration
(tmpdir, config, tag) = lmdz_config_fwd
# Skip N2O configuration
if "n2o" in tag:
pytest.skip("Skipping N2O test of the adjoint. Still issue in photolysis.")
# Replace running mode to test of the adjoint
config.update(
{"mode": {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment