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

Debug vcoorfile

parent 0eae9a37
......@@ -33,9 +33,17 @@ def make_obs(self, ddi, datastore, runsubdir, mode, tracer):
col2extract = "adj_out" if mode == "adj" else "obs"
# Include only part of the datastore
data = self.dataobs[ddi][tracer][
["tstep", "dtstep", "i", "j", col2extract, "level"]
].values
metadata = self.dataobs[ddi][tracer]["metadata"]
maindata = self.dataobs[ddi][tracer]["maindata"]
data = np.concatenate([
metadata.loc[:, ["tstep", "dtstep", "i", "j"]].values,
maindata.loc[:, [col2extract]].values,
metadata.loc[:, ["level"]].values],
axis=1)
print(__file__)
import code
code.interact(local=dict(locals(), **globals()))
# Converts level, tstep, i, j to fortran levels
data[:, [0, 2, 3, 5]] += 1
......@@ -48,7 +56,7 @@ def make_obs(self, ddi, datastore, runsubdir, mode, tracer):
# Attribute ID to each species
for k, s in enumerate(self.chemistry.acspecies.attributes):
mask = (self.dataobs[ddi][tracer]["parameter"].str.lower()
mask = (metadata["parameter"].str.lower()
== s.lower()).values
data[mask, -1] += k + 1
......
......@@ -26,19 +26,19 @@ def vcoordfromfile(datastore, file_lev, **kwargs):
"file_lev: {}\n"
"station infos: {}\n"
"station in datastore: {}".format(
file_lev, lev_stats, datastore["station"].unique()
file_lev, lev_stats, datastore["metadata"]["station"].unique()
))
computed_level = 0
for s, linfo in zip(lev_stats, lev_infos):
mask = datastore["station"].str.lower() == s.lower()
mask = datastore["metadata"]["station"].str.lower() == s.lower()
levels.loc[mask] = linfo
computed_level += 1
if computed_level != len(datastore):
missing = []
for stat in datastore["station"].unique():
if np.any(np.isnan(levels.loc[datastore["station"] == stat])):
for stat in datastore["metadata"]["station"].unique():
if np.any(np.isnan(levels.loc[datastore["metadata"]["station"] == stat])):
missing.append(stat)
raise Exception("I could not compute levels for all data points. "
......
......@@ -186,9 +186,10 @@ def ref_lmdz(tmpdir):
'CH4': {
'dir': '{}/monitor/'.format(input_dir),
'file': 'monitor_allobs_newformat.nc',
"file_statlev":
"{}/stations_levels_LMDZ39lev.txt".format(
input_dir)
"vertical_interpolation":{
"file_statlev":
"{}/stations_levels_LMDZ39lev.txt".format(input_dir)
}
}
}
}
......
......@@ -41,7 +41,7 @@ def test_integration_fwd(lmdz_config_fwd):
monitor_ref = read_datastore(os.path.join(param_dir, "monitor.nc"))
# Compare results
assert np.all(~np.isnan(monitor_ref["sim"]))
assert np.all(~np.isnan(monitor_ref["maindata"]["sim"]))
# Dump configuration into CIF examples
current_dir = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
......
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