grat.reports.builders
¶
Generates output reports using pandas.
get_site_info
¶
Pulls site attribution from the sites objects as a pandas dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_list
|
list of sites |
required |
Returns: dataframe
Source code in src/grat/reports/builders.py
daily_summary_recharge
¶
Totals recharge and WAFR volumes per day of the water year.
Covers total recharge (AF) by type (canal, basins, in-lieu, on farm), total unused WAFR (AF), total WAFR applied (AF), total WAFR (AF) and precipitation (AF).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
the current water year |
required | |
sites_list
|
list of site objects |
required | |
raw_wafr
|
dict of WAFR source to daily volume array, totalled into "Total WAFR (AF)" |
required | |
wafr
|
dict of WAFR source to daily volume array, totalled into "Total Unused WAFR (AF)" |
required |
Returns: pandas dataframe
Source code in src/grat/reports/builders.py
site_volume_report
¶
Collects the per-site daily volume arrays for a single water year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
the current water year |
required | |
sites_list
|
list of site objects |
required |
Returns: dataframe with one row per Basin, Canal or OFR site
Source code in src/grat/reports/builders.py
annual_summary_recharge
¶
Aggregates the daily summary recharge dataframe into yearly totals.
Sums the daily values for each category, and calculates the volume of water remaining in the canals + basins at the end of the water year by getting the current capacity on the last day of the water year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
daily_summary_recharge_df
|
dataframe output from the daily_summary_recharge function |
required |
Returns: pandas dataframe
Source code in src/grat/reports/builders.py
daily_summary_recharge_report
¶
Selects the columns that report 03 publishes from the daily summary.
The end-of-year capacity columns are dropped here rather than in the writer, so the frame this returns is exactly what lands in the csv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
dataframe from summary_operations.daily_summary_recharge, combined across every water year |
required |
Returns: dataframe with the report 03 columns, in report order
Source code in src/grat/reports/builders.py
daily_wafr_applied_by_site
¶
Splits the daily used-volume array into one column per day of water year, joined to the site info.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_volume_report_df
|
dataframe with the site volume report values (from site_volume_report function()) |
required | |
site_info_df
|
dataframe with the site info values (from siteInfo function()) |
required |
Returns: dataframe with daily WAFR applied by site
Source code in src/grat/reports/builders.py
daily_recharge_by_site
¶
Splits the daily recharge volume array into one column per day of water year, joined to the site info.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_volume_report_df
|
dataframe with the site volume report values (from site_volume_report function()) |
required | |
site_info_df
|
dataframe with the site info values (from siteInfo function()) |
required |
Returns: dataframe with daily recharge by site
Source code in src/grat/reports/builders.py
monthly_recharge_by_site_report
¶
Aggregates the daily recharge volume arrays into monthly totals per site and recharge volume type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_volume_report_df
|
dataframe with the site volume report values (from site_volume_report function()) |
required |
Returns: dataframe with monthly recharge by site
Source code in src/grat/reports/builders.py
monthly_recharge_by_site_report_post
¶
Pivots the monthly_recharge_by_site_report to the final format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
dataframe with the unpivoted monthly_recharge_by_site_report values |
required | |
site_info
|
dataframe with the site info |
required |
Returns: dataframe with the final format of the monthly_recharge_by_site_report
Source code in src/grat/reports/builders.py
monthly_recharge_by_site_summary
¶
Selects the columns that report 06 publishes from the pivoted monthly frame.
Report 07 publishes the same frame in full; report 06 keeps only the site identifiers and the per-month value columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
dataframe from monthly_recharge_by_site_report_post |
required |
Returns: dataframe with gratID, rechargeType and the "Year N Month M" columns
Source code in src/grat/reports/builders.py
daily_farm_recharge_report
¶
Post-process the siteOfrUsageReport df to return values grouped by crop + soilType.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_ofr_usage_report_df
|
dataframe with site OFR usage report values |
required | |
site_info_df
|
dataframe with site information |
required |
Returns: dataframe with daily_farm_recharge_report values
Source code in src/grat/reports/builders.py
yearly_aggregate_farm_recharge_report
¶
Post-process the siteOfrUsageReport df to return values grouped by crop + soilType.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_ofr_usage_report_df
|
dataframe with site OFR usage report values |
required | |
site_info_df
|
dataframe with site information |
required |
Returns: dataframe with yearly_aggregate_farm_recharge_report values
Source code in src/grat/reports/builders.py
daily_wafr_report
¶
Report the unused wafr by source for every day.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
current year |
required | |
wafr
|
dictionary of unused wafr by source |
required |
Returns: pandas dataframe with columns Year, Day, and each source of unused wafr
Source code in src/grat/reports/builders.py
atoi
¶
natural_keys
¶
Sort key that orders embedded numbers in human order.
Use as alist.sort(key=natural_keys). See https://nedbatchelder.com/blog/200712/human_sorting.html (Toothy's implementation in the comments).
Source code in src/grat/reports/builders.py
bottlenecks_capacity_limitations_report
¶
Construct dataframe with years as the rows and bottleneckIDs as the column names.
Cell values are the number of days when bottleneck capacity is hit (e.g. 0 cfs capacity remaining at bottleneck).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
current year |
required | |
bottleneck_list
|
list of bottleneck objects |
required |
Returns: dataframe
Source code in src/grat/reports/builders.py
bottlenecks_daily_conveyance_limits_by_volume
¶
Construct dataframe with years as the rows and bottleneckIDs as the column names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
current year |
required | |
bottleneck_list
|
list of bottleneck objects |
required |
Returns: dataframe with bottlenecks_daily_conveyance_limits_by_volume values
Source code in src/grat/reports/builders.py
yearly_bottleneck_capacity_logger
¶
Yearly Bottleneck Capacity Logger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
current year |
required | |
bottleneck_list
|
list of bottleneck objects |
required |
Returns: dataframe with yearly_bottleneck_capacity_logger values
Source code in src/grat/reports/builders.py
annual_recharge_by_grouping
¶
Annual Recharge by Grouping (used as input for 15,16,17 post processing).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
current year |
required | |
sites
|
list of site objects |
required |
Returns: dataframe with annual_recharge_by_grouping values
Source code in src/grat/reports/builders.py
annual_recharge_by_sw_and_gw
¶
Group by WAFR and subbasin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df_annual_recharge_by_grouping
|
dataframe with annual_recharge_by_grouping values (generated from annual_recharge_by_grouping function) |
required |
Returns: dataframe with annual_recharge_by_sw_and_gw values
Source code in src/grat/reports/builders.py
annual_recharge_by_district_and_gw
¶
Annual District Recharge by GW Basin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df_annual_recharge_by_grouping
|
dataframe with annual_recharge_by_grouping values (generated from annual_recharge_by_grouping function) |
required |
Returns: dataframe with annual_recharge_by_district_and_gw values
Source code in src/grat/reports/builders.py
annual_recharge_by_district_and_wafr
¶
Annual District Recharge by SW Source (wafr).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df_annual_recharge_by_grouping
|
dataframe with annual_recharge_by_grouping values (generated from annual_recharge_by_grouping function) |
required |
Returns: dataframe with annual_recharge_by_district_and_wafr values
Source code in src/grat/reports/builders.py
daily_recharge_by_gw_basin
¶
Post-process the siteOfrUsageReport df.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_volume_report_df
|
dataframe with the site volume report values (from site_volume_report function()) |
required | |
site_info_df
|
dataframe with the site info |
required |
Returns: transposed dataframe with daily recharge by GW basin
Source code in src/grat/reports/builders.py
875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 | |
acres_available_and_used
¶
Calculates the acres available and used for different recharge types and other categories for a given year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
the current year iteration |
required | |
site_list
|
list of site objects |
required |
Returns: dataframe with Year, USED FTB, USED In-Lieu, USED OFR, FTB, In-Lieu, OFR, DAC, Subsidence, GSC, INBASINRET
Source code in src/grat/reports/builders.py
yearly_wafr_applied_by_site
¶
Report of the WAFR applied per site for each year.
Used for joining back to the input sites polygons for viz.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
the current year iteration |
required | |
sites_list
|
list of site objects |
required |
Returns: dataframe with gratID, Year, and usedVolume
Source code in src/grat/reports/builders.py
yearly_wafr_report
¶
Create a yearly WAFR report by source with unused and total WAFR.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
the current year iteration |
required | |
wafr_dict
|
dictionary of unused WAFR by source |
required | |
raw_wafr_dict
|
dictionary of total WAFR by source |
required |
Returns: dataframe of unused and total WAFR by source
Source code in src/grat/reports/builders.py
mlrp_report
¶
Report the list of gratIDs that got converted to MLRP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_info_df
|
dataframe of site attribution, from summary_operations.get_site_info |
required |
Returns: dataframe of the gratIDs that got converted to MLRP
Source code in src/grat/reports/builders.py
daily_water_transfer_by_sustain_zone_report
¶
Report the daily water transfer by sustainability zone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
current year |
required | |
site_list
|
list of sites |
required | |
transfer_list
|
list of zones to include in the report |
required |
Returns: dataframe with daily water transfer by sustainability zone report
Source code in src/grat/reports/builders.py
yearly_water_transfer_by_sustain_zone_report
¶
Rolls the daily water transfer report up to a yearly total per sustainability zone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
daily_df
|
dataframe from daily_water_transfer_by_sustain_zone_report, combined across every water year (report 20) |
required |
Returns: dataframe of yearly totals, with the Day column dropped
Source code in src/grat/reports/builders.py
total_recharge_by_sustainability_zone_report
¶
Report the total Recharge by sustainability zone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
current year |
required | |
site_list
|
list of sites |
required |
Returns: dataframe of total recharge by sustainability zone
Source code in src/grat/reports/builders.py
total_recharge_by_district_report
¶
Report the total Recharge by district.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
current year |
required | |
site_list
|
list of sites |
required |
Returns: dataframe of total recharge by district