Learn R Programming

IsoriX (version 0.4-1)

QueryGNIP: Filter the dataset to create an isoscape

Description

This function prepares the worldwide GNIP data (GNIP_World) to be used for creating the isoscape. This function allows the trimming of data by months, years and location, and for the aggregation of selected data per weather station. The function can also be used to randomly exclude some observations.

Usage

QueryGNIP( data, month.min = 1, month.max = 12, year.min, year.max, long.min , long.max, lat.min, lat.max, prop.random = 0, random.level = "station" )

Arguments

data
A dataframe containing original isotopic measurements similar in structure to GNIP_World
month.min
A numeric indicating the minimum month to select from. Should be a round number between 1 and 12. The default value is 1 (January).
month.max
A numeric indicating the maximum month to select from. Should be a round number between 1 and 12. The default value is 12 (December).
year.min
A numeric indicating the oldest year to select from. If not provided, the oldest year of GNIP_World will be considered
year.max
A numeric indicating the most recent year to select from. If not provided, the most recent year of GNIP_World will be considered
long.min
A numeric indicating the minimum longitude to select from. Should be a number between -180 and 180. If not provided, -180 will be considered.
long.max
A numeric indicating the maximal longitude to select from. Should be a number between -180 and 180. If not provided, 180 will be considered.
lat.min
A numeric indicating the minimum latitude to select from. Should be a number between -90 and 90. If not provided, -90 will be considered.
lat.max
A numeric indicating the maximal latitude to select from. Should be a number between -90 and 90. If not provided, 90 will be considered.
prop.random
A numeric indicating the proportion of observations or weather stations (depending on the argument for random.level) that will be kept. If prop.random is greater than 0, then the function will return a list containing two dataframes: one containing the selected data, called selected.data, and one containing the remaining data, called remaining.data.
random.level
A string indicating the level at which random draws can be performed. The two possibilities are "obs", which indicates that observations are randomly drawn taken independently of their location, or "station" (default), which indicates that observations are randomly drawn at the level of weather stations.

Value

dataframe containing the filtered data aggregated by weather station, or a list, see above argument prop.random. For each weather station the mean and variance sample estimates are computed.

Details

This functions allows the user to filter the world-wide weather station data (GNIP_World) based on time (years and/ or months) and space (locations given in geographic coordinates, i.e. longitude and latitude) to calculate tailored isoscapes matching e.g. the time of sampling and speeding up the model fit by cropping/ clipping a certain area. The dataframe produced by this function can be used as input to fit the isoscape (see Isofit).

See Also

IsoriX for the complete work-flow GNIP_World for the complete dataset GNIP_Europe for an example of a dataset produced by this function

Examples

Run this code
data(GNIP_World)

### HOW DID WE CREATE THE OBJECT GNIP_Europe?

## The following example require to have downloaded
## a large elevation raster with the function GetElev()
## and will therefore not run unless you type:
## example(QueryGNIP, run.dontrun=TRUE)

## we first correct the elevations in GNIP_World:
## Not run: 
# if(require(raster)) {
#     elevationrasterbig <- raster("elevation_raster_gmted2010_30mn.tif")
#             GNIP_World$elev <- extract(
#                 elevationrasterbig,
#                 cbind(GNIP_World$long, GNIP_World$lat))
#     }
# ## End(Not run)

## then we used our function:
GNIP_Europe <- QueryGNIP(
    data=GNIP_World,
    long.min = -27.34, 
    long.max = 57.1,
    lat.min = 31.62, 
    lat.max = 68.97)
head(GNIP_Europe)
## uncomment the following to store the file:
# save(GNIP_Europe, file="GNIP_Europe.rda", compress="xz")


### CREATE ISOSCAPE-DATASET FOR WARM MONTHS IN EUROPE
GNIP_Europe_Warm <- QueryGNIP(
    data=GNIP_World,
    month.min = 5,  
    month.max = 8,
    year.min =  1960,
    year.max =  2013,
    long.min = -27.34, 
    long.max = 57.1,
    lat.min = 31.62, 
    lat.max = 68.97)

head(GNIP_Europe_Warm)


### CREATE A DATASET WITH 90% OF OBS
GNIP_World_90pct <- QueryGNIP(
    data=GNIP_World,
    prop.random=0.9,
    random.level = "obs")

lapply(GNIP_World_90pct, head) # show beginnng of both datasets

### CREATE A DATASET WITH HALF THE WEATHER STATIONS
GNIP_World_50pctStations <- QueryGNIP(
    data=GNIP_World,
    prop.random=0.5,
    random.level = "station")

lapply(GNIP_World_50pctStations, head)
    

Run the code above in your browser using DataLab