Skip to content

attributes

Management of netCDF attributes.

create_global_attributes

create_global_attributes(
    title: str,
    institution: str,
    source: str,
    catchment: str,
    comment: str,
) -> dict[str, str]

Creates STF global attributes.

Parameters:

  • title (str) –

    title

  • institution (str) –

    institution

  • source (str) –

    source

  • catchment (str) –

    catchment

  • comment (str) –

    comment

Raises:

  • ValueError

    Unexpected or insufficient information

Returns:

Source code in src/efts_io/attributes.py
 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
def create_global_attributes(
    title: str,
    institution: str,
    source: str,
    catchment: str,
    comment: str,
) -> dict[str, str]:
    """Creates STF global attributes.

    Args:
        title (str): title
        institution (str): institution
        source (str): source
        catchment (str): catchment
        comment (str): comment

    Raises:
        ValueError: Unexpected or insufficient information

    Returns:
        dict[str, str]: _description_
    """
    # catchment info should not have white spaces (and why was that???)
    # catchment = 'Upper  Murray River '
    # catchment = stringr::str_replace_all(catchment, pattern='\\s+', '_')

    if title == "":
        raise ValueError("Empty title is not accepted as a valid attribute")

    return {
        TITLE_ATTR_KEY: title,
        INSTITUTION_ATTR_KEY: institution,
        SOURCE_ATTR_KEY: source,
        CATCHMENT_ATTR_KEY: catchment,
        COMMENT_ATTR_KEY: comment,
    }

create_var_attribute_definition

create_var_attribute_definition(
    data_type_code: int = 2,
    type_description: str = "accumulated over the preceding interval",
    dat_type: str = "der",
    dat_type_description: str = "AWAP data interpolated from observations",
    location_type: str = "Point",
) -> dict[str, str]

Create variable attribute definition.

Source code in src/efts_io/attributes.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def create_var_attribute_definition(
    data_type_code: int = 2,
    type_description: str = "accumulated over the preceding interval",
    dat_type: str = "der",
    dat_type_description: str = "AWAP data interpolated from observations",
    location_type: str = "Point",
) -> dict[str, str]:
    """Create variable attribute definition."""
    return {
        TYPE_ATTR_KEY: str(data_type_code),
        TYPE_DESCRIPTION_ATTR_KEY: type_description,
        DAT_TYPE_ATTR_KEY: dat_type,
        DAT_TYPE_DESCRIPTION_ATTR_KEY: dat_type_description,
        LOCATION_TYPE_ATTR_KEY: location_type,
    }