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

Fix dummy

parent 1c5fd85e
......@@ -37,10 +37,10 @@ def outputs2native(
continue
dataout[trid] = data2dump[trid][ddi]
dataout[trid]["spec"][:] = \
datastore[ddi][trid[1]]["spec"][:]
dataout[trid]["incr"][:] = \
datastore[ddi][trid[1]]["incr"][:]
dataout[trid].loc[:, ("maindata", "spec")] = \
datastore[ddi][trid[1]][("maindata", "spec")][:]
dataout[trid].loc[:, ("maindata", "incr")] = \
datastore[ddi][trid[1]][("maindata", "incr")][:]
return dataout
......@@ -74,14 +74,14 @@ def run(self, runsubdir, mode, workdir, ddi, do_simu=True, **kwargs):
# Compute H.x or H^T.dy depending on the running mode
for spec in self.chemistry.acspecies.attributes:
specobs = self.dataobs[ddi][spec]
meteo_index = specobs["tstep"].astype(int)
meteo_index = specobs["metadata"]["tstep"].astype(int)
if mode in ["fwd", "tl"]:
# In fwd and tl, simple product of flux and footprints
specobs["spec"][:] = np.nansum(
specobs.loc[:, ("maindata", "spec")] = np.nansum(
self.dataflx[ddi][spec].values[meteo_index, 0] * H[spec],
axis=(1, 2)
)
specobs["incr"][:] = np.nansum(
specobs.loc[:, ("maindata", "incr")] = np.nansum(
self.dataflx_tl[ddi][spec].values[meteo_index, 0] * H[spec],
axis=(1, 2)
)
......@@ -104,7 +104,8 @@ def run(self, runsubdir, mode, workdir, ddi, do_simu=True, **kwargs):
# In adjoint, aggregation of footprints, to model resolution
dflx = \
specobs["adj_out"].values[:, np.newaxis, np.newaxis] * H[spec]
specobs[("maindata", "adj_out")].values[:, np.newaxis, np.newaxis] \
* H[spec]
dflx[np.isnan(dflx)] = 0.0
dflx = xr.DataArray(
......@@ -153,7 +154,7 @@ def fortran_exe(self, pg_file, mode, spec, ddi):
pg_params = pd.read_csv(pg_file)
# Init variables
meteo_index = specobs["tstep"]
meteo_index = specobs["metadata"]["tstep"]
meteo_data = self.meteo.data[ddi]
winddir = meteo_data["winddir"]
......@@ -163,11 +164,11 @@ def fortran_exe(self, pg_file, mode, spec, ddi):
# Computing distance along plume in km
dx = (
self.domain.zlon[np.newaxis]
- specobs["lon"].values[:, np.newaxis, np.newaxis]
- specobs["metadata"]["lon"].values[:, np.newaxis, np.newaxis]
)
dy = (
self.domain.zlat[np.newaxis]
- specobs["lat"].values[:, np.newaxis, np.newaxis]
- specobs["metadata"]["lat"].values[:, np.newaxis, np.newaxis]
)
dist = np.sqrt(dx ** 2 + dy ** 2) * 1e-3
......@@ -221,7 +222,7 @@ def fortran_exe(self, pg_file, mode, spec, ddi):
* np.exp(-(y ** 2) / 2.0 / sigma_y ** 2)
* 2
* np.exp(
- specobs["alt"].values[:, np.newaxis, np.newaxis] ** 2
- specobs["metadata"]["alt"].values[:, np.newaxis, np.newaxis] ** 2
/ 2.0
/ sigma_z ** 2
)
......
......@@ -41,7 +41,8 @@ def test_integration_fwd(dummy_config_fwd, pytestconfig):
parameters = os.listdir(comp_dir)
for param in parameters:
param_dir = os.path.join(comp_dir, param)
monitor_ref = read_datastore(os.path.join(param_dir, "monitor.nc"))
monitor_ref = read_datastore(
os.path.join(param_dir, "monitor.nc"))["maindata"]
# Compare results
if param in active_species:
......@@ -60,7 +61,7 @@ def test_integration_fwd(dummy_config_fwd, pytestconfig):
# Read observations
file_obs = "{}/obsvect/concs/CH4/monitor.nc".format(tmpdir)
monitor_ref = read_datastore(file_obs)
monitor_ref = read_datastore(file_obs)["metadata"]
coords = monitor_ref.loc[:, ["lon", "lat", "alt"]].drop_duplicates()
# Read fluxes
......
......@@ -155,7 +155,7 @@ def test_integration_inversion(dummy_config_inversion, settings, pytestconfig):
param_dir = os.path.join(comp_dir_post, param)
monitor_post = \
read_datastore(os.path.join(param_dir, "monitor.nc"))
read_datastore(os.path.join(param_dir, "monitor.nc"))["maindata"]
assert (
(monitor_prior.loc[:, "obs"]
- monitor_prior.loc[:, "sim"]).pow(2).sum()
......
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