Creates a date frame (and file export) from Continuous Data in the format used by the StreamThermal package.

Export.StreamThermal(
  fun.myDF,
  fun.col.SiteID = ContData.env$myName.SiteID,
  fun.col.Date = ContData.env$myName.Date,
  fun.col.Temp = ContData.env$myName.WaterTemp
)

Arguments

fun.myDF

User data that has been through the QC process of ContDataQC. Required fields are SiteID, Date, Water.Temp.C (or as defined in config.R).

fun.col.SiteID

Column name for SiteID. Default = SiteID (as defined in config.R)

fun.col.Date

Column name for SiteID. Default = Date (as defined in config.R)

fun.col.Temp

Column name for SiteID. Default = Water.Temp.C (as defined in config.R)

Value

Returns a data frame formatted for use with the R library StreamThermal (SiteID, Date, MaxT, MinT, MeanT). Statistics are calculated in the function.

Details

Required fields are StationID, Date, dailyMax, dailyMin, and dailyMean The fields are named "siteID", "Date", "MaxT", "MinT", and "MeanT".

The StreamThermal package is available on GitHub. It can be installed with the devtools package:

library(devtools)

install_github("tsangyp/StreamThermal")

Examples

#~~~~~~~~~~~~~~~~~~~~~~
# Example 1, USGS data
#~~~~~~~~~~~~~~~~~~~~~~
library(dataRetrieval)
# 1.1. Get USGS data
# code from StreamThermal T_frequency example
ExUSGSStreamTemp<-readNWISdv("01382310","00010","2011-01-01","2011-12-31"
                             ,c("00001","00002","00003"))
sitedata<-subset(ExUSGSStreamTemp, select=c("site_no","Date"
                 ,"X_00010_00001","X_00010_00002","X_00010_00003"))
