-
Notifications
You must be signed in to change notification settings - Fork 1
/
PROMICE_processing_tools.py
1338 lines (1203 loc) · 44.2 KB
/
PROMICE_processing_tools.py
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
"""
@author: Adrien Wehrlé, Jason E. Box, GEUS (Geological Survey of Denmark and Greenland), 2019
"""
import os
import glob
import pandas as pd
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from collections import Counter
import pickle
def load_data(file, year):
"""
Loading PROMICE data for a given station and all or given year(s)
into a DataFrame.
INTPUTS:
file: Path to the desired file containing PROMICE data [string]
year: Year to import. If 'all', all the years are imported [int,string]
OUTPUTS:
promice_data: Dataframe containing PROMICE data for the desired settings [DataFrame]
"""
# extract site name
global site
site = file.split("/")[-1].split("_")[0] + "_" + file.split("/")[-1].split("_")[1]
if site[:3] == "MIT" or site[:3] == "EGP" or site[:3] == "CEN":
site = site.split("_")[0]
# load data
promice_data = pd.read_csv(file, delim_whitespace=True)
# set invalid values (-999) to nan
promice_data[promice_data == -999.0] = np.nan
# only keep selected year(s) if needed
global yr
yr = year
if year != "all":
promice_data = promice_data[promice_data.Year == year]
elif isinstance(year, list):
promice_data[promice_data.Year.isin(year)]
if promice_data.empty:
print("ERROR: Selected year not available")
return
return promice_data
def BIC_processing(promice_data, fig_save=False, fig_path=None, visualisation=False):
"""
Processing, filtering and exclusion of ice ablation and albedo timeseries
spanning the onset of bare ice conditions.
INPUTS:
promice_data: Dataset imported using load_data() [DataFrame]
visualisation: If True, displays raw and processed DPT as well as air temperature,
boom height and albedo time series (default: False) [boolean]
fig_save: If True, saves figure generated with visualisation option
(default: False) [boolean]
fig_path: Path where to save figure generated with visualisation option
(default: None) [boolean]
OUTPUTS:
promice_data_proc: Processed ice ablation and albedo time
series [DataFrame]
"""
def DPT_processing(df, year):
"""
Processing of Depth Pressure Sensor (DPT) time series using PROMICE 2019-08-02
datasets.
INPUTS:
promice_data: Dataframe imported using load_data() [DataFrame]
year: Year of promice_data to process [int]
OUTPUTS:
DPT_proc: Processed ice ablation time series [pandas.series]
albedo: Albedo time series associated with ice ablation [pandas.series]
DPT_flag: Assessement of the ease to determine bare ice appearance
from ice ablation (0=no data, 1=, 2=low confidence,
3= high confidence) [int]
albedo_flag: Determines if an albedo time series will be excluded (0)
or not (1) [int]
BID: Bare Ice Day, day of bare ice appearance based on ice ablation [float]
"""
# load ice ablation and associated time
global z, doy
z = df["DepthPressureTransducer_Cor(m)"].copy()
doy = df["DayOfYear"]
def assign_nans(days):
if type(days) == int:
z[days == doy] = np.nan
else:
for d in days:
z[d == doy] = np.nan
# initialize albedo_flag
albedo_flag = 1
# manually process DPT measurements for a given site and year and
# identify theoretical ice ablation onset (IAO)
global no_proc
no_proc = 0
if site == "NUK_U":
if year in [2007, 2014, 2015]:
DPT_flag = 1
elif year in [2008, 2009]:
DPT_flag = 0
elif year == 2010:
z[doy > 203] -= 2.6
z[doy > 204] -= 8.8
z[doy >= 256] = np.nan
DPT_flag = 3
IAO = 121
elif year == 2011:
assign_nans(235)
z[doy >= 236] -= 2
z[doy >= 276] = np.nan
DPT_flag = 3
IAO = 156
albedo_flag = 0
elif year == 2012:
z[(doy >= 260) & (z >= -3)] = np.nan
DPT_flag = 3
IAO = 148
elif year == 2013:
z[doy > 202] -= 2
z[doy > 203] -= 5.8
DPT_flag = 3
IAO = 152
elif year == 2016:
z[doy >= 263] = np.nan
z[(doy <= 70) & (z <= -0.5)] = np.nan
z[(doy > 38) & (doy < 43)] = np.nan
assign_nans(np.arange(71, 76))
assign_nans([32, 92, 93])
DPT_flag = 3
IAO = 160
elif year == 2017:
z[(doy >= 250) & (z >= -0.3)] = np.nan
DPT_flag = 3
IAO = 204
elif year == 2018:
z[doy <= 103] = np.nan
z[doy >= 212] -= 8
assign_nans([123, 124, 210, 211])
z[doy >= 210] -= 1.25
DPT_flag = 3
IAO = 161
elif year == 2019:
DPT_flag = 3
IAO = 128
z[doy < 97] = np.nan
else:
no_proc = 1
elif site == "NUK_L":
if year == 2007:
DPT_flag = 1
elif year == 2008:
z[doy > 212] -= 7.1
z[doy > 211] -= 5
assign_nans(156)
DPT_flag = 3
IAO = 121
elif year == 2009:
assign_nans([90, 92, 95, 102, 105, 142, 154, 159, 169, 174])
z[doy > 236] -= 0.5
DPT_flag = 3
IAO = 136
elif year == 2010:
assign_nans(207)
z[doy > 206] -= 11.1
z[doy > 264] = np.nan
DPT_flag = 3
IAO = 107
elif year == 2011:
assign_nans([210, 238, 239, 240])
z[doy > 209] -= 1.15
z[(doy >= 237) & (doy <= 239)] -= 0.4
z[(doy >= 241) & (doy <= 242)] -= 0.2
z[doy > 280] = np.nan
DPT_flag = 3
IAO = 156
albedo_flag = 0
elif year == 2012:
assign_nans(241)
z[doy > 241] -= 12
DPT_flag = 3
IAO = 150
elif year == 2013:
assign_nans([23, 24, 204])
z[doy > 24] += 2.6
z[doy > 204] -= 5.25
DPT_flag = 3
IAO = 155
albedo_flag = 0
elif year == 2014:
z[doy > 206] -= 2.5
z[doy > 207] -= 3.35
DPT_flag = 3
IAO = 121
assign_nans([54, 55])
elif year in [2015, 2016]:
DPT_flag = 3
if year == 2015:
IAO = 159
else:
IAO = 100
elif year == 2017:
assign_nans([117, 118, 219, 220, 233, 234, 235])
z[doy > 117] -= 14.92
z[doy >= 142] -= 0.5
DPT_flag = 3
IAO = 142
elif year == 2018:
assign_nans([194, 196, 211])
z[doy > 59] -= 14.75
z[(doy >= 197) & (doy <= 210)] += 7.35
z[(doy >= 194) & (doy <= 211)] += 0.27
z[(doy >= 50) & (doy <= 70)] = np.nan
DPT_flag = 2
elif year == 2019:
DPT_flag = 3
IAO = 97
albedo_flag = 0
else:
no_proc = 1
elif site == "NUK_N":
if year in [2010, 2013]:
DPT_flag = 1
elif year == 2011:
z[doy >= 280] = np.nan
DPT_flag = 3
IAO = 164
elif year == 2012:
z[doy >= 240] = np.nan
DPT_flag = 3
IAO = 158
z[(doy >= 90) & (doy <= 156) & (z < 0)] = np.nan
assign_nans(96)
z[doy == 168] -= 0.19
assign_nans(np.arange(145, 152))
elif year == 2014:
DPT_flag = 3
IAO = 165
else:
no_proc = 1
elif site == "NUK_K":
if year == 2014:
z[(doy >= 225) & (doy <= 238)] += 1.19
assign_nans(239)
DPT_flag = 2
elif year == 2015:
DPT_flag = 3
IAO = 200
elif year == 2016:
assign_nans([23, 24, 124])
DPT_flag = 3
IAO = 166
elif year == 2017:
DPT_flag = 3
IAO = 204
elif year in [2018, 2019]:
DPT_flag = 3
IAO = 176
if year == 2019:
assign_nans([94, 127, 128, 129])
elif year == 2018:
assign_nans(177)
z[doy > 177] += 0.07
else:
no_proc = 1
elif site == "UPE_L":
if year == 2009:
z[(doy >= 120)] = np.nan
DPT_flag = 1
elif year == 2010:
assign_nans(range(271, 275))
DPT_flag = 3
IAO = 129
elif year == 2011:
z[(doy >= 262) & (doy <= 311)] = np.nan
DPT_flag = 3
IAO = 157
elif year == 2012:
z[doy > 150] -= 0.3
z[doy > 151] += 0.2
z[doy > 152] += 0.1
z[doy >= 225] -= 0.1
z[doy >= 226] -= 0.15
z[(doy >= 258) & (doy <= 308)] = np.nan
DPT_flag = 3
IAO = 148
assign_nans([149, 150, 152, 153])
elif year == 2013:
z[doy <= 70] = np.nan
assign_nans([74, 214, 215])
z[(doy >= 73) & (doy <= 75)] = np.nan
z[doy >= 214] -= 15.3
DPT_flag = 3
IAO = 160
elif year == 2014:
z[(doy >= 266) & (doy <= 270)] = np.nan
DPT_flag = 3
IAO = 158
elif year == 2015:
assign_nans(213)
z[doy >= 214] -= 0.32
z[(doy >= 253) & (doy <= 261)] = np.nan
DPT_flag = 3
IAO = 151
elif year == 2016:
DPT_flag = 0
elif year == 2017:
DPT_flag = 1
elif year == 2018:
DPT_flag = 3
IAO = 167
elif year == 2019:
DPT_flag = 3
IAO = 124
z[doy < 99] = np.nan
else:
no_proc = 1
elif site == "UPE_U":
if year == 2009:
DPT_flag = 1
elif (year >= 2010) & (year <= 2012):
DPT_flag = 3
if year == 2010:
IAO = 143
assign_nans(114)
elif year == 2011:
IAO = 159
elif year == 2012:
IAO = 153
elif year in [2013, 2018]:
DPT_flag = 2
elif year == 2014:
DPT_flag = 3
IAO = 171
elif year == 2015:
z[doy >= 216] -= 5.48
assign_nans(215)
DPT_flag = 2
elif year == 2016:
DPT_flag = 3
IAO = 183
elif year == 2017:
if year == 2017:
IAO = 190
DPT_flag = 3
elif year == 2019:
DPT_flag = 3
IAO = 161
else:
no_proc = 1
elif site == "KPC_L":
if year in [2008, 2010, 2012]:
DPT_flag = 1
elif year == 2009:
DPT_flag = 0
elif year == 2011:
DPT_flag = 0
elif year == 2013:
DPT_flag = 3
IAO = 163
elif year == 2014:
DPT_flag = 3
IAO = 165
elif year == 2015:
DPT_flag = 3
IAO = 172
elif year == 2016:
z[doy > 209] -= 6.297
assign_nans([210, 211])
DPT_flag = 3
IAO = 166
z[doy > 211] -= 0.1
elif year == 2017:
DPT_flag = 3
IAO = 160
elif year == 2018:
DPT_flag = 2
elif year == 2019:
z[doy > 192] -= 4.478
assign_nans(193)
DPT_flag = 3
IAO = 163
else:
no_proc = 1
elif site == "KPC_U":
if (year >= 2008) & (year <= 2019):
DPT_flag = 1
else:
no_proc = 1
elif site == "KAN_L":
if year == 2008:
DPT_flag = 1
elif year == 2009:
z[(doy >= 250) & (z >= -3.2)] = np.nan
z[(doy >= 260) & (np.isnan(z))] = -3.5
assign_nans(276)
DPT_flag = 3
IAO = 136
elif year == 2010:
z[(doy >= 260) & (z >= -5.1)] = np.nan
z[doy >= 280] -= 0.1
z[(doy >= 260) & (np.isnan(z))] = -5.45
assign_nans([136, 284])
DPT_flag = 3
IAO = 121
elif year == 2011:
z[doy > 155] -= 4
assign_nans(155)
DPT_flag = 3
IAO = 156
elif year == 2012:
z[doy >= 234] -= 11.56
z[(doy >= 282) & (doy <= 298)] = np.nan
assign_nans([234, 235])
DPT_flag = 3
IAO = 149
elif year == 2013:
DPT_flag = 3
IAO = 141
elif year == 2014:
z[(doy >= 290) & (doy <= 319)] = np.nan
DPT_flag = 3
IAO = 146
z[doy > 133] += 0.07
elif year == 2015:
z[doy >= 119] -= 7.08
assign_nans([118, 278])
z[doy >= 188] -= 0.29
DPT_flag = 3
IAO = 162
elif year == 2016:
z[(doy > 198)] -= 1.6
z[(doy >= 260) & (z >= -4.5)] = np.nan
z[(doy >= 260) & (z <= -5.5)] = np.nan
z[(doy >= 273) & (doy <= 280)] = np.nan
assign_nans(198)
DPT_flag = 3
IAO = 100
elif year == 2017:
z[doy > 244] -= 3.6
z[doy > 58] -= z[doy == 59]
assign_nans(244)
DPT_flag = 3
IAO = 123
elif year == 2018:
assign_nans(240)
z[doy >= 241] -= 10.65
DPT_flag = 3
IAO = 137
elif year == 2019:
z[doy >= 248] -= 1.3
DPT_flag = 3
IAO = 115
else:
no_proc = 1
elif site == "KAN_M":
if (year >= 2008) & (year <= 2011):
DPT_flag = 0
elif year == 2012:
DPT_flag = 3
IAO = 169
elif year == 2013:
DPT_flag = 3
IAO = 173
assign_nans(183)
elif year in [2014, 2015]:
DPT_flag = 1
elif year == 2016:
DPT_flag = 3
IAO = 156
elif year == 2017:
z[(doy > 100) & (doy < 135) & (z > 0.15)] = np.nan
DPT_flag = 3
IAO = 202
elif year == 2018:
z[doy >= 238] = np.nan
DPT_flag = 2
elif year == 2019:
z[doy >= 247] = np.nan
DPT_flag = 3
IAO = 172
else:
no_proc = 1
elif site == "QAS_M":
if year == 2016:
DPT_flag = 2
elif year == 2017:
assign_nans(range(141, 146))
assign_nans([151, 152, 187, 188])
z[(doy >= 196) & (doy <= 236)] = np.nan
DPT_flag = 1
elif year == 2018:
z[doy > 242] -= 5.0
assign_nans(range(241, 244))
DPT_flag = 3
IAO = 192
z[doy >= 244] -= 0.2
elif year == 2019:
z[doy >= 242] -= 4.92
DPT_flag = 3
IAO = 178
else:
no_proc = 1
elif site == "QAS_A":
if (year >= 2012) & (year <= 2015):
DPT_flag = 0
else:
no_proc = 1
elif site == "QAS_L":
if year in [2007, 2009, 2013]:
DPT_flag = 1
elif year == 2008:
z[doy >= 219] -= 7
z[doy >= 277] += 5.1
assign_nans([77, 78, 92, 103, 110, 220, 277])
z[doy >= 220] -= 1.9
DPT_flag = 3
IAO = 121
elif year == 2010:
z[(doy >= 127) & (doy <= 128)] = np.nan
assign_nans(147)
z[(doy >= 129) & (doy <= 146) & (doy <= 148)] -= 3.5
z[(doy >= 144) & (doy <= 150)] = np.nan
z[doy >= 129] -= 1.3
DPT_flag = 2
IAO = 129
elif year == 2011:
z[doy >= 222] = np.nan
DPT_flag = 3
IAO = 155
elif year == 2012:
assign_nans([133, 134])
z[doy > 132] -= 0.55
z[doy > 230] -= 0.8
DPT_flag = 3
IAO = 151
elif year == 2014:
assign_nans([125, 235])
z[doy > 124] -= 1.48
z[doy >= 236] -= 7.9
z[doy > 159] -= 0.08
DPT_flag = 3
IAO = 149
elif year == 2015:
DPT_flag = 3
IAO = 171
elif year == 2016:
assign_nans(224)
z[doy >= 225] -= 13.3
DPT_flag = 3
IAO = 133
elif year == 2017:
DPT_flag = 3
IAO = 152
z[doy >= 152] -= 0.05
elif year == 2018:
assign_nans([123, 238])
z[doy > 122] -= 1
z[doy > 132] -= 0.9
z[doy > 130] += 0.2
z[doy > 126] -= 0.2
z[doy >= 239] -= 8.2
DPT_flag = 3
IAO = 155
assign_nans(np.arange(123, 133))
assign_nans(np.arange(133, 137))
elif year == 2019:
z[doy > 142] = np.nan
z[doy >= 177] -= 1
z[doy >= 140] -= 0.4
DPT_flag = 1
else:
no_proc = 1
elif site == "QAS_U":
if year in [2008, 2009, 2013]:
DPT_flag = 1
elif year == 2010:
DPT_flag = 3
IAO = 175
elif year in [2011, 2015, 2018]:
DPT_flag = 2
elif year == 2012:
DPT_flag = 3
IAO = 196
albedo_flag = 0
elif year == 2014:
DPT_flag = 3
IAO = 206
elif year == 2016:
z[doy > 224] = np.nan
DPT_flag = 3
IAO = 202
elif year == 2017:
z[doy <= 143] = np.nan
DPT_flag = 3
IAO = 220
elif year == 2019:
z[doy >= 243] -= 2.24
z[(doy >= 241) & (doy <= 242)] = np.nan
z[doy <= 100] = np.nan
DPT_flag = 3
IAO = 200
else:
no_proc = 1
elif site == "THU_L":
if year in [2010, 2011, 2012, 2013, 2018]:
DPT_flag = 1
elif year == 2014:
z[doy > 255] = np.nan
DPT_flag = 3
IAO = 177
elif year == 2015:
z[doy >= 20] += 0.1
z[doy >= 182] -= 0.3
z[doy >= 260] -= 0.2
z[doy > 250] = np.nan
DPT_flag = 3
IAO = 163
elif year == 2016:
z[doy >= 204] -= 0.2
DPT_flag = 3
IAO = 180
elif year == 2017:
DPT_flag = 3
IAO = 194
elif year == 2019:
z[(doy > 43) & (doy < 59)] = np.nan
z[(doy < 100) & (z < -0.2)] = np.nan
DPT_flag = 3
IAO = 161
albedo_flag = 0
else:
no_proc = 1
elif site == "THU_U":
if year in [2010, 2018]:
DPT_flag = 1
elif year in [2011, 2013, 2015, 2019]:
DPT_flag = 2
elif year == 2012:
DPT_flag = 3
IAO = 191
elif year == 2014:
z[doy >= 258] += 0.85
assign_nans(258)
DPT_flag = 2
elif year == 2016:
z[doy >= 204] += 2.5
assign_nans(203)
z[z < -0.5] = np.nan
DPT_flag = 2
elif year == 2017:
z[z < -0.06] = np.nan
DPT_flag = 1
else:
no_proc = 1
elif site == "THU_U2":
if year == 2018:
assign_nans(216)
DPT_flag = 2
elif year == 2019:
DPT_flag = 1 # instrument broken
elif site == "SCO_L":
if year == 2008:
DPT_flag = 2
elif (year >= 2009) & (year <= 2013):
DPT_flag = 3
if year == 2009:
IAO = 143
elif year == 2010:
IAO = 144
albedo_flag = 0
elif year == 2011:
IAO = 158
elif year == 2012:
IAO = 150
elif year == 2013:
IAO = 151
elif year == 2014:
z[doy >= 222] -= 14.79
assign_nans(221)
DPT_flag = 2
elif year in [2015, 2016]:
if year == 2015:
DPT_flag = 1
else:
assign_nans(np.arange(115, 120))
DPT_flag = 3
IAO = 158
elif year == 2017:
assign_nans(np.arange(110, 116))
z[doy >= 219] -= 9.88
assign_nans(218)
DPT_flag = 3
IAO = 146
elif year == 2018:
DPT_flag = 3
IAO = 148
elif year == 2019:
DPT_flag = 1
else:
no_proc = 1
elif site == "SCO_U":
if year in [2008, 2018]:
DPT_flag = 2
elif year == 2009:
z[doy >= 316] = np.nan
DPT_flag = 3
IAO = 184
albedo_flag = 0
elif year == 2010:
DPT_flag = 1
elif year == 2011:
DPT_flag = 3
IAO = 161
elif year == 2012:
z[doy >= 242] -= 1.47
assign_nans(241)
DPT_flag = 3
IAO = 150
elif year in [2013, 2014]:
DPT_flag = 3
if year == 2013:
z[(doy > 22) & (doy < 26)] = np.nan
IAO = 155
else:
IAO = 162
elif year == 2015:
assign_nans([101, 102, 103, 113])
DPT_flag = 3
IAO = 170
elif year == 2016:
assign_nans([47, 60, 61])
DPT_flag = 3
IAO = 160
elif year == 2017:
z[doy >= 217] -= 12.08
assign_nans(216)
DPT_flag = 3
IAO = 153
z[(doy > 49) & (doy < 54)] = np.nan
assign_nans(np.arange(82, 93))
elif year == 2019:
DPT_flag = 3
IAO = 160
else:
no_proc = 1
elif site == "TAS_A":
if year in [2013, 2015, 2018]:
DPT_flag = 1
elif year == 2014:
z[(doy > 41) & (doy < 75)] = np.nan
DPT_flag = 3
IAO = 188
elif year == 2016:
DPT_flag = 3
IAO = 176
elif year == 2017:
DPT_flag = 3
IAO = 210
elif year == 2019:
DPT_flag = 3
IAO = 195
albedo_flag = 0
else:
no_proc = 1
elif site == "TAS_L":
if year in range(2007, 2010):
DPT_flag = 0
elif year in [2010, 2011, 2014, 2015, 2016]:
DPT_flag = 1
elif year == 2012:
z[doy >= 252] -= 2.86
assign_nans(251)
z[doy <= 83] = np.nan
DPT_flag = 3
IAO = 153
elif year == 2013:
z[doy >= 235] -= np.nan
DPT_flag = 2
IAO = 140
elif year == 2017:
z[doy >= 209] -= 10.36
assign_nans([207, 208])
DPT_flag = 2
elif year == 2018:
z[doy >= 272] += 1.29
assign_nans(271)
DPT_flag = 3
IAO = 156
elif year == 2019:
z[doy >= 121] -= 1.135
DPT_flag = 3
IAO = 143
albedo_flag = 0
else:
no_proc = 1
elif site == "TAS_U":
if year == 2008:
DPT_flag = 3
IAO = 167
assign_nans(143)
elif year in [2009, 2012]:
DPT_flag = 1
elif year == 2010:
z[doy >= 219] -= 8.07
assign_nans(218)
DPT_flag = 2
elif year == 2011:
z[doy >= 203] -= 1.558
assign_nans([202, 222])
DPT_flag = 3
IAO = 161
albedo_flag = 0
elif year == 2013:
DPT_flag = 3
IAO = 167
elif year == 2014:
z[doy >= 216] -= 1.29
assign_nans([138, 215])
DPT_flag = 3
IAO = 136
z[doy >= 138] += 1.27
assign_nans(137)
elif year == 2015:
DPT_flag = 2
else:
no_proc = 1
elif site == "MIT":
if year == 2009:
z[doy >= 224] -= 6.6
assign_nans([124, 223])
DPT_flag = 3
IAO = 222
albedo_flag = 0
elif year == 2010:
DPT_flag = 3
IAO = 190
elif year == 2011:
assign_nans(224)
DPT_flag = 3
IAO = 203
z[doy > 223] -= 0.08
elif year == 2012:
z[doy >= 250] -= 13.70
assign_nans(249)
DPT_flag = 2
elif year in [2013, 2015, 2016]:
DPT_flag = 1
elif year == 2014:
DPT_flag = 3
IAO = 188
elif year == 2017:
assign_nans(207)
DPT_flag = 3
IAO = 208
albedo_flag = 0
elif year == 2018:
DPT_flag = 2
elif year == 2019:
z[doy < 12] += 4.4
DPT_flag = 3
IAO = 186
albedo_flag = 0
else:
no_proc = 1
# stations in the accumulation area are not used for this application
elif site == "EGP" or site == "CEN" or site == "KAN_U":
print("WARNING: No processing available for %s" % site)
DPT_flag = 0
if no_proc == 1:
print("WARNING: No processing available for %s %s" % (site, year))
DPT_flag = 0
if DPT_flag != 3:
IAO = np.nan
albedo = df["Albedo_theta<70d"]
# correction for measurement platform obstruction of the radiometer field
# of view after Aoki et al (2011) that increases average PROMICE BBA by 0.034
albedo += 0.034
if albedo_flag == 0:
albedo[:] = np.nan
if np.sum(np.isnan(albedo)) == len(albedo):
albedo_flag = 0
# adjust DPT to have a null pre-melt season ice ablation
z -= np.nanmean(z[(doy < IAO) & (doy > IAO - 45)])
# determine the start of significant ice ablation (>6cm after IAO)
if DPT_flag == 3 and albedo_flag == 1:
try:
indx = np.where(z[doy > IAO] < -0.06)[0][0]
BID = doy[doy > IAO].iloc[indx]
except IndexError:
BID = np.nan
albedo_flag = 0
else:
BID = np.nan
return z, albedo, DPT_flag, BID, albedo_flag
def plot_variables():
fs = 13
mpl.rc("xtick", labelsize=fs)
mpl.rc("ytick", labelsize=fs)
mpl.rc("lines", markersize=3)
plt.figure(figsize=(10, 15))
ax1 = plt.subplot(411)
ln1 = ax1.plot(
df_y_init["DayOfYear"],
df_y_init["DepthPressureTransducer_Cor(m)"],
"ro-",
label="Raw",
zorder=3,
)
ax1.set_ylabel("Ice ablation (meters)", fontsize=fs, color="b")
ax2 = ax1.twinx()
ln2 = ax2.plot(df_y["DayOfYear"], DPT_proc, "go-", label="Processed", zorder=2)
ax2.set_ylabel("Ice ablation (meters)", fontsize=fs, color="g")
ax2.axhline(0, color="gray", LineStyle="--", zorder=1)
ax2.legend(loc="upper left")
lns = ln1 + ln2
labs = [l.get_label() for l in lns]
plt.legend(lns, labs)
ax1.get_xaxis().set_visible(False)
ax2 = plt.subplot(412, sharex=ax1)
ax2.plot(
df_y_init["DayOfYear"], df_y_init["Albedo_theta<70d"], "o-", color="purple"
)
ax2.set_ylabel("Albedo (unitless)", fontsize=fs, color="purple")
ax2.get_xaxis().set_visible(False)
ax3 = plt.subplot(413, sharex=ax1)
ax3.plot(df_y_init["DayOfYear"], HeightSensorBoom_m, "o-", color="orange")
ax3.set_ylabel("Boom height (meters)", fontsize=fs, color="orange")
ax3.get_xaxis().set_visible(False)
ax4 = plt.subplot(414, sharex=ax1)
ax4.plot(df_y_init["DayOfYear"], df_y_init["AirTemperature(C)"], "ro-")