Format a field as a netcdf file and write it to the specified file. The lat, lon, and time variables from the griddata input are used to recover the original size of the grid, reversing the flattening procedure.

write.temperature(
  fld,
  file,
  griddata,
  varname = "tas",
  varunit = "K",
  vardesc = "2m air temperature",
  tunit = "years since 2006",
  clobber = FALSE
)

Arguments

fld

A matrix [ntime x ngrid] containing the field to write out.

file

Name of the output file.

griddata

A griddata structure returned from the read.temperatures function.

varname

Name to use for the variable in the output file.

varunit

Units of the variable in the field.

vardesc

Description string to write into the longname attribute in the output file.

tunit

Units for the time variable.

clobber

If TRUE, overwrite the file if it exists; otherwise trying to write a file that already exists is an error.