grat.reports
¶
Turns GRAT model results into report dataframes.
expand
¶
Returns the requested reports plus any report they are built from.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
report names the caller asked for. |
required |
Returns: frozenset of report names to produce
Raises:
| Type | Description |
|---|---|
KeyError
|
a name is not a known report. |
Source code in src/grat/reports/catalog.py
post_process
¶
Builds the reports that can only run once every water year is done.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
report names that were selected. |
required | |
output_folder
|
path to the output folder. |
required | |
produced
|
report names that report_picker produced. |
None
|
dict of report name to result, holding the frontend series as json-ready
| Type | Description |
|---|---|
|
dicts and the post-run csv reports as dataframes |
Raises:
| Type | Description |
|---|---|
KeyError
|
a name is not a known report. |
Source code in src/grat/reports/selector.py
report_picker
¶
report_picker(
names,
output_folder,
year,
sites,
year_raw_wafr,
wafr,
bottlenecks=None,
transfer_list=None,
)
Generates the reports for a single year of results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
report names to generate. Post-run names are accepted and used only to decide which intermediates this year must contribute to. |
required | |
output_folder
|
folder to write into, or None to build the dataframes |
required | |
year
|
the current year |
required | |
sites
|
list of the sites objects |
required | |
year_raw_wafr
|
the unmodified WAFR for this year |
required | |
wafr
|
the end wafr after water has been applied to the sites |
required | |
bottlenecks
|
list of bottlenecks, or None if the run has none |
None
|
|
transfer_list
|
list of zones that can receive water from transfers |
None
|
Returns: dict of report name to dataframe, for the reports produced this year
Raises:
| Type | Description |
|---|---|
KeyError
|
a name is not a known report. |
Source code in src/grat/reports/selector.py
51 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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
read_report
¶
Reads a report back from the folder it was written into.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_folder
|
the run's output folder. |
required | |
key
|
entry in |
required | |
year
|
water year, for the reports written into a per-year subfolder. |
None
|
|
dtype
|
optional column types, passed through to |
None
|
Returns: the report as a dataframe
Raises:
| Type | Description |
|---|---|
KeyError
|
|
FileNotFoundError
|
that report is not in |
Source code in src/grat/reports/writers.py
write_report
¶
Writes a dataframe to the file that REPORT_FILES gives for key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
dataframe to write. |
required | |
output_folder
|
folder the file is written into. |
required | |
key
|
entry in |
required |
Returns: path to the csv file that was written
Raises:
| Type | Description |
|---|---|
KeyError
|
|