generated from jtr13/quarto-edav-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathch11_a.html
1136 lines (1111 loc) · 85.1 KB
/
ch11_a.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.4.553">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>ch11_a_v4</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
/* CSS for syntax highlighting */
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
</style>
<script src="ch11_a_v4_files/libs/clipboard/clipboard.min.js"></script>
<script src="ch11_a_v4_files/libs/quarto-html/quarto.js"></script>
<script src="ch11_a_v4_files/libs/quarto-html/popper.min.js"></script>
<script src="ch11_a_v4_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="ch11_a_v4_files/libs/quarto-html/anchor.min.js"></script>
<link href="ch11_a_v4_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="ch11_a_v4_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="ch11_a_v4_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="ch11_a_v4_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="ch11_a_v4_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
<script src="ch11_a_v4_files/libs/kePrint-0.0.1/kePrint.js"></script>
<link href="ch11_a_v4_files/libs/lightable-0.0.1/lightable.css" rel="stylesheet">
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js" type="text/javascript"></script>
<script type="text/javascript">
const typesetMath = (el) => {
if (window.MathJax) {
// MathJax Typeset
window.MathJax.typeset([el]);
} else if (window.katex) {
// KaTeX Render
var mathElements = el.getElementsByClassName("math");
var macros = [];
for (var i = 0; i < mathElements.length; i++) {
var texText = mathElements[i].firstChild;
if (mathElements[i].tagName == "SPAN") {
window.katex.render(texText.data, mathElements[i], {
displayMode: mathElements[i].classList.contains('display'),
throwOnError: false,
macros: macros,
fleqn: false
});
}
}
}
}
window.Quarto = {
typesetMath
};
</script>
</head>
<body class="fullcontent">
<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<main class="content quarto-banner-title-block" id="quarto-document-content">
<section id="field-soil-water-balance" class="level2">
<h2 class="anchored" data-anchor-id="field-soil-water-balance">Field Soil Water Balance</h2>
<p>We will develop a 2-layer simple soil water balance modeling for simulating 1-D fluxes in the rootzone using USCRN station at Stillwater, OK, USA as an example. Let us extract sample data from the sample station for 2021.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Yearly data from the sample station</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>CRNdat <span class="ot">=</span> <span class="fu">read.csv</span>(<span class="fu">url</span>(<span class="st">"https://www.ncei.noaa.gov/pub/data/uscrn/products/daily01/2021/CRND0103-2021-OK_Stillwater_2_W.txt"</span>), <span class="at">header=</span><span class="cn">FALSE</span>,<span class="at">sep=</span><span class="st">""</span>)</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Data headers</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a>headers<span class="ot">=</span><span class="fu">read.csv</span>(<span class="fu">url</span>(<span class="st">"https://www.ncei.noaa.gov/pub/data/uscrn/products/daily01/headers.txt"</span>), <span class="at">header=</span><span class="cn">FALSE</span>,<span class="at">sep=</span><span class="st">""</span>)</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="co"># Column names as headers from the text file</span></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="fu">colnames</span>(CRNdat)<span class="ot">=</span>headers[<span class="dv">2</span>,<span class="dv">1</span><span class="sc">:</span><span class="fu">ncol</span>(CRNdat)]</span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="co"># Replace fill values with NA</span></span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a>CRNdat[CRNdat <span class="sc">==</span> <span class="sc">-</span><span class="dv">9999</span>]<span class="ot">=</span><span class="cn">NA</span></span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a>CRNdat[CRNdat <span class="sc">==</span> <span class="sc">-</span><span class="dv">99</span>]<span class="ot">=</span><span class="cn">NA</span></span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a>CRNdat[CRNdat <span class="sc">==</span> <span class="dv">999</span>]<span class="ot">=</span><span class="cn">NA</span></span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a><span class="co"># View data sample</span></span>
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(kableExtra)</span>
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a>dataTable <span class="ot">=</span> <span class="fu">kbl</span>(<span class="fu">head</span>(CRNdat,<span class="dv">6</span>),<span class="at">full_width =</span> F)</span>
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a><span class="fu">kable_styling</span>(dataTable,<span class="at">bootstrap_options =</span> <span class="fu">c</span>(<span class="st">"striped"</span>, <span class="st">"hover"</span>, <span class="st">"condensed"</span>, <span class="st">"responsive"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<div class="table-responsive">
<table class="table table-striped table-hover table-condensed table-sm small" data-quarto-postprocess="true">
<thead>
<tr class="header">
<th style="text-align: right;" data-quarto-table-cell-role="th">WBANNO</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">LST_DATE</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">CRX_VN</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">LONGITUDE</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">LATITUDE</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">T_DAILY_MAX</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">T_DAILY_MIN</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">T_DAILY_MEAN</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">T_DAILY_AVG</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">P_DAILY_CALC</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SOLARAD_DAILY</th>
<th style="text-align: left;" data-quarto-table-cell-role="th">SUR_TEMP_DAILY_TYPE</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SUR_TEMP_DAILY_MAX</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SUR_TEMP_DAILY_MIN</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SUR_TEMP_DAILY_AVG</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">RH_DAILY_MAX</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">RH_DAILY_MIN</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">RH_DAILY_AVG</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SOIL_MOISTURE_5_DAILY</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SOIL_MOISTURE_10_DAILY</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SOIL_MOISTURE_20_DAILY</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SOIL_MOISTURE_50_DAILY</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SOIL_MOISTURE_100_DAILY</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SOIL_TEMP_5_DAILY</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SOIL_TEMP_10_DAILY</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SOIL_TEMP_20_DAILY</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SOIL_TEMP_50_DAILY</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SOIL_TEMP_100_DAILY</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">53926</td>
<td style="text-align: right;">20210101</td>
<td style="text-align: right;">2.622</td>
<td style="text-align: right;">-97.09</td>
<td style="text-align: right;">36.12</td>
<td style="text-align: right;">2.1</td>
<td style="text-align: right;">0.2</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: right;">0.8</td>
<td style="text-align: right;">23.0</td>
<td style="text-align: right;">3.51</td>
<td style="text-align: left;">C</td>
<td style="text-align: right;">1.0</td>
<td style="text-align: right;">-0.3</td>
<td style="text-align: right;">0.3</td>
<td style="text-align: right;">93.1</td>
<td style="text-align: right;">70.1</td>
<td style="text-align: right;">86.2</td>
<td style="text-align: right;">0.474</td>
<td style="text-align: right;">0.440</td>
<td style="text-align: right;">0.458</td>
<td style="text-align: right;">0.450</td>
<td style="text-align: right;">0.429</td>
<td style="text-align: right;">3.9</td>
<td style="text-align: right;">4.2</td>
<td style="text-align: right;">5.4</td>
<td style="text-align: right;">8.3</td>
<td style="text-align: right;">9.9</td>
</tr>
<tr class="even">
<td style="text-align: right;">53926</td>
<td style="text-align: right;">20210102</td>
<td style="text-align: right;">2.622</td>
<td style="text-align: right;">-97.09</td>
<td style="text-align: right;">36.12</td>
<td style="text-align: right;">6.9</td>
<td style="text-align: right;">-2.5</td>
<td style="text-align: right;">2.2</td>
<td style="text-align: right;">1.8</td>
<td style="text-align: right;">0.0</td>
<td style="text-align: right;">7.02</td>
<td style="text-align: left;">C</td>
<td style="text-align: right;">9.9</td>
<td style="text-align: right;">-4.7</td>
<td style="text-align: right;">1.1</td>
<td style="text-align: right;">94.2</td>
<td style="text-align: right;">57.3</td>
<td style="text-align: right;">78.7</td>
<td style="text-align: right;">0.466</td>
<td style="text-align: right;">0.443</td>
<td style="text-align: right;">0.459</td>
<td style="text-align: right;">0.448</td>
<td style="text-align: right;">0.432</td>
<td style="text-align: right;">4.6</td>
<td style="text-align: right;">4.7</td>
<td style="text-align: right;">5.5</td>
<td style="text-align: right;">8.0</td>
<td style="text-align: right;">9.6</td>
</tr>
<tr class="odd">
<td style="text-align: right;">53926</td>
<td style="text-align: right;">20210103</td>
<td style="text-align: right;">2.622</td>
<td style="text-align: right;">-97.09</td>
<td style="text-align: right;">36.12</td>
<td style="text-align: right;">9.1</td>
<td style="text-align: right;">-3.7</td>
<td style="text-align: right;">2.7</td>
<td style="text-align: right;">1.3</td>
<td style="text-align: right;">0.0</td>
<td style="text-align: right;">10.56</td>
<td style="text-align: left;">C</td>
<td style="text-align: right;">12.9</td>
<td style="text-align: right;">-6.2</td>
<td style="text-align: right;">-0.2</td>
<td style="text-align: right;">94.2</td>
<td style="text-align: right;">56.4</td>
<td style="text-align: right;">83.5</td>
<td style="text-align: right;">0.436</td>
<td style="text-align: right;">0.440</td>
<td style="text-align: right;">0.460</td>
<td style="text-align: right;">0.449</td>
<td style="text-align: right;">0.429</td>
<td style="text-align: right;">4.2</td>
<td style="text-align: right;">4.7</td>
<td style="text-align: right;">5.5</td>
<td style="text-align: right;">7.8</td>
<td style="text-align: right;">9.4</td>
</tr>
<tr class="even">
<td style="text-align: right;">53926</td>
<td style="text-align: right;">20210104</td>
<td style="text-align: right;">2.622</td>
<td style="text-align: right;">-97.09</td>
<td style="text-align: right;">36.12</td>
<td style="text-align: right;">14.7</td>
<td style="text-align: right;">-3.2</td>
<td style="text-align: right;">5.7</td>
<td style="text-align: right;">4.3</td>
<td style="text-align: right;">0.0</td>
<td style="text-align: right;">11.13</td>
<td style="text-align: left;">C</td>
<td style="text-align: right;">16.8</td>
<td style="text-align: right;">-6.0</td>
<td style="text-align: right;">2.0</td>
<td style="text-align: right;">94.0</td>
<td style="text-align: right;">46.2</td>
<td style="text-align: right;">76.4</td>
<td style="text-align: right;">0.423</td>
<td style="text-align: right;">0.428</td>
<td style="text-align: right;">0.461</td>
<td style="text-align: right;">0.450</td>
<td style="text-align: right;">0.430</td>
<td style="text-align: right;">4.6</td>
<td style="text-align: right;">5.0</td>
<td style="text-align: right;">5.6</td>
<td style="text-align: right;">7.6</td>
<td style="text-align: right;">9.2</td>
</tr>
<tr class="odd">
<td style="text-align: right;">53926</td>
<td style="text-align: right;">20210105</td>
<td style="text-align: right;">2.622</td>
<td style="text-align: right;">-97.09</td>
<td style="text-align: right;">36.12</td>
<td style="text-align: right;">16.2</td>
<td style="text-align: right;">-3.6</td>
<td style="text-align: right;">6.3</td>
<td style="text-align: right;">6.2</td>
<td style="text-align: right;">0.0</td>
<td style="text-align: right;">9.99</td>
<td style="text-align: left;">C</td>
<td style="text-align: right;">17.9</td>
<td style="text-align: right;">-6.5</td>
<td style="text-align: right;">3.9</td>
<td style="text-align: right;">94.0</td>
<td style="text-align: right;">22.0</td>
<td style="text-align: right;">59.5</td>
<td style="text-align: right;">0.412</td>
<td style="text-align: right;">0.417</td>
<td style="text-align: right;">0.463</td>
<td style="text-align: right;">0.453</td>
<td style="text-align: right;">0.431</td>
<td style="text-align: right;">4.8</td>
<td style="text-align: right;">5.2</td>
<td style="text-align: right;">5.7</td>
<td style="text-align: right;">7.6</td>
<td style="text-align: right;">9.1</td>
</tr>
<tr class="even">
<td style="text-align: right;">53926</td>
<td style="text-align: right;">20210106</td>
<td style="text-align: right;">2.622</td>
<td style="text-align: right;">-97.09</td>
<td style="text-align: right;">36.12</td>
<td style="text-align: right;">9.6</td>
<td style="text-align: right;">4.8</td>
<td style="text-align: right;">7.2</td>
<td style="text-align: right;">7.5</td>
<td style="text-align: right;">0.3</td>
<td style="text-align: right;">1.03</td>
<td style="text-align: left;">C</td>
<td style="text-align: right;">11.4</td>
<td style="text-align: right;">4.3</td>
<td style="text-align: right;">7.1</td>
<td style="text-align: right;">92.1</td>
<td style="text-align: right;">45.8</td>
<td style="text-align: right;">66.7</td>
<td style="text-align: right;">0.395</td>
<td style="text-align: right;">0.412</td>
<td style="text-align: right;">0.459</td>
<td style="text-align: right;">0.450</td>
<td style="text-align: right;">0.431</td>
<td style="text-align: right;">6.2</td>
<td style="text-align: right;">6.1</td>
<td style="text-align: right;">6.2</td>
<td style="text-align: right;">7.6</td>
<td style="text-align: right;">9.1</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<section id="exploratory-data-analysis-for-the-sample-station" class="level3">
<h3 class="anchored" data-anchor-id="exploratory-data-analysis-for-the-sample-station">Exploratory Data Analysis for the Sample Station</h3>
<div class="cell">
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="co"># Create Date array for the station</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">library</span>(zoo)</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">library</span>(cowplot)</span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">library</span>(ggplot2)</span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a> <span class="co"># Time (in days)</span></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a> datetime<span class="ot">=</span><span class="fu">as.Date</span>(<span class="fu">as.character</span>(CRNdat<span class="sc">$</span>LST_DATE), <span class="at">format=</span> <span class="st">"%Y%m%d"</span>)</span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a> <span class="co"># Surface soil moisture (in m3/m3)</span></span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a> SSM<span class="ot">=</span><span class="fu">na.approx</span>(CRNdat<span class="sc">$</span>SOIL_MOISTURE_5_DAILY,<span class="at">na.rm =</span> <span class="cn">FALSE</span>) </span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a> <span class="co"># Soil moisture at 50 cm depth (in m3/m3)</span></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a> SM50<span class="ot">=</span><span class="fu">na.approx</span>(CRNdat<span class="sc">$</span>SOIL_MOISTURE_50_DAILY,<span class="at">na.rm =</span> <span class="cn">FALSE</span>) </span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a> <span class="co"># Precipitation (in mm)</span></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a> PCP<span class="ot">=</span>CRNdat<span class="sc">$</span>P_DAILY_CALC </span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a> PCP[PCP<span class="sc"><</span><span class="dv">0</span>]<span class="ot">=</span><span class="dv">0</span> <span class="co"># Negative (flagged values are replaced by 0)</span></span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a> PCP[<span class="fu">is.na</span>(PCP)]<span class="ot">=</span><span class="dv">0</span> <span class="co"># NA values are replaced by 0)</span></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a> <span class="co"># Create a data frame of SM-PCP dataset for plotting</span></span>
<span id="cb2-20"><a href="#cb2-20" aria-hidden="true" tabindex="-1"></a> df<span class="ot">=</span><span class="fu">data.frame</span>(<span class="at">Date=</span>datetime, <span class="at">PCP=</span>PCP, <span class="at">SSM=</span>SSM, <span class="at">SM50=</span>SM50)</span>
<span id="cb2-21"><a href="#cb2-21" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-22"><a href="#cb2-22" aria-hidden="true" tabindex="-1"></a> <span class="co"># Plot for surface soil moisture </span></span>
<span id="cb2-23"><a href="#cb2-23" aria-hidden="true" tabindex="-1"></a> p1 <span class="ot">=</span> <span class="fu">ggplot</span>(df) <span class="sc">+</span></span>
<span id="cb2-24"><a href="#cb2-24" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_line</span>(<span class="fu">aes</span>(Date, SSM, <span class="at">color =</span> <span class="st">"SSM"</span>)) <span class="sc">+</span></span>
<span id="cb2-25"><a href="#cb2-25" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_line</span>(<span class="fu">aes</span>(Date, SM50, <span class="at">color =</span> <span class="st">"SM50"</span>)) <span class="sc">+</span></span>
<span id="cb2-26"><a href="#cb2-26" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_y_continuous</span>(<span class="at">position =</span> <span class="st">"left"</span>,</span>
<span id="cb2-27"><a href="#cb2-27" aria-hidden="true" tabindex="-1"></a> <span class="at">limits =</span> <span class="fu">c</span>(<span class="fl">0.05</span>,<span class="fl">0.475</span>),</span>
<span id="cb2-28"><a href="#cb2-28" aria-hidden="true" tabindex="-1"></a> <span class="at">expand =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">0</span>)) <span class="sc">+</span></span>
<span id="cb2-29"><a href="#cb2-29" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_color_manual</span>(<span class="at">values =</span> <span class="fu">c</span>(<span class="st">"steelblue"</span>, <span class="st">"cyan4"</span>)) <span class="sc">+</span></span>
<span id="cb2-30"><a href="#cb2-30" aria-hidden="true" tabindex="-1"></a> <span class="fu">guides</span>(<span class="at">x =</span> <span class="fu">guide_axis</span>(<span class="at">angle =</span> <span class="dv">90</span>)) <span class="sc">+</span></span>
<span id="cb2-31"><a href="#cb2-31" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_x_date</span>(<span class="at">date_breaks =</span> <span class="st">"month"</span>,</span>
<span id="cb2-32"><a href="#cb2-32" aria-hidden="true" tabindex="-1"></a> <span class="at">limits =</span> <span class="fu">c</span>(datetime[<span class="dv">1</span>], </span>
<span id="cb2-33"><a href="#cb2-33" aria-hidden="true" tabindex="-1"></a> datetime[<span class="dv">365</span>]),</span>
<span id="cb2-34"><a href="#cb2-34" aria-hidden="true" tabindex="-1"></a> <span class="at">expand =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">0</span>)) <span class="sc">+</span></span>
<span id="cb2-35"><a href="#cb2-35" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">y =</span> <span class="st">"Soil moisture [v/v]"</span>,</span>
<span id="cb2-36"><a href="#cb2-36" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="st">"Date"</span>) <span class="sc">+</span></span>
<span id="cb2-37"><a href="#cb2-37" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_minimal</span>() <span class="sc">+</span></span>
<span id="cb2-38"><a href="#cb2-38" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">axis.title.y.left =</span> <span class="fu">element_text</span>(<span class="at">hjust =</span> <span class="dv">0</span>),</span>
<span id="cb2-39"><a href="#cb2-39" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.position =</span> <span class="st">"bottom"</span>,</span>
<span id="cb2-40"><a href="#cb2-40" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.justification =</span> <span class="fu">c</span>(<span class="fl">0.1</span>, <span class="fl">0.5</span>),</span>
<span id="cb2-41"><a href="#cb2-41" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.title =</span> <span class="fu">element_blank</span>())</span>
<span id="cb2-42"><a href="#cb2-42" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-43"><a href="#cb2-43" aria-hidden="true" tabindex="-1"></a> <span class="co"># Plot for precipitation </span></span>
<span id="cb2-44"><a href="#cb2-44" aria-hidden="true" tabindex="-1"></a> p2<span class="ot">=</span> <span class="fu">ggplot</span>(df) <span class="sc">+</span></span>
<span id="cb2-45"><a href="#cb2-45" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_col</span>(<span class="fu">aes</span>(Date, PCP, <span class="at">fill =</span> <span class="st">"Total Daily Precipitation"</span>)) <span class="sc">+</span></span>
<span id="cb2-46"><a href="#cb2-46" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_y_reverse</span>(<span class="at">position =</span> <span class="st">"right"</span>,</span>
<span id="cb2-47"><a href="#cb2-47" aria-hidden="true" tabindex="-1"></a> <span class="at">limits =</span> <span class="fu">c</span>(<span class="dv">100</span>,<span class="dv">0</span>),</span>
<span id="cb2-48"><a href="#cb2-48" aria-hidden="true" tabindex="-1"></a> <span class="at">breaks =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">50</span>,<span class="dv">100</span>),</span>
<span id="cb2-49"><a href="#cb2-49" aria-hidden="true" tabindex="-1"></a> <span class="at">labels =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">50</span>,<span class="dv">100</span>),</span>
<span id="cb2-50"><a href="#cb2-50" aria-hidden="true" tabindex="-1"></a> <span class="at">expand =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">0</span>)) <span class="sc">+</span></span>
<span id="cb2-51"><a href="#cb2-51" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_x_date</span>(<span class="at">date_breaks =</span> <span class="st">"month"</span>,</span>
<span id="cb2-52"><a href="#cb2-52" aria-hidden="true" tabindex="-1"></a> <span class="at">limits =</span> <span class="fu">c</span>(datetime[<span class="dv">1</span>], datetime[<span class="dv">365</span>]),</span>
<span id="cb2-53"><a href="#cb2-53" aria-hidden="true" tabindex="-1"></a> <span class="at">expand =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">0</span>)) <span class="sc">+</span></span>
<span id="cb2-54"><a href="#cb2-54" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_fill_manual</span>(<span class="at">values =</span> <span class="fu">c</span>(<span class="st">"sienna1"</span>)) <span class="sc">+</span></span>
<span id="cb2-55"><a href="#cb2-55" aria-hidden="true" tabindex="-1"></a> <span class="fu">guides</span>(<span class="at">x =</span> <span class="fu">guide_axis</span>(<span class="at">angle =</span> <span class="dv">90</span>)) <span class="sc">+</span></span>
<span id="cb2-56"><a href="#cb2-56" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">y =</span> <span class="st">"Precipitation [mm]"</span>, <span class="at">x =</span> <span class="st">""</span>) <span class="sc">+</span></span>
<span id="cb2-57"><a href="#cb2-57" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_minimal</span>() <span class="sc">+</span></span>
<span id="cb2-58"><a href="#cb2-58" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">axis.title.y.right =</span> <span class="fu">element_text</span>(<span class="at">hjust =</span> <span class="dv">0</span>),</span>
<span id="cb2-59"><a href="#cb2-59" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.position =</span> <span class="st">"bottom"</span>,</span>
<span id="cb2-60"><a href="#cb2-60" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.justification =</span> <span class="fu">c</span>(<span class="fl">0.75</span>, <span class="fl">0.5</span>),</span>
<span id="cb2-61"><a href="#cb2-61" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.title =</span> <span class="fu">element_blank</span>())</span>
<span id="cb2-62"><a href="#cb2-62" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-63"><a href="#cb2-63" aria-hidden="true" tabindex="-1"></a>aligned_plots <span class="ot">=</span> cowplot<span class="sc">::</span><span class="fu">align_plots</span>(p1, p2, <span class="at">align =</span> <span class="st">"hv"</span>, <span class="at">axis =</span> <span class="st">"tblr"</span>)</span>
<span id="cb2-64"><a href="#cb2-64" aria-hidden="true" tabindex="-1"></a>p3<span class="ot">=</span><span class="fu">ggdraw</span>(aligned_plots[[<span class="dv">1</span>]]) <span class="sc">+</span> <span class="fu">draw_plot</span>(aligned_plots[[<span class="dv">2</span>]])</span>
<span id="cb2-65"><a href="#cb2-65" aria-hidden="true" tabindex="-1"></a><span class="fu">print</span>(p3)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="ch11_a_v4_files/figure-html/11a2-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</section>
</section>
<section id="low-pass-filtering-of-meteorological-perturbations-through-soil-profile" class="level2">
<h2 class="anchored" data-anchor-id="low-pass-filtering-of-meteorological-perturbations-through-soil-profile">Low-pass Filtering of Meteorological Perturbations Through Soil Profile</h2>
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Profile depth versus soil temperature</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>Tempdf<span class="ot">=</span><span class="fu">data.frame</span>(<span class="at">T5=</span><span class="fu">na.approx</span>(CRNdat<span class="sc">$</span>SOIL_TEMP_5_DAILY,<span class="at">na.rm =</span> <span class="cn">FALSE</span>), </span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="at">T10=</span><span class="fu">na.approx</span>(CRNdat<span class="sc">$</span>SOIL_TEMP_10_DAILY,<span class="at">na.rm =</span> <span class="cn">FALSE</span>), </span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="at">T20=</span><span class="fu">na.approx</span>(CRNdat<span class="sc">$</span>SOIL_TEMP_20_DAILY,<span class="at">na.rm =</span> <span class="cn">FALSE</span>), </span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="at">T50=</span><span class="fu">na.approx</span>(CRNdat<span class="sc">$</span>SOIL_TEMP_50_DAILY,<span class="at">na.rm =</span> <span class="cn">FALSE</span>),</span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> <span class="at">T100=</span><span class="fu">na.approx</span>(CRNdat<span class="sc">$</span>SOIL_TEMP_100_DAILY,<span class="at">na.rm =</span> <span class="cn">FALSE</span>))</span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a>df<span class="ot">=</span><span class="fu">rbind</span>(<span class="fu">data.frame</span>(<span class="at">Temp=</span>Tempdf<span class="sc">$</span>T5, <span class="at">Depth=</span><span class="dv">5</span>,<span class="at">Date=</span> datetime),</span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a><span class="fu">data.frame</span>(<span class="at">Temp=</span>Tempdf<span class="sc">$</span>T10, <span class="at">Depth=</span><span class="dv">10</span>, <span class="at">Date=</span>datetime),</span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a><span class="fu">data.frame</span>(<span class="at">Temp=</span>Tempdf<span class="sc">$</span>T20, <span class="at">Depth=</span><span class="dv">20</span>,<span class="at">Date=</span> datetime),</span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a><span class="fu">data.frame</span>(<span class="at">Temp=</span>Tempdf<span class="sc">$</span>T50, <span class="at">Depth=</span><span class="dv">50</span>,<span class="at">Date=</span>datetime),</span>
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a><span class="fu">data.frame</span>(<span class="at">Temp=</span>Tempdf<span class="sc">$</span>T100, <span class="at">Depth=</span><span class="dv">100</span>, <span class="at">Date=</span>datetime))</span>
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-14"><a href="#cb3-14" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(df, <span class="fu">aes</span>(<span class="at">x =</span> Date, <span class="at">y =</span> Depth)) <span class="sc">+</span></span>
<span id="cb3-15"><a href="#cb3-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_contour_filled</span>(<span class="fu">aes</span>(<span class="at">z =</span> Temp), <span class="at">bins =</span> <span class="dv">6</span>, <span class="at">stat =</span> <span class="st">"contour_filled"</span>) <span class="sc">+</span></span>
<span id="cb3-16"><a href="#cb3-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_fill_brewer</span>(<span class="at">palette =</span> <span class="st">"YlOrRd"</span>,<span class="at">direction =</span> <span class="dv">1</span>) <span class="sc">+</span></span>
<span id="cb3-17"><a href="#cb3-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">x =</span> <span class="st">"Date"</span>, <span class="at">y =</span> <span class="st">"Depth (cm)"</span>, <span class="at">fill =</span> <span class="st">"Temperature (°C)"</span>) <span class="sc">+</span></span>
<span id="cb3-18"><a href="#cb3-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_minimal</span>() <span class="sc">+</span> </span>
<span id="cb3-19"><a href="#cb3-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_y_reverse</span>()</span>
<span id="cb3-20"><a href="#cb3-20" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-21"><a href="#cb3-21" aria-hidden="true" tabindex="-1"></a><span class="co"># Profile depth versus soil moisture</span></span>
<span id="cb3-22"><a href="#cb3-22" aria-hidden="true" tabindex="-1"></a>SMpdf<span class="ot">=</span><span class="fu">data.frame</span>(<span class="at">SM5=</span><span class="fu">na.approx</span>(CRNdat<span class="sc">$</span>SOIL_MOISTURE_5_DAILY,<span class="at">na.rm =</span> <span class="cn">FALSE</span>), </span>
<span id="cb3-23"><a href="#cb3-23" aria-hidden="true" tabindex="-1"></a> <span class="at">SM10=</span><span class="fu">na.approx</span>(CRNdat<span class="sc">$</span>SOIL_MOISTURE_10_DAILY,<span class="at">na.rm =</span> <span class="cn">FALSE</span>), </span>
<span id="cb3-24"><a href="#cb3-24" aria-hidden="true" tabindex="-1"></a> <span class="at">SM20=</span><span class="fu">na.approx</span>(CRNdat<span class="sc">$</span>SOIL_MOISTURE_20_DAILY,<span class="at">na.rm =</span> <span class="cn">FALSE</span>), </span>
<span id="cb3-25"><a href="#cb3-25" aria-hidden="true" tabindex="-1"></a> <span class="at">SM50=</span><span class="fu">na.approx</span>(CRNdat<span class="sc">$</span>SOIL_MOISTURE_50_DAILY,<span class="at">na.rm =</span> <span class="cn">FALSE</span>),</span>
<span id="cb3-26"><a href="#cb3-26" aria-hidden="true" tabindex="-1"></a> <span class="at">SM100=</span><span class="fu">na.approx</span>(CRNdat<span class="sc">$</span>SOIL_MOISTURE_100_DAILY,<span class="at">na.rm =</span> <span class="cn">FALSE</span>))</span>
<span id="cb3-27"><a href="#cb3-27" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-28"><a href="#cb3-28" aria-hidden="true" tabindex="-1"></a>df<span class="ot">=</span><span class="fu">rbind</span>(<span class="fu">data.frame</span>(<span class="at">SM=</span>SMpdf<span class="sc">$</span>SM5, <span class="at">Depth=</span><span class="dv">5</span>,<span class="at">Date=</span> datetime),</span>
<span id="cb3-29"><a href="#cb3-29" aria-hidden="true" tabindex="-1"></a><span class="fu">data.frame</span>(<span class="at">SM=</span>SMpdf<span class="sc">$</span>SM10, <span class="at">Depth=</span><span class="dv">10</span>, <span class="at">Date=</span>datetime),</span>
<span id="cb3-30"><a href="#cb3-30" aria-hidden="true" tabindex="-1"></a><span class="fu">data.frame</span>(<span class="at">SM=</span>SMpdf<span class="sc">$</span>SM20, <span class="at">Depth=</span><span class="dv">20</span>,<span class="at">Date=</span> datetime),</span>
<span id="cb3-31"><a href="#cb3-31" aria-hidden="true" tabindex="-1"></a><span class="fu">data.frame</span>(<span class="at">SM=</span>SMpdf<span class="sc">$</span>SM50, <span class="at">Depth=</span><span class="dv">50</span>,<span class="at">Date=</span>datetime),</span>
<span id="cb3-32"><a href="#cb3-32" aria-hidden="true" tabindex="-1"></a><span class="fu">data.frame</span>(<span class="at">SM=</span>SMpdf<span class="sc">$</span>SM100, <span class="at">Depth=</span><span class="dv">100</span>, <span class="at">Date=</span>datetime))</span>
<span id="cb3-33"><a href="#cb3-33" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-34"><a href="#cb3-34" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(df, <span class="fu">aes</span>(<span class="at">x =</span> Date, <span class="at">y =</span> Depth)) <span class="sc">+</span></span>
<span id="cb3-35"><a href="#cb3-35" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_contour_filled</span>(<span class="fu">aes</span>(<span class="at">z =</span> SM), <span class="at">bins =</span> <span class="dv">6</span>, <span class="at">stat =</span> <span class="st">"contour_filled"</span>) <span class="sc">+</span></span>
<span id="cb3-36"><a href="#cb3-36" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_fill_brewer</span>(<span class="at">palette =</span> <span class="st">"YlGnBu"</span>) <span class="sc">+</span></span>
<span id="cb3-37"><a href="#cb3-37" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">x =</span> <span class="st">"Date"</span>, <span class="at">y =</span> <span class="st">"Depth (cm)"</span>, <span class="at">fill =</span> <span class="st">"Soil Moisture"</span>) <span class="sc">+</span></span>
<span id="cb3-38"><a href="#cb3-38" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_minimal</span>() <span class="sc">+</span> </span>
<span id="cb3-39"><a href="#cb3-39" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_y_reverse</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div id="fig-density" class="quarto-layout-panel">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-density-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="quarto-layout-row">
<div class="cell-output-display quarto-layout-cell-subref quarto-layout-cell" data-ref-parent="fig-density" style="flex-basis: 50.0%;justify-content: flex-start;">
<div id="fig-density-1" class="quarto-figure quarto-figure-center quarto-float anchored">
<figure class="quarto-float quarto-subfloat-fig figure">
<div aria-describedby="fig-density-1-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="ch11_a_v4_files/figure-html/fig-density-1.png" class="img-fluid figure-img" data-ref-parent="fig-density" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-subfloat-caption quarto-subfloat-fig" id="fig-density-1-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
(a) Depth versus soil temperature
</figcaption>
</figure>
</div>
</div>
<div class="cell-output-display quarto-layout-cell-subref quarto-layout-cell" data-ref-parent="fig-density" style="flex-basis: 50.0%;justify-content: flex-start;">
<div id="fig-density-2" class="quarto-figure quarto-figure-center quarto-float anchored">
<figure class="quarto-float quarto-subfloat-fig figure">
<div aria-describedby="fig-density-2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="ch11_a_v4_files/figure-html/fig-density-2.png" class="img-fluid figure-img" data-ref-parent="fig-density" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-subfloat-caption quarto-subfloat-fig" id="fig-density-2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
(b) Depth versus soil moisture
</figcaption>
</figure>
</div>
</div>
</div>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-density-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure 1: Soil temperature and moisture response with profile depth
</figcaption>
</figure>
</div>
<p>Under hydrologic equilibrium, the analytical solution of the 1-dimensional vertical water balance (differential) equation can be approximated using the relationship between the temporal changes in the rootzone soil moisture (RZSM) and the difference in SSM vis-à-vis the antecedent rootzone conditions (Wagner et al., 1999, Albergel et al., 2008, Manfreda et al., 2014). A simple recursive exponential LP filter to simulate the 1-dimensional first-order infinite-impulse response of RZSM to temporal variability in SSM is given as follows:</p>
<p><span id="eq-11.1"><span class="math display">\[ SM_t^{'}= SM_{t-1}^{'}+ D_p(SSM_t-SM_{t-1}^{'}) \tag{1}\]</span></span></p>
<p>where, <span class="math inline">\(t \ge1\)</span>; when <span class="math inline">\(t=1\)</span>, <span class="math inline">\(SM_{t=0}^{'}=SSM_{t=0}\)</span>.</p>
<p><span class="math inline">\(SM_{t}^{'}\)</span> is the temporally smoothed (filtered) SSM at time <span class="math inline">\(t\)</span> .</p>
<p>Parameter <span class="math inline">\(D_p\)</span> is the exponential filter smoothing factor of the soil profile <span class="math inline">\([-]\)</span>, also called the <em>pseudo-diffusivity coefficient</em>; <span class="math inline">\(D_p\)</span> ∈ [0,1]. It represents the effective influence of various bio-geo-physical controls such as vegetation, topography, hydroclimatology and pedological characteristics (soil profile thickness, effective soil hydraulic characteristics, etc.) on vertical fluxes between the soil surface and the rootzone.</p>
<p>Eq. 1 provides a first-order approximation of the infinite-impulse response of RZSM to temporal variability in SSM as <span class="math inline">\(SM^{'}\)</span>, and yields the exponential weighted average of the antecedent observations using weights proportional to the terms of the geometric progression: <span class="math inline">\(1, (1-D_p), (1-D_p)^2, ….(1-D_p)^n\)</span>, <span class="math inline">\(-\)</span> the discrete form of an exponential function (Hunter, 1986; Perry, 2010). This method makes two key assumption:</p>
<ol type="1">
<li><p>The lateral moisture flux to/from the rootzone is negligible, and,</p></li>
<li><p>The groundwater table is significantly deeper than the rootzone depth.</p></li>
</ol>
<section id="origins-of-low-pass-filter-relationship-in-vertical-soil-fluxes" class="level3">
<h3 class="anchored" data-anchor-id="origins-of-low-pass-filter-relationship-in-vertical-soil-fluxes">Origins of Low-pass Filter Relationship in Vertical Soil Fluxes</h3>
<p>The origins of the low-pass filter effect of soil profile on surface variability in soil moisture can be traced to the original equations for vertical flux of water int he unsaturated soil profile. We recall the Diffusivity version of Richard’s equation as follows:</p>
<p><span id="eq-11.2"><span class="math display">\[
\frac{\partial\theta} {\partial t}= \frac{\partial}{\partial z}(D(\theta)\frac{\partial\theta}{\partial z})-\frac{\partial K(\theta)}{\partial z}
\tag{2}\]</span></span></p>
<p>where, <span class="math inline">\(D\)</span> and <span class="math inline">\(K\)</span> are the hydraulic diffusivity and conductivity of the soil profile, and are a function of the water content of the soil profile, <span class="math inline">\(z\)</span> is the height above the bottom of the soil profile and <span class="math inline">\(\theta\)</span> is the soil moisture content. The right hand side of this equation contains two terms, where <span class="math inline">\(\partial/\partial z (D(\theta)\partial/\partial z)\)</span> accounts for the flux due to the suction gradient in the profile, while <span class="math inline">\(\partial K(\theta)/\partial z\)</span> pertains to the role of gravity in the vertical flow of water. Given the equivalent suction exerted by the atmosphere is several order of magnitude compare to the gravitational head gradient, we can simplify the preceeding equation as:</p>
<p><span id="eq-11.3"><span class="math display">\[
\frac{\partial\theta} {\partial t}= \frac{\partial}{\partial z}(D(\theta)\frac{\partial\theta}{\partial z})
\tag{3}\]</span></span></p>
<p>First integral of this equation can be written as: <span id="eq-11.4"><span class="math display">\[
\frac{d\theta}{dt}=D(\theta)\frac{d\theta}{dz}+C
\tag{4}\]</span></span> where, <span class="math inline">\(C\)</span> is the constant of integration. Since there is no flow at the bottom boundary of the soil profile, <span class="math inline">\(d\theta/dz=0\)</span> . Hence, <span class="math inline">\(C=0\)</span>. Writing the preceding equation in discrete form, we get:</p>
<p><span id="eq-11.5"><span class="math display">\[
\frac{\Delta\theta}{\Delta t}=D(\theta)\frac{\Delta\theta}{\Delta z}
\tag{5}\]</span></span></p>
<p>As the soil reaches the second phase of drying, it enters a phase where the rate of soil drydown is slow, and the rate of loss of water from all depths can be assumed to be the same. Simplifying the previous equation for a simple 2-layer representaiton of soil profile, with <span class="math inline">\(SSM\)</span> and <span class="math inline">\(SM\)</span> representing the surface and rootzone soil moisture respectively, we can write Eq. 5 as:<br>
<span id="eq-11.6"><span class="math display">\[
SM_t-SM_{t-1}=D(SM) \times (SSM_{t}-SM_{t-1})
\tag{6}\]</span></span></p>
<p>or,</p>
<p><span id="eq-11.7"><span class="math display">\[
SM_t=SM_{t-1}+ D(SM) \times (SSM_{t}-SM_{t-1})
\tag{7}\]</span></span></p>
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p><span style="color:blue;">This equation is analogous to the low-pass filter equation provided earlier. Given the true form of the relationship between the hydraulic diffusivity (or pseudo-diffusivity) with the soil moisture content is not known in the field, often times, the value of <span class="math inline">\(D\)</span> and <span class="math inline">\(D_p\)</span> is assumed to be constant for simplicity.</span></p>
</div>
</div>
</section>
<section id="propagation-of-drying-front-in-the-soil-profile" class="level3">
<h3 class="anchored" data-anchor-id="propagation-of-drying-front-in-the-soil-profile">Propagation of Drying Front in the Soil Profile</h3>
<p>We will demonstrate the application of low-pass filter to capture the propagation of drying front from the surface to the deeper profiles.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Function for implementing LP filter on surface soil moisture</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a>lp_filt<span class="ot">=</span><span class="cf">function</span>(SSM, Dp){</span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="co"># PARAMETERS---</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="co"># SSM= Surface soil moisture</span></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="co"># Dp= Pseudo-diffusivity coefficient</span></span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> <span class="co"># RETURNS---</span></span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a> <span class="co"># SSMf=filtered surface soil moisture (excluding the spinup period)</span></span>
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a> SSMf<span class="ot">=</span><span class="fu">c</span>() <span class="co"># Empty array to store filtered SSM </span></span>
<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a> buffer<span class="ot">=</span><span class="fl">0.01</span><span class="sc">*</span>(<span class="fu">max</span>(SSM)<span class="sc">-</span><span class="fu">min</span>(SSM)) <span class="co"># To decrease sensitivity to noise in sensor readings (1% of SSM range)</span></span>
<span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-12"><a href="#cb4-12" aria-hidden="true" tabindex="-1"></a> <span class="co"># Apply recursive filter</span></span>
<span id="cb4-13"><a href="#cb4-13" aria-hidden="true" tabindex="-1"></a> SSMf[<span class="dv">1</span>]<span class="ot">=</span>SSM[<span class="dv">1</span>] <span class="co"># Initialize the series</span></span>
<span id="cb4-14"><a href="#cb4-14" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> (t <span class="cf">in</span> <span class="dv">2</span><span class="sc">:</span><span class="fu">length</span>(SSM)) </span>
<span id="cb4-15"><a href="#cb4-15" aria-hidden="true" tabindex="-1"></a> SSMf[t]<span class="ot">=</span><span class="fu">ifelse</span>(SSM[t] <span class="sc">></span> (SSM[t<span class="dv">-1</span>]<span class="sc">+</span>buffer),<span class="fu">max</span>(SSM[t], SSMf[t<span class="dv">-1</span>]),SSMf[t<span class="dv">-1</span>]<span class="sc">+</span>Dp<span class="sc">*</span>(SSM[t]<span class="sc">-</span>SSMf[t<span class="dv">-1</span>]))</span>
<span id="cb4-16"><a href="#cb4-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(SSMf) </span>
<span id="cb4-17"><a href="#cb4-17" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb4-18"><a href="#cb4-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-19"><a href="#cb4-19" aria-hidden="true" tabindex="-1"></a><span class="co"># Filtered surface soil moisture with varying values of Dp</span></span>
<span id="cb4-20"><a href="#cb4-20" aria-hidden="true" tabindex="-1"></a>SSM<span class="ot">=</span>SMpdf<span class="sc">$</span>SM5 <span class="co"># Surface soil moisture</span></span>
<span id="cb4-21"><a href="#cb4-21" aria-hidden="true" tabindex="-1"></a>SSMf_1<span class="ot">=</span><span class="fu">lp_filt</span>(SSM, <span class="at">Dp=</span> <span class="fl">0.1</span>)</span>
<span id="cb4-22"><a href="#cb4-22" aria-hidden="true" tabindex="-1"></a>SSMf_05<span class="ot">=</span><span class="fu">lp_filt</span>(SSM, <span class="at">Dp=</span> <span class="fl">0.05</span>)</span>
<span id="cb4-23"><a href="#cb4-23" aria-hidden="true" tabindex="-1"></a>SSMf_02<span class="ot">=</span><span class="fu">lp_filt</span>(SSM, <span class="at">Dp=</span> <span class="fl">0.02</span>)</span>
<span id="cb4-24"><a href="#cb4-24" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-25"><a href="#cb4-25" aria-hidden="true" tabindex="-1"></a><span class="co"># Plot surface soil moisture with filtered time series</span></span>
<span id="cb4-26"><a href="#cb4-26" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(SSM, <span class="at">type=</span><span class="st">"l"</span>, <span class="at">col=</span><span class="st">"gray80"</span>, <span class="at">lwd=</span><span class="dv">3</span>, <span class="at">ylab=</span><span class="st">"Value"</span>, <span class="at">xlab=</span><span class="st">"Time"</span>, </span>
<span id="cb4-27"><a href="#cb4-27" aria-hidden="true" tabindex="-1"></a><span class="at">main=</span><span class="st">"Filtered v/s observed SSM for varying Dp"</span>)</span>
<span id="cb4-28"><a href="#cb4-28" aria-hidden="true" tabindex="-1"></a><span class="fu">lines</span>(SSMf_1, <span class="at">col=</span><span class="st">"red"</span>)</span>
<span id="cb4-29"><a href="#cb4-29" aria-hidden="true" tabindex="-1"></a><span class="fu">lines</span>(SSMf_05, <span class="at">col=</span><span class="st">"purple"</span>)</span>
<span id="cb4-30"><a href="#cb4-30" aria-hidden="true" tabindex="-1"></a><span class="fu">lines</span>(SSMf_02, <span class="at">col=</span><span class="st">"blue"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="ch11_a_v4_files/figure-html/unnamed-chunk-2-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Normalized filtered surface soil moisture</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>SSMf_1norm<span class="ot">=</span>(SSMf_1<span class="sc">-</span><span class="fu">min</span>(SSMf_1))<span class="sc">/</span>(<span class="fu">max</span>(SSMf_1)<span class="sc">-</span><span class="fu">min</span>(SSMf_1))</span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a>SSMf_05norm<span class="ot">=</span>(SSMf_05<span class="sc">-</span><span class="fu">min</span>(SSMf_05))<span class="sc">/</span>(<span class="fu">max</span>(SSMf_05)<span class="sc">-</span><span class="fu">min</span>(SSMf_05))</span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a>SSMf_02norm<span class="ot">=</span>(SSMf_02<span class="sc">-</span><span class="fu">min</span>(SSMf_02))<span class="sc">/</span>(<span class="fu">max</span>(SSMf_02)<span class="sc">-</span><span class="fu">min</span>(SSMf_02))</span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a><span class="co"># Weighted average of soil moisture at multiple depths to estimate RZSM</span></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a>RZSM<span class="ot">=</span>(SMpdf<span class="sc">$</span>SM5<span class="sc">*</span>(<span class="fl">7.5</span><span class="dv">-0</span>)<span class="sc">+</span> <span class="co"># 0- 7.5 cm depth</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a>SMpdf<span class="sc">$</span>SM10<span class="sc">*</span>(<span class="dv">15</span><span class="fl">-7.5</span>)<span class="sc">+</span> <span class="co"># 7.5-15 cm depth</span></span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a>SMpdf<span class="sc">$</span>SM20<span class="sc">*</span>(<span class="dv">35-15</span>)<span class="sc">+</span> <span class="co"># 15-35 cm depth</span></span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a>SMpdf<span class="sc">$</span>SM50<span class="sc">*</span>(<span class="dv">75-35</span>)<span class="sc">+</span> <span class="co"># 35-75 cm depth</span></span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a>SMpdf<span class="sc">$</span>SM100<span class="sc">*</span>(<span class="dv">100-75</span>))<span class="sc">/</span><span class="dv">100</span> <span class="co"># 75-100 cm depth</span></span>
<span id="cb5-12"><a href="#cb5-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-13"><a href="#cb5-13" aria-hidden="true" tabindex="-1"></a>rzsm_norm<span class="ot">=</span>(RZSM<span class="sc">-</span><span class="fu">min</span>(RZSM))<span class="sc">/</span>(<span class="fu">max</span>(RZSM)<span class="sc">-</span><span class="fu">min</span>(RZSM))</span>
<span id="cb5-14"><a href="#cb5-14" aria-hidden="true" tabindex="-1"></a>ssm_norm<span class="ot">=</span>(SSM<span class="sc">-</span><span class="fu">min</span>(SSM))<span class="sc">/</span>(<span class="fu">max</span>(SSM)<span class="sc">-</span><span class="fu">min</span>(SSM))</span>
<span id="cb5-15"><a href="#cb5-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-16"><a href="#cb5-16" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(rzsm_norm, <span class="at">type=</span><span class="st">"l"</span>, <span class="at">col=</span><span class="st">"gray80"</span>, <span class="at">lwd=</span><span class="dv">3</span>, <span class="at">ylab=</span><span class="st">"Value"</span>, <span class="at">xlab=</span><span class="st">"Time"</span>, </span>
<span id="cb5-17"><a href="#cb5-17" aria-hidden="true" tabindex="-1"></a><span class="at">main=</span><span class="st">"Comparison of RZSM with SSM and filtered SSM (normalized to 0-1)"</span>)</span>
<span id="cb5-18"><a href="#cb5-18" aria-hidden="true" tabindex="-1"></a><span class="fu">lines</span>(ssm_norm, <span class="at">col=</span><span class="st">"red"</span>)</span>
<span id="cb5-19"><a href="#cb5-19" aria-hidden="true" tabindex="-1"></a><span class="fu">lines</span>(SSMf_05norm, <span class="at">col=</span><span class="st">"blue"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="ch11_a_v4_files/figure-html/unnamed-chunk-2-2.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</section>
</section>
<section id="priestley-taylor-method-for-estimating-potential-et-pet" class="level2">
<h2 class="anchored" data-anchor-id="priestley-taylor-method-for-estimating-potential-et-pet">Priestley-Taylor Method for Estimating Potential ET (PET)</h2>
<p>This formulation is based on physical principles and can be seen as a simplified version of the Penman-Monteith formula for calculating evapotranspiration. The simplification involves removing the aerodynamic terms from the Penman-Monteith equation and using a constant (<span class="math inline">\(α\)</span>), which has been empirically derived and is estimated to be 1.26 for open bodies of water, but can range from <1 (humid conditions) to almost 2 (arid conditions). This constant tends to be higher in arid regions or areas experiencing significant water stress. The Priestley-Taylor formula can be used for calculating daily evapotranspiration and can also be applied to smaller time intervals (hourly, for example) if the necessary data is available.</p>
<p><span class="math display">\[
\text { PET }=\left(\frac{\alpha}{\lambda_v \rho_{\mathrm{w}}}\right) \times \frac{\Delta}{\Delta+\gamma} \times \text {R}
\]</span></p>
<p>if <span class="math inline">\(T_{mean}< 0^oC\)</span></p>
<p><span class="math display">\[
\Delta=0.3405 \times \mathrm{e}^\left(0.0642 \mathrm{~T}_{\text {mean}}\right) \\
\]</span></p>
<p>if <span class="math inline">\(T_{mean}> 0^oC\)</span> <span class="math display">\[
\Delta=0.3221 \times \mathrm{e}^\left(0.0803 \mathrm{~T}_{\mathrm{mean}}^{0.8876}\right)
\]</span></p>
<p>where,</p>
<blockquote class="blockquote">
<p><span class="math inline">\(PET\)</span>= Daily potential evapotranspiration (<span class="math inline">\(m\)</span>)</p>
<p><span class="math inline">\(λv\)</span> = Latent heat of vaporization (2260 <span class="math inline">\(kJ/kg\)</span>)</p>
<p><span class="math inline">\(ρw\)</span> = Density of water (1000 <span class="math inline">\(kg/m^3\)</span>)</p>
<p><span class="math inline">\(γ\)</span> = Psychrometric constant ( 4.95x <span class="math inline">\(10^{-4}\)</span> <span class="math inline">\(kg/m^3/^oC\)</span>)</p>
<p><span class="math inline">\(Rad\)</span> = Daily solar radiation incident on a horizontal earth surface (<span class="math inline">\(kg/m^2\)</span>)</p>
<p><span class="math inline">\(Δ\)</span> = Slope of the saturation vapor density curve from the psychrometric chart (<span class="math inline">\(kg/^oC\)</span>)</p>
<p><span class="math inline">\(T_{mean}\)</span> = Daily mean air temperature (<span class="math inline">\(^oC\)</span>)</p>
<p><span class="math inline">\(\alpha\)</span> = Priestley-Taylor correction factor</p>
</blockquote>
<div class="cell">
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Parameters for Priestley-Taylor formula</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a>lambdaV<span class="ot">=</span> <span class="dv">2260</span> <span class="co"># Latent heat of vaporization </span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a>rhoW<span class="ot">=</span> <span class="dv">1000</span> <span class="co"># Density of water </span></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a>gamma<span class="ot">=</span> <span class="fl">4.95</span><span class="sc">*</span><span class="fl">1e-4</span> <span class="co"># Psychrometric constant</span></span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a>alpha<span class="ot">=</span><span class="fl">1.2</span> <span class="co"># Priestley-Taylor correction factor</span></span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a><span class="co"># PET estimation using Priestley-Taylor method </span></span>
<span id="cb6-8"><a href="#cb6-8" aria-hidden="true" tabindex="-1"></a> PT_PET<span class="ot">=</span><span class="cf">function</span>(Tmean,Rad,alpha){</span>
<span id="cb6-9"><a href="#cb6-9" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb6-10"><a href="#cb6-10" aria-hidden="true" tabindex="-1"></a> deltaVal<span class="ot">=</span><span class="fu">rep</span>(<span class="dv">0</span>, <span class="fu">length</span>(Tmean)) <span class="co"># Create empty array</span></span>
<span id="cb6-11"><a href="#cb6-11" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb6-12"><a href="#cb6-12" aria-hidden="true" tabindex="-1"></a> <span class="co"># When Tmean<0</span></span>
<span id="cb6-13"><a href="#cb6-13" aria-hidden="true" tabindex="-1"></a> deltaVal[Tmean<span class="sc"><</span><span class="dv">0</span>]<span class="ot">=</span><span class="fl">0.3405</span><span class="sc">*</span><span class="fu">exp</span>(<span class="fl">0.0642</span><span class="sc">*</span>Tmean[Tmean<span class="sc"><</span><span class="dv">0</span>])</span>
<span id="cb6-14"><a href="#cb6-14" aria-hidden="true" tabindex="-1"></a> <span class="co"># When Tmean>=0</span></span>
<span id="cb6-15"><a href="#cb6-15" aria-hidden="true" tabindex="-1"></a> deltaVal[Tmean<span class="sc">>=</span><span class="dv">0</span>]<span class="ot">=</span><span class="fl">0.3221</span><span class="sc">*</span><span class="fu">exp</span>(<span class="fl">0.0803</span><span class="sc">*</span>((Tmean[Tmean<span class="sc">>=</span><span class="dv">0</span>])<span class="sc">^</span><span class="fl">0.8876</span>))</span>
<span id="cb6-16"><a href="#cb6-16" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb6-17"><a href="#cb6-17" aria-hidden="true" tabindex="-1"></a> <span class="co"># Priestley-Taylor equation </span></span>
<span id="cb6-18"><a href="#cb6-18" aria-hidden="true" tabindex="-1"></a> PETval<span class="ot">=</span>(alpha<span class="sc">/</span>(lambdaV<span class="sc">*</span>rhoW))<span class="sc">*</span>(deltaVal<span class="sc">/</span>(deltaVal<span class="sc">+</span>gamma))<span class="sc">*</span>Rad</span>
<span id="cb6-19"><a href="#cb6-19" aria-hidden="true" tabindex="-1"></a> PETval[PETval<span class="sc"><</span><span class="dv">0</span>]<span class="ot">=</span><span class="dv">0</span></span>
<span id="cb6-20"><a href="#cb6-20" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(PETval) <span class="co">#estimate in m</span></span>
<span id="cb6-21"><a href="#cb6-21" aria-hidden="true" tabindex="-1"></a> }</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>As we can see from the function above, Priestley-Taylor formula requires mean temperature and solar radiation as inputs. So, we will collect the meteorological dataset namely <em>a</em>) Mean daily temperature <em>b</em>) Total solar radiation from the sample station and estimate the value of total daily potential evapotranspiration (in m). We will also store total daily precipitation, which will be used as model forcing.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="co"># Observed meteorological forcings </span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> Rad<span class="ot">=</span>CRNdat<span class="sc">$</span>SOLARAD_DAILY<span class="sc">*</span><span class="dv">1000</span> <span class="co"># (as 1 MJ= 1000 KJ)</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> Tmean<span class="ot">=</span>CRNdat<span class="sc">$</span>T_DAILY_MEAN</span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> PCP<span class="ot">=</span>CRNdat<span class="sc">$</span>P_DAILY_CALC<span class="sc">/</span><span class="dv">10</span> <span class="co"># convert units from mm to cm</span></span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a> <span class="co"># Linear gap-filling of missing samples and removing flagged samples</span></span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">library</span>(zoo)</span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a> Tmean<span class="ot">=</span><span class="fu">na.approx</span>(Tmean,<span class="at">na.rm =</span> <span class="cn">FALSE</span>)</span>
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a> Rad<span class="ot">=</span><span class="fu">na.approx</span>(Rad,<span class="at">na.rm =</span> <span class="cn">FALSE</span>)</span>
<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a> PCP[PCP<span class="sc"><</span><span class="dv">0</span>]<span class="ot">=</span><span class="dv">0</span> <span class="co"># Negative (flagged values are replaced by 0)</span></span>
<span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a> PCP[<span class="fu">is.na</span>(PCP)]<span class="ot">=</span><span class="dv">0</span> <span class="co"># NA values are replaced by 0)</span></span>
<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-14"><a href="#cb7-14" aria-hidden="true" tabindex="-1"></a> <span class="co"># Create data frame for met forcings for the station</span></span>
<span id="cb7-15"><a href="#cb7-15" aria-hidden="true" tabindex="-1"></a> datetime<span class="ot">=</span><span class="fu">as.Date</span>(<span class="fu">as.character</span>(CRNdat<span class="sc">$</span>LST_DATE), <span class="at">format=</span> <span class="st">"%Y%m%d"</span>)</span>
<span id="cb7-16"><a href="#cb7-16" aria-hidden="true" tabindex="-1"></a> forcings<span class="ot">=</span><span class="fu">data.frame</span>(<span class="at">Date=</span>datetime,PCP, Rad,Tmean)</span>
<span id="cb7-17"><a href="#cb7-17" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb7-18"><a href="#cb7-18" aria-hidden="true" tabindex="-1"></a> <span class="co"># Apply Priestley-Taylor method for PET estimation using the PT_PET function</span></span>
<span id="cb7-19"><a href="#cb7-19" aria-hidden="true" tabindex="-1"></a> PET<span class="ot">=</span><span class="fu">PT_PET</span>(Tmean,Rad,alpha)</span>
<span id="cb7-20"><a href="#cb7-20" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb7-21"><a href="#cb7-21" aria-hidden="true" tabindex="-1"></a> <span class="co"># Plot estimated PET time series</span></span>
<span id="cb7-22"><a href="#cb7-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="at">data=</span>forcings)<span class="sc">+</span></span>
<span id="cb7-23"><a href="#cb7-23" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_line</span>(<span class="fu">aes</span>(<span class="at">x =</span> datetime, <span class="at">y =</span> PET), <span class="at">color=</span><span class="st">"steelblue"</span>) <span class="sc">+</span> </span>
<span id="cb7-24"><a href="#cb7-24" aria-hidden="true" tabindex="-1"></a> <span class="fu">xlab</span>(<span class="st">"Date"</span>) <span class="sc">+</span> <span class="co"># Add labels to the axes</span></span>
<span id="cb7-25"><a href="#cb7-25" aria-hidden="true" tabindex="-1"></a> <span class="fu">ylab</span>(<span class="st">"PET [in m]"</span>)<span class="sc">+</span></span>
<span id="cb7-26"><a href="#cb7-26" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_bw</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="ch11_a_v4_files/figure-html/11a5-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</section>
</main>
<!-- /main column -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
const toggleBodyColorMode = (bsSheetEl) => {
const mode = bsSheetEl.getAttribute("data-mode");
const bodyEl = window.document.querySelector("body");
if (mode === "dark") {
bodyEl.classList.add("quarto-dark");
bodyEl.classList.remove("quarto-light");
} else {
bodyEl.classList.add("quarto-light");
bodyEl.classList.remove("quarto-dark");
}
}
const toggleBodyColorPrimary = () => {
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
if (bsSheetEl) {
toggleBodyColorMode(bsSheetEl);
}
}
toggleBodyColorPrimary();
const icon = "";
const anchorJS = new window.AnchorJS();
anchorJS.options = {
placement: 'right',
icon: icon
};
anchorJS.add('.anchored');
const isCodeAnnotation = (el) => {
for (const clz of el.classList) {
if (clz.startsWith('code-annotation-')) {
return true;
}
}
return false;
}
const clipboard = new window.ClipboardJS('.code-copy-button', {
text: function(trigger) {
const codeEl = trigger.previousElementSibling.cloneNode(true);
for (const childEl of codeEl.children) {
if (isCodeAnnotation(childEl)) {
childEl.remove();
}
}
return codeEl.innerText;
}
});
clipboard.on('success', function(e) {
// button target
const button = e.trigger;
// don't keep focus
button.blur();
// flash "checked"
button.classList.add('code-copy-button-checked');
var currentTitle = button.getAttribute("title");
button.setAttribute("title", "Copied!");
let tooltip;
if (window.bootstrap) {
button.setAttribute("data-bs-toggle", "tooltip");
button.setAttribute("data-bs-placement", "left");
button.setAttribute("data-bs-title", "Copied!");
tooltip = new bootstrap.Tooltip(button,
{ trigger: "manual",
customClass: "code-copy-button-tooltip",
offset: [0, -8]});
tooltip.show();
}
setTimeout(function() {
if (tooltip) {
tooltip.hide();
button.removeAttribute("data-bs-title");
button.removeAttribute("data-bs-toggle");
button.removeAttribute("data-bs-placement");
}
button.setAttribute("title", currentTitle);
button.classList.remove('code-copy-button-checked');
}, 1000);
// clear code selection
e.clearSelection();
});
var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//);
var mailtoRegex = new RegExp(/^mailto:/);
var filterRegex = new RegExp('/' + window.location.host + '/');
var isInternal = (href) => {
return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href);
}
// Inspect non-navigation links and adorn them if external
var links = window.document.querySelectorAll('a[href]:not(.nav-link):not(.navbar-brand):not(.toc-action):not(.sidebar-link):not(.sidebar-item-toggle):not(.pagination-link):not(.no-external):not([aria-hidden]):not(.dropdown-item):not(.quarto-navigation-tool)');
for (var i=0; i<links.length; i++) {
const link = links[i];
if (!isInternal(link.href)) {
// undo the damage that might have been done by quarto-nav.js in the case of
// links that we want to consider external
if (link.dataset.originalHref !== undefined) {
link.href = link.dataset.originalHref;
}
}
}
function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) {
const config = {
allowHTML: true,
maxWidth: 500,
delay: 100,
arrow: false,
appendTo: function(el) {
return el.parentElement;
},
interactive: true,
interactiveBorder: 10,
theme: 'quarto',
placement: 'bottom-start',
};
if (contentFn) {
config.content = contentFn;
}
if (onTriggerFn) {
config.onTrigger = onTriggerFn;
}
if (onUntriggerFn) {
config.onUntrigger = onUntriggerFn;
}
window.tippy(el, config);
}
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
for (var i=0; i<noterefs.length; i++) {
const ref = noterefs[i];
tippyHover(ref, function() {
// use id or data attribute instead here
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
try { href = new URL(href).hash; } catch {}
const id = href.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
if (note) {
return note.innerHTML;
} else {
return "";
}
});
}
const xrefs = window.document.querySelectorAll('a.quarto-xref');
const processXRef = (id, note) => {
// Strip column container classes
const stripColumnClz = (el) => {
el.classList.remove("page-full", "page-columns");
if (el.children) {
for (const child of el.children) {
stripColumnClz(child);
}
}
}
stripColumnClz(note)
if (id === null || id.startsWith('sec-')) {
// Special case sections, only their first couple elements
const container = document.createElement("div");
if (note.children && note.children.length > 2) {
container.appendChild(note.children[0].cloneNode(true));
for (let i = 1; i < note.children.length; i++) {
const child = note.children[i];
if (child.tagName === "P" && child.innerText === "") {
continue;
} else {
container.appendChild(child.cloneNode(true));
break;
}
}
if (window.Quarto?.typesetMath) {
window.Quarto.typesetMath(container);
}
return container.innerHTML
} else {
if (window.Quarto?.typesetMath) {
window.Quarto.typesetMath(note);
}
return note.innerHTML;
}
} else {
// Remove any anchor links if they are present
const anchorLink = note.querySelector('a.anchorjs-link');
if (anchorLink) {
anchorLink.remove();
}
if (window.Quarto?.typesetMath) {
window.Quarto.typesetMath(note);
}
// TODO in 1.5, we should make sure this works without a callout special case
if (note.classList.contains("callout")) {
return note.outerHTML;
} else {
return note.innerHTML;
}
}
}
for (var i=0; i<xrefs.length; i++) {
const xref = xrefs[i];
tippyHover(xref, undefined, function(instance) {
instance.disable();
let url = xref.getAttribute('href');
let hash = undefined;
if (url.startsWith('#')) {
hash = url;
} else {
try { hash = new URL(url).hash; } catch {}
}
if (hash) {
const id = hash.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
if (note !== null) {
try {
const html = processXRef(id, note.cloneNode(true));
instance.setContent(html);
} finally {
instance.enable();
instance.show();
}
} else {
// See if we can fetch this
fetch(url.split('#')[0])
.then(res => res.text())
.then(html => {
const parser = new DOMParser();
const htmlDoc = parser.parseFromString(html, "text/html");
const note = htmlDoc.getElementById(id);
if (note !== null) {
const html = processXRef(id, note);
instance.setContent(html);
}
}).finally(() => {
instance.enable();
instance.show();
});
}
} else {
// See if we can fetch a full url (with no hash to target)
// This is a special case and we should probably do some content thinning / targeting
fetch(url)
.then(res => res.text())
.then(html => {
const parser = new DOMParser();
const htmlDoc = parser.parseFromString(html, "text/html");
const note = htmlDoc.querySelector('main.content');
if (note !== null) {
// This should only happen for chapter cross references
// (since there is no id in the URL)
// remove the first header
if (note.children.length > 0 && note.children[0].tagName === "HEADER") {
note.children[0].remove();
}
const html = processXRef(null, note);
instance.setContent(html);
}
}).finally(() => {
instance.enable();
instance.show();
});
}
}, function(instance) {
});
}
let selectedAnnoteEl;
const selectorForAnnotation = ( cell, annotation) => {
let cellAttr = 'data-code-cell="' + cell + '"';
let lineAttr = 'data-code-annotation="' + annotation + '"';
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
return selector;
}
const selectCodeLines = (annoteEl) => {
const doc = window.document;
const targetCell = annoteEl.getAttribute("data-target-cell");
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
const lineIds = lines.map((line) => {
return targetCell + "-" + line;
})
let top = null;
let height = null;
let parent = null;
if (lineIds.length > 0) {
//compute the position of the single el (top and bottom and make a div)
const el = window.document.getElementById(lineIds[0]);