names(sitedata)<-c("siteID","Date","MaxT","MinT","MeanT")
#
# 1.2. Run StreamThermal
# Library (install if needed)
# devtools::install_github("tsangyp/StreamThermal")
# Library (load)
require(StreamThermal)
#> Loading required package: StreamThermal
#~~~~~
# StreamThermal
(ST.freq <- T_frequency(sitedata))
#>   SiteInfo FmaxcT1 FmaxcT2 FmaxcT3 FmaxcT4 FmaxcT5 FmaxcT6 FmaxcT7 FmaxcT8
#> 1 01382310       0       0       0       0      17      29      31      30
#>   FmaxcT9 FmaxcT10 FmaxcT11 FmaxcT12 FmincT1 FmincT2 FmincT3 FmincT4 FmincT5
#> 1      30       12        0        0       0       0       0       0       7
#>   FmincT6 FmincT7 FmincT8 FmincT9 FmincT10 FmincT11 FmincT12 FmeancT1 FmeancT2
#> 1      24      31      28      25        3        0        0        0        0
#>   FmeancT3 FmeancT4 FmeancT5 FmeancT6 FmeancT7 FmeancT8 FmeancT9 FmeancT10
#> 1        0        0       10       26       31       28       26         7
#>   FmeancT11 FmeancT12 FmaxcTsp FmincTsp FmeancTsp FmaxcTsu FmincTsu FmeancTsu
#> 1         0         0       17        7        10       90       83        85
#>   FmaxcTfa FmincTfa FmeancTfa FmaxcTwi FmincTwi FmeancTwi
#> 1       42       28        33        0        0         0
(ST.mag  <- T_magnitude(sitedata))
#>   SiteInfo   ADmax1 ADmax2   ADmax3 ADmax4   ADmax5   ADmax6   ADmax7   ADmax8
#> 1 01382310 1.825806  1.775 4.864516   9.88 17.20645 21.47333 24.09677 22.68387
#>   ADmax9  ADmax10  ADmax11 ADmax12    ADmin1    ADmin2   ADmin3   ADmin4
#> 1  20.03 15.01613 9.793333     6.2 0.9419355 0.5214286 2.764516 7.513333
#>     ADmin5 ADmin6   ADmin7   ADmin8   ADmin9  ADmin10  ADmin11  ADmin12
#> 1 14.65806  18.62 20.36452 19.96774 18.46333 13.23548 8.106667 4.825806
#>    ADmean1  ADmean2  ADmean3  ADmean4  ADmean5 ADmean6  ADmean7  ADmean8
#> 1 1.322581 1.107143 3.654839 8.566667 15.89355      20 22.01613 21.32903
#>    ADmean9 ADmean10 ADmean11 ADmean12 MaxDmeanSp MinDmeanSp AvgDmeanSp
#> 1 19.27667 14.16774 8.916667 5.535484       22.4        1.6   9.380435
#>   MaxDmeanSu MinDmeanSu AvgDmeanSu MaxDmeanFa MinDmeanFa AvgDmeanFa MaxDmeanWi
#> 1         25       13.8   21.12717       21.5        7.2   14.12088        8.6
#>   MinDmeanWi AvgDmeanWi Max30MovingAMeanT Max30MovingAMaxT Max21MovingAMeanT
#> 1        0.1   2.706667          22.16667         24.32333          22.40476
#>   Max21MovingAMaxT Max14MovingAMeanT Max14MovingAMaxT Max7MovingAMeanT
#> 1         24.59048          22.67857         24.73571         23.21429
#>   Max7MovingAMaxT Max3MovingAMeanT Max3MovingAMaxT
#> 1        25.17143         23.96667            26.1
(ST.roc  <- T_rateofchange(sitedata))
#>   SiteInfo   RC1       RC2       RC3       RC4 RC5  RC6  RC7  RC8       RC9
#> 1 01382310 0.108 0.1352941 0.2866667 0.3518519 0.4 1.54 0.96 2.24 0.4357143
#>   RC10      RC11      RC12      RCsp      RCsu      RCfa       RCwi
#> 1 0.32 0.4111111 0.2434783 0.2337079 0.5090909 0.1881579 0.02715655
(ST.tim  <- T_timing(sitedata))
#>   SiteInfo JDmaxMaxT1 JDmaxMaxT2 JDmaxMaxT3 JDmaxMaxT4 JDmaxMaxT5 JDmaxMaxT6
#> 1 01382310          0         48         76        118        150        151
#>   JDmaxMaxT7 JDmaxMaxT8 JDmaxMaxT9 JDmaxMaxT10 JDmaxMaxT11 JDmaxMaxT12
#> 1        202        219        246         273         313         339
#>   JDminMinT1 JDminMinT2 JDminMinT3 JDminMinT4 JDminMinT5 JDminMinT6 JDminMinT7
#> 1         26         38         61         91        125        156        195
#>   JDminMinT8 JDminMinT9 JDminMinT10 JDminMinT11 JDminMinT12 JDmaxMeanT1
#> 1        224        260         301         322         352           1
#>   JDmaxMeanT2 JDmaxMeanT3 JDmaxMeanT4 JDmaxMeanT5 JDmaxMeanT6 JDmaxMeanT7
#> 1          48          76         117         150         151         202
#>   JDmaxMeanT8 JDmaxMeanT9 JDmaxMeanT10 JDmaxMeanT11 JDmaxMeanT12 JDmaxMaxTSp
#> 1         219         246          273          313          339         150
#>   JDminMinTSp JDmaxMeanTSp JDmaxMaxTSu JDminMinTSu JDmaxMeanTSu JDmaxMaxTFa
#> 1          61          150         202         224          202         246
#>   JDminMinTFa JDmaxMeanTFa JDmaxMaxTWi JDminMinTWi JDmaxMeanTWi JDM30MAMeanT
#> 1         322          246         339          38          339          198
#>   JDM30MAMaxT JDM30MADRT JDM21MAMeanT JDM21MAMaxT JDM21MADRT JDM14MAMeanT
#> 1         198        199          194         194        196          232
#>   JDM14MAMaxT JDM14MADRT JDM7MAMeanT JDM7MAMaxT JDM7MADRT JDM3MAMeanT
#> 1         197        195         230        201       196       219.5
#>   JDM3MAMaxT JDM3MADRT
#> 1        202       196
(ST.var  <- T_variability(sitedata)) # example in package doesn't work
#> Warning: numerical expression has 2 elements: only the first used
#> Warning: longer object length is not a multiple of shorter object length
#>   SiteInfo ADrange1 ADrange2 ADrange3 ADrange4 ADrange5 ADrange6 ADrange7
#> 1 01382310 0.883871 1.253571      2.1 2.366667 2.548387 2.853333 3.732258
#>   ADrange8 ADrange9 ADrange10 ADrange11 ADrange12 Rmean1 Rmean2 Rmean3 Rmean4
#> 1 2.716129 1.566667  1.780645  1.686667  1.374194    2.7    2.3    4.3    9.5
#>   Rmean5 Rmean6 Rmean7 Rmean8 Rmean9 Rmean10 Rmean11 Rmean12     CVDmax1
#> 1     10    7.7    4.8   11.2    6.1     9.6     3.7     5.6 0.003412039
#>       CVDmax2     CVDmax3    CVDmax4     CVDmax5     CVDmax6     CVDmax7
#> 1 0.003374441 0.004481093 0.01052133 0.009344021 0.007532948 0.004818057
#>       CVDmax8     CVDmax9   CVDmax10   CVDmax11    CVDmax12     CVDmin1
#> 1 0.008345638 0.005903455 0.00829473 0.00336615 0.005113964 0.002115504
#>       CVDmin2     CVDmin3     CVDmin4     CVDmin5     CVDmin6     CVDmin7
#> 1 0.002302309 0.003237424 0.009493291 0.009466815 0.008493875 0.004149277
#>       CVDmin8     CVDmin9    CVDmin10    CVDmin11    CVDmin12    CVDmean1
#> 1 0.009612627 0.006737451 0.009036975 0.003359177 0.005527881 0.002561632
#>     CVDmean2    CVDmean3    CVDmean4    CVDmean5    CVDmean6    CVDmean7
#> 1 0.00252351 0.003427647 0.009716645 0.009179103 0.008198479 0.004453308
#>     CVDmean8    CVDmean9   CVDmean10   CVDmean11   CVDmean12 RmaxSp RminSp
#> 1 0.00905868 0.006180587 0.008621446 0.003187786 0.005343299   21.2   19.8
#>   RmeanSp RmaxSu RminSu RmeanSu RmaxFa RminFa RmeanFa RmaxWi RminWi RmeanWi
#> 1    20.8   12.6   11.3    11.2   13.8   14.6    14.3    8.6    8.1     8.5
#>   Max30MovingADRT DiffExtreme6.30 Max21MovingADRT DiffExtreme5.21
#> 1            3.89            1.95        4.004762               0
#>   Max14MovingADRT DiffExtreme4.14 Max7MovingADRT DiffExtreme2.7 Max3MovingADRT
#> 1        4.371429             1.6       4.542857           0.55              5
#>   DiffExtreme1.3
#> 1              0
#
#~~~~~~~~~~~~~~~~~~~~~~
# Example 2, ContDataQC Summary Stats Data
#~~~~~~~~~~~~~~~~~~~~~~
# 2.1. Load ContDataQC file that has been processed with SummaryStats
myFile <- "DATA_test2_Aw_20130101_20141231.csv"
myData <- read.csv(file.path(path.package("ContDataQC"),"extdata",myFile)
                   , stringsAsFactors=FALSE)
