mcross_sect

../../_images/MXSECTION.png

Generates a vertical cross section data unit of upper air fields along a specified transect line. For each upper air field, point values are interpolated along the transect line, with a spacing consistent with the resolution of the input GRIB data.

The cross section data can be plotted (using a default visualisation based on the range of data values) or saved as a NetCDF data file (NetCDF) using write().

If an orography is plotted it can be customised by applying an mgraph() visual definition.

If access to the output computed values is not required, or for more control of the plotting, use mxsectview().

Note

This function performs the same task as the Cross Section Data icon in Metview’s user interface. It accepts its parameters as keyword arguments, described below.

mcross_sect(**kwargs)

Generates vertical cross section data.

Parameters
  • data (Fieldset) –

    Specifies the GRIB data (Fieldset) from which to derive the cross-section. It must contain multi-level fields, in a latitude-longitude or Gaussian grid. The following vertical coordinates are supported:

    • pressure levels

    • ECMWF model levels (hybrid levels used by the IFS). In this case you must include parameter LNSP (logarithm of surface pressure) should you want the orography and the vertical axis of the plot in pressure levels rather than model levels when visualising the output.

    • general coordinates defined by vertical_coordinates

    If wind arrows are to be plotted, then the input data should include three-dimensional wind data, i.e. the u/v/w wind components should all be present. If more than one time and/or forecast step is contained in data, mcross_sect() returns a set of cross sections.

  • line (list[number], default: [0, -180, 0, 180]) –

    Specifies the coordinates of a transect line along which the cross-section is calculated in [lat1, lon1, lat2, lon2] format. The cross section is calculated from a set of geographical points taken along the input transect line. The point selection takes into consideration the resolution of the data and assures that a minimum of 64 points will be used. Note that it is possible to define a line through either poles by describing the line’s coordinates as follows:

    • First, when specifying the latitudes of the two points, imagine that the latitude values go above 90 when you cross the North Pole and below -90 when you cross the South Pole.

    • Next, if you wish a straight line, ensure that the two longitude values are the same.

    E.g. a straight-line cross-section going through the South pole from 60S/25E to 60S/155W can be specified as -60/25/-120/25. Here the fact that one of the latitude values is below -90 indicates to Metview that the cross-section will go through the South Pole. Since the two longitude values are identical a straight line will be defined. If the longitudes were different two curves would be used (one to the pole and another one away from it).

  • wind_parallel ({"on", "off"}, default: "on") – When this option is “on”, the wind components are projected onto the cross section plane. For 2D (horizontal) wind the result is a signed scalar data (a contour plot). When 3D wind data are available a vector plot is produced with the vertical component scaled/computed as specified in parameter w_wind_scaling_factor_mode.

  • wind_perpendicular ({"on", "off"}, default: "off") – When this option is “on”, the wind components are projected onto the normal vector of the cross section plane. The result is a signed scalar data (a contour plot). wind_perpendicular cannot be set to “on” if wind_parallel is also “on”.

  • wind_intensity ({"on", "off"}, default: "off") –

    When this option is “on” the result depends on other settings:

    • When both wind_parallel and wind_perpendicular are “off”, the result is the length of the 2D/3D wind vector at the cross section plane.

    • When wind_parallel is “on”, the result is the absolute value of the projected wind onto the cross section plane.

    • When wind_perpendicular is “on”, the result is the absolute value of the wind projected onto the normal vector of the cross section plane.

  • wind_unprojected ({"on", "off"}, default: "off") –

    This option only has any effect when it is “on” and all wind_parallel, wind_perpendicular and wind_intensity are “off”. In this case the 2D (horizontal) wind is sampled along the cross section plane and plotted as vector data.

    New in Metview version 5.12.0.

  • lnsp_param (number, default: 152) – Specifies the ecCodes paramId used to identify the Logarithm of Surface Pressure (LNSP) in the input data.

  • u_wind_param (number, default: 131) – Specifies the ecCodes paramId used to identify the U wind component in the input data.

  • v_wind_param (number, default: 132) – Specifies the ecCodes paramId used to identify the V wind component in the input data.

  • w_wind_param (number, default: 135) – Specifies the ecCodes paramId used to identify the vertical wind component in the input data. The default value is 135 i.e. pressure velocity in Pa/s (as used by ECMWF).

  • t_param (number, default: 130) – Specifies the ecCodes paramId used to identify the temperature in the input data. Used in the vertical wind computations when w_wind_scaling_factor_mode is set to “compute”.

  • horizontal_point_mode ({"interpolate", "nearest_gridpoint"}, default: "interpolate") – Specifies how the geographical points along the input transect line will be computed. Setting this option to “interpolate” will create a regular set of interpolated geographical points along the transect line. Setting this option to “nearest_gridpoint” will instead select the nearest points from the data.

  • vertical_coordinates ({"default", "user"}, default: "default") – Setting this option to “user” will enable the use of arbitrary vertical coordinates. In this mode, additional GRIB fields should be supplied (one per level) where the values of the grid points represent the heights of their locations.

  • vertical_coordinate_param (str) – Specifies the ecCodes paramId of the general vertical coordinates if vertical_coordinates is “user”.

  • vertical_coordinate_extrapolate ({"on", "off"}, default: "off") – Performs an extrapolation for target levels outside the input vertical coordinate range. Only used when vertical_coordinates is “user”.

  • vertical_coordinate_extrapolate_mode ({"constant", "linear"}, default: "constant") –

    Specifies the extrapolation technique. In “constant” mode the values on the nearest input levels are copied onto the target extrapolated levels. In “linear” mode a linear extrapolation is performed using the nearest two input levels. Enabled when vertical_coordinate_extrapolate is “on”.

    New in Metview version 5.16.0.

  • vertical_coordinate_extrapolate_fixed_sign ({"on", "off"}, default: "on") –

    When vertical_coordinate_extrapolate_mode is “on” it controls whether the extrapolated values can differ in sign from the values on the nearest input levels. When it is “on” it prevents e.g. wind components to change sign due to extrapolation.

    New in Metview version 5.16.0.

  • w_wind_scaling_factor_mode ({"automatic", "user", "compute"}, default: "automatic") –

    Specifies the representation of the vertical wind component (defined as w_wind_param ). The valid values are as follows:

    • ”automatic”: the values are scaled by a factor based on the geographical area, the top/bottom pressure levels and the size of the plot window. This option was kept to provide compatibility with earlier Metview versions.

    • ”user”: the values are scaled by the factor defined via parameter w_wind_scaling_factor.

    • ”compute”: in this mode, supposing that w_wind_param defines the the pressure velocity, the vertical wind component in m/s is computed by w_from_omega(). To make it work, the input data have to be specified either on pressure levels or on model levels together with LNSP. The temperature paramId is defined by t_param. When temperature is not available, the computations will use a constant temperature value of 273.16 K. Having computed the vertical wind component, a scaling with the factor defined by w_wind_scaling_factor is still applied to the resulting values.

  • w_wind_scaling_factor (number, default: -100) – Specifies the vertical wind scaling factor if w_wind_scaling_factor_mode is set to ‘user” or “compute”.

  • level_selection_type ({"from_data", "count", "level_list"}, default: "from_data") –

    Specifies the method to define the output vertical levels. The possible values are:

    • ”from_data”: the algorithm depends on the level type.

      • if the input and output level types are the same the input levels will also be used as output levels

      • if model level data used with pressure axis first computes the absolute bottom pressure level from the data. Next for each model level computes the average pressure along the cross section line and uses it as the vertical pressure co-ordinate for that level. Finally computes extra levels at the bottom by adding an offset (10 hPa) until it reaches the bottom pressure level. This will avoid blank areas in the plot near the orography line.

      • when vertical_coordinates is “user” on each input level computes the average output coordinate along the cross section line and uses it as the output vertical co-ordinate for that level. When “vertical_coordinate_extrapolate” is “on” additional levels are added to avoid blank areas in the plot near the orography line.

    • ”count”: calculates the output vertical levels by taking into account the bottom and top levels (bottom_level and top_level) and the given number of levels (level_count). The computed levels will be evenly spaced on either a linear or a logarithmic scale depending on the value of vertical_scaling.

    • ”level_list”: use the given list of levels in level_list

    When vertical_coordinates is “user” options “count” and “level_list” are only available since Metview version 5.16.0.

  • level_list (number or list[number], default: 0.01) – Specifies the list of output vertical levels. Only available if level_selection_type is set to “level_list”.

  • level_count (number, default: 100) – Specifies the number of output vertical levels if level_selection_type is set to “count”.

  • vertical_scaling ({"linear", "log"}, default: "linear") – Specifies the type of the vertical_axis.

  • bottom_level (number, default: 1100.0) – Specifies the lower limit of the cross section, as a pressure value (hPa) or model level number (hybrid levels). Available when level_selection_type is “count”.

  • top_level (number, default: 0.01) – Specifies the upper limit of the cross section, as a pressure level (hPa) or model level number (hybrid levels). Available when level_selection_type is “count”.

Return type

NetCDF