Read in IBWC Manta time series, 2023_02_24_to_2023_03_08_ibwc_5259_direct_download.csv, calibration logs, back-calibrate RV values, and recalculate TRYP and CDOM values from the RV values and a “stable” calibration based on long-term mean RV-TYRP values for the IBWC sonde (SN 5259).

Field names are different between wqdatalive and direct download.

Read in Manta data

##             Date.time Temp_deg_C pH_units ORP_mV Depth_m SpCond_uS.cm Turb_FNU
## 1 2023-02-24 09:00:00      11.29     7.98 -265.4       0         2823    195.5
## 2 2023-02-24 09:05:00      11.32     7.97 -242.5       0         2825    178.2
## 3 2023-02-24 09:10:00      11.41     7.96 -257.9       0         2823    145.7
## 4 2023-02-24 09:15:00      11.49     7.95 -278.6       0         2823    163.9
## 5 2023-02-24 09:20:00      11.62     7.95 -282.2       0         2822    140.1
## 6 2023-02-24 09:25:00      11.76     7.95 -257.8       0         2822    128.4
##   HDO_.Sat HDO_mg.l CDOM_ppb TRYP_ppb pH_mV
## 1     67.6     7.09    46.68    53.83 -65.9
## 2     50.1     5.24    51.92    60.19 -65.6
## 3     45.0     4.70    53.77    66.67 -65.0
## 4     41.9     4.37    58.26    64.86 -64.4
## 5     40.6     4.22    57.55    68.36 -64.2
## 6     38.7     4.01    56.09    68.64 -64.2
## [1] "2023-02-24 09:00:00 PST" "2023-03-08 09:10:00 PST"

Plot time series for QAQC

Plot conductivity (identifies when sonde is dry)

Plot regular time series of turb, cond, tryp, cdom, no flags applied

Zoom into the sampling period

Load in QAQC notes

Make sure it worked by plotting resulting time series on top of original

Read in cal logs

Plot time series with calibration dates on top. Note: for Feb 24 - March 8, most recent cal was 2023-02-08, and next was 2023-04-014, both are outside of the plot window.

Find which calibration dates overlap the monitored time period….separately for each back-calibrated parameter since not every parameter is calibrated every time.

Plot all time series together, with calibration dates in purple to check for discontinuities Discontinuities could be due to cleaning, so not alwasy a problem.

## [1] "More than 2 calibration points for TRYP"

##         manta                date sensor serial_no units          rv   old new
## 24 MT12215259 2023-02-08 11:05:33   TRYP  12215259   ppb 0.016197590 16.90 100
## 25 MT12215259 2023-02-08 11:24:05   TRYP  12215259   ppb 0.015042900 90.00 100
## 26 MT12215259 2023-02-08 11:26:20   TRYP  12215259   ppb 0.004701376 11.06   0
##    srf   comment           Date.time       Date
## 24 100 Done/Quit 2023-02-08 11:05:33 2023-02-08
## 25 100           2023-02-08 11:24:05 2023-02-08
## 26 100     Done* 2023-02-08 11:26:20 2023-02-08

Plot original and RV values. If there’s only one calibration period, the red and green series will overlap perfectly. Note that the red time series, which is in the final output, excludes the data from the QAQC flagged times.

Zoom into the sampled time period

## [1] "No zero point in the calibration.  Assuming RV value at new calibration value is long-term min RV"

##         manta                date sensor serial_no units       rv    old new
## 21 MT12215259 2022-11-30 10:44:39   CDOM  12215259   ppb 1.717417 303.53 300
##    srf comment           Date.time       Date
## 21 100    Done 2022-11-30 10:44:39 2022-11-30

##         manta                date sensor serial_no units         rv   old new
## 22 MT12215259 2022-12-01 13:14:46   TURB      1901   NTU 0.09248231 55.20 100
## 23 MT12215259 2022-12-01 13:16:38   TURB      1901   NTU 0.02240163 -1.22   0
##    srf comment           Date.time       Date
## 22 N/A         2022-12-01 13:14:46 2022-12-01
## 23 174   Done* 2022-12-01 13:16:38 2022-12-01
## Warning in xy.coords(x, y, xlabel, ylabel, log): 14 y values <= 0 omitted from
## logarithmic plot

Apply standard calibration to TRYP, CDOM, TURB TRYP: RV = 0.004 (0 ppb), RV = 0.016 @ 100ppb

Plot original and recalibrated TRYP and CDOM. For TRYP (2023-02-24 to 2023-03-08), difference is largest close to zero since the zero value was different in the cal log compared with the long-term average (“standard calibration”)

Zoom in on Storm Event.

Add flags

## [1] "More than one column in dataset matches the QAQC parameter name."

Write to a new file