Skip to content

Commit 4c2642f

Browse files
authored
Merge pull request #59 from ecmwf/feat/restructure
Feat/restructure
2 parents f94c313 + b611829 commit 4c2642f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+71
-4676
lines changed

hat/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
try:
2-
from ._version import __version__
3-
except ImportError:
4-
__version__ = ""
1+
from ._version import __version__

hat/cli.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import yaml
2+
import argparse
3+
4+
from .compute_hydrostats.stat_calc import stat_calc
5+
from .extract_timeseries.extractor import extractor
6+
from .station_mapping.mapper import mapper
7+
8+
def commandlineify(func):
9+
def wrapper():
10+
parser = argparse.ArgumentParser(description="Run tool with YAML config")
11+
parser.add_argument("config", help="Path to the YAML config file")
12+
args = parser.parse_args()
13+
confpath = args.config
14+
with open(confpath, "r") as file:
15+
config = yaml.safe_load(file)
16+
func(config)
17+
return wrapper
18+
19+
mapper_cli = commandlineify(mapper)
20+
extractor_cli = commandlineify(extractor)
21+
stat_calc_cli = commandlineify(stat_calc)

hat/compute_hydrostats/stat_calc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
def load_da(ds_config):
9-
ds = ekd.from_source(*ds_config["datasource"]).to_xarray(xarray_open_mfdataset_kwargs={"chunks": {"time": "auto"}})
9+
ds = ekd.from_source(*ds_config["source"]).to_xarray(xarray_open_mfdataset_kwargs={"chunks": {"time": "auto"}})
1010
var_name = find_main_var(ds, 2)
1111
da = ds[var_name]
1212
return da
@@ -45,5 +45,6 @@ def stat_calc(config):
4545
func = getattr(stats, stat)
4646
stat_dict[stat] = func(sim_da, obs_da, new_coords.get("t", "time"))
4747
ds = xr.Dataset(stat_dict)
48-
48+
if config["output"].get("file", None) is not None:
49+
ds.to_netcdf(config["output"]["file"])
4950
return ds

hat/config.py

Lines changed: 0 additions & 127 deletions
This file was deleted.

hat/config_json/__init__.py

Whitespace-only changes.

hat/config_json/river_network_coordinate_names.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

hat/config_json/timeseries.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)