Skip to content

Commit

Permalink
Merge pull request #3105 from aarondonahue/io/add_standard_name_metadata
Browse files Browse the repository at this point in the history
Automatically merged using mergify
PR title: Add standard name metadata to most EAMxx output variables
PR author: AaronDonahue
PR labels: ['I/O', 'CI: automerge']
  • Loading branch information
mergify[bot] authored Nov 20, 2024
2 parents 35c97e8 + d44a616 commit c98f074
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 3 deletions.
8 changes: 7 additions & 1 deletion components/eamxx/src/share/io/scorpio_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,9 +1044,15 @@ register_variables(const std::string& filename,

// Gather longname (if not already in the io: string attributes)
if (str_atts.count("long_name")==0) {
auto longname = m_longnames.get_longname(name);
auto longname = m_default_metadata.get_longname(name);
scorpio::set_attribute(filename, name, "long_name", longname);
}

// Gather standard name, CF-Compliant (if not already in the io: string attributes)
if (str_atts.count("standard_name")==0) {
auto standardname = m_default_metadata.get_standardname(name);
scorpio::set_attribute(filename, name, "standard_name", standardname);
}
}
}
// Now register the average count variables
Expand Down
2 changes: 1 addition & 1 deletion components/eamxx/src/share/io/scorpio_output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class AtmosphereOutput
std::map<std::string,std::shared_ptr<atm_diag_type>> m_diagnostics;
std::map<std::string,std::vector<std::string>> m_diag_depends_on_diags;
std::map<std::string,bool> m_diag_computed;
LongNames m_longnames;
DefaultMetadata m_default_metadata;

// Use float, so that if output fp_precision=float, this is a representable value.
// Otherwise, you would get an error from Netcdf, like
Expand Down
84 changes: 83 additions & 1 deletion components/eamxx/src/share/io/scream_io_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ std::string find_filename_in_rpointer (
const OutputAvgType avg_type = OutputAvgType::Instant,
const IOControl& control = {});

