grat.loaders.helpers
¶
Data loader helper functions.
water_year
¶
October 1st is the start of the water year. IE Oct 1st, 2022 is in Water Year 2023.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
calendar year |
required |
month
|
int
|
calendar month |
required |
Returns:
| Type | Description |
|---|---|
int
|
water year |
Source code in src/grat/loaders/helpers.py
day_of_water_year
¶
Calculate the day of the water year (DOWY) based on the given calendar year, month, and day.
The water year starts on October 1st, so for example, October 1st, 2022 is in Water Year 2023.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Calendar year |
required |
month
|
int
|
Calendar month |
required |
day
|
int
|
Calendar day |
required |
Returns:
| Type | Description |
|---|---|
int
|
Day of the water year (DOWY) |
Source code in src/grat/loaders/helpers.py
rename_dictionary_keys
¶
Replaces keys in a dictionary with new names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
dict
|
input dictionary |
required |
keymap
|
dict
|
key values to rename ({'from-key': 'to-key'}) |
required |
Returns:
| Type | Description |
|---|---|
dict
|
dictionary |
Source code in src/grat/loaders/helpers.py
split_multivalues
¶
Split a string of comma separated values into a list.
Spaces around each value are removed, and empty values are dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
string
|
string of comma separated values |
required |
Returns:
| Type | Description |
|---|---|
|
list of values |
Source code in src/grat/loaders/helpers.py
single_value_as_string
¶
If the list has a single value, return it as a string. Otherwise return the list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
list_of_values
|
list of values |
required |
Returns:
| Type | Description |
|---|---|
|
string or list |