dvas_recipes.uaii2022 package

Copyright (c) 2020-2022 MeteoSwiss, contributors listed in AUTHORS.

Distributed under the terms of the GNU General Public License v3.0 or later.

SPDX-License-Identifier: GPL-3.0-or-later

Submodules

dvas_recipes.uaii2022.basic module

Copyright (c) 2020-2023 MeteoSwiss, contributors listed in AUTHORS.

Distributed under the terms of the GNU General Public License v3.0 or later.

SPDX-License-Identifier: GPL-3.0-or-later

Module content: basic high-level recipes for the UAII2022 campaign

dvas_recipes.uaii2022.basic.prf_summary()

Exports a summary of the different profiles in the DB.

Args:

dvas_recipes.uaii2022.basic.flag_phases(prfs)

Flag the different profile phases, i.e. prelaunch, ascent, and descent.

Parameters:

prfs (MultiRSProfile|MultiGDPProfile) – the profiles to flag (individually).

If available, this function will use the metadata info to set the flags. If no first or burst timestamp is defined, any point beyond the max altitude will be flagged as descent. If no first or launch timestamp is set, the profile is assumed to start at the launch time.

Important

This function assumes that the profiles have not been shifted in any way (yet) !

Returns:

MultiRSProfile|MultiGDPProfile – the flagged profiles.

dvas_recipes.uaii2022.basic.cleanup_steps(prfs, resampling_freq, interp_dist, crop_descent, crop_flgs, timeofday=None, fid=None)

Execute a series of cleanup-steps common to GDP and non-GDP profiles. This function is here to avoid duplicating code. The cleanup-up profiles are directly saved to the DB with the tag: TAG_CLN

Parameters:
  • prfs (MultiRSProfile|MultiGDPProfile) – the profiles to cleanup.

  • resampling_freq (str) – time step frequency, to feed pandas.timedelta_range(), e.g. ‘1s’.

  • interp_dist (float|int) – distance to the nearest real measurement, in s, beyond which a resampled point is forced to NaN (i.e. “dvas does not interpolate !”)

  • crop_descent (bool) – if True, and data with the flag “descent” will be cropped out for good.

  • crop_flgs (list) – any data flagged with any one of these flag names will be cropped out for good.

  • timeofday (str) – if set, will tag the Profile with this time of day. Defaults to None.

  • fid (str) – if set, will add the flight id to the profile metadata. Defaults to None.

Note

Pre-launch data is always cropped.

dvas_recipes.uaii2022.biglambda module

Copyright (c) 2020-2022 MeteoSwiss, contributors listed in AUTHORS.

Distributed under the terms of the GNU General Public License v3.0 or later.

SPDX-License-Identifier: GPL-3.0-or-later

Module content: high-level OSCAR-related routines for the UAII 2022 recipe

dvas_recipes.uaii2022.biglambda.biglambda_tod(prf_tags, mid, tods, suffix='', institution='', gph_min=0, gph_bin_size=100, gph_bin_count=350)

Highest-level recipe function responsible for assembling OSCAR profiles, and storing the result in a dedicated netCDF.

Parameters:
  • prf_tags (list of str) – tag name(s) for the search query into the database.

  • mid (str) – ‘mid’ to process.

  • tods (list of str) – times-of-day to process (OR).

  • suffix (str, optional) – name of the netCDF file suffix. Defaults to ‘’.

  • institution (str, optional) – for the netCDF eponym field. Defaults to ‘’.

  • gph_min (list, optional) – min gph altitude to consider, in m. Defaults to 0.

  • gph_bin_size (int, optional) – gph bin size, in m. Defaults to 100.

  • gph_bin_count (int, optional) – gph bin count. Defaults to 350.

dvas_recipes.uaii2022.biglambda.compute_biglambda(start_with_tags, mids=None, tods=None, **kwargs)

Highest-level recipe function responsible for assembling Big Lambda profiles, and storing the result in a dedicated netCDF.

Parameters:
  • start_with_tags (str|list of str) – tag name(s) for the search query into the database.

  • mids (list, optional) – list of ‘mid’ to process. Defaults to None = all.

  • tods (list of list|str, optional) – list of time-of-days to process sequentially, e.g. [‘daytime’, [‘nighttime’, ‘twilight’]]. Defaults to None=all.

  • **kwargs (optional) – all fed to biglambda_tod().

