R/calculateGlobalAverage.R

Defines functions calculateGlobalAverage

calculateGlobalAverage <- function(M) {
 
 # Author:           Andre Paul
 # Written:          2011-11-30
 # Last updated:     2014-01-07
 # Input arguments:
 #    Model               = structure array containing grid-cell volumes
 #                          and tracer concentration
 #M
 # Output arguments:
 #    globalAveragetracer = globally-averaged temperature field
 #
 # Dependencies:     none

 # Introduce local variables for readability
 ny     <- M$sizes$ny
 volume <- M$grids$volume
 tracer <- M$variables$tracer

 # Compute volume-weighted global average
 wmean <- sum(volume * tracer) / sum(volume)

 return(wmean)
}
garciapintado/rdafEbm1D documentation built on May 3, 2019, 8:04 p.m.