easy_vic_build.tools.params_func.GlobalParamParser
Parser utilities for VIC global parameter files.
Classes
Parser for VIC global-parameter text files. |
|
|
Container for parameters within one global-parameter section. |
- class easy_vic_build.tools.params_func.GlobalParamParser.GlobalParamSection(allow_duplicates=False)[source]
Bases:
objectContainer for parameters within one global-parameter section.
Initialize a section container.
- Parameters:
allow_duplicates (bool, optional) – Whether repeated parameter names should be stored as lists.
- __init__(allow_duplicates=False)[source]
Initialize a section container.
- Parameters:
allow_duplicates (bool, optional) – Whether repeated parameter names should be stored as lists.
- class easy_vic_build.tools.params_func.GlobalParamParser.GlobalParamParser[source]
Bases:
objectParser for VIC global-parameter text files.
Initialize an empty parser state.
- add_section(name)[source]
Add a section if it does not already exist.
- Parameters:
name (str) – Section name.
Notes
Duplicate keys are enabled for sections matching
FORCE_TYPE,DOMAIN_TYPE, andOUTVAR*.
- set(section, name, value)[source]
Set one parameter value in a section.
- Parameters:
section (str) – Section name.
name (str) – Parameter name.
value (str) – Parameter value.
Notes
Section is created automatically if missing.
- set_section_values(section_name, section_dict)[source]
Replace all parameters in a section.
- Parameters:
section_name (str) – Section name.
section_dict (dict) – Mapping from parameter name to value or list of values.
Notes
Existing parameters in this section are replaced.
- get(section_name, param_name)[source]
Get one parameter value from a section.
- Parameters:
section_name (str) – Section name.
param_name (str) – Parameter name.
- Returns:
Parameter value.
- Return type:
str
- Raises:
KeyError – If section or parameter is missing.
- load(file_or_path, header_lines=5)[source]
Load and parse global-parameter text.
- Parameters:
file_or_path (str or file-like object) – File path or readable file-like object.
header_lines (int, optional) – Number of header lines to store before section parsing.
- Raises:
ValueError – If input is neither path-like nor file-like.