dvas_recipes.uaii2022.dtas module

Copyright (c) 2020-2022 MeteoSwiss, contributors listed in AUTHORS.

Distributed under the terms of the GNU General Public License v3.0 or later.

SPDX-License-Identifier: GPL-3.0-or-later

Module content: high-level delta recipes for the UAII2022 campaign

dvas_recipes.uaii2022.export module

Copyright (c) 2020-2023 MeteoSwiss, contributors listed in AUTHORS.

Distributed under the terms of the GNU General Public License v3.0 or later.

SPDX-License-Identifier: GPL-3.0-or-later

Module content: export recipes for the UAII2022 campaign

dvas_recipes.uaii2022.export.get_nc_fname(suffix: str, fid: str, edt: str, typ: str, mid: str = None, pid: str = None)

Assemble the netCDF filename for a given flight/mid.

Parameters:
  • suffix (str) – filename suffix.

  • fid (str) – Flight id.

  • edt (str) – formatted event datetime, e.g. ‘YYYYMMDDThhmmss’.

  • typ (str) – ‘cws’, ‘gdp’, or ‘mdp’.

  • mid (str, optional) – model id. Useless if typ == ‘cws’. Defaults to None.

  • pid (str, optional) – product id. Useless if typ == ‘cws’. Defaults to None.

Returns:

str – the netcdf filename

dvas_recipes.uaii2022.export.add_cf_attributes(grp, title='', institution: str = '', comment: str = None)

” Add global UAII attributes to a netCDF group.

Parameters:

grp – netCDF Dataset or group to add the info to.

dvas_recipes.uaii2022.export.set_attribute(grp, name, value)

Safe attribute setting function, with in-built check mecanism in case the attribute already exists.

Parameters:
  • grp – netCDF Dataset or group

  • name (str) – attribute name

  • value – attribute value

dvas_recipes.uaii2022.export.add_dvas_attributes(grp, prf)

Add dvas-related Global Attributes to a netCDF file.

Parameters:
  • grp – netCDF Dataset or group.

  • prf – MultiProfile, MultiRSProfile, MultiGDPProfile, MultiCWSProfile of length 1.

dvas_recipes.uaii2022.export.add_nc_variable(grp, prf)

Fills a netCDF Dataset with the Profile data.

Parameters:
  • grp – netCDF Dataset or group

  • prf – MultiProfile, MultiRSProfile, MultiGDPProfile, MultiCWSProfile of length 1.

dvas_recipes.uaii2022.flgs module

Copyright (c) 2020-2023 MeteoSwiss, contributors listed in AUTHORS.

Distributed under the terms of the GNU General Public License v3.0 or later.

SPDX-License-Identifier: GPL-3.0-or-later

Module content: high-level flagging recipes for the UAII2022 campaign

dvas_recipes.uaii2022.gdps module

Copyright (c) 2020-2022 MeteoSwiss, contributors listed in AUTHORS.

Distributed under the terms of the GNU General Public License v3.0 or later.

SPDX-License-Identifier: GPL-3.0-or-later

Module content: high-level GDP recipes for the UAII2022 campaign

dvas_recipes.uaii2022.plots module

Copyright (c) 2020-2022 MeteoSwiss, contributors listed in AUTHORS.

Distributed under the terms of the GNU General Public License v3.0 or later.

SPDX-License-Identifier: GPL-3.0-or-later

Module content: high-level plotting for the UAII2022 recipe

dvas_recipes.uaii2022.plots.covmat_stats(covmats)

Takes a closer look at the true covariance matrix computed by dvas for a combined profile.

Looks in particular at the error one does by ignoring it and assuming the combined profile uncertainties behave like a ucu, ucs, or uct types or uncertainties.

Parameters:

covmats (dict) – the outcome of dvas.tools.gdps.combine()[1], i.e. the dict of covariance matrices.

dvas_recipes.uaii2022.sync module

Copyright (c) 2020-2023 MeteoSwiss, contributors listed in AUTHORS.

Distributed under the terms of the GNU General Public License v3.0 or later.

SPDX-License-Identifier: GPL-3.0-or-later

Module content: high-level synchronization recipes for the UAII2022 campaign

dvas_recipes.uaii2022.sync.adjust_first_timestamp(prfs, sync_shifts, mtdta_key='first_timestamp')

Apply the sync_shifts to the first_timstamp stored in the metadata.