# Subset
Col.Keep <- c("SiteID", "Date", "Water.Temp.C")
sitedata <- myData[,Col.Keep]
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sitedata <- Export.StreamThermal(myData)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 2.2. Run StreamThermal
require(StreamThermal)
#~~~~~
# StreamThermal
(ST.freq <- T_frequency(sitedata))
#>   SiteInfo FmaxcT1 FmaxcT2 FmaxcT3 FmaxcT4 FmaxcT5 FmaxcT6 FmaxcT7 FmaxcT8
#> 1    Test2     NaN     NaN     NaN     NaN      17      30      32      31
#>   FmaxcT9 FmaxcT10 FmaxcT11 FmaxcT12 FmincT1 FmincT2 FmincT3 FmincT4 FmincT5
#> 1      30      NaN      NaN      NaN     NaN     NaN     NaN     NaN       7
#>   FmincT6 FmincT7 FmincT8 FmincT9 FmincT10 FmincT11 FmincT12 FmeancT1 FmeancT2
#> 1      30      32      30      26      NaN      NaN      NaN      NaN      NaN
#>   FmeancT3 FmeancT4 FmeancT5 FmeancT6 FmeancT7 FmeancT8 FmeancT9 FmeancT10
#> 1      NaN      NaN       13       30       32       31       30       NaN
#>   FmeancT11 FmeancT12 FmaxcTsp FmincTsp FmeancTsp FmaxcTsu FmincTsu FmeancTsu
#> 1       NaN       NaN      NaN      NaN       NaN       93       92        93
#>   FmaxcTfa FmincTfa FmeancTfa FmaxcTwi FmincTwi FmeancTwi
#> 1      NaN      NaN       NaN      NaN      NaN       NaN
(ST.mag  <- T_magnitude(sitedata))
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#>   SiteInfo ADmax1 ADmax2 ADmax3 ADmax4   ADmax5  ADmax6   ADmax7   ADmax8
#> 1    Test2    NaN    NaN    NaN    NaN 16.63206 21.0987 21.19138 21.53984
#>     ADmax9 ADmax10 ADmax11 ADmax12 ADmin1 ADmin2 ADmin3 ADmin4   ADmin5
#> 1 20.02567     NaN     NaN     NaN    NaN    NaN    NaN    NaN 14.21474
#>     ADmin6   ADmin7   ADmin8   ADmin9 ADmin10 ADmin11 ADmin12 ADmean1 ADmean2
#> 1 18.80953 19.43972 19.36206 17.98767     NaN     NaN     NaN     NaN     NaN
#>   ADmean3 ADmean4  ADmean5  ADmean6  ADmean7  ADmean8  ADmean9 ADmean10
#> 1     NaN     NaN 15.38745 19.89716 20.28798 20.44721 18.84335      NaN
#>   ADmean11 ADmean12 MaxDmeanSp MinDmeanSp AvgDmeanSp MaxDmeanSu MinDmeanSu
#> 1      NaN      NaN        NaN        NaN        NaN   22.43556   18.06298
#>   AvgDmeanSu MaxDmeanFa MinDmeanFa AvgDmeanFa MaxDmeanWi MinDmeanWi AvgDmeanWi
#> 1   20.21498        NaN        NaN        NaN        NaN        NaN        NaN
#>   Max30MovingAMeanT Max30MovingAMaxT Max21MovingAMeanT Max21MovingAMaxT
#> 1          21.11725         22.15333          20.97687         22.03014
#>   Max14MovingAMeanT Max14MovingAMaxT Max7MovingAMeanT Max7MovingAMaxT
#> 1          21.23605         22.40393         21.86726          23.198
#>   Max3MovingAMeanT Max3MovingAMaxT
#> 1          22.2375        24.48967
(ST.roc  <- T_rateofchange(sitedata))
#>   SiteInfo RC1 RC2 RC3 RC4       RC5       RC6       RC7      RC8       RC9
#> 1    Test2 NaN NaN NaN NaN 0.4328067 0.1452781 0.3250758 1.093146 0.1784598
#>   RC10 RC11 RC12 RCsp     RCsu RCfa RCwi
#> 1  NaN  NaN  NaN  NaN 1.093146  NaN  NaN
(ST.tim  <- T_timing(sitedata))
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#>   SiteInfo JDmaxMaxT1 JDmaxMaxT2 JDmaxMaxT3 JDmaxMaxT4 JDmaxMaxT5 JDmaxMaxT6
#> 1    Test2        NaN        NaN        NaN        NaN        150        178
#>   JDmaxMaxT7 JDmaxMaxT8 JDmaxMaxT9 JDmaxMaxT10 JDmaxMaxT11 JDmaxMaxT12
#> 1        197        223        262         NaN         NaN         NaN
#>   JDminMinT1 JDminMinT2 JDminMinT3 JDminMinT4 JDminMinT5 JDminMinT6 JDminMinT7
#> 1        NaN        NaN        NaN        NaN        132        154        210
#>   JDminMinT8 JDminMinT9 JDminMinT10 JDminMinT11 JDminMinT12 JDmaxMeanT1
#> 1        226        265         NaN         NaN         NaN         NaN
#>   JDmaxMeanT2 JDmaxMeanT3 JDmaxMeanT4 JDmaxMeanT5 JDmaxMeanT6 JDmaxMeanT7
#> 1         NaN         NaN         NaN         150         178         198
#>   JDmaxMeanT8 JDmaxMeanT9 JDmaxMeanT10 JDmaxMeanT11 JDmaxMeanT12 JDmaxMaxTSp
#> 1         223         243          NaN          NaN          NaN         NaN
#>   JDminMinTSp JDmaxMeanTSp JDmaxMaxTSu JDminMinTSu JDmaxMeanTSu JDmaxMaxTFa
#> 1         NaN          NaN         223         226          223         NaN
#>   JDminMinTFa JDmaxMeanTFa JDmaxMaxTWi JDminMinTWi JDmaxMeanTWi JDM30MAMeanT
#> 1         NaN          NaN         NaN         NaN          NaN          209
#>   JDM30MAMaxT JDM30MADRT JDM21MAMeanT JDM21MAMaxT JDM21MADRT JDM14MAMeanT
#> 1         210        269          214         215        272          218
#>   JDM14MAMaxT JDM14MADRT JDM7MAMeanT JDM7MAMaxT JDM7MADRT JDM3MAMeanT
#> 1         219        278         221        222       283         222
#>   JDM3MAMaxT JDM3MADRT
#> 1        261       283
(ST.var  <- T_variability(sitedata))
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#> Warning: some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
#>   SiteInfo ADrange1 ADrange2 ADrange3 ADrange4 ADrange5 ADrange6 ADrange7
#> 1    Test2      NaN      NaN      NaN      NaN 2.417323 2.289167 1.751656
#>   ADrange8 ADrange9 ADrange10 ADrange11 ADrange12 Rmean1 Rmean2 Rmean3 Rmean4
#> 1 2.177774    2.038       NaN       NaN       NaN    NaN    NaN    NaN    NaN
#>     Rmean5   Rmean6   Rmean7   Rmean8   Rmean9 Rmean10 Rmean11 Rmean12 CVDmax1
#> 1 7.790521 2.905562 3.575833 4.372583 5.175333     NaN     NaN     NaN     NaN
#>   CVDmax2 CVDmax3 CVDmax4     CVDmax5     CVDmax6     CVDmax7     CVDmax8
#> 1     NaN     NaN     NaN 0.008014304 0.003303075 0.004120679 0.004063426
#>      CVDmax9 CVDmax10 CVDmax11 CVDmax12 CVDmin1 CVDmin2 CVDmin3 CVDmin4
#> 1 0.01108073      NaN      NaN      NaN     NaN     NaN     NaN     NaN
#>       CVDmin5     CVDmin6     CVDmin7     CVDmin8     CVDmin9 CVDmin10 CVDmin11
#> 1 0.007500157 0.003100429 0.003020969 0.004748352 0.005618307      NaN      NaN
#>   CVDmin12 CVDmean1 CVDmean2 CVDmean3 CVDmean4    CVDmean5    CVDmean6
#> 1      NaN      NaN      NaN      NaN      NaN 0.007422009 0.002948373
#>      CVDmean7    CVDmean8    CVDmean9 CVDmean10 CVDmean11 CVDmean12 RmaxSp
#> 1 0.003403629 0.003707559 0.005513046       NaN       NaN       NaN    NaN
#>   RminSp RmeanSp RmaxSu RminSu  RmeanSu RmaxFa RminFa RmeanFa RmaxWi RminWi
#> 1    NaN     NaN  6.129  6.095 4.372583    NaN    NaN     NaN    NaN    NaN
#>   RmeanWi Max30MovingADRT DiffExtreme6.30 Max21MovingADRT DiffExtreme5.21
#> 1     NaN        2.818533         1.82021        3.277714               0
#>   Max14MovingADRT DiffExtreme4.14 Max7MovingADRT DiffExtreme2.7 Max3MovingADRT
#> 1        3.204357        1.616734       5.034571     0.01802083       9.707667
#>   DiffExtreme1.3
#> 1              0


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Save Results to Excel (each group on its own worksheet)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
library(XLConnect)
# Descriptions
#
Desc.freq <- "Frequency metrics indicate numbers of days in months or seasons
that key events exceed user-defined temperatures. "
#
Desc.mag <- "Magnitude metrics characterize monthly and seasonal averages and
the maximum and minimum from daily temperatures as well as 3-, 7-, 14-, 21-,
and 30-day moving averages for mean and maximum daily temperatures."
#
Desc.roc <- "Rate of change metrics include monthly and seasonal rate of
change, which indicates the difference in magnitude of maximum and minimum
temperatures divided by number of days between these events."
#
Desc.tim <- "Timing metrics indicate Julian days of key events including
mean, maximum, and minimum temperatures; they also indicate Julian days of
mean, maximum, and minimum values over moving windows of specified size."
#
Desc.var <- "Variability metrics summarize monthly and seasonal range in
daily mean temperatures as well as monthly coefficient of variation of daily
mean, maximum, and minimum temperatures. Variability metrics also include
moving averages for daily ranges and moving variability in extreme
temperatures, calculated from differences in average high and low
temperatures over various time periods"
#
Group.Desc <- c(Desc.freq, Desc.mag, Desc.roc, Desc.tim, Desc.var)
df.Groups <- as.data.frame(cbind(c("freq","mag","roc","tim","var")
                           ,Group.Desc))
