plans.parsers.inmet#

Parse data from INMET files (Brazillian Meteorological Office)

Overview#

# todo [major docstring improvement] – overview Mauris gravida ex quam, in porttitor lacus lobortis vitae. In a lacinia nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

Example#

Classes

Automatic([name])

Parser object for INMET Automatic Stations provided by any date range.

ConventionalDaily([name])

Parser object for INMET Conventional Stations - Daily measurements.

ConventionalHourly([name])

class plans.parsers.inmet._StationINMET_(name='MyStationINMET')[source]#

Bases: object

This is a base object for parsing Inmet Stations datasets

Objects downstream will use or overwrite this methods

__init__(name='MyStationINMET')[source]#

Initialization method

Parameters:

name (str) – name of station

get_metadata()[source]#

Base metata getter method

Returns:

dictionary of metadata

Return type:

dict

update()[source]#

Base update method

Returns:

None

Return type:

None

_metadata_util()[source]#

Utility method for naming conversions

Returns:

utility dictionaries

Return type:

dict, dict

_standardize_metadata_fields(metadata)[source]#

Utility method for standardizing metadata fields

Parameters:

metadata (dict) – dictionary of incoming metadata

Returns:

new standard metatada dictionary

Return type:

dict

_get_columns_gls()[source]#

Retrieve the glossary mapping and its mirror.

Returns:

A tuple containing the glossary mapping and its mirror.

Return type:

tuple[dict, dict]

get_glossary()[source]#

Generate a glossary DataFrame from the stored glossary mapping.

Returns:

A DataFrame containing field names and their source descriptions.

Return type:

class.`pandas.DataFrame`

fix_text(text, remove_spaces=False)[source]#

Standardize text by converting to uppercase and replacing specific characters.

Parameters:
  • text (str) – The inputs text to be processed.

  • remove_spaces (bool, optional) – Whether to remove spaces from the text.

Returns:

The processed text.

Return type:

str

read_metadata(file_path)[source]#

Read station metadata from a file and return it as a dictionary.

Parameters:

file_path (str) – Path to the metadata file.

Returns:

Dictionary containing metadata fields and values.

Return type:

dict

load_metadata(file_path)[source]#

Load station metadata from a file and store it in a DataFrame.

Parameters:

file_path (str) – Path to the metadata file.

Returns:

None

Return type:

None

read_data(file_path)[source]#

read all data from file

Parameters:

file_path (str) – file path

Returns:

pandas dataframe

Return type:

class.`pandas.DataFrame`

load_data(file_path)[source]#

Load data from a file and update the instance.

Parameters:

file_path (str) – Path to the data file.

Returns:

None

Return type:

None

export_data(folder, append_id=True)[source]#

Export the data to a CSV file.

Parameters:
  • folder (str) – Folder where the file will be saved.

  • append_id (bool, optional) – Whether to append the station ID to the filename.

Returns:

Path to the exported file.

Return type:

str

export_metadata(folder)[source]#

Export station metadata to a CSV file.

Parameters:

folder (str) – Folder where the file will be saved.

Returns:

Path to the exported metadata file.

Return type:

str

export_glossary(folder)[source]#

Export the glossary to a CSV file.

Parameters:

folder (str) – Folder where the file will be saved.

Returns:

Path to the exported glossary file.

Return type:

str

export(folder)[source]#

Export data, metadata, and glossary to CSV files.

Parameters:

folder (str) – Folder where the files will be saved.

Returns:

Dictionary containing paths to the exported files.

Return type:

dict

class plans.parsers.inmet._Conventional_(name='MyConvetional')[source]#

Bases: _StationINMET_

__init__(name='MyConvetional')[source]#

Initialization method

Parameters:

name (str) – name of station

_metadata_util()[source]#

Utility method for naming conversions

Returns:

utility dictionaries

Return type:

dict, dict

class plans.parsers.inmet.ConventionalHourly(name='MyConvetionalHourly')[source]#

Bases: _Conventional_

__init__(name='MyConvetionalHourly')[source]#

Initialization method

Parameters:

name (str) – name of station

class plans.parsers.inmet.ConventionalDaily(name='MyConvetionalDaily')[source]#

Bases: _Conventional_

Parser object for INMET Conventional Stations - Daily measurements.

__init__(name='MyConvetionalDaily')[source]#

Initialization method

Parameters:

name (str) – name of station

class plans.parsers.inmet._Automatic_(name='MyAutomatic')[source]#

Bases: _StationINMET_

Base Parser object for automatic INMET stations

__init__(name='MyAutomatic')[source]#

Initialization method

Parameters:

name (str) – name of station

class plans.parsers.inmet.Automatic(name='MyAutomatic')[source]#

Bases: _Automatic_

Parser object for INMET Automatic Stations provided by any date range.

__init__(name='MyAutomatic')[source]#

Initialization method

Parameters:

name (str) – name of station

_metadata_util()[source]#

Utility method for naming conversions

Returns:

utility dictionaries

Return type:

dict, dict