Skip to content

Commit

Permalink
Simplify runoff forcing file name template config
Browse files Browse the repository at this point in the history
We no longer need the possibility of having multiple runoff file name templates
for different bathymetries, flatten the config dict.
  • Loading branch information
douglatornell committed Feb 9, 2023
1 parent 75e7ab7 commit ee2c18c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 36 deletions.
5 changes: 2 additions & 3 deletions config/nowcast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,9 @@ rivers:
TheodosiaDiversion: /results/forcing/rivers/observations/Theodosia_Diversion_flow
# Destination directory for river runoff forcing file
rivers dir: /results/forcing/rivers/
# Templates for the runoff forcing file names
# Template for the runoff forcing file name
# **Must be quoted to project {} characters**
file templates:
b202108: 'R202108Dailies_{:y%Ym%md%d}.nc'
file template: 'R202108Dailies_{:y%Ym%md%d}.nc'
prop_dict modules:
b202108: salishsea_tools.river_202108
turbidity:
Expand Down
52 changes: 23 additions & 29 deletions notebooks/ProductionDailyRiverNCfile.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -135,7 +135,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand All @@ -154,21 +154,7 @@
"no secondary\n",
"[[424.640526]]\n",
"howe\n",
"no secondary\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/media/doug/warehouse/MEOPAR/SalishSeaNowcast/nowcast/daily_river_flows.py:129: ParserWarning: Length of header or names does not match length of data. This leads to a loss of data with index_col=False.\n",
" river_flow = pd.read_csv(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"no secondary\n",
"[[95.57461136]]\n",
"jdf\n",
"no secondary\n",
Expand All @@ -180,13 +166,15 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/media/doug/warehouse/MEOPAR/SalishSeaNowcast/nowcast/daily_river_flows.py:129: ParserWarning: Length of header or names does not match length of data. This leads to a loss of data with index_col=False.\n",
"/media/doug/warehouse/MEOPAR/SalishSeaNowcast/nowcast/daily_river_flows.py:127: ParserWarning: Length of header or names does not match length of data. This leads to a loss of data with index_col=False.\n",
" river_flow = pd.read_csv(\n",
"/media/doug/warehouse/MEOPAR/SalishSeaNowcast/nowcast/daily_river_flows.py:129: ParserWarning: Length of header or names does not match length of data. This leads to a loss of data with index_col=False.\n",
"/media/doug/warehouse/MEOPAR/SalishSeaNowcast/nowcast/daily_river_flows.py:127: ParserWarning: Length of header or names does not match length of data. This leads to a loss of data with index_col=False.\n",
" river_flow = pd.read_csv(\n",
"/media/doug/warehouse/MEOPAR/SalishSeaNowcast/nowcast/daily_river_flows.py:129: ParserWarning: Length of header or names does not match length of data. This leads to a loss of data with index_col=False.\n",
"/media/doug/warehouse/MEOPAR/SalishSeaNowcast/nowcast/daily_river_flows.py:127: ParserWarning: Length of header or names does not match length of data. This leads to a loss of data with index_col=False.\n",
" river_flow = pd.read_csv(\n",
"/media/doug/warehouse/MEOPAR/SalishSeaNowcast/nowcast/daily_river_flows.py:129: ParserWarning: Length of header or names does not match length of data. This leads to a loss of data with index_col=False.\n",
"/media/doug/warehouse/MEOPAR/SalishSeaNowcast/nowcast/daily_river_flows.py:127: ParserWarning: Length of header or names does not match length of data. This leads to a loss of data with index_col=False.\n",
" river_flow = pd.read_csv(\n",
"/media/doug/warehouse/MEOPAR/SalishSeaNowcast/nowcast/daily_river_flows.py:127: ParserWarning: Length of header or names does not match length of data. This leads to a loss of data with index_col=False.\n",
" river_flow = pd.read_csv(\n"
]
},
Expand All @@ -201,17 +189,23 @@
"[[133.01744522]]\n",
"fraser\n",
"[[943.07805743]]\n",
"files read\n",
"/tmp/R202108Dailies_y2023m02d05.nc\n"
"files read\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/media/doug/warehouse/MEOPAR/SalishSeaNowcast/nowcast/daily_river_flows.py:129: ParserWarning: Length of header or names does not match length of data. This leads to a loss of data with index_col=False.\n",
"/media/doug/warehouse/MEOPAR/SalishSeaNowcast/nowcast/daily_river_flows.py:127: ParserWarning: Length of header or names does not match length of data. This leads to a loss of data with index_col=False.\n",
" river_flow = pd.read_csv(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"/tmp/R202108Dailies_y2023m02d05.nc\n"
]
}
],
"source": [
Expand Down Expand Up @@ -723,7 +717,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -736,7 +730,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -745,7 +739,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -768,7 +762,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 8,
"outputs": [],
"source": [
"def nemo_yyyymmdd(data_date):\n",
Expand All @@ -789,7 +783,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand Down
6 changes: 2 additions & 4 deletions nowcast/daily_river_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

prop_dict_name = "river_202108"

bathy_type = "b202108"


names = [
"bute",
Expand Down Expand Up @@ -460,9 +458,9 @@ def write_file(day, runoff, config):

# set up filename
directory = Path(config["rivers"]["rivers dir"])
filename_tmpls = config["rivers"]["file templates"][bathy_type]
filename_tmpl = config["rivers"]["file template"]

filename = directory / filename_tmpls.format(day.date())
filename = directory / filename_tmpl.format(day.date())
print(filename)

netcdf_title = f"Rivers for {day.date()}"
Expand Down

0 comments on commit ee2c18c

Please sign in to comment.