In this example we work through the following steps:

  1. Import the cf package.
  2. Read a field from disk and find a summary of its contents.
  3. Import the cfplot package.
  4. Make a lineplot of the field.
  5. Read in a second field and find a summary of its contents.
  6. Make a lineplot of the field.
  7. Regrid the first field to the grid of the second and summarize the resulting field.
  8. Make a lineplot of the resulting field.

1. Import the cf package.

In [1]:
import cf

2. Read a field from disk and find a summary of its contents.

In [2]:
f = cf.read('cru_1D_yearly.nc')
f
Out[2]:
<CF Field: long_name:precipitation(long_name:time(10), long_name:latitude(1), long_name:longitude(1)) mm>
In [3]:
print f
long_name:precipitation field summary
-------------------------------------
Data           : long_name:precipitation(long_name:time(10), long_name:latitude(1), long_name:longitude(1)) mm
Cell methods   : long_name:time: mean long_name:latitude: long_name:longitude: mean
Axes           : long_name:longitude(1) = [0.0] degrees_east
               : long_name:latitude(1) = [0.0] degrees_north
               : long_name:time(10) = [1981-07-02 00:00:00, ..., 1990-07-02 00:00:00] gregorian

3. Import the cfplot package.

In [4]:
%matplotlib inline

import cfplot as cfp

4. Make a lineplot of the field.

In [5]:
cfp.lineplot(f)

5. Read in a second field and find a summary of its contents.

In [6]:
g = cf.read('cru_1D_monthly.nc')
g
Out[6]:
<CF Field: long_name:precipitation(long_name:time(120), long_name:latitude(1), long_name:longitude(1)) mm>
In [7]:
print g
long_name:precipitation field summary
-------------------------------------
Data           : long_name:precipitation(long_name:time(120), long_name:latitude(1), long_name:longitude(1)) mm
Cell methods   : long_name:latitude: long_name:longitude: mean
Axes           : long_name:longitude(1) = [0.0] degrees_east
               : long_name:latitude(1) = [0.0] degrees_north
               : long_name:time(120) = [1981-01-16 00:00:00, ..., 1990-12-16 00:00:00] gregorian

6. Make a lineplot of the field.

In [8]:
cfp.lineplot(g)

7. Regrid the first field to the grid of the second and summarize the resulting field.

In [9]:
h = f.regridc(g, axes='T', method='bilinear')
h
Out[9]:
<CF Field: long_name:precipitation(long_name:time(120), long_name:latitude(1), long_name:longitude(1)) mm>
In [10]:
print h
long_name:precipitation field summary
-------------------------------------
Data           : long_name:precipitation(long_name:time(120), long_name:latitude(1), long_name:longitude(1)) mm
Cell methods   : long_name:time: mean long_name:latitude: long_name:longitude: mean
Axes           : long_name:longitude(1) = [0.0] degrees_east
               : long_name:latitude(1) = [0.0] degrees_north
               : long_name:time(120) = [1981-01-16 00:00:00, ..., 1990-12-16 00:00:00] gregorian

8. Make a lineplot of the resulting field.

In [11]:
cfp.lineplot(h)