diff --git a/Metadata-standard-names.md b/Metadata-standard-names.md index 6602945..c3b2027 100644 --- a/Metadata-standard-names.md +++ b/Metadata-standard-names.md @@ -32,7 +32,7 @@ Currently, the only dimension which supports all six dimension types is horizont * `integer`: units = count * `vertical_dimension`: number of vertical levels * `integer`: units = count -* `vertical_dimension_plus_one`: number of vertical levels + 1 +* `vertical_interface_dimension`: number of vertical interfaces * `integer`: units = count * `vertical_layer_index`: index of a particular vertical level * `integer`: units = count @@ -53,7 +53,7 @@ Currently, the only dimension which supports all six dimension types is horizont ## constants * `avogadro_number`: Avogadro number * `real(kind=kind_phys)`: units = molecules mole-1 -* `reference_air_pressure_for_atmosphere_vertical_coordinate`: Reference air pressure for atmosphere vertical coordinate +* `reference_surface_air_pressure_for_atmosphere_vertical_coordinate`: Reference surface air pressure for atmosphere vertical coordinate * `real(kind=kind_phys)`: units = Pa * `boltzmann_constant`: Boltzmann constant * `real(kind=kind_phys)`: units = J K-1 @@ -81,7 +81,7 @@ Currently, the only dimension which supports all six dimension types is horizont * `gravitational_acceleration`: Gravitational acceleration * `real(kind=kind_phys)`: units = m s-2 * `cell_area`: Cell area - * `real(kind=kind_phys)`: units = steradian + * `real(kind=kind_phys)`: units = m2 * `cell_weight`: Cell weight * `real(kind=kind_phys)`: units = none ## state_variables @@ -98,7 +98,7 @@ Note that appending '_on_previous_timestep' to standard_names in this section yi * `real(kind=kind_phys)`: units = Pa * `surface_air_pressure`: Surface air pressure * `real(kind=kind_phys)`: units = Pa -* `surface_dry_air_pressure`: Surface dry air pressure +* `surface_pressure_of_dry_air`: Surface pressure of dry air * `real(kind=kind_phys)`: units = Pa * `surface_geopotential`: Surface geopotential * `real(kind=kind_phys)`: units = m2 s-2 @@ -118,19 +118,19 @@ Note that appending '_on_previous_timestep' to standard_names in this section yi * `real(kind=kind_phys)`: units = Pa s-1 * `air_pressure`: Midpoint air pressure * `real(kind=kind_phys)`: units = Pa -* `dry_air_pressure`: Dry midpoint pressure +* `air_pressure_of_dry_air`: Dry midpoint pressure * `real(kind=kind_phys)`: units = Pa * `air_pressure_thickness`: Air pressure thickness * `real(kind=kind_phys)`: units = Pa -* `dry_air_pressure_thickness`: Dry air pressure thickness +* `air_pressure_thickness_of_dry_air`: Air pressure thickness of dry air * `real(kind=kind_phys)`: units = Pa * `reciprocal_of_air_pressure_thickness`: Reciprocal of air pressure thickness * `real(kind=kind_phys)`: units = Pa-1 -* `reciprocal_of_dry_air_pressure_thickness`: Reciprocal of dry air pressure thickness +* `reciprocal_of_air_pressure_thickness_of_dry_air`: Reciprocal of air pressure thickness of dry air * `real(kind=kind_phys)`: units = Pa-1 * `ln_air_pressure`: Ln air pressure * `real(kind=kind_phys)`: units = 1 -* `ln_dry_air_pressure`: Ln dry air pressure +* `ln_air_pressure_of_dry_air`: Ln air pressure of dry air * `real(kind=kind_phys)`: units = 1 * `reciprocal_of_dimensionless_exner_function_wrt_surface_air_pressure`: inverse exner function w.r.t. surface pressure, (ps/p)^(R/cp) * `real(kind=kind_phys)`: units = 1 @@ -140,11 +140,11 @@ Note that appending '_on_previous_timestep' to standard_names in this section yi * `real(kind=kind_phys)`: units = kg/kg moist or dry air depending on type * `air_pressure_at_interface`: Air pressure at interface * `real(kind=kind_phys)`: units = Pa -* `dry_air_pressure_at_interface`: Dry air pressure at interface +* `air_pressure_of_dry_air_at_interface`: Air pressure of dry air at interface * `real(kind=kind_phys)`: units = Pa * `ln_air_pressure_at_interface`: Ln air pressure at interface * `real(kind=kind_phys)`: units = 1 -* `ln_dry_air_pressure_at_interface`: Ln dry air pressure at interface +* `ln_air_pressure_of_dry_air_at_interface`: Ln air pressure of dry air at interface * `real(kind=kind_phys)`: units = 1 * `largest_model_top_pressure_that_allows_molecular_diffusion`: Largest model top pressure that allows molecular diffusion * `real(kind=kind_phys)`: units = Pa @@ -1093,8 +1093,6 @@ Standard / required CCPP variables * `real`: units = flag * `number_of_timesteps_for_concurrent_radiation_and_remainder_physics_calls_after_model_initialization`: Number of timesteps for concurrent radiation and remainder physics calls after model initialization * `integer`: units = count -* `gravitational_acceleration`: Gravitational acceleration - * `real(kind=kind_phys)`: units = m s-2 * `gas_constant_dry_air`: Gas constant dry air * `real(kind=kind_phys)`: units = J kg-1 K-1 * `gas_constant_water_vapor`: Gas constant water vapor @@ -1107,12 +1105,6 @@ Standard / required CCPP variables * `real(kind=kind_phys)`: units = none * `ratio_of_dry_air_to_water_vapor_gas_constants_minus_one`: Ratio of dry air to water vapor gas constants minus one * `real(kind=kind_phys)`: units = none -* `tendency_of_y_wind_due_to_model_physics`: Tendency of y wind due to model physics - * `real(kind=kind_phys)`: units = m s-2 -* `tendency_of_x_wind_due_to_model_physics`: Tendency of x wind due to model physics - * `real(kind=kind_phys)`: units = m s-2 -* `tendency_of_air_temperature_due_to_model_physics`: Tendency of air temperature due to model physics - * `real(kind=kind_phys)`: units = K s-1 * `tendency_of_vertically_diffused_tracer_concentration`: Tendency of vertically diffused tracer concentration * `real(kind=kind_phys)`: units = kg kg-1 s-1 * `vertically_diffused_tracer_concentration`: Vertically diffused tracer concentration @@ -1301,8 +1293,6 @@ Standard / required CCPP variables * `real(kind=kind_phys)`: units = frac * `surface_albedo_diffuse_NIR`: Surface albedo diffuse NIR * `real(kind=kind_phys)`: units = frac -* `area_type`: Area type - * `real(kind=kind_phys)`: units = flag * `surface_stochastic_weights_from_coupled_process`: Surface stochastic weights from coupled process * `real(kind=kind_phys)`: units = none * `air_pressure_at_layer_for_RRTMGP_in_hPa`: Air pressure at layer for RRTMGP in hPa @@ -2193,7 +2183,7 @@ Standard / required CCPP variables * `real(kind=kind_phys)`: units = um * `sppt_weights_from_coupled_process`: Sppt weights from coupled process * `real(kind=kind_phys)`: units = none -* `total_ampltiude_of_sppt_perturbation`: Total ampltiude of sppt perturbation +* `total_amplitude_of_sppt_perturbation`: Total amplitude of sppt perturbation * `real(kind=kind_phys)`: units = none * `convective_cloud_water_mixing_ratio_in_xyz_dimensioned_restart_array`: Convective cloud water mixing ratio in xyz dimensioned restart array * `real(kind=kind_phys)`: units = kg kg-1 @@ -2843,8 +2833,6 @@ Standard / required CCPP variables * `real(kind=kind_phys)`: units = none * `tendency_of_air_temperature_due_to_shortwave_heating_assuming_clear_sky_on_radiation_time_step_and_radiation_levels`: Tendency of air temperature due to shortwave heating assuming clear sky on radiation time step and radiation levels * `real(kind=kind_phys)`: units = K s-1 -* `air_temperature_on_previous_timestep`: Air temperature on previous timestep - * `real(kind=kind_phys)`: units = K * `specific_humidity_on_previous_timestep`: Specific humidity on previous timestep * `real(kind=kind_phys)`: units = kg kg-1 * `lwe_surface_snow_from_coupled_process`: Lwe surface snow from coupled process diff --git a/check_xml_unique.py b/check_xml_unique.py new file mode 100755 index 0000000..90f901a --- /dev/null +++ b/check_xml_unique.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python + +""" +Remove duplicates from a metadata standard-name XML library file. +""" + +import argparse +import sys +import os.path +import xml.etree.ElementTree as ET +from xml_tools import read_xml_file +import copy + +############################################################################### +def parse_command_line(args, description): +############################################################################### + parser = argparse.ArgumentParser(description=description, + formatter_class=argparse.RawTextHelpFormatter) + + parser.add_argument("standard_name_file", + metavar='', + type=str, help="XML file with standard name library") + parser.add_argument("--overwrite", action='store_true', + help="flag to remove duplicates and overwrite the file") + + pargs = parser.parse_args(args) + return pargs + +############################################################################### +def main_func(): +############################################################################### + """Parse the standard names database file and notify of duplicates. + """ + # Parse command line arguments + args = parse_command_line(sys.argv[1:], __doc__) + stdname_file = os.path.abspath(args.standard_name_file) + _, root = read_xml_file(stdname_file) + + #get list of all standard names + all_std_names = [] + for name in root.findall('./section/standard_name'): + all_std_names.append(name.attrib['name']) + + #get list of all unique and duplicate standard names, in source order + seen = set() + uniq_std_names = [] + dup_std_names = [] + for x in all_std_names: + if x not in seen: + uniq_std_names.append(x) + seen.add(x) + else: + dup_std_names.append(x) + + if args.overwrite: + #delete all duplicate elements after the first + if len(dup_std_names)>0: + print('The following duplicate standard names were found:') + for dup in dup_std_names: + rm_elements = root.findall('./section/standard_name[@name="%s"]'%dup)[1:] + print("{0}, ({1} duplicate(s))".format(dup, len(rm_elements))) + print('Removing duplicates and overwriting {}'.format(stdname_file)) + for dup in dup_std_names: + rm_parents = root.findall('./section/standard_name[@name="%s"]...'%dup)[1:] + for par in rm_parents: + rm_ele = par.findall('./standard_name[@name="%s"]'%dup) + for ele in rm_ele: + par.remove(ele) + + _.write(stdname_file, "utf-8") + else: + print('No duplicate standard names were found.') + else: + #write out duplicate standard names + if len(dup_std_names)>0: + print('The following duplicate standard names were found:') + for dup in dup_std_names: + rm_elements = root.findall('./section/standard_name[@name="%s"]'%dup)[1:] + print("{0}, ({1} duplicate(s))".format(dup, len(rm_elements))) + else: + print('No duplicate standard names were found.') + +############################################################################### +if __name__ == "__main__": + main_func() \ No newline at end of file diff --git a/standard_names.xml b/standard_names.xml index fad6224..e132166 100644 --- a/standard_names.xml +++ b/standard_names.xml @@ -40,8 +40,8 @@ long_name="number of vertical levels"> integer - + integer real - + real @@ -125,7 +125,7 @@ real - real + real real @@ -151,7 +151,7 @@ real - + real @@ -187,26 +187,26 @@ long_name="Midpoint air pressure"> real - real real - + real real - + real real - + real real - + real real - + real @@ -1684,9 +1684,6 @@ integer - - real - real @@ -1705,15 +1702,6 @@ real - - real - - - real - - - real - real @@ -1996,9 +1984,6 @@ real - - real - real @@ -3334,7 +3319,7 @@ real - + real @@ -4309,9 +4294,6 @@ real - - real - real