Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

When performing computations between two fields, they must be on the same grid, with the same number of points. If this is not the case, you will need to use interpolation to transform one field onto the other's grid. See Processing Data.

 

One way to do this could be to simply multiply the temperature field by the land-sea mask field - this would preserve the land points by simply multiplying them by 1, but would convert the other points to 0. In some cases this might be what we want, but not here for two reasons:

  • zero might be a valid value for many meteorological parameters, so it can't be used as a mask
  • if we want to compute the mean over the field, the sea points will still be used and will simply result in a lower mean

So we will convert the zeros to missing values using the bitmap() and nobitmap() functions, whose documentation is reproduced here:

Panel

fieldset bitmap (fieldset,number)
fieldset bitmap (fieldset,fieldset)

Returns a copy of the input fieldset (first argument) with zero or more of its values replaced with grib missing value indicators. If the second argument is a number, then any value equal to that number in the input fieldset is replaced with the missing value indicator. If the second argument is another fieldset with the same number of fields as the first fieldset, then the result takes the arrangement of missing values from the second fieldset. If the second argument is another fieldset with one field, the arrangement of missing values from that field are copied into all fields of the output fieldset. See also nobitmap .

fieldset nobitmap ( fieldset,number )

Returns a copy of the input fieldset (first argument) with all of its missing values replaced with the number specified by the second argument. See also bitmap .

Try the following steps:

  • modify the lsm variable to have missing values where there are currently zeros (visualise to verify)
  • read t2m.grib into a new variable t2m
  • copy the missing value mask from lsm to t2m (plot t2m to verify)
  • compute and print the mean value of t2m - use the function integrate()

The code should in fact only be a few lines.

Extra Work

Computing different means

Try computing the mean value over the sea points. This should be just one small change to your code.

Compute the mean value over a sub-area rather than over the whole globe.

  simply multiply