Skip to content

Statistical Evaluation

barronh edited this page Apr 20, 2016 · 3 revisions

How do I evaluate my model?

PseudoNetCDF provides a method for evaluating models using predefined functions or your own functions. First, get a sense for what functions are predefined. Then look at the first method using the Python Environment and the second using the command line interface (CLI).

These tutorials show work with CMAQ, but can easily be modified for CAMx or GEOS-Chem (see [modifications](Tutorial Modifications))

What functions are available?

pydoc PseudoNetCDF.pnceval

Method 1 - Python Environment

# input must exist on your machine
inpathmod = '/path/to/inputfile'
inpathobs = '/path/to/obsfile' # CSV with latitude,longitude,time,O3

from matplotlib import pyplot as plt

# import NetCDF Processing loading functions
from PseudoNetCDF.pncparse import pncparse
from PseudoNetCDF.pnceval import FB, FE

# Read in all inputs with the following options
# returns all files and an archive of arguments (including defaults)
# implicit option '-f', 'netcdf' opens the file as netcdf (other -f options "bpch", "uamiv")
# option '--from-conv', 'ioapi' uses the ioapi meta-data to derive latitudes, longitudes, and time variables
# option '--slice', 'LAY,0' takes the first layer
obsfiles, args = pncparse(args = ['-f', 'csv,coordkeys=["time","latitude","longitude"]', inpathobs])
obsfile = obsfiles[0]
olat, olon = obsfile.variables['latitude'][:], obsfile.variables['longitude'][:]
latloncoords = '/'.join(['%f,%f' % lonlat for lonlat in zip(olon, olat)])
modfiles, args = pncparse(args = [inpathmod '--from-conv', 'ioapi', '--variables', 'O3', '--slice', 'LAY,0', '--extract', lonlatcoords])
modfile = modfiles[0]
modv = modfile.varialbes['O3'][:]
obsv = obsfile.variables['O3'][:]
for vark in args.variables:
    print vark, 'Fractional Bias', FB(obsv, modv)
    print vark, 'Fractional Error', FE(obsv, modv)

Method 2 - CLI

pncgen --extract="lon1,lat1/lon2,lat2/.../lonN,latN" inpath modatobspath
pnceval --funcs=FB,FE --variables=O3 obspath modatobspath