Station#

The Station holds all the data related to a single station. This includes:

  • observational data, stored as SensorData,

  • metadata, stored as a Site,

  • and timeseries of a model source, stored as ModelTimeSeries.

Constructor#

Station(stationname, site, all_sensor_data)

Represents a weather station, holding metadata, sensor data, and model data.

Data attributes#

A summary of all the attributes that hold or return data.

Station.name

The name of the station.

Station.site

The Site instance of the station.

Station.sensordata

The SensorData related to the station, as a dictionary.

Station.df

Station DataFrame constructor.

Station.metadf

Construct a DataFrame representation of metadata.

Station.outliersdf

Construct a DataFrame representation of all the outliers.

Station.gapsdf

Construct a DataFrame representation of all the gaps.

Station.modeldatadf

Construct a DataFrame representation of all the present model data.

Station.present_observations

Get a list of all the present observation types.

Station.start_datetime

Get the earliest start datetime from the observation data.

Station.end_datetime

Get the latest end datetime from the observation data.

Station.modeldata

Retrieve the model data associated with the station.

General methods and attributes#

Station.get_sensor(obstype)

Get the SensorData instance for a specific observation type.

Station.add_to_sensordata(new_sensordata[, ...])

Add a new SensorData to the Station.

Station.get_modeltimeseries(obstype[, ...])

Get the ModelTimeSeries instance for a specific observation type.

Station.add_to_modeldata(new_modeltimeseries)

Add a new ModelTimeSeries to the Station.

Station.get_info([printout])

Retrieve and optionally print detailed information about the station.

Station.resample(target_freq[, obstype, ...])

Resample observation data to a specified frequency.

Exporting and converting methods#

Station.to_csv([filepath, overwrite])

Save the station observations to a CSV file.

Station.to_parquet([filepath, overwrite])

Save the station observations to a parquet file.

Station.to_xr()

Merge all sensor and model data of a station into a single Dataset.

Station.to_netcdf([filepath, overwrite])

Save the Station as a netCDF file.

Visualisations#

Station.make_plot_of_modeldata([obstype, ...])

Generate a time series plot of model data for a specific observation type.

Station.make_plot([obstype, colorby, ...])

Generate a time series plot for observational data.

Special methods#

The Station class implements several Python special methods for convenience:

  • __add__: Combine two Station objects, merging sensordata, site and modeltimeseries.

  • __eq__: Test equality between two Station objects.

  • __str__ and __repr__: String representations for printing and debugging.

  • copy: Create a (deep) copy of the Station.

Example usage:

from metobs_toolkit.dataset import Dataset

# Assume sta1 and sta2 are Station instances
sta_extend = sta1 + sta2  # Merge Stations

# Equality check
if sta1 == sta2:
    print("Stations are equal")

# Copying
copy_of_1 = sta1.copy(deep=True)

# String representation
print(str(sta1))