Reads a calibration data file as supplied by Ocean Optics. Wavelength and calibration values are stored as data and the metadata parsed from the header or supplied as arguments as attributes of the same object, including the time and date of the calibration. The whole file header is in addition stored as a comment.
Usage
read_oo_caldata(
file,
time = NULL,
geocode = NULL,
label = NULL,
descriptor = NULL,
tz = NULL,
locale = NULL,
verbose = getOption("photobiology.verbose", default = FALSE)
)
Arguments
- file
character string Path or file to read.
- time
a
POSIXct
object, but ifNULL
the date stored in file is used, and ifNA
thewhen.measured
attribute is set toNA
.- geocode
A one row data frame with numeric columns
lon
andlat
, and optionally a character columnaddress
.- label
character string, but if
NULL
the value offile
is used, and ifNA
the "what.measured" attribute is set toNA
.- descriptor
list A list describing the instrument, used to set attribute
instr.descriptor
.- tz
character Time zone is by default read from the file.
- locale
The locale controls defaults that vary from place to place. The default locale is US-centric (like R), but you can use
locale
to create your own locale that controls things like the default time zone, encoding, decimal mark, big mark, and day/month names.- verbose
Logical indicating the level of warnings wanted.
Details
The format of the data used by Ocean Optics seems to have remained
consistent in time and with spectrometer model, but not the header. In
particular, the format of the date and whether time is included or not
varies. The function is able to decode three different date formats that I
have come across. If decoding fails with a message indicating that parsing
has failed, the problem can be overcome by passing the date as an argument
to parameter time
when calling the function, as in this case no
decoding of the date is attempted. The easiest approach is to use function
dmy
or similar from package 'lubridate'.
When no time zone information is included in the file header, the
local time zone is used, which in many cases will shift the date by one
day. If you know where the calibration was done, the correct TZ can be
passed as an argument. Anyway as calibrations are usually considered valid
for one or two years, this shift is only rarely important,