1.1.make.import.data {pems.utils} | R Documentation |
making and importing data
Description
Various pems.utils functions to make and import data as pems objects.
Usage
#making pems objects
is.pems(x, full.test = TRUE, ...)
pems(x, units = NULL, constants = NULL, history = NULL,
...)
pems.element(x, name = NULL, units = NULL,
...)
#associated
isPEMS(...)
makePEMS(...)
makePEMSElement(...)
rebuildPEMS(x, ...)
## S3 method for class 'data.frame'
as.pems(x, ...)
#importing data as pems objects
#general
import2PEMS(file.name = file.choose(), ...,
file.reader = read.delim,
output="pems")
importTAB2PEMS(..., file.reader = read.delim)
importCSV2PEMS(..., file.reader = read.csv)
#Horiba OBS
importOBS2PEMS(file.name = file.choose(),
pems = "Horiba OBS",
constants = NULL, history = NULL,
analytes = c("co", "co2", "nox", "hc"),
fuel = c("petrol", "diesel", "gasoline"), ...)
importOB12PEMS(file.name = file.choose(),
pems = "Horiba OBS",
constants = NULL, history = NULL,
analytes = c("co", "co2", "nox", "hc"),
fuel = c("petrol", "diesel", "gasoline"), ...)
#3DATX parSYNC
importParSYNC2PEMS(file.name = file.choose(),
reset.signals = TRUE,
history = NULL, constants = NULL,
pm.analyzer = "parSYNC", ... )
#3DATX CAGE
importCAGE2PEMS(..., calibrator = "CAGE")
#Sensors Inc SEMTECH
importSEMTECH2PEMS(file.name = file.choose(),
history = NULL, constants = NULL,
pems = "SEMTECH", ...)
#RoyalTek GPS
importRoyalTek2PEMS(file.name = file.choose(),
file.type = c("special", "txt", "nmea"),
vbox = "RoyalTEk", history = NULL,
constants = NULL, ...)
#KML files
importKML2PEMS(file.name = file.choose(), history = NULL,
constants = NULL, source = "Unknown", ...)
Arguments
x |
(A required object) For |
full.test |
(Logical) For |
... |
(Optional) Other arguments, handling varies. For
|
units , constants , history |
(Default pems arguments) These are arguments that are routinely generated for
|
name |
(Default pems.element argument) |
file.name |
(file connection, etc.) For |
file.type , file.reader |
Data reader parameters for some |
output |
Where included in formal arguments, an option to control function output. |
pems , vbox , pm.analyzer , calibrator , source |
(Character vectors) For some |
analytes |
(Character vector) For |
fuel |
Some |
reset.signals |
(Logical or Character vector) For |
Details
is.pems
tests if an object is/is not a pems
object.
pems
makes a pems
object using supplied data and information.
pems.element
makes a pems.element
object using supplied data and information.
as.pems...
functions attempt to convert a supplied object into a pems
object.
Currently, there is only a data.frame
method and (by default
) a pems
method.
isPEMS
, makePEMS
and makePEMSElement
are historical code, retained for
backward compatibility.
rebuildPEMS
rebuilds pems
object as a different build version.
Crude import...
functions import simple file structures, and are useful for getting
data quickly into R:pems.utils
. importTAB2PEMS
imports tab delimited files and
clipboard content. importCSV2PEMS
imports comma delimited files. Both assume a simple
file structure (i.e. data series in columns with names as headers), but require some time data
management by the user. Note: These are wrappers for import2PEMS
.
Other import...
import specific file types.
importOBS2PEMS
imports standard Horiba OBS files and converts them to pems
objects. See Notes below.
importOB12PEMS
imports .OB1
files and converts them to pems
objects. OB1
files are generated by a Visual Basic PEMS data handler used during the RETEMM project. Notes below.
importParSYNC2PEMS
imports standard parSYNC files and converts them to pems
objects. See Notes below.
importCAGE2PEMS
imports standard CAGE files and converts them to pems
objects.
See importParSYNC2PEMS
Notes below.
importSEMTECH2PEMS
imports Sensors Inc. SEMTECH ECOSTAR files and converts them to pems
objects. See Notes below.
importRoyalTek2PEMS
imports .txt
and .nmea
format Royal Tek GPS files and
converts them to pems
objects. See Notes below.
importKML2PEMS
imports .kml
format KML files and
converts them to pems
objects. See Notes below.
Value
is.pems
return a logical, TRUE
if the supplied object is pems
class,
otherwise FALSE
. If the argument full.test = TRUE
is also supplied, additional
information about the object is returned as comment(output)
.
pems
and pems.element
functions return pems
and pems.element
objects, respectively, made using the supplied file and any additional information also
supplied in the same call.
rebuildPEMS
rebuilts the supplied pems
object. The default rebuilds as the lastest
build structure.
import...
functions return a pems
object, made using the supplied file and any
additional information also supplied in the same call.
Note
isPEMS
, makePEMS
and makePEMSElement
were earlier functions that performed
the same functions as is.pems
, pems
and pems.elements
, respectively. The
the current versions of these functions are wrappers for their replacements.
With the crude import...
functions (import2PEMS
, importTAB2PEMS
,
importCSV2PEMS
) modifications are minimal. Unless any additional changes are requested
in the import...(...)
call, the data is simply read in as a data.frame
and
converted to a pems
object.
With importOBS2PEMS
, OBS data is also modified as follows: data series names are simplified and
converted to lower case to simplify use in R; the data series time.stamp
and local.time
are added (generated using the file time stamp, the row counter and the log.rate constant);
data series latitude
and longitude
are resigned according to set N/S and E/W values,
if these are present/valid; latitude
and longitude
units are also reset to 'd.degLat'
and 'd.degLon'
. Any data series names in analytes
is renamed 'conc.[analyte name]'
.
If not supplied in the importOBS2PEMS
, typical OBS constants are currently assumed. Several of these
are based on emission source fuel. Defaults for these are generated according to fuel
(default
'petrol'
).
With importOB12PEMS
, handling is similar to that with importOBS2PEMS
.
With importParSYNC2PEMS
, the parSYNC data modifications are as follows: parSYNC Date and Time
data-series are merged and converted into *POSIX
as time.stamp
; local.time
is calculated
from this; the parSYNC data series Timestamp is retained as parsync.timestamp
; by default units are
removed from data-series names, but retained as units(pems)
; (again by default) all names are
converted to lower case. The default option reset.signal = TRUE
reverses the voltage reading
of opacity and ionization time-series (x = - x), if present. Alternatively, imports can be identified
specifically by name, e.g. reset.signal = "opacity"
to just reset opacity. Typical OBS constants
are currently assumed, if not supplied. Several of these are based on emission source fuel. The default
assumption is that the fuel is 'petrol'
unless fuel
has been assigned.
With importCAGE2PEMS
, handling is similar to that with importParSYNC2PEMS
.
With importSEMTECH2PEMS
, SEMTECH data is imported and modified as follows: data series names are simplified and
converted to lower case to simplify use in R; the data series time.stamp
and local.time
are added (generated using the file time stamp). Defaults constants are assigned according to fuel
(default
'petrol'
). This function in in-development and has so far only been used with files from two
sources, so handle with care, and time.format
has varied so may need resetting for some files.
With importRoyalTek2PEMS
, the Royal Tek data modifications are currently being documented.
With importKML2PEMS
, the function attempts to import and time.stamp, latitude, longtiude and altitude data
in the suppled KML file. This function in in-development and has so far only been used with KML files from one
source, so handle with care.
Author(s)
Karl Ropkins
References
References in preparation.
See Also
See ref.unit.conversions
and convertUnits
for general unit handling;
merge.pems
for pems data merging and alignment.
Examples
###########
##example 1
###########
#make little pems
data <- data.frame(speed=1:10, emissions=1:10)
units <- c("m/s", "g/s")
pems <- pems(x = data, units=units, example="my record")
pems #the pems object
summary(pems) #summary of held data
pems$speed #the speed pems.element
#import data file as pems using import... functions
#For example, to import CSV file as pems object
## Not run:
pems <- importCSV2PEMS()
## End(Not run)