Values¶
Internal structure to organise DSSAT file data and variable values.
-
class
tradssat.tmpl.vals.
FileValueSet
[source]¶ Represents the set of values in a DSSAT file.
-
add_row
(sect, subsect=None, vals=None)[source]¶ Adds a row to the file.
Parameters: - sect (str) – Name of section.
- subsect (int) – Subsection number. If
None
, will add row to all subsections. - vals (dict) – Dictionnary of new row variable values.
-
add_section
(name)[source]¶ Adds a section to the file.
Parameters: name (str) – Name of the new section.
-
-
class
tradssat.tmpl.vals.
HeaderValues
[source]¶ Represents DSSAT file header variables and their values.
-
changed
()[source]¶ Checks if the header variables values have been changed.
Returns: Return type: bool
-
get_value
(var)[source]¶ Obtain the value of a header variable.
Parameters: var (str) – The variable of interest. Returns: The value of the variable. Return type: np.ndarray
-
set_vars
(subsect)[source]¶ Sets the variables of the header.
Parameters: subsect (ValueSubSection) – The subsection with variables and their values already specified.
-
-
class
tradssat.tmpl.vals.
ValueSection
(name)[source]¶ Represents the structure and variable values in a DSSAT file section.
-
add_subsection
(subsect)[source]¶ Add a subsection to the section.
Parameters: subsect (ValueSubSection) – The new subsection.
-
get_header_var
(var)[source]¶ Obtain the value of a header variable.
Parameters: var (str) – The name of the variable Returns: The value of the header variable. Return type: np.ndarray
-
set_header_vars
(h_vars)[source]¶ Sets the section’s header variables.
Parameters: h_vars (ValueSubSection) – The subsection representing the header variables.
-
-
class
tradssat.tmpl.vals.
ValueSubSection
(l_vars, l_vals)[source]¶ Represents the variables and values in a DSSAT file subsection.
-
add_row
(vals=None)[source]¶ Adds a row to the subsection.
Parameters: vals (dict) – The values for the new row. Any missing value will be assigned the corresponding missing code for that variable (usually -99).
-
changed
()[source]¶ Checks whether any variable in the subsection has been changed.
Returns: Return type: bool
-
check_dims
()[source]¶ Checks that all variables in the subsection have the same size. (If not, the subsection cannot write to disk.)
Raises: ValueError
– If not all variables have the same size.
-
-
class
tradssat.tmpl.vals.
VariableValue
(var, val)[source]¶ Represents a DSSAT file variable.
-
add_value
(val)[source]¶ Adds a value to the variable’s matrix.
Parameters: val (int | float) – The new value.
-
remove_value
(i)[source]¶ Removes a value from the variable’s matrix.
Parameters: i (np.ndarray) – The indices of the value(s) to remove. May be a list of indices, or else a boolean mask of the same size as the variable.
-