#
SiteID <- sitedata[1,1]
myDate <- format(Sys.Date(),"%Y%m%d")
myTime <- format(Sys.time(),"%H%M%S")
Notes.User <- Sys.getenv("USERNAME")
# Notes section (add min/max dates)
Notes.Names <- c("Dataset (SiteID)", "Analysis.Date (YYYYMMDD)"
                 , "Analysis.Time (HHMMSS)", "Analysis.User")
Notes.Data <- c(SiteID, myDate, myTime, Notes.User)
df.Notes <- as.data.frame(cbind(Notes.Names, Notes.Data))
Notes.Summary <- summary(sitedata)
# Open/Create file
## New File Name
myFile.XLSX <- paste("StreamThermal"
                     , SiteID
                     , myDate
                     , myTime
                     , "xlsx"
                     , sep=".")
## Copy over template with Metric Definitions
file.copy(file.path(path.package("ContDataQC")
                                 ,"extdata"
                                 ,"StreamThermal_MetricList.xlsx")
          , myFile.XLSX)
#> [1] TRUE
## load workbook, create if not existing
wb <- loadWorkbook(myFile.XLSX, create = TRUE)
# create sheets
createSheet(wb, name = "NOTES")
createSheet(wb, name = "freq")
createSheet(wb, name = "mag")
createSheet(wb, name = "roc")
createSheet(wb, name = "tim")
createSheet(wb, name = "var")
# write to worksheet
writeWorksheet(wb, df.Notes, sheet = "NOTES", startRow=1)
writeWorksheet(wb, df.Groups, sheet="NOTES", startRow=10)
#> Error: NoSuchMethodError (Java): org.apache.xmlbeans.XmlCursor.close()V
writeWorksheet(wb, Notes.Summary, sheet = "NOTES", startRow=20)
#> Error: NoSuchMethodError (Java): org.apache.xmlbeans.XmlCursor.close()V
writeWorksheet(wb, ST.freq, sheet = "freq")
writeWorksheet(wb, ST.mag, sheet = "mag")
writeWorksheet(wb, ST.roc, sheet = "roc")
writeWorksheet(wb, ST.tim, sheet = "tim")
writeWorksheet(wb, ST.var, sheet = "var")
# save workbook
saveWorkbook(wb, myFile.XLSX)