Reading and Transforming Forecast and Observations Data

Andrew Singleton

harp training 16/02/2022

Read Gridded forecasts

  • Reading and writing is done with harpIO package
  • read_grid() to read from a named file
  • read_forecast() to read from multiple files
  • Can read grib, FA and NetCDF
  • NetCDF requires the user to provide information about dimensions
  • All gridded data can be interpolated to points, regridded or cross sections extracted

read_grid()

  • At minimum takes a file name and a parameter
  • Can also specify lead time, ensembe member, vertical level
  • Output can be a list of geofields or a data frame
  • Must specify the vertical level type if upper air data
  • Gridded data are of geofield class.
  • If more than 1 2d field a geolist is returned

Examples

read_forecast()

  • A wrapper to call read_grid() for multiple files
  • Needs date-times and a file template
  • Sequences of date-times can be made using seq_dates()
  • Can deal with lagged and multimodel ensembles
  • By default no data are returned to the calling environment
  • Can output to new files (when interpolate is selected)

Anatomy of a file template

  • Everything in `{ }´ is replaced by dynamic data
"{fcst_model}/{YYYY}/{MM}/{DD}/{HH}/mbr{MBR3}/fc{YYYY}{MM}{DD}{HH}+{LDT3}grib"

Examples

Combining parameters

  • Some parameters can be calculated as they are read in
  • Most obvious example is wind speed / direction from U and V
  • Parameters can be shown with show_harp_parameters()
    • And for a file format with show_harp_parameters("<format>")

Reading analysis data

  • Analyses can be read with the new read_analysis() function
  • It will always get every time from the file
  • plot_field() doesn’t yet work properly on data frames returned by read_analysis()

Examples

Reading point observations

  • The read_obs() function is used
  • Works in exactly the same way as read_forecast()
  • Only works for vobs currently

Examples

Other data formats

  • Any data format can conceivably by read in by read_forecast() and read_obs()
  • All that’s required is a function that takes the appropriate arguments and returns data in the appropriate format
  • read_forecast() and read_obs() will look for a function called read_<file_format>().
  • Special options can be passed via `file_format_opts()

Transformations

  • Transformations are done using the transformation and transformation_opts() arguments
  • Available transformations are
    • "interpolate"
    • "regrid"
    • "xsection"
  • Each has a function to generate options
    • interpolate_opts()
    • regrid_opts()
    • xsection_opts()

Examples

Up next - Verification workflow

  • We will cover writing out data from read_forecast() and read_obs() to SQLite files at the beginning of that session

HAVE A NICE EVENING!