Skip to content
Snippets Groups Projects
Commit 55ae099f authored by Florian Ziemen's avatar Florian Ziemen
Browse files

move simulation namelist parameters into separate dictionary

parent 0529bc9d
No related branches found
No related tags found
1 merge request!7Improve dakuan processing
This diff is collapsed.
%% Cell type:code id: tags:
``` python
import pandas as pd
import yaml
```
%% Cell type:code id: tags:
``` python
df = pd.read_excel("../inputs/enso_tuning.xlsx", index_col=0)
df.loc[df["Remark"].isna(), "Remark"] = ""
```
%% Cell type:code id: tags:
``` python
always_add = {
"experiment": "coming decade - icon xpp enso tuning",
"contact": "Dakuan Yu",
}
always_copy = ["Remark", "Resolution"]
defaults = df.iloc[5]
defaults
runs = {}
for name, row in df.iloc[4:].iterrows():
runs[name] = dict(always_add)
if name == defaults.name:
runs[name] |= {k.lower(): v for k, v in row.items() if v}
runs[name] |= dict(
parameters={
k.lower(): v for k, v in row.items() if v and k not in always_copy
}
)
else:
runs[name] |= dict(parameters=dict(defaults=defaults.name))
for k, v in row.items():
if k in always_copy:
if v:
runs[name][k.lower()] = v
else:
if v != defaults[k]:
runs[name][k.lower()] = v
runs[name]["defaults"] = defaults.name
runs[name]["parameters"][k.lower()] = v
```
%% Cell type:code id: tags:
``` python
with open("../inputs/icon-xpp-enso.metadata", "w") as mdf:
yaml.dump(runs, mdf)
```
......
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