extract.monthly.averages {climates} R Documentation

## Extract Monthly Longterm Climate Averages

### Description

need a function to create monthy averages given a set of years

### Usage

```extract.monthly.averages(nc, min.year, max.year)
```

### Arguments

 `nc` ~~Describe `nc` here~~ `min.year` ~~Describe `min.year` here~~ `max.year` ~~Describe `max.year` here~~

### Details

give it the nc file from retrieve.nc, min year and max year

...

### Note

~~further notes~~

~~who you are~~

### References

~put references to the literature/web site here ~

~~objects to See Also as `help`, ~~~

### Examples

```## Not run:
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(nc,min.year,max.year) {
#ensure nc1 & nc2 are from retrieve.nc
if (all(c('dat','tim','yy','mm', 'lat', 'lon') %in% names(nc))==FALSE)
stop('nc must have objects named dat, lat, lon, tim, yy and mm as from
retrieve.nc of clim.pact package')
#do the work
#track lat, long and time
lat = nc\$lat
lon = nc\$lon
mm = 1:12
#create an output array
out.data = array(0,dim=c(length(mm),length(lat),length(lon)))
#get the array subset which is from the start year to end year
years = which(nc\$yy %in% min.year:max.year)
#cycle through all the data in those years
for (ii in years) out.data[nc\$mm[ii],,] = out.data[nc\$mm[ii],,] + nc\$dat[ii,,]
#now get the average by deviding by the number of months
for (ii in mm) out.data[ii,,] = out.data[ii,,] / (max.year-min.year+1)
#return the information
return(list(dat=out.data,lon=lon,lat=lat,tim=mm))
}

## End(Not run)
```

[Package climates version 0.1-1.6 Index]