
Read '.CSV' File Saved by PSI's Software.
Source:R/read-psi-spectrapen-csv.r
read_spectrapen_csv.RdReads and parses the header of a processed .CSV file as output by the by the PSI (Photon Systems Instruments, Czech Republic) SpectraPen miniature spectrometer.
Usage
read_spectrapen_csv(
file,
start.row = 1,
date = NULL,
geocode = NULL,
label = NULL,
tz = NULL,
locale = readr::default_locale()
)Arguments
- file
character string.
- start.row
integer The first line to read, counting from the top of the file.
- date
a
POSIXctobject to use to set the"when.measured"attribute. IfNULL, the default, the date is extracted from the file header.- geocode
A data frame with columns
lonandlatused to set attribute"where.measured". IfNULL, the default, the location is extracted from the file header.- label
character string, but if
NULLthe label fromfileheader is used, if the label is missing, the index is used, and ifNAthe "what.measured" attribute is not set.- tz
character Time zone used for interpreting times saved in the file header.
- locale
The locale controls defaults that vary from place to place. The default locale is US-centric (like R), but you can use
localeto create your own locale that controls things like the default time zone, encoding, decimal mark, big mark, and day/month names.
Examples
# fetch path to example file to read
file.name <-
system.file("extdata", "spectrum-psi-spectrapen-SP.csv",
package = "photobiologyInOut", mustWork = TRUE)
spectrapen.mspct <- read_spectrapen_csv(file = file.name)
spectrapen.mspct
#> Object: source_mspct [6 x 1]
#> --- Member: spct.13 ---
#> Object: source_spct [256 x 2]
#> Wavelength range 327.1-793 nm, step 1.7-1.9 nm
#> Label: spct.13
#> Measured on 2022-10-11 19:08:01 UTC
#> Variables:
#> w.length: Wavelength [nm]
#> s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#> --
#> # A tibble: 256 × 2
#> w.length s.e.irrad
#> <dbl> <dbl>
#> 1 327. 0.0373
#> 2 329 0.0356
#> 3 331. 0.0325
#> 4 333. 0.0276
#> 5 335. 0.0240
#> 6 336. 0.0190
#> 7 338. 0.0184
#> 8 340. 0.0159
#> 9 342. 0.0129
#> 10 344 0.0120
#> # ℹ 246 more rows
#> --- Member: spct.14 ---
#> Object: source_spct [256 x 2]
#> Wavelength range 327.1-793 nm, step 1.7-1.9 nm
#> Label: spct.14
#> Measured on 2022-10-11 19:08:05 UTC
#> Variables:
#> w.length: Wavelength [nm]
#> s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#> --
#> # A tibble: 256 × 2
#> w.length s.e.irrad
#> <dbl> <dbl>
#> 1 327. 0.0371
#> 2 329 0.0326
#> 3 331. 0.0299
#> 4 333. 0.0271
#> 5 335. 0.0240
#> 6 336. 0.0204
#> 7 338. 0.0187
#> 8 340. 0.0169
#> 9 342. 0.0140
#> 10 344 0.0122
#> # ℹ 246 more rows
#> --- Member: spct.15 ---
#> Object: source_spct [256 x 2]
#> Wavelength range 327.1-793 nm, step 1.7-1.9 nm
#> Label: spct.15
#> Measured on 2022-10-11 19:08:10 UTC
#> Variables:
#> w.length: Wavelength [nm]
#> s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#> --
#> # A tibble: 256 × 2
#> w.length s.e.irrad
#> <dbl> <dbl>
#> 1 327. 0.0391
#> 2 329 0.0369
#> 3 331. 0.0310
#> 4 333. 0.0269
#> 5 335. 0.0256
#> 6 336. 0.0222
#> 7 338. 0.0191
#> 8 340. 0.0169
#> 9 342. 0.0143
#> 10 344 0.0119
#> # ℹ 246 more rows
#> --- Member: spct.16 ---
#> Object: source_spct [256 x 2]
#> Wavelength range 327.1-793 nm, step 1.7-1.9 nm
#> Label: spct.16
#> Measured on 2022-10-11 19:08:32 UTC
#> Variables:
#> w.length: Wavelength [nm]
#> s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#> --
#> # A tibble: 256 × 2
#> w.length s.e.irrad
#> <dbl> <dbl>
#> 1 327. 0.0974
#> 2 329 0.0832
#> 3 331. 0.0793
#> 4 333. 0.0636
#> 5 335. 0.0598
#> 6 336. 0.0508
#> 7 338. 0.0483
#> 8 340. 0.0416
#> 9 342. 0.0361
#> 10 344 0.0319
#> # ℹ 246 more rows
#> --- Member: spct.17 ---
#> Object: source_spct [256 x 2]
#> Wavelength range 327.1-793 nm, step 1.7-1.9 nm
#> Label: spct.17
#> Measured on 2022-10-11 19:08:36 UTC
#> Variables:
#> w.length: Wavelength [nm]
#> s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#> --
#> # A tibble: 256 × 2
#> w.length s.e.irrad
#> <dbl> <dbl>
#> 1 327. 0.0918
#> 2 329 0.0876
#> 3 331. 0.0819
#> 4 333. 0.0717
#> 5 335. 0.0603
#> 6 336. 0.0530
#> 7 338. 0.0456
#> 8 340. 0.0389
#> 9 342. 0.0375
#> 10 344 0.0306
#> # ℹ 246 more rows
#> --- Member: spct.18 ---
#> Object: source_spct [256 x 2]
#> Wavelength range 327.1-793 nm, step 1.7-1.9 nm
#> Label: spct.18
#> Measured on 2022-10-11 19:08:42 UTC
#> Variables:
#> w.length: Wavelength [nm]
#> s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#> --
#> # A tibble: 256 × 2
#> w.length s.e.irrad
#> <dbl> <dbl>
#> 1 327. 0.105
#> 2 329 0.0900
#> 3 331. 0.0882
#> 4 333. 0.0712
#> 5 335. 0.0629
#> 6 336. 0.0580
#> 7 338. 0.0504
#> 8 340. 0.0444
#> 9 342. 0.0379
#> 10 344 0.0324
#> # ℹ 246 more rows
#>
#> --- END ---
getWhenMeasured(spectrapen.mspct)
#> # A tibble: 6 × 2
#> spct.idx when.measured
#> <fct> <dttm>
#> 1 spct.13 2022-10-11 19:08:01
#> 2 spct.14 2022-10-11 19:08:05
#> 3 spct.15 2022-10-11 19:08:10
#> 4 spct.16 2022-10-11 19:08:32
#> 5 spct.17 2022-10-11 19:08:36
#> 6 spct.18 2022-10-11 19:08:42
getWhatMeasured(spectrapen.mspct)
#> # A tibble: 6 × 2
#> spct.idx what.measured
#> <fct> <chr>
#> 1 spct.13 spct.13
#> 2 spct.14 spct.14
#> 3 spct.15 spct.15
#> 4 spct.16 spct.16
#> 5 spct.17 spct.17
#> 6 spct.18 spct.18
cat(comment(spectrapen.mspct))