Parameters:
  • prfs – RSProfiles, GDPProfiles, or CWSProfiles.

  • sync_shifts (list of int) – the sync shifts to apply.

  • mtdta_key (str, optional) – the metadata key to adjust. Defaults to MTDTA_FIRST.

This routine fixes #256.

dvas_recipes.uaii2022.sync.apply_sync_shifts(var_name, filt, sync_length, sync_shifts, is_gdp)

Apply shifts to GDP and non-GDP profiles from a given flight, and upload them to the db.

Parameters:
  • var_name (str) – name of variable to sync, e.g. ‘temp’

  • filt (str) – filtering query for the database.

  • sync_length (int) – length of the sync’ed profiles.

  • sync_shifts (list of int) – relative shifts required to sync the profiles. Convention: row n become row n+shift.

  • is_gdp (list of bool) – to keep track of GDPs, in order to also sync their uncertainties.

dvas_recipes.uaii2022.tools module

Copyright (c) 2020-2022 MeteoSwiss, contributors listed in AUTHORS.

Distributed under the terms of the GNU General Public License v3.0 or later.

SPDX-License-Identifier: GPL-3.0-or-later

Module content: UAII2022 recipe tools

dvas_recipes.uaii2022.tools.get_query_filter(tags_in: list = None, tags_in_or: list = None, tags_out: list = None, mids: list = None, oids: list = None) str

Assembles a str to query the dvas DB, given a list of tags to include and/or exclude.

Parameters:
  • tags_in (list, optional) – list of tags required to be present (AND)

  • tags_in_or (list, optional) – list of tags required to be present (OR)

  • tags_out (list, optional) – list of tags required to be absent

  • mids (list, optional) – list of mids required (OR)

  • oids (list, optional) – list of oids required (OR)

  • tods (list, optional) – list of times-of-day to look for (OR)

Returns:

str – the query filter

dvas_recipes.uaii2022.tools.find_tropopause(rs_prf, min_alt=5500, algo='gruan')

Find the tropopause altitude in a given RSProfile.

Parameters:
  • rs_prf (RSProfile) – the temperature profile from which to derive the tropopause height.

  • min_alt (int| float, optional) – minimum altitude above which to look for the tropopause. Defaults to 5000 m.

  • algo (str, optional) – which algorithm to use, one of [‘wmo1957’, ‘mch’, ‘gruan’]. Defaults to ‘gruan’. See below for details.

Returns:

float, float, float – the troposphere index, altitude, and timestep.

Note

The WMO definition of the tropopause(s) is as follows:

” (a) The first tropopause is defined as the lowest level at which the lapse rate decreases to 2degC/km or less, provided also the average lapse rate between this level and all higher levels within 2 km does not exceed 2degC/km

(b) If above the first tropopause the average lapse rate between any level and all higher levels within 1 km exceeds 3degC/km, then a second tropopause is defined by the same criterion as under (a). This tropopause may be either within or above the 1 km layer.”

Source: World Meteorological Organization (1957), Meteorology - A three-dimensional science: Second session of the Commission for Aerology, WMO Bulletin, vol. IV, no. 4, https://library.wmo.int/doc_num.php?explnum_id=6960

The lapse rate is the decrease of an atmospheric variable with height, the variable being temperature unless otherwise specified.

Typically, the lapse rate is the negative of the rate of temperature change with altitude change.

The 1957 WMO definition (algo=’wmo1957’) of the tropopause is problematic for high resolution profile data, as it leads to a detection of the tropopause several hundred meters below the “knee” of the profile. This behavior is caused by the averaging of all subsequent levels, which allows for a significant number of them to fail the lapse rate criteria if enough others do.

The algo=’mch’ alternative defines the first tropopause as the lowest level at which the lapse rate decreases to 2deg/km or less, provided also ALL the lapse rateS between this level and all higher levels within 2km do not exceed 2deg/km.

The algo=’gruan’ alternative is used to compute the tropopause in GRUAN Data Products, including the RS41. It defines the first tropopause as the lowest level at which the lapse rate decreases to 2deg/km or less, provided also ALL the MEAN lapse rateS (between this level and all higher levels, COMPUTED FROM ALL SEQUENTIAL LEVEL PAIRS LOCATED WITHIN A GIVEN LEVEL INTERVAL) within 2 km do not exceed 2deg/km.