12.2. Model Output Contents#

On surface maps we plotted temperature, dewpoint temperature, mean sea-level pressure, wind speed and direction, and current weather symbols, which are all typical values recorded by Automated Surface Observing Stations (ASOS) and are standardized. For model output, there are not a common set of data or naming convention used for variables between different types of data (e.g., GFS, NARR, NCEP-NCAR Reanalysis). There are small differences between the different models and for that reason we need a method to find out what variables are available in contained within each file. This is particularly easy in the Jupyter Notebook environment if we use the xarray module.

Here we’ll demonstrate how to gain access to a gridded file and inspect the contents of the file (e.g., what variables are contained within the file), all of which can be completed in a standard Jupyter Notebook.

from datetime import datetime, time, timedelta

from metpy.plots import declarative
import xarray as xr

yesterday = datetime.utcnow() - timedelta(days=1)
date = datetime.combine(yesterday, time(0))

# Access the 1 Degree GFS from the Unidata THREDDS server
ds = xr.open_dataset('https://thredds.ucar.edu/thredds/dodsC/grib'
                     f'/NCEP/GFS/Global_onedeg/GFS_Global_onedeg_'
                     f'{date:%Y%m%d}_{date:%H%M}.grib2')

List File Contents#

We can quickly and easily list the variable names that are contained within our model output files. This listing will contain both dimension variables (e.g., time, latitude, and longitude) as well as the variables that we might wish to plot (e.g., Temperature_isobaric). Non-dimension variables are capitalized if accessing data through a THREDDS server (a very common way for accessing these data).

list(ds.variables)
['lat',
 'lon',
 'reftime',
 'time',
 'time1',
 'time2',
 'time3',
 'height_above_ground',
 'pressure_difference_layer',
 'height_above_ground1',
 'altitude_above_msl',
 'altitude_above_msl1',
 'isobaric',
 'height_above_ground_layer',
 'height_above_ground_layer1',
 'pressure_difference_layer1',
 'pressure_difference_layer2',
 'height_above_ground2',
 'sigma_layer',
 'depth_below_surface_layer',
 'height_above_ground3',
 'isobaric1',
 'height_above_ground4',
 'height_above_ground5',
 'potential_vorticity_surface',
 'sigma',
 'hybrid',
 'hybrid1',
 'LatLon_Projection',
 'time1_bounds',
 'time3_bounds',
 'pressure_difference_layer_bounds',
 'height_above_ground_layer_bounds',
 'height_above_ground_layer1_bounds',
 'pressure_difference_layer1_bounds',
 'pressure_difference_layer2_bounds',
 'sigma_layer_bounds',
 'depth_below_surface_layer_bounds',
 'Absolute_vorticity_isobaric',
 'Albedo_surface_Mixed_intervals_Average',
 'Apparent_temperature_height_above_ground',
 'Cloud_mixing_ratio_isobaric',
 'Cloud_mixing_ratio_hybrid',
 'Cloud_water_entire_atmosphere_single_layer',
 'Convective_available_potential_energy_pressure_difference_layer',
 'Convective_available_potential_energy_surface',
 'Convective_inhibition_pressure_difference_layer',
 'Convective_inhibition_surface',
 'Convective_precipitation_surface_Mixed_intervals_Accumulation',
 'Convective_precipitation_rate_surface',
 'Dewpoint_temperature_height_above_ground',
 'Geopotential_height_surface',
 'Geopotential_height_cloud_ceiling',
 'Geopotential_height_highest_tropospheric_freezing',
 'Geopotential_height_isobaric',
 'Geopotential_height_zeroDegC_isotherm',
 'Geopotential_height_maximum_wind',
 'Geopotential_height_tropopause',
 'Geopotential_height_potential_vorticity_surface',
 'Graupel_snow_pellets_isobaric',
 'Graupel_snow_pellets_hybrid',
 'Haines_index_surface',
 'High_cloud_cover_high_cloud',
 'High_cloud_cover_high_cloud_Mixed_intervals_Average',
 'ICAO_Standard_Atmosphere_Reference_Height_maximum_wind',
 'ICAO_Standard_Atmosphere_Reference_Height_tropopause',
 'Ice_cover_surface',
 'Ice_growth_rate_altitude_above_msl',
 'Ice_temperature_surface',
 'Ice_thickness_surface',
 'Ice_water_mixing_ratio_isobaric',
 'Ice_water_mixing_ratio_hybrid',
 'Land_cover_0__sea_1__land_surface',
 'Latent_heat_net_flux_surface_Mixed_intervals_Average',
 'Low_cloud_cover_low_cloud_Mixed_intervals_Average',
 'Low_cloud_cover_low_cloud',
 'Maximum_temperature_height_above_ground_Mixed_intervals_Maximum',
 'Medium_cloud_cover_middle_cloud',
 'Medium_cloud_cover_middle_cloud_Mixed_intervals_Average',
 'Minimum_temperature_height_above_ground_Mixed_intervals_Minimum',
 'Momentum_flux_u-component_surface_Mixed_intervals_Average',
 'Momentum_flux_v-component_surface_Mixed_intervals_Average',
 'Per_cent_frozen_precipitation_surface',
 'Potential_temperature_sigma',
 'Precipitable_water_entire_atmosphere_single_layer',
 'Precipitation_rate_surface',
 'Precipitation_rate_surface_Mixed_intervals_Average',
 'Pressure_surface',
 'Pressure_low_cloud_bottom_Mixed_intervals_Average',
 'Pressure_middle_cloud_bottom_Mixed_intervals_Average',
 'Pressure_middle_cloud_top_Mixed_intervals_Average',
 'Pressure_high_cloud_bottom_Mixed_intervals_Average',
 'Pressure_low_cloud_top_Mixed_intervals_Average',
 'Pressure_high_cloud_top_Mixed_intervals_Average',
 'Pressure_maximum_wind',
 'Pressure_height_above_ground',
 'Pressure_tropopause',
 'Pressure_convective_cloud_top',
 'Pressure_convective_cloud_bottom',
 'Pressure_potential_vorticity_surface',
 'Pressure_reduced_to_MSL_msl',
 'Rain_mixing_ratio_isobaric',
 'Rain_mixing_ratio_hybrid',
 'Relative_humidity_pressure_difference_layer',
 'Relative_humidity_sigma_layer',
 'Relative_humidity_isobaric',
 'Relative_humidity_zeroDegC_isotherm',
 'Relative_humidity_height_above_ground',
 'Relative_humidity_sigma',
 'Relative_humidity_entire_atmosphere_single_layer',
 'Relative_humidity_highest_tropospheric_freezing',
 'Sensible_heat_net_flux_surface_Mixed_intervals_Average',
 'Snow_depth_surface',
 'Snow_mixing_ratio_isobaric',
 'Snow_mixing_ratio_hybrid',
 'Soil_temperature_depth_below_surface_layer',
 'Soil_type_surface',
 'Specific_humidity_pressure_difference_layer',
 'Specific_humidity_isobaric',
 'Specific_humidity_height_above_ground',
 'Storm_relative_helicity_height_above_ground_layer',
 'Surface_roughness_surface',
 'Temperature_middle_cloud_top_Mixed_intervals_Average',
 'Temperature_low_cloud_top_Mixed_intervals_Average',
 'Temperature_high_cloud_top_Mixed_intervals_Average',
 'Temperature_pressure_difference_layer',
 'Temperature_surface',
 'Temperature_isobaric',
 'Temperature_altitude_above_msl',
 'Temperature_maximum_wind',
 'Temperature_tropopause',
 'Temperature_height_above_ground',
 'Temperature_sigma',
 'Temperature_potential_vorticity_surface',
 'Total_cloud_cover_boundary_layer_cloud_Mixed_intervals_Average',
 'Total_cloud_cover_isobaric',
 'Total_cloud_cover_entire_atmosphere_Mixed_intervals_Average',
 'Total_cloud_cover_entire_atmosphere',
 'Total_cloud_cover_convective_cloud',
 'Total_ozone_entire_atmosphere_single_layer',
 'Total_precipitation_surface_Mixed_intervals_Accumulation',
 'Categorical_Rain_surface_Mixed_intervals_Average',
 'Categorical_Rain_surface',
 'Categorical_Freezing_Rain_surface_Mixed_intervals_Average',
 'Categorical_Freezing_Rain_surface',
 'Categorical_Ice_Pellets_surface_Mixed_intervals_Average',
 'Categorical_Ice_Pellets_surface',
 'Categorical_Snow_surface_Mixed_intervals_Average',
 'Categorical_Snow_surface',
 'Convective_Precipitation_Rate_surface_Mixed_intervals_Average',
 'Potential_Evaporation_Rate_surface',
 'Ozone_Mixing_Ratio_isobaric',
 'Reflectivity_height_above_ground',
 'Reflectivity_hybrid',
 'Composite_reflectivity_entire_atmosphere',
 'Vertical_Speed_Shear_tropopause',
 'Vertical_Speed_Shear_potential_vorticity_surface',
 'U-Component_Storm_Motion_height_above_ground_layer',
 'V-Component_Storm_Motion_height_above_ground_layer',
 'Frictional_Velocity_surface',
 'Ventilation_Rate_planetary_boundary',
 'MSLP_Eta_model_reduction_msl',
 'Zonal_Flux_of_Gravity_Wave_Stress_surface_Mixed_intervals_Average',
 'Meridional_Flux_of_Gravity_Wave_Stress_surface_Mixed_intervals_Average',
 'Planetary_Boundary_Layer_Height_surface',
 'Pressure_of_level_from_which_parcel_was_lifted_pressure_difference_layer',
 'Downward_Short-Wave_Radiation_Flux_surface_Mixed_intervals_Average',
 'Upward_Short-Wave_Radiation_Flux_atmosphere_top_Mixed_intervals_Average',
 'Upward_Short-Wave_Radiation_Flux_surface_Mixed_intervals_Average',
 'Downward_Long-Wave_Radp_Flux_surface_Mixed_intervals_Average',
 'Upward_Long-Wave_Radp_Flux_atmosphere_top_Mixed_intervals_Average',
 'Upward_Long-Wave_Radp_Flux_surface_Mixed_intervals_Average',
 'Cloud_Work_Function_entire_atmosphere_single_layer_Mixed_intervals_Average',
 'Sunshine_Duration_surface',
 'Surface_Lifted_Index_surface',
 'Best_4_layer_Lifted_Index_surface',
 'Volumetric_Soil_Moisture_Content_depth_below_surface_layer',
 'Ground_Heat_Flux_surface_Mixed_intervals_Average',
 'Plant_Canopy_Surface_Water_surface',
 'Wilting_Point_surface',
 'Liquid_Volumetric_Soil_Moisture_non_Frozen_depth_below_surface_layer',
 'Field_Capacity_surface',
 'Vegetation_surface',
 'Vertical_velocity_geometric_isobaric',
 'Vertical_velocity_pressure_isobaric',
 'Vertical_velocity_pressure_sigma',
 'Visibility_surface',
 'Water_equivalent_of_accumulated_snow_depth_surface',
 'Water_runoff_surface_Mixed_intervals_Accumulation',
 'Wind_speed_gust_surface',
 'u-component_of_wind_pressure_difference_layer',
 'u-component_of_wind_isobaric',
 'u-component_of_wind_maximum_wind',
 'u-component_of_wind_altitude_above_msl',
 'u-component_of_wind_tropopause',
 'u-component_of_wind_height_above_ground',
 'u-component_of_wind_sigma',
 'u-component_of_wind_potential_vorticity_surface',
 'u-component_of_wind_planetary_boundary',
 'v-component_of_wind_pressure_difference_layer',
 'v-component_of_wind_isobaric',
 'v-component_of_wind_altitude_above_msl',
 'v-component_of_wind_maximum_wind',
 'v-component_of_wind_height_above_ground',
 'v-component_of_wind_tropopause',
 'v-component_of_wind_sigma',
 'v-component_of_wind_potential_vorticity_surface',
 'v-component_of_wind_planetary_boundary']

What did you find?



Access Variable Specifics#

Let’s look at a single variable: Geopotential_height_isobaric, which is the variable for heights of pressure surfaces (i.e., what we typically plot on maps). Type the following into a new cell and run it.

There are two methods to access our variables:

Dot Method:

ds.Geopotential_height_isobaric

or

Dictionary-like Method:

ds['Geopotential_height_isobaric']

Both methods are equivalent and as long as there are no spaces or dashed in the name of a variable, either method will work. If there is a space or a dash, then only the dictionary method will work.

For example, the wind components (e.g., u-component_of_wind_isobaric) must use the dictionary method because of the dash in the name of the variable.

The output in a Jupyter Notebook will have an HTML representation that you can interact with. For example, click on the triangle icons to expand or minimize information about different aspects of the data contained within that file for that variable.

# Information about the Geopotential_height_isobaric variable
ds.Geopotential_height_isobaric
<xarray.DataArray 'Geopotential_height_isobaric' (time2: 129, isobaric: 41,
                                                  lat: 181, lon: 360)>
[344631240 values with dtype=float32]
Coordinates:
  * lat       (lat) float32 90.0 89.0 88.0 87.0 86.0 ... -87.0 -88.0 -89.0 -90.0
  * lon       (lon) float32 0.0 1.0 2.0 3.0 4.0 ... 356.0 357.0 358.0 359.0
    reftime   datetime64[ns] ...
  * time2     (time2) datetime64[ns] 2024-08-29 ... 2024-09-14
  * isobaric  (isobaric) float32 1.0 2.0 4.0 7.0 ... 9.5e+04 9.75e+04 1e+05
