MET Tool: PB2NC
MET Tool: PB2NCPB2NC Tool: General
PB2NC Functionality
The PB2NC tool is used to stratify (i.e. subset) the contents of an input PrepBufr point observation file and reformat it into NetCDF format for use by the Point-Stat or Ensemble-Stat tool. In this session, we will run PB2NC on a PrepBufr point observation file prior to running Point-Stat. Observations may be stratified by variable type, PrepBufr message type, station identifier, a masking region, elevation, report type, vertical level category, quality mark threshold, and level of PrepBufr processing. Stratification is controlled by a configuration file and discussed on the next page.
The PB2NC tool may be run on both PrepBufr and Bufr observation files. As of met-6.1, support for Bufr is limited to files containing embedded tables. Support for Bufr files using external tables will be added in a future release.
For more information about the PrepBufr format, visit:
https://emc.ncep.noaa.gov/emc/pages/infrastructure/bufrlib.php
For information on where to download PrepBufr files, visit:
https://dtcenter.org/community-code/model-evaluation-tools-met/input-data
PB2NC Usage
Usage: pb2nc | ||
prepbufr_file | input prepbufr path/filename | |
netcdf_file | output netcdf path/filename | |
config_file | configuration path/filename | |
[-pbfile prepbufr_file] | additional input files | |
[-valid_beg time] | Beginning of valid time window [YYYYMMDD_[HH[MMSS]]] | |
[-valid_end time] | End of valid time window [YYYYMMDD_[HH[MMSS]]] | |
[-nmsg n] | Number of PrepBufr messages to process | |
[-index] | List available observation variables by message type (no output file) | |
[-dump path] | Dump entire contents of PrepBufr file to directory | |
[-obs_var var] | Sets the variable list to be saved from input BUFR files | |
[-log file] | Outputs log messages to the specified file | |
[-v level] | Level of logging | |
[-compression level] | NetCDF file compression |
At a minimum, the input prepbufr_file, the output netcdf_file, and the configuration config_file must be passed in on the command line. Also, you may use the -pbfile command line argument to run PB2NC using multiple input PrepBufr files, likely adjacent in time.
When running PB2NC on a new dataset, users are advised to run with the -index option to list the observation variables that are present in that file.
Configure
ConfigurePB2NC Tool: Configure
cd ${METPLUS_TUTORIAL_DIR}/output/met_output/pb2nc
The behavior of PB2NC is controlled by the contents of the configuration file passed to it on the command line. The default PB2NC configuration may be found in the data/config/PB2NCConfig_default file.
The configurable items for PB2NC are used to filter out the PrepBufr observations that should be retained or derived. You may find a complete description of the configurable items in the pb2nc configuration file section of the MET User's Guide or in the Configuration File Overview.
For this tutorial, edit the PB2NCConfig_tutorial_run1 file as follows:
- Set:
message_type = [ "ADPUPA", "ADPSFC" ];to retain only those 2 message types. Message types are described in:
http://www.emc.ncep.noaa.gov/mmb/data_processing/prepbufr.doc/table_1.htm - Set:
obs_window = {
beg = -1800;
end = 1800;
}so that only observations within 1800 second (30 minutes) of the file time will be retained.
- Set:
mask = {
grid = "G212";
poly = "";
}to retain only those observations residing within NCEP Grid 212, on which the forecast data resides.
- Set:
obs_bufr_var = [ "QOB", "TOB", "UOB", "VOB", "D_WIND", "D_RH" ];to retain observations for specific humidity, temperature, the u-component of wind, and the v-component of wind and to derive observation values for wind speed and relative humidity.
While we are request these observation variable names from the input file, the following corresponding strings will be written to the output file: SPFH, TMP, UGRD, VGRD, WIND, RH. This mapping of input PrepBufr variable names to output variable names is specified by the obs_prepbufr_map config file entry. This enables the new features in the current version of MET to be backward compatible with earlier versions.
Run
RunPB2NC Tool: Run
${METPLUS_DATA}/met_test/data/sample_obs/prepbufr/ndas.t00z.prepbufr.tm12.20070401.nr \
tutorial_pb_run1.nc \
PB2NCConfig_tutorial_run1 \
-v 2
PB2NC is now filtering the observations from the PrepBufr file using the configuration settings we specified and writing the output to the NetCDF file name we chose. This should take a few minutes to run. As it runs, you should see several status messages printed to the screen to indicate progress. You may use the -v command line option to turn off (-v 0) or change the amount of log information printed to the screen.
If you'd like to filter down the observations further, you may want to narrow the time window or modify other filtering criteria. We will do that after inspecting the resultant NetCDF file.
Output
OutputPB2NC Tool: Output
When PB2NC is finished, you may view the output NetCDF file it wrote using the ncdump utility.
In the NetCDF header, you'll see that the file contains nine dimensions and nine variables. The obs_arr variable contains the actual observation values. The obs_qty variable contains the corresponding quality flags. The four header variables (hdr_typ, hdr_sid, hdr_vld, hdr_arr) contain information about the observing locations.
The obs_var, obs_unit, and obs_desc variables describe the observation variables contained in the output. The second entry of the obs_arr variable (i.e. var_id) lists the index into these array for each observation. For example, for observations of temperature, you'd see TMP in obs_var, KELVIN in obs_unit, and TEMPERATURE OBSERVATION in obs_desc. For observations of temperature in obs_arr, the second entry (var_id) would list the index of that temperature information.
Plot-Point-Obs
The plot_point_obs tool plots the location of these NetCDF point observations. Just like plot_data_plane is useful to visualize gridded data, run plot_point_obs to make sure you have point observations where you expect.
tutorial_pb_run1.nc \
tutorial_pb_run1.ps
Each red dot in the plot represents the location of at least one observation value. The plot_point_obs tool has additional command line options for filtering which observations get plotted and the area to be plotted.
By default, the points are plotted on the full globe.
tutorial_pb_run1.nc \
tutorial_pb_run1_zoom.ps \
-data_file ${METPLUS_DATA}/met_test/data/sample_fcst/2007033000/nam.t00z.awip1236.tm00.20070330.grb
MET extracts the grid information from the first record of that GRIB file and plots the points on that domain.
The plot_data_plane tool can be run on the NetCDF output of any of the MET point observation pre-processing tools (pb2nc, ascii2nc, madis2nc, and lidar2nc).
Reconfigure and Rerun
Reconfigure and RerunPB2NC Tool: Reconfigure and Rerun
Now we'll rerun PB2NC, but this time we'll tighten the observation acceptance criteria.
- Set:
message_type = [];to retain all message types.
- Set:
obs_window = {
beg = -25*30;
end = 25*30;
}so that only observations 25 minutes before and 25 minutes after the top of the hour are retained.
- Set:
quality_mark_thresh = 1;to retain only the observations marked "Good" by the NCEP quality control system.
${METPLUS_DATA}/met_test/data/sample_obs/prepbufr/ndas.t00z.prepbufr.tm12.20070401.nr \
tutorial_pb_run2.nc \
PB2NCConfig_tutorial_run2 \
-v 2
The majority of the observations were rejected because their valid time no longer fell inside the tighter obs_window setting.
When configuring PB2NC for your own projects, you should err on the side of keeping more data rather than less. As you'll see, the grid-to-point verification tools (Point-Stat and Ensemble-Stat) allow you to further refine which point observations are actually used in the verification. However, keeping a lot of point observations that you'll never actually use will make the data files larger and slightly slow down the verification. For example, if you're using a Global Data Assimilation (GDAS) PREPBUFR file to verify a model over Europe, it would make sense to only keep those point observations that fall within your model domain.