metobs_toolkit.Dataset.apply_titan_buddy_check#

Dataset.apply_titan_buddy_check(obstype='temp', use_constant_altitude=False)[source]#

Apply the TITAN buddy check on the observations.

The buddy check compares an observation against its neighbours (i.e. buddies). The check looks for buddies in a neighbourhood specified by a certain radius. The buddy check flags observations if the (absolute value of the) difference between the observations and the average of the neighbours normalized by the standard deviation in the circle is greater than a predefined threshold.

See the titanlib documentation on the buddy check for futher details.

The observation and outliers attributes will be updated accordingly.

Parameters:
  • obstype (String, optional) – Name of the observationtype you want to apply the checks on. The default is ‘temp’.

  • use_constant_altitude (bool, optional) – Use a constant altitude for all stations. The default is False.

Return type:

None.

Note

To update the check settings, use the update_titan_qc_settings method of the Dataset class.

Warning

To use this method, you must install titanlib. Windows users must have a c++ compiler installed. See the titanlib documentation: metno/titanlib.

Examples

>>> import metobs_toolkit
>>>
>>> # Import data into a Dataset
>>> dataset = metobs_toolkit.Dataset()
>>> dataset.update_settings(
...                         input_data_file=metobs_toolkit.demo_datafile,
...                         input_metadata_file=metobs_toolkit.demo_metadatafile,
...                         template_file=metobs_toolkit.demo_template,
...                         )
>>> dataset.import_data_from_file()
>>> dataset.coarsen_time_resolution(freq='1h')
>>>
>>> #Update some temperature QC settings
>>> dataset.update_titan_qc_settings(obstype='temp',
...                                  buddy_min_std=1.5,
...                                  buddy_threshold=3.2,
...                                  buddy_num_min=5)
buddy num min for the TITAN buddy check updated:  2--> 5
buddy threshold for the TITAN buddy check updated:  1.5--> 3.2
buddy min std for the TITAN buddy check updated:  1.0--> 1.5
>>> # Apply buddy check on the temperature observations
>>> dataset.apply_titan_buddy_check(obstype='temp',
...                                 use_constant_altitude=True)
>>> dataset
Dataset instance containing:
     *28 stations
     *['temp', 'humidity', 'wind_speed', 'wind_direction'] observation types
     *10080 observation records
     *35 records labeled as outliers
     *0 gaps
     *3 missing observations
     *records range: 2022-09-01 00:00:00+00:00 --> 2022-09-15 23:00:00+00:00 (total duration:  14 days 23:00:00)
     *time zone of the records: UTC
     *Coordinates are available for all stations.