grat.run
¶
Runs the model and produces the reports, in one call.
This is the only module that imports both grat.model and grat.reports. The model
knows nothing about reports; the reports layer knows nothing about how a run is driven.
They meet here, through start_analysis's on_year hook.
One call runs every water year and writes the reports::
result = run_grat(sites, wafr, bottlenecks, crop_calendar, precip,
reports=["annual_summary_recharge", "daily_summary_recharge"])
result["zip_path"] # the archive to hand to someone
result["reports"] # the report names that were produced
result["series"]["unused_wafr"] # the frontend visualisation data
Any report the run produced can then be read back as a dataframe, without the run having held anything in memory::
from grat import read_report
read_report(result["output_folder"], "annual_summary_recharge")
read_report(result["output_folder"], "daily_recharge_by_site", year=2047)
run_grat
¶
run_grat(
raw_sites,
raw_wafr,
raw_bottlenecks,
crop_calendar,
precip,
*,
reports=ALL_REPORTS,
output_parent=".",
zip_output=True,
zip_name=None,
**model_kwargs,
)
Runs the model across every water year and produces the requested reports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_sites
|
every canal, basin and farm, in processing order. |
required | |
raw_wafr
|
water available for recharge, indexed as |
required | |
raw_bottlenecks
|
the bottlenecks restricting delivery, or None. |
required | |
crop_calendar
|
accepted application rate, indexed as |
required | |
precip
|
precipitation, indexed as |
required | |
reports
|
report names to produce. Defaults to everything in the catalog; pass a smaller list and only the intermediates those reports need are built. |
ALL_REPORTS
|
|
output_parent
|
directory to create the timestamped results folder in. |
'.'
|
|
zip_output
|
zip the results folder when the run finishes. |
True
|
|
zip_name
|
name for the zip, defaulting to the results folder's name. |
None
|
|
**model_kwargs
|
passed through to |
{}
|
Returns:
| Type | Description |
|---|---|
|
A dict with four keys: |
|
|
|
|
|
|
|
|
Raises:
| Type | Description |
|---|---|
KeyError
|
a report name is not in the catalog. |
ValueError
|
on Windows, |
Source code in src/grat/run.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |