{ "cells": [ { "cell_type": "markdown", "id": "e10d29eb-bc3e-4373-8f56-e47efbb05781", "metadata": {}, "source": [ "# Standard Name Convention\n", "\n", "The \"Standard Name Convention\" is one realization of a convention promoted by the toolbox. It is based on the idea, that every dataset must have a physical unit (or none if it is dimensionless) and that datasets must be identifiable via an identifier attribute rather than the dataset name itself.\n", "\n", "The key standard attributes are \n", "\n", " - `standard_name`: A human- and machine-readable dataset identifier based on construction rules and listed in a \"Standard Name Table\",\n", " - `standard_name_table`: List of `standard_name` together with the base unit (SI) and a comprehensive description. It also includes additional information about how a `standard_name` can be transformed into a new `standard_name`\n", " - `units`: The unit attribute of a dataset. Must not be SI-unit, but must be convertible to it and then match the registered SI-unit in the Standard name table,\n", " - `long_name`: An alternative name if no `standard_name` is applicable." ] }, { "cell_type": "markdown", "id": "3c8617b6-48de-4065-84b9-022a3b0dff7b", "metadata": {}, "source": [ "This concept is first introduced by the Climate and Forecast community and is called [CF-convention](http://cfconventions.org/). The `h5RDMtoolbox` adopts the concept and implements a general version of it, so that users can define their own discipline- or problem-specific standard name convention.\n", "\n", "Main benefits of the convention are:\n", "- achieving self-describing files, which are human and machine interpretation interpretable,\n", "- validating correctness of dataset identifiers (standard_name) and their units\n", "- allowing unit-aware processing of data.\n", "\n", "This chapter walks you through the concept and shows how to apply it" ] }, { "cell_type": "code", "execution_count": 1, "id": "2ae9884b-2609-471a-ab4c-97e300ca804d", "metadata": {}, "outputs": [], "source": [ "import h5rdmtoolbox as h5tbx\n", "import warnings\n", "warnings.filterwarnings('ignore')\n", "\n", "from h5rdmtoolbox.convention.standard_names.table import StandardNameTable" ] }, { "cell_type": "markdown", "id": "8fe8adf7-f44c-4f1a-8fe2-3c1272cfa0ac", "metadata": {}, "source": [ "## Standard Name Tables" ] }, { "cell_type": "markdown", "id": "c82acdaa-9075-4c3d-a511-d8c7fc6f36e5", "metadata": {}, "source": [ "### Example 1: cf-convention" ] }, { "cell_type": "markdown", "id": "e9e3b996-8114-43e0-935b-b1fc8b2385f2", "metadata": {}, "source": [ "The Standard name table should be defined in documents (typically XML or YAML). The corresponding object then can be initialized by the respective constructor methods (`from_yaml`, `from_web`, ...).\n", "\n", "For reading the original CF-convention table, do the following:" ] }, { "cell_type": "code", "execution_count": 2, "id": "66808089-b59f-4dd2-86ab-a1c1904ebf44", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
  • StandardNameTable: (name: cf-standard-name-table.xml, version_number: 79, last_modified: 2022-03-19T15:25:54Z, institution: Centre for Environmental Data Analysis, contact: support@ceda.ac.uk, version: v79.0.0, url: https://cfconventions.org/Data/cf-standard-names/79/src/cf-standard-name-table.xml)
  • " ], "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cf = StandardNameTable.from_web(\"https://cfconventions.org/Data/cf-standard-names/79/src/cf-standard-name-table.xml\",\n", " known_hash='4c29b5ad70f6416ad2c35981ca0f9cdebf8aab901de5b7e826a940cf06f9bae4')\n", "cf" ] }, { "cell_type": "markdown", "id": "863d53e1-843b-4476-b9e2-ea959c4442d8", "metadata": {}, "source": [ "The standard names are items of the table object:" ] }, { "cell_type": "code", "execution_count": 3, "id": "e5854f39-80ee-4992-9bd8-9c0324cec174", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cf['x_wind']" ] }, { "cell_type": "code", "execution_count": 4, "id": "ba9d882a-c00d-4ba4-a142-6542a57fdeff", "metadata": {}, "outputs": [ { "data": { "text/html": [ "m/s" ], "text/latex": [ "$\\frac{\\mathrm{m}}{\\mathrm{s}}$" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cf['x_wind'].units" ] }, { "cell_type": "code", "execution_count": 5, "id": "ddea8a72-2b32-430e-99e0-4afceaca8167", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'\"x\" indicates a vector component along the grid x-axis, positive with increasing x. Wind is defined as a two-dimensional (horizontal) air velocity vector, with no vertical component. (Vertical motion in the atmosphere has the standard name upward_air_velocity.).'" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cf['x_wind'].description" ] }, { "cell_type": "markdown", "id": "bf7d5b2e-4173-4ccc-956e-539ec28ff058", "metadata": {}, "source": [ "## Example 2: User defined table" ] }, { "cell_type": "markdown", "id": "56f1cdac-4f0f-41e3-8664-0f8ebacb973f", "metadata": {}, "source": [ "Initializing standard name tables from a web-resource should be the standard process, because a project or community might defined it and published it under a DOI.\n", "\n", "The `h5rdmtoolbox` especially supports tables that are published on [Zenodo](https://zenodo.org/):" ] }, { "cell_type": "code", "execution_count": 6, "id": "920d862d-78c1-4399-b204-1f711a1e60da", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
  • StandardNameTable: (institution: Karlsruhe Institute of Technology, contact: https://orcid.org/0000-0001-8729-0482, valid_characters: ['^a-zA-Z0-9_'], pattern: ^[0-9 ].*, last_modified: 2023-07-18 09:05:38.112885+00:00, version: v4.1.0-alpha, zenodo_doi: 10428795)
  • " ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "snt = StandardNameTable.from_zenodo(10428795)\n", "snt" ] }, { "cell_type": "markdown", "id": "dd72c3e2-506e-4db9-b5a5-67dee5439e84", "metadata": {}, "source": [ "Here are the standard names of the table:" ] }, { "cell_type": "code", "execution_count": 7, "id": "42ed6878-d4a1-450f-8ea5-e81311bd40c2", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['absolute_pressure',\n", " 'ambient_static_pressure',\n", " 'ambient_temperature',\n", " 'auxiliary_fan_rotational_speed',\n", " 'blade_inlet_angle',\n", " 'blade_inlet_diameter',\n", " 'blade_number',\n", " 'blade_outlet_angle',\n", " 'blade_outlet_diameter',\n", " 'coordinate',\n", " 'density',\n", " 'difference_of_total_pressure_to_static_pressure_between_across_fan',\n", " 'difference_of_wall_static_pressure_across_fan',\n", " 'difference_of_wall_static_pressure_across_orifice',\n", " 'dynamic_pressure',\n", " 'dynamic_viscosity',\n", " 'fan_efficiency',\n", " 'fan_flow_coefficient',\n", " 'fan_inlet_area',\n", " 'fan_outlet_area',\n", " 'fan_power_coefficient',\n", " 'fan_pressure_coefficient',\n", " 'fan_rotational_speed',\n", " 'fan_shaft_power',\n", " 'fan_specific_speed',\n", " 'fan_torque',\n", " 'fan_volume_flow_rate',\n", " 'impeller_diameter',\n", " 'impeller_inlet_width',\n", " 'impeller_outlet_width',\n", " 'impeller_volume_flow_rate',\n", " 'impeller_weight',\n", " 'inner_diameter_of_orifice',\n", " 'kinematic_viscosity',\n", " 'mass_flow_rate',\n", " 'outer_diameter_of_orifice',\n", " 'pulse_delay',\n", " 'relative_humidity',\n", " 'static_pressure',\n", " 'temperature',\n", " 'time',\n", " 'total_pressure',\n", " 'turbulent_kinetic_energy',\n", " 'velocity',\n", " 'vorticity',\n", " 'wall_static_pressure',\n", " 'xx_reynolds_stress',\n", " 'yx_reynolds_stress',\n", " 'yy_reynolds_stress',\n", " 'yz_reynolds_stress',\n", " 'zx_reynolds_stress',\n", " 'zy_reynolds_stress',\n", " 'zz_reynolds_stress']" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "snt.names" ] }, { "cell_type": "markdown", "id": "3550c51e-d670-4344-a0d4-25bed5a80530", "metadata": {}, "source": [ "In a notebook, we can also get a nice overview of the table by calling `dump()`:" ] }, { "cell_type": "code", "execution_count": 8, "id": "659bcfdd-7333-4f78-9ccc-c9d44b28d8b3", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
    descriptionunitsvectoralias
    absolute_pressurePressure is force per unit area. Absolute air pressure is pressure deviation to a total vacuum.PaNaNNaN
    ambient_static_pressureStatic air pressure is the amount of pressure exerted by air that is not moving. Ambient static air pressure is the static air pressure of the surrounding air.PaNaNNaN
    ambient_temperatureAir temperature is the bulk temperature of the air, not the surface (skin) temperature. Ambient air temperature is the temperature of the surrounding air.KNaNNaN
    auxiliary_fan_rotational_speedNumber of revolutions of an auxiliary fan.1/sNaNNaN
    blade_inlet_angleAngle of blade at inlet.radNaNNaN
    blade_inlet_diameterThe inner diameter of the test fan (D1).mNaNNaN
    blade_numberThe blade number is the number of blades of the test fan.NaNNaN
    blade_outlet_angleAngle of blade at inlet.radNaNNaN
    blade_outlet_diameterThe outer diameter of the test fan (D2).mNaNNaN
    coordinateThe spatial coordinate.mTrueNaN
    densityAir density is defined as the mass of air divided by its volume.kg/m**3NaNNaN
    difference_of_total_pressure_to_static_pressure_between_across_fanThe difference of static pressure at fan outlet w.r.t. the total pressure upstream of the fan. The total pressure generally is not known at the fan inlet pipe but further upstream, e.g. in a settling chamber. The dataset must provide detailed information, e.g. referencing to the respective pressure measurement device containing the exact location in the setup.PaNaNdifference_of_total_pressure_to_static_pressure_between_fan_outlet_and_fan_inlet
    difference_of_wall_static_pressure_across_fanStatic air pressure is the amount of pressure exerted by air that is not moving. Difference of wall static air pressure across a fan is the difference between the static air pressure downstream (at fan_outlet) of the fan and the total air pressure upstream of the fan at the wall (at fan_inlet).PaNaNNaN
    difference_of_wall_static_pressure_across_orificeDiffernece of static air pressure across orifice to compute volume flow rate according to DIN EN ISO 5167.PaNaNNaN
    dynamic_pressureDynamic air pressure is a measure for kinetic energy per unit volume of moving air.PaNaNNaN
    dynamic_viscosityDynamic air viscosity indicates the resistance of air towards deformation under shear stress. (https://doi.org/10.1016/B978-0-08-096949-7.00020-0).Pa*sNaNNaN
    fan_efficiencyTotal fan efficiency as defined in (CAROLUS, Thomas. Ventilatoren-Aerodynamischer Entwurf, Schallvorhersage. Konstruktion, 2013, 2. Jg., p.5, eq.1.16).NaNNaN
    fan_flow_coefficientAir flow coefficient is a dimensionless number as defined in (CAROLUS, Thomas. Ventilatoren-Aerodynamischer Entwurf, Schallvorhersage. Konstruktion, 2013, 2. Jg., p.2, eq.1.3). The addition \"of_fan\" indicates that this coefficient applies to the deployed fan.NaNNaN
    fan_inlet_areaThe fan cross-sectional area at the location \"fan_inlet\" for fans with a casing. The position of the referred cross-sectional area is in the pipe upstream of the fan. The area is generally taken to compute the dynamic pressure at the inlet of the fan based on the volume flow rate.m**2NaNNaN
    fan_outlet_areaThe fan cross-sectional area at the location \"fan_outlet\" for fans with a casing. The position of the referred cross-sectional area is in the pipe downstream of the fan. The area is generally taken to compute the dynamic pressure at the outlet of the fan based on the volume flow rate.m**2NaNNaN
    fan_power_coefficientPower coefficient is a dimensionless number as defined in (CAROLUS, Thomas. Ventilatoren-Aerodynamischer Entwurf, Schallvorhersage. Konstruktion, 2013, 2. Jg., p.2, eq.1.5). The addition \"of_fan\" indicates that this coefficient applies for the deployed fan.NaNNaN
    fan_pressure_coefficientTotal pressure coefficient is a dimensionless number as defined in (CAROLUS, Thomas. Ventilatoren-Aerodynamischer Entwurf, Schallvorhersage. Konstruktion, 2013, 2. Jg., p.2, eq.1.4). The addition \"of_fan\" indicates that this coefficient applies for the deployed fan.NaNNaN
    fan_rotational_speedNumber of revolutions of the test fan.1/sNaNNaN
    fan_shaft_powerPower of fan drive shaft.WNaNNaN
    fan_specific_speedSpecific speed of the fan as defined in (CAROLUS, Thomas. Ventilatoren-Aerodynamischer Entwurf, Schallvorhersage. Konstruktion, 2013, 2. Jg., p.2, eq.1.6).NaNNaN
    fan_torqueThe torque acting on the impeller of the fan.NmNaNNaN
    fan_volume_flow_rateAir volume flow rate is the volume of air that passes a cross section per unit time. The volume flow rate of the fan is the volume flow entering and leaving the fan. Due to gaps between the impeller and the housing, the volume flow rate is lower than the volume flow rate through the impeller (see impeller_volume_flow_rate).m**3/sNaNNaN
    impeller_diameterThe diameter of the impeller of the test fan, also D3. For some fans D2 is equal to D3.mNaNNaN
    impeller_inlet_widthThe width of the impeller inlet.mNaNNaN
    impeller_outlet_widthThe width of the impeller outlet.mNaNNaN
    impeller_volume_flow_rateAir volume flow rate is the volume of air that passes a cross section per unit time. The volume flow rate of the impeller is the volume flow entering and leaving the impeller. Due to gaps between the impeller and the housing, this volume flow rate is higher than the volume flow rate through the fan (see fan_volume_flow_rate).m**3/sNaNNaN
    impeller_weightWeight of the impeller.kgNaNNaN
    inner_diameter_of_orificeInner diameter of an orifice.mNaNNaN
    kinematic_viscosityDynamic air viscosity indicates the resistance of air towards deformation under shear stress. Kinematic viscosity. Dynamic air viscosity divided by air denisity equals kinematic air viscosity. (https://doi.org/10.1016/B978-0-12-410461-7.00007-9).m**2/sNaNNaN
    mass_flow_rateAir mass flow rate is the mass of air that passes a certain cross sectiont per unit time.kg/sNaNNaN
    outer_diameter_of_orificeOuter diameter of an orifice.mNaNNaN
    pulse_delayTime between two laser pulses.sNaNNaN
    relative_humidityRelative humidity is a measure of the water vapor content of air.NaNNaN
    static_pressureStatic air pressure is the amount of pressure exerted by air that is not moving.PaNaNNaN
    temperatureAir temperature is the bulk temperature of the air, not the surface (skin) temperature. (CF Conventions).degCNaNNaN
    timeRecording time since start of experiment.sNaNNaN
    total_pressureThe sum of dynamic and static air pressure.PaNaNNaN
    turbulent_kinetic_energyThe kinetic energy per unit mass of a fluid.m**2/s**2NaNNaN
    velocityVelocity.m/sTrueNaN
    vorticityVorticity.1/sTrueNaN
    wall_static_pressureStatic air pressure is the amount of pressure exerted by air that is not moving. Wall static air pressure is the static air pressure at the wall.PaNaNNaN
    xx_reynolds_stressReynolds stress is a tensor quantity. \"xx\" indicates that the variations of x-velocity is used.m**2/s**2NaNNaN
    yx_reynolds_stressReynolds stress is a tensor quantity. \"yx\" indicates that the variations of x- and y-velocity are used.m**2/s**2NaNNaN
    yy_reynolds_stressReynolds stress is a tensor quantity. \"yy\" indicates that the variations of y-velocity is used.m**2/s**2NaNNaN
    yz_reynolds_stressReynolds stress is a tensor quantity. \"yz\" indicates that the variations of y- and z-velocity are used.m**2/s**2NaNNaN
    zx_reynolds_stressReynolds stress is a tensor quantity. \"zx\" indicates that the variations of z- and x-velocity are used.m**2/s**2NaNNaN
    zy_reynolds_stressReynolds stress is a tensor quantity. \"zy\" indicates that the variations of z- and y-velocity are used. in y-axis direction.m**2/s**2NaNNaN
    zz_reynolds_stressReynolds stress is a tensor quantity. \"zy\" indicates that the variations of z-velocity is used.m**2/s**2NaNNaN
    " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "snt.dump()" ] }, { "cell_type": "markdown", "id": "00ee187b-daa9-4d76-a9b1-0a5eaa164ae5", "metadata": {}, "source": [ "### Transformation of base standard names\n", "Not all allowed standard names must be included in the table. There are some so-called transformations of the listed ones. \n", "There are two ways to transform a standard name.\n", "\n", " 1. Using affixes: Adding a prefix or a suffix\n", " 2. Apply a mathematical operation to the name" ] }, { "cell_type": "markdown", "id": "2bae1cdb-e1f0-44fc-bc8e-8252299f759f", "metadata": {}, "source": [ "#### 1. Adding affixes\n", "\n", "Note, that 'x_velocity' is not part of the table:" ] }, { "cell_type": "code", "execution_count": 9, "id": "05b349d9-a4ae-4ea0-bab6-84790489c0be", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "'x_velocity' in snt" ] }, { "cell_type": "markdown", "id": "96ecfa73-c223-4c5f-aaec-2314ad158fbc", "metadata": {}, "source": [ "... but 'velocity' is. And it is a vector. The vector property tells us, if we can add a \"vector component name\" as a prefix, e.g. a \"x\" or \"y\":" ] }, { "cell_type": "code", "execution_count": 10, "id": "176f7fa3-342b-46eb-b1b1-495bcc862345", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "snt['velocity'].is_vector()" ] }, { "cell_type": "markdown", "id": "b7cede44-5eb5-409e-ba04-23c9972eaea1", "metadata": {}, "source": [ "Which vector component exist, are defined in the table:" ] }, { "cell_type": "code", "execution_count": 11, "id": "aa4d2628-8004-4c4c-a995-4057108e0aa9", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'x': 'X indicates the x-axis component of the vector.',\n", " 'y': 'Y indicates the y-axis component of the vector.',\n", " 'z': 'Z indicates the z-axis component of the vector.'}" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "snt.affixes['component'].values" ] }, { "cell_type": "markdown", "id": "d3247f88-8b4e-4a73-9894-b475f3985b2d", "metadata": {}, "source": [ "Thus, by indexing \"x_velocity\" the table checks whether the prefix is valid and if yes returns the new (transformed) standard name:" ] }, { "cell_type": "code", "execution_count": 12, "id": "824bb0b3-bcb3-4261-904b-ca43ff12a097", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
      \n", "
    • \n", " \n", " \n", "
        \n", "
      • units : m/s
      • description : Velocity. X indicates the x-axis component of the vector.
      • \n", "
      \n", "
    " ], "text/plain": [ "" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "snt['x_velocity']" ] }, { "cell_type": "markdown", "id": "0652b4e4-850b-4d23-abbd-6a04726f9597", "metadata": {}, "source": [ "#### Apply a mathematical operation\n", "\n", "During processing of data, often times datasets are transformed in with mathematical function like taking the square or applying a derivative of one quantity with respect to (wrt) another one. Some mathemtaical operations like these are supported in the version, e.g.:" ] }, { "cell_type": "code", "execution_count": 13, "id": "8c04d645-d666-4c55-9247-bb2bdc80734a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
      \n", "
    • \n", " \n", " \n", "
        \n", "
      • units : 1/s
      • description : Derivative of x_velocity with respect to x_coordinate. Velocity. X indicates the x-axis component of the vector. The spatial coordinate. X indicates the x-axis component of the vector.
      • \n", "
      \n", "
    " ], "text/plain": [ "" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "snt['derivative_of_x_velocity_wrt_x_coordinate']" ] }, { "cell_type": "code", "execution_count": 14, "id": "1214cbb8-0ce9-4a06-bef3-c760f565fbba", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
      \n", "
    • \n", " \n", " \n", "
        \n", "
      • units : Pa**2
      • description : Square of static_pressure. Static air pressure is the amount of pressure exerted by air that is not moving.
      • \n", "
      \n", "
    " ], "text/plain": [ "" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "snt['square_of_static_pressure']" ] }, { "cell_type": "code", "execution_count": 15, "id": "9e52b5c0-ef1b-45b0-a407-f21cf57725f7", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
      \n", "
    • \n", " \n", " \n", "
        \n", "
      • units : Pa
      • description : Arithmetic mean of static_pressure. Static air pressure is the amount of pressure exerted by air that is not moving.
      • \n", "
      \n", "
    " ], "text/plain": [ "" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "snt['arithmetic_mean_of_static_pressure']" ] }, { "cell_type": "markdown", "id": "75829775-75a0-4a71-95fd-22904df4ed37", "metadata": {}, "source": [ "## Usage with HDF5 files\n", "\n", "Let's apply the convention to HDF5 files. We lazyly take the existing tutorial convention and remove some standard attributes in order to limit the example to the relevant attributes of the standard name convention:" ] }, { "cell_type": "code", "execution_count": 16, "id": "380c7cf8-5285-417f-9f98-5e3f13884e73", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Convention(\"standard name convention\")" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "zenodo_cv = h5tbx.convention.from_zenodo('https://zenodo.org/record/8357399')\n", "sn_cv = zenodo_cv.pop('contact', 'comment', 'references', 'data_type')\n", "sn_cv.name = 'standard name convention'\n", "sn_cv.register()\n", "\n", "h5tbx.use(sn_cv)\n", "sn_cv" ] }, { "cell_type": "markdown", "id": "79d6d6a4-fa74-475d-985a-aa9fb80f481d", "metadata": {}, "source": [ "Find out about the available standard names: We do this by creating a file and retrieving the attribute`standard_name_table`. Based on the convention, it is set by default, so it is available without explicitly setting it:" ] }, { "cell_type": "code", "execution_count": 17, "id": "710cbde5-3c3f-4c68-8a7e-5492f2ee3e87", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The available (base) standard names are: ['absolute_pressure', 'ambient_static_pressure', 'ambient_temperature', 'auxiliary_fan_rotational_speed', 'blade_inlet_angle', 'blade_inlet_diameter', 'blade_number', 'blade_outlet_angle', 'blade_outlet_diameter', 'coordinate', 'density', 'difference_of_total_pressure_to_static_pressure_between_across_fan', 'difference_of_wall_static_pressure_across_fan', 'difference_of_wall_static_pressure_across_orifice', 'dynamic_pressure', 'dynamic_viscosity', 'fan_efficiency', 'fan_flow_coefficient', 'fan_inlet_area', 'fan_outlet_area', 'fan_power_coefficient', 'fan_pressure_coefficient', 'fan_rotational_speed', 'fan_shaft_power', 'fan_specific_speed', 'fan_torque', 'fan_volume_flow_rate', 'impeller_diameter', 'impeller_inlet_width', 'impeller_outlet_width', 'impeller_volume_flow_rate', 'impeller_weight', 'inner_diameter_of_orifice', 'kinematic_viscosity', 'mass_flow_rate', 'outer_diameter_of_orifice', 'pulse_delay', 'relative_humidity', 'static_pressure', 'temperature', 'time', 'total_pressure', 'turbulent_kinetic_energy', 'velocity', 'vorticity', 'wall_static_pressure', 'xx_reynolds_stress', 'yx_reynolds_stress', 'yy_reynolds_stress', 'yz_reynolds_stress', 'zx_reynolds_stress', 'zy_reynolds_stress', 'zz_reynolds_stress']\n" ] } ], "source": [ "with h5tbx.File() as h5:\n", " snt = h5.standard_name_table\n", "\n", "print('The available (base) standard names are: ', snt.names)" ] }, { "cell_type": "markdown", "id": "96aaf313-11d0-45c1-a5bb-543a6da46945", "metadata": {}, "source": [ "One possible dataset based on the standard name table could be \"x_velocity\". This is possible, because *component* is available in the list of **affixes**. Based on the transformation pattern, it is clear the \"component\" is a **prefix**. \"x\" is within the available components, so \"x_velocity\" is a valid transformed standard name from the given table:" ] }, { "cell_type": "code", "execution_count": 18, "id": "9dc045e8-3c61-4cd8-ba4a-3e2d50df4558", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Available affixes: dict_keys(['component', 'device', 'location', 'reference_frame'])\n", "\n", "Values for the component prefix:\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "print('Available affixes: ', snt.affixes.keys())\n", "\n", "print('\\nValues for the component prefix:')\n", "snt.affixes['component']" ] }, { "cell_type": "markdown", "id": "45ff1a5d-f98c-4f29-b39c-ba94fd94eba5", "metadata": {}, "source": [ "Let's access the name from the table. It exists and the description is adjusted, too:" ] }, { "cell_type": "code", "execution_count": 19, "id": "f27c8aa3-c074-4b69-ae35-f29b43bde04b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
      \n", "
    • \n", " \n", " \n", "
        \n", "
      • units : m/s
      • description : Velocity. X indicates the x-axis component of the vector.
      • \n", "
      \n", "
    " ], "text/plain": [ "" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "snt['x_velocity']" ] }, { "cell_type": "markdown", "id": "57146951-aae0-4293-898d-325af8d60799", "metadata": {}, "source": [ "Creating a x-velocity dataset:" ] }, { "cell_type": "code", "execution_count": 20, "id": "9de466f1-a31c-4067-91a4-6562d1389ceb", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
    \n", "\n", "
      \n", "
    • \n", " \n", " \n", " \n", "
      • standard_name_table: 10428795
      • \n", "
      \n", "\n", "
        \n", " \n", " \n", " (3) [int32]\n", "
        • standard_name: x_velocity
        • units: km/s
        • \n", "
        \n", "
      \n", "
    • \n", "
    \n", "
    " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "with h5tbx.File() as h5:\n", " h5.create_dataset('u', data=[1,2,3], standard_name='x_velocity', units='km/s')\n", " h5.dump()" ] }, { "cell_type": "markdown", "id": "99c69908-5189-4adf-a1da-3f8ca3051191", "metadata": {}, "source": [ "## Usage with HDF5 files (update)" ] }, { "cell_type": "code", "execution_count": 21, "id": "51075c5a-d8d0-41fa-9ab2-653e011dedd3", "metadata": {}, "outputs": [], "source": [ "from ontolutils import SSNO" ] }, { "cell_type": "code", "execution_count": 22, "id": "3ee62f0a-aea6-429f-bcda-7329b2ef42c0", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
    \n", "\n", " \n", "
    " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "with h5tbx.File(mode='w') as h5:\n", " ds = h5.create_dataset('u', data=3)\n", " ds.attrs['standard_name', SSNO.hasStandardName] = 'x_velocity'\n", " ds.rdf.object['standard_name'] = SSNO.StandardName # https://matthiasprobst.github.io/ssno#StandardName\n", " \n", " ds = h5.create_dataset('v', data=3)\n", " ds.attrs['standard_name', SSNO.hasStandardName] = 'y_velocity'\n", " ds.rdf.object['standard_name'] = SSNO.StandardName # https://matthiasprobst.github.io/ssno#StandardName\n", " h5.dump(collapsed=False)\n", "\n", "hdf_filename = h5.hdf_filename" ] }, { "cell_type": "code", "execution_count": null, "id": "76917f96-4487-475d-af05-a1bfe15f2f21", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.19" } }, "nbformat": 4, "nbformat_minor": 5 }