Attributes: (12/13)
    long_name:                       Geopotential height @ Isobaric surface
    units:                           gpm
    abbreviation:                    HGT
    grid_mapping:                    LatLon_Projection
    Grib_Variable_Id:                VAR_0-3-5_L100
    Grib2_Parameter:                 [0 3 5]
    ...                              ...
    Grib2_Parameter_Category:        Mass
    Grib2_Parameter_Name:            Geopotential height
    Grib2_Level_Type:                100
    Grib2_Level_Desc:                Isobaric surface
    Grib2_Generating_Process_Type:   Forecast
    Grib2_Statistical_Process_Type:  UnknownStatType--1

What units of Geopotential Height?



How many available forecast hours are there?



How many vertical levels are there?



# Information about the Geopotential_height_isobaric variable
# This example uses the dictionary-like method for accessing
# the varaible.
ds['u-component_of_wind_isobaric']
<xarray.DataArray 'u-component_of_wind_isobaric' (time2: 129, isobaric: 41,
                                                  lat: 181, lon: 360)>
[344631240 values with dtype=float32]
Coordinates:
  * lat       (lat) float32 90.0 89.0 88.0 87.0 86.0 ... -87.0 -88.0 -89.0 -90.0
  * lon       (lon) float32 0.0 1.0 2.0 3.0 4.0 ... 356.0 357.0 358.0 359.0
    reftime   datetime64[ns] ...
  * time2     (time2) datetime64[ns] 2024-08-29 ... 2024-09-14
  * isobaric  (isobaric) float32 1.0 2.0 4.0 7.0 ... 9.5e+04 9.75e+04 1e+05
Attributes: (12/13)
    long_name:                       u-component of wind @ Isobaric surface
    units:                           m/s
    abbreviation:                    UGRD
    grid_mapping:                    LatLon_Projection
    Grib_Variable_Id:                VAR_0-2-2_L100
    Grib2_Parameter:                 [0 2 2]
    ...                              ...
    Grib2_Parameter_Category:        Momentum
    Grib2_Parameter_Name:            u-component of wind
    Grib2_Level_Type:                100
    Grib2_Level_Desc:                Isobaric surface
    Grib2_Generating_Process_Type:   Forecast
    Grib2_Statistical_Process_Type:  UnknownStatType--1

You will ALWAYS want to check the gridded file to know what different variables are called and know some of the basic information about the variable (e.g., how many vertical level, what units they are in, etc.). Use the information on this page to help you out!