ShiftLon: Shift longitudes of a data array

View source: R/ShiftLon.R

ShiftLonR Documentation

Shift longitudes of a data array

Description

Shift the longitudes of a data array. Only reasonable for global longitude shifting. It is useful for map plotting or aligning datasets.

Usage

ShiftLon(data, lon, westB, lon_dim = "lon", ncores = NULL)

Arguments

data

A named multidimensional array with at least 'lon_dim' dimension.

lon

A numeric vector of longitudes. The values are expected to be monotonic increasing.

westB

A number indicating the west boundary of the new longitudes.

lon_dim

A character string indicating the name of the longitude dimension in 'data'. The default value is 'lon'.

ncores

An integer indicating the number of cores used for computation. The default value is NULL (use only one core).

Value

A list of 2:

data

Array of the shifted data with the same dimensions as parameter 'data'.

lon

The monotonic increasing new longitudes with the same length as parameter 'lon' and start at 'westB'.

Examples

data <- array(data = 1:50, dim = c(lon = 360, lat = 181))
lon <- array(data = 0:359, dim = c(lon = 360))
lat <- -90:90 ## lat does not change
shifted <- ShiftLon(data = data, lon = lon, westB = -180, ncores = 1)

 ## Not run: 
s2dv::PlotEquiMap(var = data, lon = lon, lat = lat, filled.continents = FALSE)
s2dv::PlotEquiMap(var = shifted$data, lon = shifted$lon, lat = lat, filled.continents = FALSE)
 
## End(Not run)
 

ClimProjDiags documentation built on May 29, 2024, 8:56 a.m.