Learn R Programming

APSIM (version 0.8.2)

prepareMet: Convert raw data to the correct APSIM met format.

Description

PrepareMet accepts a data frame containing met data and prepares it for writing to an APSIM formatted source file.

Usage

prepareMet(data, lat = stop("Latitude required."),
  lon = stop("Longitude required."), newNames = NULL, date.format = "AU")

Arguments

data
A data frame containing the data to prepare.
lat
Latitude in decimal degrees.
lon
Longitude in decimal degrees.
newNames
(optional) A vector of new column names.
date.format
(optional) A string containg the date format to use.

Value

  • A metFile S4 class containing the prepared met data.

Importing External Data

prepareMet accepts a standard R data frame as an argument. As such, you can use any importation package that returns data in or can be coerced to a data frame. Some examples: #'
  • Microsoft Excel files - readxl
  • NetCDF - RNetCDF
  • MySQL database - RMySQL
  • Generic databases (including Microsoft SQL Server) - RODBC

Details

It will generate year/day columns from an existing date column, check to ensure that dates are continuous and checks for the existence of required column names (year, day, radn, mint, maxt and rain). It will interpolate 365 day leap years (e.g. no extra day from GCMs) and returns a metFile object that can be used with other APSIM functions.

Examples

Run this code
data(Kingsthorpe)
prepareMet(kingsData, -27.48, 151.81, newNames=
  c("Date", "maxt", "mint", "rain", "evaporation",
   "radn", "vp", "Windrun.km", "RH.at.9am", "SVP.at.9am"))

Run the code above in your browser using DataLab