SODAR#

SODAR wind profiles from the Horel group MesoWest archive.

Reads SODAR (SOnic Detection And Ranging) wind-profile data that the Horel group archives as monthly HDF5 files under horel-group/oper/mesowest/sodar_data/hdf5archive:

{SID}_full_metadata_log.h5    station metadata + variable scale factors
{SID}_{YYYY}_{MM}_sodar.h5    one month of profiles

The archive is located through the Horel group space (uataq.filesystem.groupspaces.horel.MESOWEST_DIR); pass mesowest_dir=... to read a copy elsewhere.

SODAR stations are MesoWest stations, not UATAQ sites, so they are not part of the configuration and are read directly with Sodar rather than through uataq.read_data(). Profiles are returned as an xarray.Dataset with dimensions (Time_UTC, level).

Examples

>>> from uataq.sodar import Sodar
>>> sodar = Sodar("USDR1")
>>> data = sodar.read_data(time_range=["2019-01-01", "2019-01-31"])
>>> winds = Sodar.get_winds_at_height(data, height=100)
uataq.sodar.NODATA: int = -9999#

Horel group NoData value in the SODAR archive.

uataq.sodar.list_stations(mesowest_dir=None)[source]#

List the SODAR station IDs available in the archive.

A station is available if it has a {SID}_full_metadata_log.h5 file.

Parameters:

mesowest_dir (str, optional) – MesoWest data directory. Defaults to uataq.filesystem.groupspaces.horel.MESOWEST_DIR.

Returns:

Sorted station IDs.

Return type:

list[str]

class uataq.sodar.Sodar(SID, mesowest_dir=None)[source]#

Horel group SODAR wind profiler.

Parameters:
SID#

Upper-case station identifier.

Type:

str

sodar_dir#

{mesowest_dir}/sodar_data.

Type:

str

archive_dir#

{mesowest_dir}/sodar_data/hdf5archive.

Type:

str

metafile#

Path to the station’s metadata log.

Type:

str

meta#

Station metadata log (location, name, changes).

Type:

pandas.DataFrame

variables#

Variable metadata indexed by SHORTNAME; the MULT column holds the integer scale factor applied in parse().

Type:

pandas.DataFrame

Raises:

FileNotFoundError – If the archive directory or the station’s metadata log does not exist.

model = 'sodar'#
species_measured = ('wind',)#
__init__(SID, mesowest_dir=None)[source]#

Initialize the Sodar and read the station’s metadata log.

get_files(lvl='raw', time_range=None)[source]#

List archived SODAR HDF5 files for this station within a time range.

Parameters:
  • lvl (str, optional) – Processing level. Only 'raw' is available.

  • time_range (TimeRange | TimeRangeTypes, optional) – Keep files whose month overlaps [start, stop). Default is None which lists all files.

Returns:

Matching file paths, sorted by month.

Return type:

list[str]

static parse(file, variables)[source]#

Parse a single SODAR HDF5 file into an xarray Dataset.

NoData (-9999) becomes NaN and each variable listed in variables is divided by its MULT scale factor.

Parameters:
Returns:

STATION_ID on Time_UTC and one (Time_UTC, level) variable per profile field (e.g. HEIGHT, WD, WS).

Return type:

xarray.Dataset

read_data(lvl='raw', time_range=None, num_processes=1)[source]#

Read and combine SODAR profiles over a time range.

Parameters:
  • lvl (str, optional) – Processing level. Only 'raw' is available.

  • time_range (TimeRange | TimeRangeTypes, optional) – Time range to read, start <= Time_UTC < stop (see uataq.timerange.TimeRange). A date string as the stop includes that whole day. Default is None which reads all data.

  • num_processes (int | 'max', optional) – Number of processes used to parse files. Default is 1.

Returns:

Profiles with dimensions (Time_UTC, level), sorted by time.

Return type:

xarray.Dataset

Raises:

FileNotFoundError – If no files overlap time_range.

static get_winds_at_height(data, height)[source]#

Extract wind direction and speed at a given height.

The level is matched against HEIGHT at every timestamp, so the result is correct even if the range gates change within data. Timestamps without a level at height are dropped.

Parameters:
Returns:

direction and speed columns indexed by Time_UTC.

Return type:

pandas.DataFrame

Raises:

ValueError – If no level is at height anywhere in data.