-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFigure_S2.m
executable file
·856 lines (658 loc) · 27.2 KB
/
Figure_S2.m
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
%% find GSCD raw constrain and GSCD regression constrain
clear all; clc;
US = load('us_coor.txt');
SL = load('sl_coor.txt');
scatter_size = 20; label_size = 10; legend_size = 10; tick_size = 10; colorbar_size= 11;title_size = 10; line_width = 1; text_size = 11;
%1-gauge id, 2-lat, 3-lon, 4-cluster id, 5- default, 6-regional best,
%7-gscd mean, 8-gscd std, 9-gscd 95% PI mean, 10 gscd 95% PI std
out_q10_metric = nan(464, 10);
out_q90_metric = nan(464, 10);
out_qmean_metric = nan(464, 10);
% load observations
obs = readtable('../camel_Hydrologic_features.csv');
out_obs = nan(464,7); %1-gauge id, 2-lat, 3-lon, 4-cluster id,, 5-q10_mm_d, 6-q90_mm_d, 7-qmean_mm_d
out_obs(:,1) = obs.Gauge_ID;
out_obs(:,2) = obs.Gauge_Lat;
out_obs(:,3) = obs.Gauge_Lon;
out_obs(:,4) = obs.Cluster;
out_obs(:,5) = obs.q10_mm_d;
out_obs(:,6) = obs.q90_mm_d;
out_obs(:,7) = obs.mean_annual_mm_d;
out_obs = sortrows(out_obs, 1);
out_q10_metric(:,1:4) = out_obs(:,1:4);
out_q90_metric(:,1:4) = out_obs(:,1:4);
out_qmean_metric(:,1:4) = out_obs(:,1:4);
clear obs;
%% ---------------------------------------------------------------------------------------------------------
% 1) default metric
temp = readtable('../../ensemble_sim/default_sim1.csv');
out_default = nan(464,7); %1-gauge id, 2-lat, 3-lon, 4-cluster id,, 5-q10_mm_d, 6-q90_mm_d, 7-qmean_mm_d
out_default(:,1) = temp.Gauge_ID;
out_default(:,2) = temp.Gauge_Lat;
out_default(:,3) = temp.Gauge_Lon;
out_default(:,4) = temp.Cluster;
out_default(:,5) = temp.q10_mm_d;
out_default(:,6) = temp.q90_mm_d;
out_default(:,7) = temp.qmean_mm_d;
out_default = sortrows(out_default, 1);
clear temp;
out_q10_metric(:,5) = (out_default(:,5) - out_obs(:,5)); % sim - obs
out_q90_metric(:,5) = (out_default(:,6) - out_obs(:,6)); % sim - obs
out_qmean_metric(:,5) = (out_default(:,7) - out_obs(:,7)); % sim - obs
%% ---------------------------------------------------------------------------------------------------------
% 2) regional best
% region_par_qmean = [954 1300 518 1276 680 496 118]; % 1- 1307
% region_par_q10 = [1 1 1 1 8 2 1];
% region_par_q90 = [49 24 247 579 963 172 210];
para_q10 = load('camel_regional_id_1000_q10.txt');
para_q90 = load('camel_regional_id_1000_q90.txt');
para_qmean = load('camel_regional_id_1000_qmean.txt');
par1000 = load('./sucessful_par_id_1000');
par1307 = load('./sucessful_par_id_1307');
index1000 = ismember(par1307, par1000);
temp = readtable('../../ensemble_sim/ensemble_q10');
out_regional = nan(464, 7); %1-gauge id, 2-lat, 3-lon, 4-cluster id, 5-q10_mm_d, 6-q90_mm_d, 7-qmean_mm_d
out_regional(:,1) = temp.Var1;
out_regional(:,2) = temp.Var2;
out_regional(:,3) = temp.Var3;
out_regional(:,4) = temp.Var4;
out_regional = sortrows(out_regional, 1);
temp = sortrows(temp, 1);
for i = 1:464
temp1 = table2array(temp(i, 5:end));
temp1 = temp1(index1000);
temp2 = nan(10,1);
for j = 1:7
if out_regional(i,4)==j
par_id = para_q10(j,2:11);
for k = 1:10
temp2(k,1) = temp1(par_id(k));
end
end
end
out_q10_metric(i,6) = 1 - crps(temp2, out_obs(i,5)) / abs(out_default(i,5) - out_obs(i,5));
end
temp = readtable('../../ensemble_sim/ensemble_q90');
temp = sortrows(temp, 1);
for i = 1:464
temp1 = table2array(temp(i, 5:end));
temp1 = temp1(index1000);
temp2 = nan(10,1);
for j = 1:7
if out_regional(i,4)==j
par_id = para_q90(j,2:11);
for k = 1:10
temp2(k,1) = temp1(par_id(k));
end
end
end
out_q90_metric(i,6) = 1 - crps(temp2, out_obs(i,6)) / abs(out_default(i,6) - out_obs(i,6));
if out_qmean_metric(i,1) == 1144000
regional_best_c1 = temp2;
end
if out_qmean_metric(i,1) == 14216500
regional_best_c2 = temp2;
end
if out_qmean_metric(i,1) == 9430500
regional_best_c3 = temp2;
end
if out_qmean_metric(i,1) == 9312600
regional_best_c4 = temp2;
end
if out_qmean_metric(i,1) == 8195000
regional_best_c5 = temp2;
end
if out_qmean_metric(i,1) == 5507600
regional_best_c6 = temp2;
end
if out_qmean_metric(i,1) == 2363000
regional_best_c7 = temp2;
end
end
temp = readtable('../../ensemble_sim/ensemble_qmean');
temp = sortrows(temp, 1);
for i = 1:464
temp1 = table2array(temp(i, 5:end));
temp1 = temp1(index1000);
temp2 = nan(10,1);
for j = 1:7
if out_regional(i,4)==j
par_id = para_qmean(j,2:11);
for k = 1:10
temp2(k,1) = temp1(par_id(k));
end
end
end
out_qmean_metric(i,6) = 1 - crps(temp2, out_obs(i,7)) / abs(out_default(i,7) - out_obs(i,7));
end
% out_q10_metric(:,6) = abs(out_regional(:,5) - out_obs(:,5)); % sim - obs
% out_q90_metric(:,6) = abs(out_regional(:,6) - out_obs(:,6)); % sim - obs
% out_qmean_metric(:,6) = abs(out_regional(:,7) - out_obs(:,7)); % sim - obs
% out_q10_metric(:,6) = out_regional(:,5);
% out_q90_metric(:,6) = out_regional(:,6);
% out_qmean_metric(:,6) = out_regional(:,7);
%% ---------------------------------------------------------------------------------------------------------
% 4) GSCD regression data only
var = nan(464, 10); % 1-gauge id, 2-lat, 3-lon, 4-cluster id, 5-q10 low, 6-q_10 up, 7-q90 low, 8-q90 up, 9-qmean low, 10-qmean up
temp = readtable('../gscd_camel_regression/q10.csv');
var(:,1) = temp.V1;
var(:,2) = temp.V3;
var(:,3) = temp.V4;
var(:,4) = temp.V2;
var(:,5) = temp.V7;
var(:,6) = temp.V8;
temp = readtable('../gscd_camel_regression/q90.csv');
var(:,7) = temp.V7;
var(:,8) = temp.V8;
temp = readtable('../gscd_camel_regression/qmean.csv');
var(:,9) = temp.V7;
var(:,10) = temp.V8;
var = sortrows(var,1);
temp = readtable('../../ensemble_sim/ensemble_q10');
temp = sortrows(temp,1);
for i = 1:464
temp1 = table2array(temp(i, 5:end));
temp1 = temp1(index1000);
low = var(i,5);
up = var(i,6);
indices = find(temp1 > low & temp1 < up); % 1- 350
if length(indices)>1
temp2 = nan(length(indices), 1);
for j = 1:length(indices)
temp2(j,1) = temp1(indices(j));
end
out_q10_metric(i,7) = 1 - crps(temp2, out_obs(i,5)) / abs(out_default(i,5) - out_obs(i,5));
end
if length(indices)==1
temp2 = temp1(indices);
out_q10_metric(i,7) = 1 - abs(temp2 - out_obs(i,5)) / abs(out_default(i,5) - out_obs(i,5));
end
end
temp = readtable('../../ensemble_sim/ensemble_q90');
temp = sortrows(temp,1);
for i = 1:464
temp1 = table2array(temp(i, 5:end));
temp1 = temp1(index1000);
low = var(i,7);
up = var(i,8);
indices = find(temp1 > low & temp1 < up); % 1- 350
if length(indices)>1
temp2 = nan(length(indices), 1);
for j = 1:length(indices)
temp2(j,1) = temp1(indices(j));
end
out_q90_metric(i,7) = 1 - crps(temp2, out_obs(i,6)) / abs(out_default(i,6) - out_obs(i,6));
end
if length(indices)==1
temp2 = temp1(indices);
out_q90_metric(i,7) = 1 - abs(temp2 - out_obs(i,6)) / abs(out_default(i,6) - out_obs(i,6));
end
if out_qmean_metric(i,1) == 1144000
regression_c1 = temp2;
end
if out_qmean_metric(i,1) == 14216500
regression_c2 = temp2;
end
if out_qmean_metric(i,1) == 9430500
regression_c3 = temp2;
end
if out_qmean_metric(i,1) == 9312600
regression_c4 = temp2;
end
if out_qmean_metric(i,1) == 8195000
regression_c5 = temp2;
end
if out_qmean_metric(i,1) == 5507600
regression_c6 = temp2;
end
if out_qmean_metric(i,1) == 2363000
regression_c7 = temp2;
end
end
temp = readtable('../../ensemble_sim/ensemble_qmean');
temp = sortrows(temp,1);
for i = 1:464
temp1 = table2array(temp(i, 5:end));
temp1 = temp1(index1000);
low = var(i,9);
up = var(i,10);
indices = find(temp1 > low & temp1 < up); % 1- 350
if length(indices)>1
temp2 = nan(length(indices), 1);
for j = 1:length(indices)
temp2(j,1) = temp1(indices(j));
end
out_qmean_metric(i,7) = 1 - crps(temp2, out_obs(i,7)) / abs(out_default(i,7) - out_obs(i,7));
end
if length(indices)==1
temp2 = temp1(indices);
out_qmean_metric(i,7) = 1 - abs(temp2 - out_obs(i,7)) / abs(out_default(i,7) - out_obs(i,7));
end
end
%% ---------------------------------------------------------------------------------------------------------
% 4) GSCD regression data + regional best
var = nan(464, 10); % 1-gauge id, 2-lat, 3-lon, 4-cluster id, 5-q10 low, 6-q_10 up, 7-q90 low, 8-q90 up, 9-qmean low, 10-qmean up
temp = readtable('../gscd_camel_regression/q10.csv');
var(:,1) = temp.V1;
var(:,2) = temp.V3;
var(:,3) = temp.V4;
var(:,4) = temp.V2;
var(:,5) = temp.V7;
var(:,6) = temp.V8;
temp = readtable('../gscd_camel_regression/q90.csv');
var(:,7) = temp.V7;
var(:,8) = temp.V8;
temp = readtable('../gscd_camel_regression/qmean.csv');
var(:,9) = temp.V7;
var(:,10) = temp.V8;
var = sortrows(var,1);
temp = readtable('../../ensemble_sim/ensemble_q10');
temp = sortrows(temp,1);
cluster_id = table2array(temp(:,4));
for i = 1:464
temp1 = table2array(temp(i, 5:end));
temp1 = temp1(index1000);
low = var(i,5);
up = var(i,6);
indices = find(temp1 > low & temp1 < up); % 1- 350
% 1) use full constrain members
if length(indices)>=10
temp2 = nan(length(indices), 1);
for j = 1:length(indices)
temp2(j,1) = temp1(indices(j));
end
out_q10_metric(i,9) = 1 - crps(temp2, out_obs(i,5)) / abs(out_default(i,5) - out_obs(i,5));
end
% 2) if no constrain, use the top 10 members
if length(indices)==0
temp2 = nan(10,1);
for k = 1:7
if cluster_id(i)==k
par_id = para_q10(k,2:21);
for j = 1:10
temp2(j,1) = temp1(par_id(j));
end
end
end
out_q10_metric(i,9) = 1 - crps(temp2, out_obs(i,5)) / abs(out_default(i,5) - out_obs(i,5));
end
% 3) mixed with constain but no 10 parameters
if length(indices)>0 && length(indices)<10
temp2 = nan(10, 1);
for j = 1:length(indices)
temp2(j,1) = temp1(indices(j));
end
need_num = 10 - length(indices);
count1 = length(indices)+1;
for k = 1:7
if cluster_id(i)==k
par_id = para_q10(k,2:21);
for j = 1:20
if ismember(par_id(j), indices)
continue
else
temp2(count1,1) = temp1(par_id(j));
count1 = count1 + 1;
if count1 == 11
break
end
end
end
end
end
out_q10_metric(i,9) = 1 - crps(temp2, out_obs(i,5)) / abs(out_default(i,5) - out_obs(i,5));
end
% if length(indices)>=1
% temp2 = nan(length(indices), 1);
% for j = 1:length(indices)
% temp2(j,1) = abs(temp1(indices(j)) - out_obs(i,5));
% end
% out_q10_metric(i,9) = mean(temp2);
% end
% if length(indices)>=2
% out_q10_metric(i,10) = std(temp2);
% end
end
temp = readtable('../../ensemble_sim/ensemble_q90');
temp = sortrows(temp,1);
for i = 1:464
temp1 = table2array(temp(i, 5:end));
temp1 = temp1(index1000);
low = var(i,7);
up = var(i,8);
indices = find(temp1 > low & temp1 < up); % 1- 350
% 1) use full constrain members
if length(indices)>=10
temp2 = nan(length(indices), 1);
for j = 1:length(indices)
temp2(j,1) = temp1(indices(j));
end
out_q90_metric(i,9) = 1 - crps(temp2, out_obs(i,6)) / abs(out_default(i,6) - out_obs(i,6));
end
% 2) if no constrain, use the top 10 members
if length(indices)==0
temp2 = nan(10,1);
for k = 1:7
if cluster_id(i)==k
par_id = para_q90(k,2:21);
for j = 1:10
temp2(j,1) = temp1(par_id(j));
end
end
end
out_q90_metric(i,9) = 1 - crps(temp2, out_obs(i,6)) / abs(out_default(i,6) - out_obs(i,6));
end
% 3) mixed with constain but no 10 parameters
if length(indices)>0 && length(indices)<10
temp2 = nan(10, 1);
for j = 1:length(indices)
temp2(j,1) = temp1(indices(j));
end
need_num = 10 - length(indices);
count1 = length(indices)+1;
for k = 1:7
if cluster_id(i)==k
par_id = para_q90(k,2:21);
for j = 1:20
if ismember(par_id(j), indices)
continue
else
temp2(count1,1) = temp1(par_id(j));
count1 = count1 + 1;
if count1 == 11
break
end
end
end
end
end
out_q90_metric(i,9) = 1 - crps(temp2, out_obs(i,6)) / abs(out_default(i,6) - out_obs(i,6));
end
% if length(indices)>=1
% temp2 = nan(length(indices), 1);
% for j = 1:length(indices)
% temp2(j,1) = abs(temp1(indices(j)) - out_obs(i,6));
% end
% out_q90_metric(i,9) = mean(temp2);
% end
% if length(indices)>=2
% out_q90_metric(i,10) = std(temp2);
% end
if out_qmean_metric(i,1) == 1144000
hybrid_c1 = temp2;
end
if out_qmean_metric(i,1) == 14216500
hybrid_c2 = temp2;
end
if out_qmean_metric(i,1) == 9430500
hybrid_c3 = temp2;
end
if out_qmean_metric(i,1) == 9312600
hybrid_c4 = temp2;
end
if out_qmean_metric(i,1) == 8195000
hybrid_c5 = temp2;
end
if out_qmean_metric(i,1) == 5507600
hybrid_c6 = temp2;
end
if out_qmean_metric(i,1) == 2363000
hybrid_c7 = temp2;
end
end
temp = readtable('../../ensemble_sim/ensemble_qmean');
temp = sortrows(temp,1);
for i = 1:464
temp1 = table2array(temp(i, 5:end));
temp1 = temp1(index1000);
low = var(i,9);
up = var(i,10);
indices = find(temp1 > low & temp1 < up); % 1- 350
% 1) use full constrain members
if length(indices)>=10
temp2 = nan(length(indices), 1);
for j = 1:length(indices)
temp2(j,1) = temp1(indices(j));
end
out_qmean_metric(i,9) = 1 - crps(temp2, out_obs(i,7)) / abs(out_default(i,7) - out_obs(i,7));
end
% 2) if no constrain, use the top 10 members
if length(indices)==0
temp2 = nan(10,1);
for k = 1:7
if cluster_id(i)==k
par_id = para_qmean(k,2:21);
for j = 1:10
temp2(j,1) = temp1(par_id(j));
end
end
end
out_qmean_metric(i,9) = 1 - crps(temp2, out_obs(i,7)) / abs(out_default(i,7) - out_obs(i,7));
end
% 3) mixed with constain but no 10 parameters
if length(indices)>0 && length(indices)<10
temp2 = nan(10, 1);
for j = 1:length(indices)
temp2(j,1) = temp1(indices(j));
end
need_num = 10 - length(indices);
count1 = length(indices)+1;
for k = 1:7
if cluster_id(i)==k
par_id = para_qmean(k,2:21);
for j = 1:20
if ismember(par_id(j), indices)
continue
else
temp2(count1,1) = temp1(par_id(j));
count1 = count1 + 1;
if count1 == 11
break
end
end
end
end
end
out_qmean_metric(i,9) = 1 - crps(temp2, out_obs(i,7)) / abs(out_default(i,7) - out_obs(i,7));
end
% if length(indices)>=1
% temp2 = nan(length(indices), 1);
% for j = 1:length(indices)
% temp2(j,1) = abs(temp1(indices(j)) - out_obs(i,7));
% end
% out_qmean_metric(i,9) = mean(temp2);
% end
% if length(indices)>=2
% out_qmean_metric(i,10) = std(temp2);
% end
end
%% plot the metric
figure;
% regional best parameter --------------------------------------------------------
ax(1) = subplot(3,3,1)
gauge_id = 1144000;
index = find(out_qmean_metric(:,1)==gauge_id);
[f,xi] = ksdensity(regional_best_c1);
fill([xi fliplr(xi)], [f zeros(size(f))], 'b', 'FaceAlpha', 0.2, 'EdgeColor', 'none'); hold on;
% plot(xi,f); hold on;
[f,xi] = ksdensity(regression_c1);
fill([xi fliplr(xi)], [f zeros(size(f))], [0.8500 0.3250 0.0980], 'FaceAlpha', 0.3, 'EdgeColor', 'none'); hold on;
% plot(xi,f); hold on;
xline(out_obs(index, 6), '--g', 'Linewidth', line_width+1);
xline(out_default(index, 6), '--r', 'Linewidth', line_width+1);
% xline(out_regional(index, 7), '--g', 'Linewidth', line_width+1);
xlabel('Q90 (mm/d)', 'FontSize', label_size);
ylabel('Density', 'FontSize', label_size);
title('(a) C1-Northeast: Gauge 01144000', 'FontSize', label_size)
% legend('GSCD Data Constrain', 'GSCD Regression 95% P.I. Constrain', 'Obs.', 'Default Parameter', 'Regional Best Parameter')
set(gca,'FontSize',tick_size);
% text(0.05, 0.15, '(a)', 'FontSize',text_size, 'FontWeight', 'bold', 'Units','Normalized')
text(0.05, 0.9, 'CRPSS R-P = 0.87', 'FontSize',text_size, 'Units','Normalized')
text(0.05, 0.80, 'CRPSS Hybrid/R-S = 0.72', 'FontSize',text_size, 'Units','Normalized')
ylim([0, 2]);
ax(2) = subplot(3,3,2)
gauge_id = 14216500;
index = find(out_qmean_metric(:,1)==gauge_id);
[f,xi] = ksdensity(regional_best_c2);
fill([xi fliplr(xi)], [f zeros(size(f))], 'b', 'FaceAlpha', 0.2, 'EdgeColor', 'none'); hold on;
% plot(xi,f); hold on;
[f,xi] = ksdensity(regression_c2);
fill([xi fliplr(xi)], [f zeros(size(f))], [0.8500 0.3250 0.0980], 'FaceAlpha', 0.3, 'EdgeColor', 'none'); hold on;
% plot(xi,f); hold on;
xline(out_obs(index, 6), '--g', 'Linewidth', line_width+1);
xline(out_default(index, 6), '--r', 'Linewidth', line_width+1);
% xline(out_regional(index, 7), '--g', 'Linewidth', line_width+1);
xlabel('Q90 (mm/d)', 'FontSize', label_size);
ylabel('Density', 'FontSize', label_size);
title('(b) C2-Pacific: Gauge 14216500', 'FontSize', label_size)
% legend('GSCD Data Constrain', 'GSCD Regression 95% P.I. Constrain', 'Obs.', 'Default Parameter', 'Regional Best Parameter')
set(gca,'FontSize',tick_size);
% text(0.05, 0.15, '(a)', 'FontSize',text_size, 'FontWeight', 'bold', 'Units','Normalized')
text(0.05, 0.9, 'CRPSS R-P = -1.07', 'FontSize',text_size, 'Units','Normalized')
text(0.05, 0.80, 'CRPSS Hybrid/R-S = 0.58', 'FontSize',text_size, 'Units','Normalized')
ylim([0, 0.6]);
ax(3) = subplot(3,3,3)
gauge_id = 09430500;
index = find(out_qmean_metric(:,1)==gauge_id);
[f,xi] = ksdensity(regional_best_c3, 'bandwidth', 1);
fill([xi fliplr(xi)], [f zeros(size(f))], 'b', 'FaceAlpha', 0.2, 'EdgeColor', 'none'); hold on;
% plot(xi,f); hold on;
[f,xi] = ksdensity(regression_c3);
fill([xi fliplr(xi)], [f zeros(size(f))], [0.8500 0.3250 0.0980], 'FaceAlpha', 0.3, 'EdgeColor', 'none'); hold on;
% plot(xi,f); hold on;
xline(out_obs(index, 6), '--g', 'Linewidth', line_width+1);
xline(out_default(index, 6), '--r', 'Linewidth', line_width+1);
% xline(out_regional(index, 7), '--g', 'Linewidth', line_width+1);
xlabel('Q90 (mm/d)', 'FontSize', label_size);
ylabel('Density', 'FontSize', label_size);
title('(c) C3-AZ/NM: Gauge 09430500', 'FontSize', label_size)
% legend('GSCD Data Constrain', 'GSCD Regression 95% P.I. Constrain', 'Obs.', 'Default Parameter', 'Regional Best Parameter')
set(gca,'FontSize',tick_size);
% text(0.05, 0.15, '(a)', 'FontSize',text_size, 'FontWeight', 'bold', 'Units','Normalized')
text(0.05, 0.9, 'CRPSS R-P = 0.79', 'FontSize',text_size, 'Units','Normalized')
text(0.05, 0.80, 'CRPSS Hybrid/R-S = 0.95', 'FontSize',text_size, 'Units','Normalized')
ylim([0, 5]);
xlim([0,2]);
ax(4) = subplot(3,3,4)
gauge_id = 09312600;
index = find(out_qmean_metric(:,1)==gauge_id);
[f,xi] = ksdensity(regional_best_c4);
fill([xi fliplr(xi)], [f zeros(size(f))], 'b', 'FaceAlpha', 0.2, 'EdgeColor', 'none'); hold on;
% plot(xi,f); hold on;
[f,xi] = ksdensity(regression_c4);
fill([xi fliplr(xi)], [f zeros(size(f))], [0.8500 0.3250 0.0980], 'FaceAlpha', 0.3, 'EdgeColor', 'none'); hold on;
% plot(xi,f); hold on;
xline(out_obs(index, 6), '--g', 'Linewidth', line_width+1);
xline(out_default(index, 6), '--r', 'Linewidth', line_width+1);
% xline(out_regional(index, 7), '--g', 'Linewidth', line_width+1);
xlabel('Q90 (mm/d)', 'FontSize', label_size);
ylabel('Density', 'FontSize', label_size);
title('(d) C4-Rockies: Gauge 09312600', 'FontSize', label_size)
% legend('GSCD Data Constrain', 'GSCD Regression 95% P.I. Constrain', 'Obs.', 'Default Parameter', 'Regional Best Parameter')
set(gca,'FontSize',tick_size);
% text(0.05, 0.15, '(a)', 'FontSize',text_size, 'FontWeight', 'bold', 'Units','Normalized')
text(0.05, 0.9, 'CRPSS R-P = 0.63', 'FontSize',text_size, 'Units','Normalized')
text(0.05, 0.80, 'CRPSS Hybrid/R-S = 0.89', 'FontSize',text_size, 'Units','Normalized')
ylim([0, 2]);
xlim([0,2.5]);
ax(5) = subplot(3,3,5)
gauge_id = 08195000;
index = find(out_qmean_metric(:,1)==gauge_id);
[f,xi] = ksdensity(regional_best_c5);
fill([xi fliplr(xi)], [f zeros(size(f))], 'b', 'FaceAlpha', 0.2, 'EdgeColor', 'none'); hold on;
% plot(xi,f); hold on;
[f,xi] = ksdensity(regression_c5);
fill([xi fliplr(xi)], [f zeros(size(f))], [0.8500 0.3250 0.0980], 'FaceAlpha', 0.3, 'EdgeColor', 'none'); hold on;
% plot(xi,f); hold on;
xline(out_obs(index, 6), '--g', 'Linewidth', line_width+1);
xline(out_default(index, 6), '--r', 'Linewidth', line_width+1);
% xline(out_regional(index, 7), '--g', 'Linewidth', line_width+1);
xlabel('Q90 (mm/d)', 'FontSize', label_size);
ylabel('Density', 'FontSize', label_size);
title('(e) C5-Great Plains: Gauge 08195000', 'FontSize', label_size)
% legend('GSCD Data Constrain', 'GSCD Regression 95% P.I. Constrain', 'Obs.', 'Default Parameter', 'Regional Best Parameter')
set(gca,'FontSize',tick_size);
% text(0.05, 0.15, '(a)', 'FontSize',text_size, 'FontWeight', 'bold', 'Units','Normalized')
text(0.05, 0.9, 'CRPSS R-P = 0.52', 'FontSize',text_size, 'Units','Normalized')
text(0.05, 0.80, 'CRPSS Hybrid/R-S = 0.92', 'FontSize',text_size, 'Units','Normalized')
ylim([0,5]);
xlim([0,1]);
ax(6) = subplot(3,3,6)
gauge_id = 05507600;
index = find(out_qmean_metric(:,1)==gauge_id);
[f,xi] = ksdensity(regional_best_c6);
fill([xi fliplr(xi)], [f zeros(size(f))], 'b', 'FaceAlpha', 0.2, 'EdgeColor', 'none'); hold on;
% plot(xi,f); hold on;
[f,xi] = ksdensity(regression_c6);
fill([xi fliplr(xi)], [f zeros(size(f))], [0.8500 0.3250 0.0980], 'FaceAlpha', 0.3, 'EdgeColor', 'none'); hold on;
% plot(xi,f); hold on;
xline(out_obs(index, 6), '--g', 'Linewidth', line_width+1);
xline(out_default(index, 6), '--r', 'Linewidth', line_width+1);
% xline(out_regional(index, 7), '--g', 'Linewidth', line_width+1);
xlabel('Q90 (mm/d)', 'FontSize', label_size);
ylabel('Density', 'FontSize', label_size);
title('(f) C6-Midwest: Gauge 05507600', 'FontSize', label_size)
% legend('GSCD Data Constrain', 'GSCD Regression 95% P.I. Constrain', 'Obs.', 'Default Parameter', 'Regional Best Parameter')
set(gca,'FontSize',tick_size);
% text(0.05, 0.15, '(a)', 'FontSize',text_size, 'FontWeight', 'bold', 'Units','Normalized')
text(0.05, 0.9, 'CRPSS R-P = 0', 'FontSize',text_size, 'Units','Normalized')
text(0.05, 0.80, 'CRPSS Hybrid/R-S = 0.56', 'FontSize',text_size, 'Units','Normalized')
ylim([0, 2]);
ax(7) = subplot(3,3,7)
gauge_id = 02363000;
index = find(out_qmean_metric(:,1)==gauge_id);
[f,xi] = ksdensity(regional_best_c7);
fill([xi fliplr(xi)], [f zeros(size(f))], 'b', 'FaceAlpha', 0.2, 'EdgeColor', 'none'); hold on;
% plot(xi,f); hold on;
[f,xi] = ksdensity(regression_c7);
fill([xi fliplr(xi)], [f zeros(size(f))], [0.8500 0.3250 0.0980], 'FaceAlpha', 0.3, 'EdgeColor', 'none'); hold on;
% plot(xi,f); hold on;
xline(out_obs(index, 6), '--g', 'Linewidth', line_width+1);
xline(out_default(index, 6), '--r', 'Linewidth', line_width+1);
% xline(out_regional(index, 7), '--g', 'Linewidth', line_width+1);
xlabel('Q90 (mm/d)', 'FontSize', label_size);
ylabel('Density', 'FontSize', label_size);
title('(g) C7-Southeast: Gauge 02363000', 'FontSize', label_size)
% legend('GSCD Data Constrain', 'GSCD Regression 95% P.I. Constrain', 'Obs.', 'Default Parameter', 'Regional Best Parameter')
set(gca,'FontSize',tick_size);
% text(0.05, 0.15, '(a)', 'FontSize',text_size, 'FontWeight', 'bold', 'Units','Normalized')
text(0.05, 0.9, 'CRPSS R-P = 0.56', 'FontSize',text_size, 'Units','Normalized')
text(0.05, 0.80, 'CRPSS Hybrid/R-S = 0.90', 'FontSize',text_size, 'Units','Normalized')
ylim([0, 1.5]);
ax(1) = subplot(3,3,8)
gauge = [1144000, 14216500, 9430500, 9312600, 8195000, 5507600, 2363000];
coor = nan(7, 2);
for i = 1:7
index = find(out_qmean_metric(:,1)==gauge(i));
coor(i,1:2) = out_qmean_metric(index,2:3);
end
plot(US(:,1), US(:,2),'.','MarkerSize',2,'Color','black'); hold on;
plot(SL(:,1), SL(:,2),'.','MarkerSize',2,'Color','black'); hold on;
scatter(coor(:,2), coor(:,1), scatter_size, 'o','filled', 'MarkerFaceColor',[0.8500 0.3250 0.0980], 'LineWidth',line_width-0.5); hold on;
labels = {'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7'};
text(coor(:,2), coor(:,1), labels, 'VerticalAlignment', 'bottom', 'HorizontalAlignment', 'right', 'FontSize',text_size+4,'FontWeight','BOLD' ,'Color',[0.8500 0.3250 0.0980]);
xlim([-128 -64]); ylim([23 52]); box on;
xticks = [-120,-110,-100,-90,-80, -70];
xticklabels_deg = cell(size(xticks));
for i = 1:numel(xticks)
xticklabels_deg{i} = [num2str(-xticks(i)) '°W'];
end
set(gca, 'XTick', xticks);
set(gca, 'XTickLabel', xticklabels_deg);
yticks = [25, 30, 35, 40, 45, 50];
yticklabels_deg = cell(size(yticks));
for i = 1:numel(yticks)
yticklabels_deg{i} = [num2str(yticks(i)) '°N'];
end
set(gca, 'YTick', yticks);
set(gca, 'YTickLabel', yticklabels_deg);
set(gca, 'XTickLabel', xticklabels_deg);
% text(0.05, 0.15, '(h)', 'FontSize',text_size, 'FontWeight', 'bold', 'Units','Normalized')
title('(h) Selected Basin Location', 'FontSize', label_size)
%% output the plot
fig = gcf;
fig.PaperUnits = 'inches';
% fig.PaperPosition = [0 0 10 5];
fig.PaperPositionMode = 'auto';
fig.PaperPosition = [0 0 14 8];
print('./figure', '-dpng', '-r300')