struct LongNames {
struct DefaultMetadata {

std::string get_longname (const std::string& name) {
if (name_2_longname.count(name)>0) {
Expand All @@ -83,6 +83,15 @@ struct LongNames {
}
}

std::string get_standardname (const std::string& name) {
if (name_2_standardname.count(name)>0) {
return name_2_standardname.at(name);
} else {
// TODO: Do we want to print a Warning message? I'm not sure if its needed.
return name;
}
}

// Create map of longnames, can be added to as developers see fit.
std::map<std::string,std::string> name_2_longname = {
{"lev","hybrid level at midpoints (1000*(A+B))"},
Expand All @@ -92,6 +101,79 @@ struct LongNames {
{"hyam","hybrid A coefficient at layer midpoints"},
{"hybm","hybrid B coefficient at layer midpoints"}
};

// Create map of longnames, can be added to as developers see fit.
std::map<std::string,std::string> name_2_standardname = {
{"p_mid" , "air_pressure"},
{"p_mid_at_cldtop" , "air_pressure_at_cloud_top"},
{"T_2m" , "air_temperature"},
{"T_mid" , "air_temperature"},
{"T_mid_at_cldtop" , "air_temperature_at_cloud_top"},
{"aero_g_sw" , "asymmetry_factor_of_ambient_aerosol_particles"},
{"pbl_height" , "atmosphere_boundary_layer_thickness"},
{"precip_liq_surf_mass" , "atmosphere_mass_content_of_liquid_precipitation"},
{"cldlow" , "low_type_cloud_area_fraction"},
{"cldmed" , "medium_type_cloud_area_fraction"},
{"cldhgh" , "high_type_cloud_area_fraction"},
{"cldtot" , "cloud_area_fraction"},
{"cldfrac_tot_at_cldtop" , "cloud_area_fraction"},
{"cldfrac_tot" , "cloud_area_fraction_in_atmosphere_layer"},
{"cldfrac_tot_for_analysis" , "cloud_area_fraction_in_atmosphere_layer"},
{"cldfrac_rad" , "cloud_area_fraction_in_atmosphere_layer"},
{"qi" , "cloud_ice_mixing_ratio"},
{"qc" , "cloud_liquid_water_mixing_ratio"},
{"U" , "eastward_wind"},
{"eff_radius_qi" , "effective_radius_of_cloud_ice_particles"},
{"eff_radius_qc" , "effective_radius_of_cloud_liquid_water_particles"},
{"eff_radius_qc_at_cldtop" , "effective_radius_of_cloud_liquid_water_particles_at_liquid_water_cloud_top"},
{"eff_radius_qr" , "effective_radius_of_cloud_rain_particles"},
{"qv" , "humidity_mixing_ratio"},
{"cldfrac_ice_at_cldtop" , "ice_cloud_area_fraction"},
{"cldfrac_ice" , "ice_cloud_area_fraction_in_atmosphere_layer"},
{"omega" , "lagrangian_tendency_of_air_pressure"},
{"landfrac" , "land_area_fraction"},
{"latitude" , "latitude"},
{"cldfrac_liq_at_cldtop" , "liquid_water_cloud_area_fraction"},
{"cldfrac_liq" , "liquid_water_cloud_area_fraction_in_atmosphere_layer"},
{"longitude" , "longitude"},
{"rainfrac" , "mass_fraction_of_liquid_precipitation_in_air"},
{"V" , "northward_wind"},
{"nc" , "number_concentration_of_cloud_liquid_water_particles_in_air"},
{"cdnc_at_cldtop" , "number_concentration_of_cloud_liquid_water_particles_in_air_at_liquid_water_cloud_top"},
{"ni" , "number_concentration_of_ice_crystals_in_air"},
{"aero_tau_sw" , "optical_thickness_of_atmosphere_layer_due_to_ambient_aerosol_particles"},
{"aero_tau_lw" , "optical_thickness_of_atmosphere_layer_due_to_ambient_aerosol_particles"},
{"aero_ssa_sw" , "single_scattering_albedo_in_air_due_to_ambient_aerosol_particles"},
{"sunlit" , "sunlit_binary_mask"},
{"ps" , "surface_air_pressure"},
{"LW_flux_dn_at_model_bot" , "surface_downwelling_longwave_flux_in_air"},
{"SW_flux_dn_at_model_bot" , "surface_downwelling_shortwave_flux_in_air"},
{"SW_clrsky_flux_dn_at_model_bot" , "surface_downwelling_shortwave_flux_in_air_assuming_clear_sky"},
{"phis" , "surface_geopotential"},
{"surf_radiative_T" , "surface_temperature"},
{"surf_sens_flux" , "surface_upward_sensible_heat_flux"},
{"SW_flux_dn_at_model_top" , "toa_incoming_shortwave_flux"},
{"LW_flux_up_at_model_top" , "toa_outgoing_longwave_flux"},
{"LW_clrsky_flux_up_at_model_top" , "toa_outgoing_longwave_flux_assuming_clear_sky"},
{"surf_evap" , "water_evapotranspiration_flux"},
{"AtmosphereDensity" , "air_density"},
{"PotentialTemperature" , "air_potential_temperature"},
{"SeaLevelPressure" , "air_pressure_at_mean_sea_level"},
{"IceWaterPath" , "atmosphere_mass_content_of_cloud_ice"},
{"LiqWaterPath" , "atmosphere_mass_content_of_cloud_liquid_water"},
{"VapWaterPath" , "atmosphere_mass_content_of_water_vapor"},
{"AerosolOpticalDepth550nm" , "atmosphere_optical_thickness_due_to_ambient_aerosol_particles"},
{"Exner" , "dimensionless_exner_function"},
{"z_mid" , "geopotential_height"},
{"geopotential_mid" , "geopotential_height"},
{"RelativeHumidity" , "relative_humidity"},
{"surface_upward_latent_heat_flux" , "surface_upward_latent_heat_flux"},
{"LongwaveCloudForcing" , "toa_longwave_cloud_radiative_effect"},
{"ShortwaveCloudForcing" , "toa_shortwave_cloud_radiative_effect"},
{"VirtualTemperature" , "virtual_temperature"},
{"VaporFlux" , "water_evapotranspiration_flux"},
{"wind_speed" , "wind_speed"}
};

};

Expand Down

0 comments on commit c98f074

Please sign in to comment.