Plotting global mean temperatures spatiallyΒΆ

In this recipe, we will plot the global mean temperature spatially.

  1. Import cf-python and cf-plot:

import cfplot as cfp

import cf
  1. Read the field constructs:

f = cf.read("~/recipes/cru_ts4.06.1901.2021.tmp.dat.nc")
print(f)
[<CF Field: ncvar%stn(long_name=time(1452), long_name=latitude(360), long_name=longitude(720))>,
 <CF Field: long_name=near-surface temperature(long_name=time(1452), long_name=latitude(360), long_name=longitude(720)) degrees Celsius>]
  1. Select near surface temperature by index and look at its contents:

temp = f[1]
print(temp)
Field: long_name=near-surface temperature (ncvar%tmp)
-----------------------------------------------------
Data            : long_name=near-surface temperature(long_name=time(1452), long_name=latitude(360), long_name=longitude(720)) degrees Celsius
Dimension coords: long_name=time(1452) = [1901-01-16 00:00:00, ..., 2021-12-16 00:00:00] gregorian
                : long_name=latitude(360) = [-89.75, ..., 89.75] degrees_north
                : long_name=longitude(720) = [-179.75, ..., 179.75] degrees_east
  1. Average the monthly mean surface temperature values by the time axis using the collapse method:

global_avg = temp.collapse("mean", axes="long_name=time")
  1. Plot the global mean surface temperatures:

cfp.con(global_avg, lines=False, title="Global mean surface temperature")
plot 03 recipe

Total running time of the script: ( 0 minutes 8.465 seconds)

Gallery generated by Sphinx-Gallery