cdm_reader_mapper.metmetpy.platform_type package

Internal metmetpy platfrom_type information.

Subpackages

Submodules

cdm_reader_mapper.metmetpy.platform_type.correction_functions module

Internal metmetpy correction functions.

Created on Tue Jun 25 09:07:05 2019

@author: iregon

cdm_reader_mapper.metmetpy.platform_type.correction_functions.deck_700_icoads(data)[source]

Adjust ICOADS platform codes for dataset 700.

  • Fill missing platform values with ‘7’ (drifters)

  • Change platform from ‘5’ to ‘6’ (buoys) for records with:
    • ID matching 5-digit regex

    • Source ID == ‘147’

Parameters:

data (pd.DataFrame) – Input dataframe containing ICOADS columns for ID, source, and platform.

Return type:

DataFrame

Returns:

pd.DataFrame – DataFrame with adjusted platform codes.

cdm_reader_mapper.metmetpy.platform_type.correction_functions.deck_717_gdac(data)[source]

Fill and adjust platform type for GDAC deck 717 dataset.

Rules: - If platform column is NA, assign ‘7’ (drifters) - If column ‘N’ is NaN and platform == 0, assign ‘9’ (buoys)

Parameters:

data (pd.DataFrame) – Input DataFrame containing platform column and ‘N’ column.

Return type:

DataFrame

Returns:

pd.DataFrame – DataFrame with adjusted platform column.

cdm_reader_mapper.metmetpy.platform_type.correction_functions.deck_792_icoads(data)[source]

Adjust ICOADS platform codes for dataset 792.

For rows meeting all of the following conditions:
  • ID consists of digits only

  • ID length is not 5 or 7

  • ID does not start with ‘7’

  • Source ID equals ‘103’

  • Platform code equals ‘5’

The platform code is updated to ‘6’ (buoy).

Parameters:

data (pd.DataFrame) – Input DataFrame containing ICOADS columns for ID, source, and platform. Column names should correspond to properties.metadata_datamodels (tuples for multi-index or strings).

Return type:

DataFrame

Returns:

pd.DataFrame – DataFrame with updated platform codes where conditions are met. All other rows remain unchanged.

Notes

  • Uses overwrite_data internally to modify only the specified rows.

  • Preserves the original DataFrame structure and column types.

cdm_reader_mapper.metmetpy.platform_type.correction_functions.deck_892_icoads(data)[source]

Adjust ICOADS platform codes for dataset 892.

For records matching all of the following conditions:
  • ID column matches exactly 5 digits

  • Source ID equals ‘29’

  • Platform code equals ‘5’

The platform code is changed to ‘6’ (buoy).

Parameters:

data (pd.DataFrame) – Input DataFrame containing ICOADS columns for ID, source, and platform. Column names should correspond to properties.metadata_datamodels entries (can be tuples for multi-index or strings).

Return type:

DataFrame

Returns:

pd.DataFrame – DataFrame with updated platform codes where conditions are met. All other rows remain unchanged.

Notes

  • Only affects rows meeting all three conditions simultaneously.

  • This function preserves the original DataFrame structure, including column order and type (multi-index or single-level).

cdm_reader_mapper.metmetpy.platform_type.correction_functions.deck_992_icoads(data)[source]

Adjust ICOADS platform codes for dataset 992.

Rules: 1. If ID matches regex ‘^6202+$’, has length 7, source=’114’, and platform=’5’, change platform to ‘4’ (light vessels). 2. If ID is numeric, length not 7 or 5, does not start with ‘7’, source=’114’, platform=’5’, change platform to ‘6’ (buoys).

Parameters:

data (pd.DataFrame) – Input DataFrame with ICOADS columns for ID, source, and platform.

Return type:

DataFrame

Returns:

pd.DataFrame – DataFrame with adjusted platform codes.

cdm_reader_mapper.metmetpy.platform_type.correction_functions.fill_value(fill_serie, fill_value, self_condition_value=None, fillna=False, out_condition=None, out_condition_values=None, self_out_conditions='intersect')[source]

Fill values in a Series conditionally, with optional self and external conditions.

Modes: 1. If no self_condition_value and no out_condition_values, fills all NA values. 2. If self_condition_value is given, fill where Series equals this value. 3. If out_condition and out_condition_values are given, fill only where the external conditions match (can combine with self_condition_value). 4. self_out_conditions controls whether self and external conditions are combined with “intersect” (AND) or “join” (OR). 5. fillna always allows filling of NA values.

Parameters:
  • fill_serie (pd.Series) – Series to fill.

  • fill_value (Any) – Value used to fill.

  • self_condition_value (Any, optional) – Value in fill_serie that triggers filling.

  • fillna (bool, default False) – Whether to fill NA values in addition to conditions.

  • out_condition (pd.DataFrame, optional) – External DataFrame with conditions for filling.

  • out_condition_values (dict, optional) – Mapping of columns in out_condition to values that trigger filling.

  • self_out_conditions ({"intersect", "join"}, default "intersect") – How to combine self_condition and out_condition: - “intersect” = AND - “join” = OR

Return type:

Series

Returns:

pd.Series – Series with values conditionally filled.

cdm_reader_mapper.metmetpy.platform_type.correction_functions.is_num(x)[source]

Check whether a value represents a numeric string.

Parameters:

x (Any) – The value to test.

Return type:

bool

Returns:

bool – True if x is a string containing only numeric characters (0-9), False otherwise. Non-string values will return False.

cdm_reader_mapper.metmetpy.platform_type.correction_functions.overwrite_data(data, loc, pt_col, value)[source]

Overwrite values in a DataFrame column based on a boolean location mask.

Parameters:
  • data (pd.DataFrame) – The input DataFrame.

  • loc (array-like of bool) – Boolean mask indicating which rows to overwrite.

  • pt_col (str) – Name of the column to overwrite.

  • value (Any) – Value to assign to the specified rows and column.

Return type:

DataFrame

Returns:

pd.DataFrame – DataFrame with updated values in the specified column.