Coder Social home page Coder Social logo

eof's Introduction

EOF

Empirical Orthogonal Function to compute spatial and temporal pattern of geographic data (Adapted from Wikle, C. K., Zammit-Mangion, A., and Cressie, N. (2019), Spatio-Temporal Statistics with R)


Required R packages

reshape2


Defination of Variables

stdata: 2D array of data, matrix format: space (row) x time (columun)

var1: value of first dimension of space (ex. longitude)

var2: value of second dimension of space (ex. latitude)

time: value of timestep

EOFnumber: number of EOF to obtain in the output


Example

library(ncdf4)

library(lubridate)

nc <- nc_open('uwnd.mon.mean.nc') #download from: https://psl.noaa.gov/data/gridded/data.ncep.reanalysis2.pressure.html

time <- ncvar_get(nc=nc,varid='time')

date <- as.POSIXct(as.character(as.Date(time/24,origin='1800-01-01')))

time <- decimal_date(as.POSIXct(as.character(as.Date(time/24,origin='1800-01-01'))))

lon <- ncvar_get(nc=nc,varid='lon')

lat <- ncvar_get(nc=nc,varid='lat')

p <- ncvar_get(nc=nc,varid='level')

u <- ncvar_get(nc=nc,varid='uwnd')

u <- u[,,which(p==500),]

nc <- nc_open('vwnd.mon.mean.nc') #download from: https://psl.noaa.gov/data/gridded/data.ncep.reanalysis2.pressure.html

v <- ncvar_get(nc=nc,varid='vwnd')

v <- v[,,which(p==500),]

wind <- u+1i*v

stdata <- u

var1 <- lon

var2 <- lat

time <- time

eof_output <- EOF(stdata = stdata,var1 = var1, var2 = var2, time = time,EOFnumber = 2)

EOFspace <- eof_output[[1]]

EOFtime <- eof_output[[2]]

EOFd <- eof_output[[3]]

eof's People

Contributors

yuming-jin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.