Commit 025b8a8b authored by Antoine Berchet's avatar Antoine Berchet
Browse files

Fixing interpolation of initial conditions with NOAA glob_avg

parent 848970bd
......@@ -43,5 +43,5 @@ def default_fetch(
list_files[datei] = list(set(local_files))
list_dates[datei] = list(set(tmp_dates))
return list_files, list_dates
......@@ -70,8 +70,10 @@ def init_components(plugin):
if comp in backups
else None)
)
if cmp is None and not hasattr(tracer, "fetch"):
print(comp, trcr)
if (cmp is None or hasattr(tracer, "read")) \
and not hasattr(tracer, "fetch"):
warning(
"{} in your Yaml is not recognized as"
" a valid input for the model"
......@@ -84,7 +86,6 @@ def init_components(plugin):
elif cmp is not None:
tracer.read = getattr(tracer, "read",
cmp.read)
tracer.fetch = getattr(
tracer, "fetch",
getattr(cmp, "fetch",
......
......@@ -47,6 +47,15 @@ input_arguments = {
"accepted": float
},
"pressure_unit": {
"doc": "Unit for the pressure in the VCOORD file",
"default": "Pa",
"accepted": {
"Pa": "Pascals",
"hPa": "hectoPascals"
}
},
"emissublayer": {
"doc": "Use a sub-layer for surface emissions",
"default": 0,
......
......@@ -40,5 +40,5 @@ def fetch(
path.link(f, target_file)
list_files[datei] = os.path.basename(target_file)
return list_files, list_dates
......@@ -74,5 +74,6 @@ def get_domain(ref_dir, ref_file, input_dates, target_dir, tracer=None):
setup.domain.nlev = len(pres)
setup.domain.sigma_a = pres.values / 1e2
setup.domain.sigma_b = 0. * pres.values
setup.domain.pressure_unit = "hPa"
return setup.domain
......@@ -43,7 +43,7 @@ def read(
tmp = readnc(os.path.join(tracdir, ff),
[self.varname_init])
data.append(tmp[0])
# Putting in DataArray
xmod = xr.DataArray(
data, coords={"time": dates}, dims=("time", "lev", "lat", "lon")
......
......@@ -58,11 +58,20 @@ def forward(
psurf = transf.psurf
pres_in = sigma_a_in + psurf * sigma_b_in
pres_out = sigma_a_out + psurf * sigma_b_out
# Converting all pressure to Pa if need
if getattr(xmod[trid]["tracer"].domain, "pressure_unit") == "hPa":
pres_in *= 100
if getattr(domain_out, "pressure_unit") == "hPa":
pres_out *= 100
if "log_interp" in mapper["outputs"][trid]:
pres_in = np.log10(pres_in)
pres_out = np.log10(pres_out)
print(__file__)
import code
code.interact(local=dict(locals(), **globals()))
pres_tmp = np.sort(np.unique(np.append(pres_in, pres_out)))
df_pres = pd.DataFrame(range(len(pres_in)), index=pres_in)
df_pres = df_pres.reindex(pres_tmp).interpolate(method="index")
......@@ -90,7 +99,7 @@ def forward(
coords={"time": var_in.time},
dims=("time", "lev", "lat", "lon"),
)
pipe.datastore = xmod
return pipe
......@@ -9,6 +9,11 @@ from .baseclass import Plugin
class Domain(Plugin):
def __init__(self, **kwargs):
"""Create a Model Class"""
super(Domain, self).__init__(**kwargs)
@classmethod
def register_plugin(cls, name, version, module, **kwargs):
"""Register a module for a plugin and version with possibly options
......
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