-
Notifications
You must be signed in to change notification settings - Fork 0
/
1_data_processing.py
2034 lines (1747 loc) · 81 KB
/
1_data_processing.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
# -*- coding: utf-8 -*-
"""
@author: bav@geus.dk
tip list:
%matplotlib inline
%matplotlib qt
import pdb; pdb.set_trace()
"""
import pandas as pd
from datetime import datetime, timedelta
import numpy as np
from scipy.interpolate import interp1d
import progressbar
import matplotlib.pyplot as plt
import firn_temp_lib as ftl
import time
import os
import xarray as xr
import time
import matplotlib
matplotlib.use('Agg')
def interp_pandas(s, kind="quadratic"):
# A mask indicating where `s` is not null
m = s.notna().values
s_save = s.copy()
# Construct an interpolator from the non-null values
# NB 'kind' instead of 'method'!
kw = dict(kind=kind, fill_value="extrapolate")
f = interp1d(s[m].index, s.loc[m].values.reshape(1, -1)[0], **kw)
# Apply this to the indices of the nulls; reconstruct a series
s[~m] = f(s[~m].index)[0]
plt.figure()
s.plot(ax=plt.gca(), marker="o", linestyle="none")
s_save.plot(ax=plt.gca(), marker="o", linestyle="none")
# plt.xlim(0, 60)
return s
needed_cols = ["date", "site", "latitude", "longitude", "elevation", "depthOfTemperatureObservation", "temperatureObserved", "reference", "reference_short", "note", "error", "durationOpen", "durationMeasured", "method"]
# %% Mock and Weeks
print("Loading Mock and Weeks")
df_all = pd.DataFrame(
columns=[ "date", "site", "latitude", "longitude", "elevation", "depthOfTemperatureObservation", "temperatureObserved", "reference", "reference_short", "note", "error", "durationOpen", "durationMeasured", "method"]
)
df_MW = pd.read_excel("Data/MockandWeeks/CRREL RR- 170 digitized.xlsx")
df_MW.loc[df_MW.Month.isnull(), "Day"] = 1
df_MW.loc[df_MW.Month.isnull(), "Month"] = 1
df_MW["date"] = pd.to_datetime(df_MW[["Year", "Month", "Day"]])
df_MW["note"] = "as reported in Mock and Weeks 1965"
df_MW["depthOfTemperatureObservation"] = 10
df_MW = df_MW.rename(
columns={
"Refstationnumber": "site",
"Lat(dec_deg)": "latitude",
"Lon(dec_deg)": "longitude",
"Elevation": "elevation",
"10msnowtemperature(degC)": "temperatureObserved",
"Reference": "reference",
}
)
df_MW = df_MW.loc[df_MW["temperatureObserved"].notnull()]
df_MW["durationOpen"] = "NA"
df_MW["durationMeasured"] = "NA"
df_MW["error"] = 0.5
df_MW[
"method"
] = "thermohms and a Wheats tone bridge, standard mercury or alcohol thermometers"
df_all = pd.concat((df_all,
df_MW[needed_cols],
), ignore_index=True,
)
# %% Benson (not reported in Mock and Weeks)
print("Loading Benson 1962")
df_benson = pd.read_excel("Data/Benson 1962/Benson_1962.xlsx")
df_benson.loc[df_benson.Month.isnull(), "Day"] = 1
df_benson.loc[df_benson.Month.isnull(), "Month"] = 1
df_benson["date"] = pd.to_datetime(df_MW[["Year", "Month", "Day"]])
df_benson["note"] = ""
df_benson["depthOfTemperatureObservation"] = 10
df_benson = df_benson.rename(
columns={
"Refstationnumber": "site",
"Lat(dec_deg)": "latitude",
"Lon(dec_deg)": "longitude",
"Elevation": "elevation",
"10msnowtemperature(degC)": "temperatureObserved",
"Reference": "reference",
}
)
# only keeping measurements not in Mock and Weeks
msk = (df_benson.site == "0-35") | (df_benson.site == "French Camp VI")
df_benson = df_benson.loc[msk, :]
df_benson["durationOpen"] = "measured in pit wall or borehole bottom after excavation"
df_benson["durationMeasured"] = "few minutes"
df_benson["error"] = "NA"
df_benson["method"] = "Weston bimetallic thermometers"
df_all = pd.concat((df_all,
df_benson[needed_cols],
), ignore_index=True,
)
# %% Polashenski
print("Loading Polashenski")
df_Pol = pd.read_csv("Data/Polashenski/2013_10m_Temperatures.csv")
df_Pol.columns = df_Pol.columns.str.replace(" ", "")
df_Pol.date = pd.to_datetime(df_Pol.date, format="%m/%d/%y")
df_Pol["reference"] = "Polashenski, C., Z. Courville, C. Benson, A. Wagner, J. Chen, G. Wong, R. Hawley, and D. Hall (2014), Observations of pronounced Greenland ice sheet firn warming and implications for runoff production, Geophys. Res. Lett., 41, 4238–4246, doi:10.1002/2014GL059806."
df_Pol["reference_short"] = "Polashenski et al. (2014)"
df_Pol["note"] = ""
df_Pol["longitude"] = -df_Pol["longitude"]
df_Pol["depthOfTemperatureObservation"] = (
df_Pol["depthOfTemperatureObservation"].str.replace("m", "").astype(float)
)
df_Pol[
"durationOpen"
] = "string lowered in borehole and left 30min for equilibrating with surrounding firn prior measurement start"
df_Pol["durationMeasured"] = "overnight ~10 hours"
df_Pol["error"] = 0.1
df_Pol["method"] = "thermistor string"
df_all = pd.concat((df_all,
df_Pol[needed_cols],
), ignore_index=True,
)
# %% Stauffer and Oeschger 1979
print('Loading Stauffer and Oeschger measurements')
df_s_o = pd.read_excel("Data/Stauffer and Oeschger 1979/Stauffer&Oeschger1979.xlsx")
df_s_o["reference"] = "Stauffer B. and H. Oeschger. 1979. Temperaturprofile in bohrloechern am rande des Groenlaendischen Inlandeises. Hydrologie und Glaziologie an der ETH Zurich. Mitteilung Nr. 41."
df_s_o["reference_short"] = "Stauffer and Oeschger (1979)"
df_s_o["note"] = "site location estimated by M. Luethi"
df_s_o["method"] = "Fenwal Thermistor UUB 31-J1"
df_s_o["durationOpen"] = 0
df_s_o["durationMeasured"] = 0
df_s_o["error"] = 0.1
df_all = pd.concat((df_all, df_s_o[needed_cols]), ignore_index=True)
# %% Ken's dataset
print("Loading Kens dataset")
df_Ken = pd.read_excel(
"Data/greenland_ice_borehole_temperature_profiles-main/data_filtered.xlsx"
)
df_Ken['reference_short'] = df_Ken.reference_short+' as in Mankoff et al. (2022)'
df_all = pd.concat((df_all, df_Ken[needed_cols]), ignore_index=True)
# %% Thomsen shallow thermistor
df = pd.read_excel("Data/Thomsen/data-formatted.xlsx")
for date in df.date.unique():
tmp = df.loc[df.date == date]
if tmp.temperature.isnull().any():
df.loc[df.date == date, "temperature"] = interp_pandas(
tmp.set_index("depth").temperature
).values
df["depthOfTemperatureObservation"] = df["depth"]
df["temperatureObserved"] = df["temperature"]
df["note"] = "from unpublished pdf"
df["date"] = pd.to_datetime(df.date)
df["reference"] = "Thomsen, H. ., Olesen, O. ., Braithwaite, R. . and Bøggild, C. .: Ice drilling and mass balance at Pâkitsoq, Jakobshavn, central West Greenland, Rapp. Grønlands Geol. Undersøgelse, 152, 80–84, doi:10.34194/rapggu.v152.8160, 1991."
df["reference_short"] = "Thomsen et al. (1991)"
df["method"] = "thermistor"
df["durationOpen"] = "NA"
df["durationMeasured"] = "NA"
df["error"] = 0.2
df_all = pd.concat((df_all, df[needed_cols]), ignore_index=True)
# %% Sumup
df_sumup = pd.read_csv("Data/Sumup/SUMup_temperature_2022.csv")
df_sumup = df_sumup.loc[df_sumup.Latitude > 0]
df_sumup = df_sumup.loc[
df_sumup.Citation != 30
] # Redundant with Miege and containing positive temperatures
df_sumup["date"] = pd.to_datetime(df_sumup.Timestamp)
df_sumup["note"] = "as reported in Sumup"
df_sumup["reference"] = ""
df_sumup["site"] = ""
df_sumup.loc[
df_sumup.Citation == 32, "reference"
] = "Graeter, K., Osterberg, E. C., Ferris, D., Hawley, R. L., Marshall, H. P. and Lewis, G.: Ice Core Records of West Greenland Surface Melt and Climate Forcing, Geophys. Res. Lett., doi:10.1002/2017GL076641, 2018."
df_sumup.loc[
df_sumup.Citation == 32, "reference_short"
] = "Graeter et al. (2018) as in SUMup"
df_sumup.loc[
df_sumup.Citation == 33, "reference"
] = "Lewis, G., Osterberg, E., Hawley, R., Marshall, H. P., Meehan, T., Graeter, K., McCarthy, F., Overly, T., Thundercloud, Z. and Ferris, D.: Recent precipitation decrease across the western Greenland ice sheet percolation zone, Cryosph., 13(11), 2797–2815, doi:10.5194/tc-13-2797- 2019, 2019."
df_sumup.loc[
df_sumup.Citation == 33, "reference_short"
] = "Lewis et al. (2019) as in SUMup"
site_list = pd.DataFrame(
np.array(
[
[44, "GTC01"],
[45, "GTC02"],
[46, "GTC04"],
[47, "GTC05"],
[48, "GTC06"],
[49, "GTC07"],
[50, "GTC08"],
[51, "GTC09"],
[52, "GTC11"],
[53, "GTC12"],
[54, "GTC13"],
[55, "GTC14"],
[56, "GTC15"],
[57, "GTC16"],
]
),
columns=["id", "site"],
).set_index("id")
for ind in site_list.index:
df_sumup.loc[df_sumup.Name == int(ind), "site"] = site_list.loc[ind, "site"]
df_sumup = df_sumup.drop(["Name", "Citation", "Timestamp"], axis=1)
df_sumup = df_sumup.rename(
columns={
"Latitude": "latitude",
"Longitude": "longitude",
"Elevation": "elevation",
"Depth": "depthOfTemperatureObservation",
"Temperature": "temperatureObserved",
"Duration": "durationMeasured",
"Error": "error",
"Open_Time": "durationOpen",
"Method": "method",
}
)
df_all = pd.concat((df_all,
df_sumup[needed_cols],
), ignore_index=True,
)
# ====> only temperature at 18m depth
# %% McGrath
print("Loading McGrath")
df_mcgrath = pd.read_excel(
"Data/McGrath/McGrath et al. 2013 GL055369_Supp_Material.xlsx"
)
df_mcgrath = df_mcgrath.loc[df_mcgrath["Data Type"] != "Met Station"]
df_mcgrath["depthOfTemperatureObservation"] = np.array(
df_mcgrath["Data Type"].str.split("m").to_list()
)[:, 0].astype(int)
df_mcgrath = df_mcgrath.rename(
columns={
"Observed\nTemperature (°C)": "temperatureObserved",
"Latitude\n(°N)": "latitude",
"Longitude (°E)": "longitude",
"Elevation\n(m)": "elevation",
"Reference": "reference",
"Location": "site",
}
)
df_mcgrath["note"] = "as reported in McGrath et al. (2013)"
df_mcgrath["date"] = pd.to_datetime(
(df_mcgrath.Year * 10000 + 101).apply(str), format="%Y%m%d"
)
df_mcgrath["site"] = df_mcgrath["site"].str.replace("B4", "4")
df_mcgrath["site"] = df_mcgrath["site"].str.replace("B5", "5")
df_mcgrath["site"] = df_mcgrath["site"].str.replace("4-425", "5-0")
df_mcgrath["method"] = "digital Thermarray system from RST©"
df_mcgrath["durationOpen"] = 0
df_mcgrath["durationMeasured"] = 30
df_mcgrath["error"] = 0.07
df_mcgrath
df_all = pd.concat((df_all,
df_mcgrath[needed_cols],
), ignore_index=True,
)
# adding real date to Benson's measurement
df_fausto = pd.read_excel(
"Data/misc/Data_Sheet_1_ASnowDensityDatasetforImprovingSurfaceBoundaryConditionsinGreenlandIceSheetFirnModeling.XLSX",
skiprows=[0],
)
df_fausto.Name = df_fausto.Name.str.replace("station ", "")
for site in df_fausto.Name:
if any(df_all.site == site):
if np.sum(df_all.site == site) > 1:
print(
df_all.loc[
df_all.site == site,
["temperatureObserved", "depthOfTemperatureObservation"],
]
)
print("duplicate, removing from McGrath")
df_all = df_all.loc[
~np.logical_and(
df_all.site == site,
df_all["note"] == "as reported in McGrath et al. (2013)",
)
]
print(
site,
df_all.loc[df_all.site == site].date.values,
df_fausto.loc[df_fausto.Name == site, ["year", "Month", "Day"]].values,
)
if (
df_all.loc[df_all.site == site].date.iloc[0].year
== df_fausto.loc[df_fausto.Name == site, ["year"]].iloc[0].values
):
df_all.loc[df_all.site == site, "date"] = (
pd.to_datetime(
df_fausto.loc[df_fausto.Name == site, ["year", "Month", "Day"]]
)
.astype("datetime64[ns]")
.iloc[0]
)
print("Updating date")
else:
print("Different years")
# %% Hawley GrIT
print("Loading Hawley GrIT")
import warnings
warnings.filterwarnings('ignore', category=UserWarning, module='openpyxl')
df_hawley = pd.read_excel("Data/Hawley GrIT/GrIT2011_9m-borehole_calc-temps.xlsx")
df_hawley = df_hawley.rename(
columns={
"Pit name (tabs)": "site",
"Date": "date",
"Lat (dec.degr)": "latitude",
"Long (dec.degr)": "longitude",
"Elevation": "elevation",
"9-m temp": "temperatureObserved",
}
)
df_hawley["depthOfTemperatureObservation"] = 9
df_hawley["note"] = ""
df_hawley[
"reference"
] = "Bob Hawley. 2014. Traverse physical, chemical, and weather observations. arcitcdata.io, doi:10.18739/A2W232. "
df_hawley["reference_short"] = "Hawley (2014) GrIT"
df_hawley = df_hawley.loc[[isinstance(x, float) for x in df_hawley.temperatureObserved]]
df_hawley = df_hawley.loc[df_hawley.temperatureObserved.notnull()]
df_hawley["method"] = "thermistor"
df_hawley["durationOpen"] = 2
df_hawley["durationMeasured"] = 0
df_hawley["error"] = "not reported"
df_all = pd.concat((df_all, df_hawley[needed_cols]), ignore_index=True)
# %% PROMICE
print("Loading PROMICE")
df_promice = pd.read_csv("Data/PROMICE/PROMICE_10m_firn_temperature.csv", sep=";")
df_promice = df_promice.loc[df_promice.temperatureObserved.notnull()]
df_promice = df_promice.loc[df_promice.site != "QAS_A", :]
df_promice.loc[(df_promice.site == "CEN") & (df_promice.temperatureObserved > -18),
"temperatureObserved"] = np.nan
df_promice["method"] = "RS Components thermistors 151-243"
df_promice["durationOpen"] = 0
df_promice["durationMeasured"] = 30 * 24
df_promice["error"] = 0.2
df_promice["note"] = ""
df_all = pd.concat((df_all, df_promice[needed_cols]), ignore_index=True)
# %% GC-Net
print("Loading GC-Net")
df_GCN = pd.read_csv("Data/GC-Net/10m_firn_temperature.csv")
df_GCN = df_GCN.loc[df_GCN.temperatureObserved.notnull()]
df_GCN["method"] = "thermocouple"
df_GCN["durationOpen"] = 0
df_GCN["durationMeasured"] = 30 * 24
df_GCN["error"] = 0.5
msk = ((df_GCN.site=='NASA-SE')
& (df_GCN.date>'1999-01-10')
& (df_GCN.date<'1999-05-10'))
df_GCN.loc[msk, 'temperatureObserved' ] = np.nan
df_all = pd.concat((df_all, df_GCN[needed_cols]), ignore_index=True)
# %% Steffen 2001 table (that could not be found in the GC-Net AWS data)
print('Loading Steffen 2001 table')
df = pd.read_excel("Data/GC-Net/steffen2001.xlsx")
df["depthOfTemperatureObservation"] = 10
df["temperatureObserved"] = df["temperature"]
df["note"] = "annual average"
df["date"] = [pd.to_datetime(str(yr) + "-12-01") for yr in df.year]
df[
"reference"
] = "Steffen, K., Box, J.E. and Abdalati, W., 1996. Greenland climate network: GC-Net. US Army Cold Regions Reattach and Engineering (CRREL), CRREL Special Report, pp.98-103. and Steffen, K. and J. Box: Surface climatology of the Greenland ice sheet: Greenland Climate Network 1995-1999, J. Geophys. Res., 106, 33,951-33,972, 2001 and Steffen, K., Vandecrux, B., Houtz, D., Abdalati, W., Bayou, N., Box, J., Colgan, L., Espona Pernas, L., Griessinger, N., Haas-Artho, D., Heilig, A., Hubert, A., Iosifescu Enescu, I., Johnson-Amin, N., Karlsson, N. B., Kurup, R., McGrath, D., Cullen, N. J., Naderpour, R., Pederson, A. Ø., Perren, B., Philipps, T., Plattner, G.K., Proksch, M., Revheim, M. K., Særrelse, M., Schneebli, M., Sampson, K., Starkweather, S., Steffen, S., Stroeve, J., Watler, B., Winton, Ø. A., Zwally, J., Ahlstrøm, A.: GC-Net Level 1 automated weather station data, https://doi.org/10.22008/FK2/VVXGUT, GEUS Dataverse, V2, 2023. and Vandecrux, B., Box, J.E., Ahlstrøm, A.P., Andersen, S.B., Bayou, N., Colgan, W.T., Cullen, N.J., Fausto, R.S., Haas-Artho, D., Heilig, A., Houtz, D.A., How, P., Iosifescu Enescu , I., Karlsson, N.B., Kurup Buchholz, R., Mankoff, K.D., McGrath, D., Molotch, N.P., Perren, B., Revheim, M.K., Rutishauser, A., Sampson, K., Schneebeli, M., Starkweather, S., Steffen, S., Weber, J., Wright, P.J., Zwally, J., Steffen, K.: The historical Greenland Climate Network (GC-Net) curated and augmented Level 1 dataset, Submitted to ESSD, 2023"
df["reference_short"] = "Historical GC-Net: Steffen et al. (1996, 2001, 2023); Vandecrux et al. (2023)"
df["error"] = 0.5
df_all = pd.concat((df_all, df[needed_cols]), ignore_index=True)
# %% Historical swc
df_swc = pd.DataFrame()
df_swc["depthOfTemperatureObservation"] = [10]*3
df_swc["site"] = ["Swiss Camp"]*3
df_swc["latitude"] = [69.57346306]*3
df_swc["longitude"] = [-49.2955275]*3
df_swc["elevation"] = [1155]*3
df_swc["note"] = [""]*3
df_swc["temperatureObserved"] = [-9.1, -9.3, -9.3]
df_swc["date"] = pd.to_datetime(["1990-07-01","1990-08-01","1990-08-24" ])
df_swc["reference_short"] = ["Ohmura et al. (1992)"]*3
df_swc[
"reference"
] = ["Ohmura, A., Steffen, K., Blatter, H., Greuell, W., Rotach, M., Stober, M., Konzelmann, T., Forrer, J., Abe-Ouchi, A., Steiger, D. and Niederbaumer, G.: Energy and mass balance during the melt season at the equilibrium line altitude. Paakitsoq, Greenland ice sheet: Progress report, 2, 1992."]*3
df_swc["method"] = ["NA"]*3
df_swc["durationOpen"] = ["NA"]*3
df_swc["durationMeasured"] =[ "NA"]*3
df_swc["error"] = ["NA"]*3
df_all = pd.concat((df_all, df_swc[needed_cols]), ignore_index=True)
# %% Miege aquifer
print("Loading firn aquifer data")
metadata = np.array([ ["FA-13", 66.181, 39.0435, 1563],
["FA-15-1", 66.3622, 39.3119, 1664],
["FA-15-2", 66.3548, 39.1788, 1543]])
# mean_accumulation = 1 # m w.e. from Miege et al. 2014
# thickness_accum = 2.7 # thickness of the top 1 m w.e. in the FA13 core
thickness_accum = 1.4 # Burial of the sensor between their installation in Aug 2015 and revisit in Aug 2016
df_miege = pd.DataFrame()
for k, site in enumerate(["FA_13", "FA_15_1", "FA_15_2"]):
depth = pd.read_csv(
"Data/Miege firn aquifer/" + site + "_Firn_Temperatures_Depths.csv"
).transpose()
if k == 0:
depth = depth.iloc[5:].transpose()
else:
depth = depth.iloc[5:, 0]
temp = pd.read_csv("Data/Miege firn aquifer/" + site + "_Firn_Temperatures.csv")
dates = pd.to_datetime((temp.Year * 1000000 + temp.Month * 10000
+ temp.Day * 100 + temp["Hours (UTC)"]).apply(str),
format="%Y%m%d%H")
temp = temp.iloc[:, 4:]
ellapsed_hours = (dates - dates[0]).dt.total_seconds()/60/60
accum_depth = ellapsed_hours.values * thickness_accum / 365 / 24
depth_cor = pd.DataFrame()
depth_cor = depth.values.reshape((1, -1)).repeat(
len(dates), axis=0
) + accum_depth.reshape((-1, 1)).repeat(len(depth.values), axis=1)
df_10 = ftl.interpolate_temperature(
dates, depth_cor, temp.values, title=site + " Miller et al. (2020)"
)
df_10.loc[np.greater(df_10["temperatureObserved"], 0), "temperatureObserved"] = 0
df_10 = df_10.set_index("date", drop=False).resample("M").mean()
df_10["site"] = site
df_10["latitude"] = float(metadata[k, 1])
df_10["longitude"] = -float(metadata[k, 2])
df_10["elevation"] = float(metadata[k, 3])
df_10["depthOfTemperatureObservation"] = 10
df_10[
"reference"
] = "Miller, O., Solomon, D.K., Miège, C., Koenig, L., Forster, R., Schmerr, N., Ligtenberg, S.R., Legchenko, A., Voss, C.I., Montgomery, L. and McConnell, J.R., 2020. Hydrology of a perennial firn aquifer in Southeast Greenland: an overview driven by field data. Water Resources Research, 56(8), p.e2019WR026348. Dataset doi:10.18739/A2R785P5W"
df_10["reference_short"] = "Miller et al. (2020)"
df_10["note"] = "interpolated to 10 m, monthly snapshot"
# plt.figure()
# df_10.temperatureObserved.plot()
df_miege = pd.concat((df_miege, df_10.drop(columns=['date']).reset_index()))
df_miege["method"] = "digital thermarray system from RST©"
df_miege["durationOpen"] = 0
df_miege["durationMeasured"] = 30
df_miege["error"] = 0.07
df_all = pd.concat((df_all, df_miege[needed_cols]), ignore_index=True)
# %% Harper ice temperature
print("Loading Harper ice temperature")
df_harper = pd.read_csv(
"Data/Harper ice temperature/harper_iceTemperature_2015-2016.csv"
)
num_row = df_harper.shape[0]
df_harper["date"] = np.nan
df_harper["temperatureObserved"] = np.nan
df_harper["note"] = ""
df_harper.iloc[:num_row, df_harper.columns.get_loc("borehole")] = df_harper["borehole"].iloc[:num_row] + "_2015"
df_harper.iloc[num_row:, df_harper.columns.get_loc("borehole")] = df_harper["borehole"].iloc[num_row:] + "_2016"
df_harper.iloc[:num_row, df_harper.columns.get_loc("date")] = pd.to_datetime("2015-01-01")
df_harper.iloc[num_row:, df_harper.columns.get_loc("date")] = pd.to_datetime("2016-01-01")
df_harper.iloc[:num_row, df_harper.columns.get_loc("temperatureObserved")] = df_harper["temperature_2015_celsius"].iloc[:num_row]
df_harper.iloc[num_row:, df_harper.columns.get_loc("temperatureObserved")] = df_harper["temperature_2016_celsius"].iloc[num_row:]
df_harper["depth"] = df_harper.depth_m - df_harper.height_m
df_harper = df_harper.loc[df_harper.depth < 100]
df_harper = df_harper.drop(
columns=["height_m", "temperature_2015_celsius", "temperature_2016_celsius", "yearDrilled", "dateDrilled", "depth_m"]
)
df_harper = df_harper.loc[df_harper.temperatureObserved.notnull()]
for borehole in df_harper["borehole"].unique():
# print(borehole, df_harper.loc[df_harper["borehole"] == borehole, "depth"].min())
if df_harper.loc[df_harper["borehole"] == borehole, "depth"].min() > 20:
df_harper = df_harper.loc[df_harper["borehole"] != borehole]
continue
new_row = df_harper.loc[df_harper["borehole"] == borehole].iloc[0, :].copy()
new_row["depth"] = 10
new_row["temperatureObserved"] = np.nan
df_harper = pd.concat((df_harper, new_row))
df_harper = df_harper.set_index(["depth"]).sort_index()
# not interpolating anymore
# plt.figure()
# for borehole in df_harper["borehole"].unique():
# s = df_harper.loc[df_harper["borehole"] == borehole, "temperatureObserved"]
# s.iloc[0] = interp1d(
# s.iloc[1:].index, s.iloc[1:], kind="linear", fill_value="extrapolate"
# )(10)
# s.plot(marker='o',label='_no_legend_')
# df_harper.loc[df_harper['borehole']==borehole,'temperatureObserved'].plot(marker='o',label=borehole)
# plt.legend()
# df_harper.loc[df_harper["borehole"] == borehole, "temperatureObserved"] = s.values
# df_harper.loc[df_harper["borehole"] == borehole, "note"] = (
# "interpolated from " + str(s.iloc[1:].index.values) + " m depth"
# )
df_harper = df_harper.reset_index()
# df_harper = df_harper.loc[df_harper.depth == 10]
df_harper[
"reference"
] = "Hills, B. H., Harper, J. T., Humphrey, N. F., & Meierbachtol, T. W. (2017). Measured horizontal temperature gradients constrain heat transfer mechanisms in Greenland ice. Geophysical Research Letters, 44. https://doi.org/10.1002/2017GL074917; https://doi.org/10.18739/A24746S04"
df_harper["reference_short"] = "Hills et al. (2017)"
df_harper = df_harper.rename(
columns={
"borehole": "site",
"latitude_WGS84": "latitude",
"longitude_WGS84": "longitude",
"Elevation_m": "elevation",
"depth": "depthOfTemperatureObservation",
}
)
df_harper["method"] = "TMP102 digital temperature sensor"
df_harper["durationOpen"] = 0
df_harper["durationMeasured"] = 30 * 24
df_harper["error"] = 0.1
df_all = pd.concat((df_all,
df_harper[needed_cols],
), ignore_index=True,
)
# %% FirnCover
print("Loading FirnCover")
time.sleep(0.2)
filepath = os.path.join("Data/FirnCover/FirnCoverData_2.0_2021_07_30.h5")
sites = ["Summit", "KAN-U", "NASA-SE", "Crawford", "EKT", "Saddle", "EastGrip", "DYE-2"]
statmeta_df, sonic_df, rtd_df, rtd_dep, metdata_df = ftl.load_metadata(filepath, sites)
statmeta_df["elevation"] = [1840, 2119, 2361, 2370, 2456, 1942, 3208, 2666]
rtd_df = rtd_df.reset_index()
rtd_df = rtd_df.set_index(["sitename", "date"])
df_firncover = pd.DataFrame()
for site in sites:
df_d = rtd_df.xs(site, level="sitename").reset_index()
# df_d.to_csv('FirnCover_'+site+'.csv')
df_10 = ftl.interpolate_temperature(
df_d["date"],
df_d[["depth_" + str(i) for i in range(24)]].values,
df_d[["rtd" + str(i) for i in range(24)]].values,
title=site + " FirnCover",
)
df_10 = df_10.set_index("date").resample("M").mean().reset_index()
df_10["site"] = site
if site == "Crawford":
df_10["site"] = "CP1"
df_10["latitude"] = statmeta_df.loc[site, "latitude"]
df_10["longitude"] = statmeta_df.loc[site, "longitude"]
df_10["elevation"] = statmeta_df.loc[site, "elevation"]
df_firncover = pd.concat((df_firncover, df_10))
df_firncover[
"reference"
] = "MacFerrin, M. J., Stevens, C. M., Vandecrux, B., Waddington, E. D., and Abdalati, W. (2022) The Greenland Firn Compaction Verification and Reconnaissance (FirnCover) dataset, 2013–2019, Earth Syst. Sci. Data, 14, 955–971, https://doi.org/10.5194/essd-14-955-2022,"
df_firncover["reference_short"] = "MacFerrin et al. (2021, 2022)"
df_firncover["note"] = ""
df_firncover["depthOfTemperatureObservation"] = 10
# Correction of FirnCover bias
p = np.poly1d([1.03093649, -0.49950273])
df_firncover["temperatureObserved"] = p(df_firncover["temperatureObserved"].values)
df_firncover["method"] = "Resistance Temperature Detectors + correction"
df_firncover["durationOpen"] = 0
df_firncover["durationMeasured"] = 30 * 24
df_firncover["error"] = 0.5
df_all = pd.concat((df_all,
df_firncover[needed_cols],
), ignore_index=True,
)
# %% SPLAZ KAN_U
print("Loading SPLAZ at KAN-U")
site = "KAN_U"
num_therm = [32, 12, 12]
df_splaz = pd.DataFrame()
for k, note in enumerate(["SPLAZ_main", "SPLAZ_2", "SPLAZ_3"]):
ds = xr.open_dataset("Data/SPLAZ/T_firn_KANU_" + note + ".nc")
df = ds.to_dataframe()
df.reset_index(inplace=True)
df2 = pd.DataFrame()
df2["date"] = df.loc[df["level"] == 1, "time"]
for i in range(1, num_therm[k] + 1):
df2["rtd" + str(i - 1)] = df.loc[df["level"] == i, "Firn temperature"].values
df2["depth_" + str(i - 1)] = df.loc[df["level"] == i, "depth"].values
df2[df2 == -999] = np.nan
df2 = df2.set_index(["date"]).resample("D").mean()
df_10 = ftl.interpolate_temperature(
df2.index,
df2[["depth_" + str(i) for i in range(num_therm[k])]].values,
df2[["rtd" + str(i) for i in range(num_therm[k])]].values,
min_diff_to_depth=1.5,
kind="linear",
title="KAN_U " + note,
)
# for i in range(10):
# plt.figure()
# plt.plot(df2.iloc[i*20,0:12].values,-df2.iloc[i*20,12:].values)
# plt.plot(df_10.iloc[i*20,1],-10,marker='o')
# plt.title(df2.index[i*20])
# plt.xlim(-15,0)
df_10 = df_10.set_index("date").resample("M").mean().reset_index()
df_10["note"] = note
df_10["latitude"] = 67.000252
df_10["longitude"] = -47.022999
df_10["elevation"] = 1840
df_splaz = pd.concat((df_splaz, df_10))
df_splaz[
"reference"
] = "Charalampidis, C., Van As, D., Colgan, W.T., Fausto, R.S., Macferrin, M. and Machguth, H., 2016. Thermal tracing of retained meltwater in the lower accumulation area of the Southwestern Greenland ice sheet. Annals of Glaciology, 57(72), pp.1-10."
df_splaz["reference_short"] = "Charalampidis et al. (2016); Charalampidis et al. (2022) "
df_splaz["site"] = site
df_splaz["depthOfTemperatureObservation"] = 10
df_splaz["method"] = "RS 100 kΩ negative-temperature coefficient thermistors"
df_splaz["durationOpen"] = 0
df_splaz["durationMeasured"] = 30 * 24
df_splaz["error"] = 0.2
df_all = pd.concat((df_all, df_splaz[needed_cols]), ignore_index=True)
# %% Load Humphrey data
print("loading Humphrey")
df = pd.read_csv("Data/Humphrey string/location.txt", delim_whitespace=True)
df_humphrey = pd.DataFrame(
columns=["site", "latitude", "longitude", "elevation", "date", "T10m"]
)
for site in df.site:
try:
df_site = pd.read_csv(
"Data/Humphrey string/" + site + ".txt",
header=None,
delim_whitespace=True,
names=["doy"] + ["IceTemperature" + str(i) + "(C)" for i in range(1, 33)],
)
except: # Exception as e:
# print(e)
continue
print(site)
temp_label = df_site.columns[1:]
# the first column is a time stamp and is the decimal days after the first second of January 1, 2007.
df_site["time"] =[ pd.to_datetime('2007-01-01') + pd.Timedelta(days=d) for d in df_site.iloc[:, 0]]
if site == "T1old":
df_site["time"] = [
datetime(2006, 1, 1) + timedelta(days=d) for d in df_site.iloc[:, 0]
]
df_site = df_site.loc[df_site["time"] <= df_site["time"].values[-1], :]
df_site = df_site.set_index("time")
df_site = df_site.resample("H").mean()
depth = [0.25, 0.50, 0.75, 1.00, 1.25, 1.50, 1.75, 2.00, 2.25, 2.50, 2.75, 3.00, 3.25, 3.50, 3.75, 4.00, 4.25, 4.50, 4.75, 5.00, 5.25, 5.00, 5.50, 6.00, 6.50, 7.00, 7.50, 8.00, 8.50, 9.00, 9.50, 10.0]
if site != "H5": df_site = df_site.iloc[24 * 30 :, :]
if site == "T4": df_site = df_site.loc[:"2007-12-05"]
if site == "H2": depth = np.array(depth) - 1
if site == "H4": depth = np.array(depth) - 0.75
if site in ["H3", "G165", "T1new"]: depth = np.array(depth) - 0.50
df_hs = pd.read_csv("Data/Humphrey string/" + site + "_surface_height.csv")
df_hs.time = pd.to_datetime(df_hs.time)
df_hs = df_hs.set_index("time")
df_hs = df_hs.resample("H").mean()
df_site["surface_height"] = np.nan
df_site["surface_height"] = df_hs.iloc[df_hs.index.get_indexer(df_site.index, method="nearest")].values
depth_label = ["depth_" + str(i) for i in range(1, len(temp_label) + 1)]
for i in range(len(temp_label)):
df_site[depth_label[i]] = (
depth[i] + df_site["surface_height"].values - df_site["surface_height"].iloc[0]
)
if site != "H5":
df_site[temp_label[i]] = (
df_site[temp_label[i]].rolling(24 * 3, center=True).mean().values
)
df_10 = ftl.interpolate_temperature(
df_site.index,
df_site[depth_label].values,
df_site[temp_label].values,
title=site + " Humphrey et al. (2012)",
)
df_10 = df_10.set_index("date").resample("M").mean().reset_index()
df_10["site"] = site
df_10["latitude"] = df.loc[df.site == site, "latitude"].values[0]
df_10["longitude"] = df.loc[df.site == site, "longitude"].values[0]
df_10["elevation"] = df.loc[df.site == site, "elevation"].values[0]
df_humphrey = pd.concat((df_humphrey, df_10))
df_humphrey = df_humphrey.reset_index(drop=True)
df_humphrey = df_humphrey.loc[df_humphrey.temperatureObserved.notnull()]
df_humphrey["depthOfTemperatureObservation"] = 10
df_humphrey["reference"] = "Humphrey, N. F., Harper, J. T., and Pfeffer, W. T. (2012), Thermal tracking of meltwater retention in Greenlands accumulation area, J. Geophys. Res., 117, F01010, doi:10.1029/2011JF002083. Data available at: https://instaar.colorado.edu/research/publications/occasional-papers/firn-stratigraphy-and-temperature-to-10-m-depth-in-the-percolation-zone-of/"
df_humphrey["reference_short"] = "Humphrey et al. (2012)"
df_humphrey["note"] = "no surface height measurements, using interpolating surface height using CP1 and SwissCamp stations"
df_humphrey["method"] = "sealed 50K ohm thermistors"
df_humphrey["durationOpen"] = 0
df_humphrey["durationMeasured"] = 30 * 24
df_humphrey["error"] = 0.5
df_all = pd.concat((df_all, df_humphrey[needed_cols]), ignore_index=True)
# %% loading Hills
print("Loading Hills")
df_meta = pd.read_csv("Data/Hills/metadata.txt", sep=" ")
df_meta.date_start = pd.to_datetime(df_meta.date_start, format="%m/%d/%y")
df_meta.date_end = pd.to_datetime(df_meta.date_end, format="%m/%d/%y")
df_meteo = pd.read_csv("Data/Hills/Hills_33km_meteorological.txt", sep="\t")
df_meteo["date"] = pd.to_datetime("2014-07-18") + pd.to_timedelta((df_meteo.Time.values - 197) *24*60, unit='minute').round('T')
df_meteo = df_meteo.set_index("date").resample("D").mean()
df_meteo["surface_height"] = df_meteo.DistanceToTarget.iloc[0] - df_meteo.DistanceToTarget
df_hills = pd.DataFrame()
for site in df_meta.site[:-1]:
print(site)
df = pd.read_csv("Data/Hills/Hills_" + site + "_IceTemp.txt", sep="\t")
df["date"] = [
df_meta.loc[df_meta.site == site, "date_start"].values[0]
+ pd.Timedelta(int(f * 24 * 60 * 60), "seconds")
for f in (df.Time.values - int(df.Time.values[0]))
]
df = df.set_index("date")
df["surface_height"] = np.nan
df.loc[[i in df_meteo.index for i in df.index], "surface_height"] = df_meteo.loc[
[i in df.index for i in df_meteo.index], "surface_height"
]
df["surface_height"] = df.surface_height.interpolate(
method="linear", limit_direction="both"
)
if all(np.isnan(df.surface_height)):
df["surface_height"] = 0
plt.figure()
df.surface_height.plot()
plt.title(site)
depth = df.columns[1:-1].str.replace("Depth_", "").values.astype(float)
print(len(depth))
temp_label = ["temp_" + str(len(depth) - i) for i in range(len(depth))]
depth_label = ["depth_" + str(len(depth) - i) for i in range(len(depth))]
for i in range(len(temp_label)):
df = df.rename(columns={df.columns[i + 1]: temp_label[i]})
df.iloc[:14, i + 1] = np.nan
if site in ["T-14", "T-11b"]:
df.iloc[:30, i + 1] = np.nan
df[depth_label[i]] = (
depth[i] + df["surface_height"].values - df["surface_height"].iloc[0]
)
df = df.resample("D").mean()
df_10 = ftl.interpolate_temperature(
df.index,
df[depth_label].values,
df[temp_label].values,
title=site,
)
df_10 = df_10.set_index("date").resample("M").mean().reset_index()
df_10["latitude"] = df_meta.latitude[df_meta.site == site].iloc[0]
df_10["longitude"] = df_meta.longitude[df_meta.site == site].iloc[0]
df_10["elevation"] = df_meta.elevation[df_meta.site == site].iloc[0]
df_10["depthOfTemperatureObservation"] = 10
df_10["site"] = site
df_hills = pd.concat((df_hills, df_10))
df_hills["note"] = "monthly mean, interpolated at 10 m"
df_hills[
"reference"
] = "Hills, B. H., Harper, J. T., Meierbachtol, T. W., Johnson, J. V., Humphrey, N. F., and Wright, P. J.: Processes influencing heat transfer in the near-surface ice of Greenlands ablation zone, The Cryosphere, 12, 3215–3227, https://doi.org/10.5194/tc-12-3215-2018, 2018. data: https://doi.org/10.18739/A2QV3C418"
df_hills["reference_short"] = "Hills et al. (2018)"
df_hills[
"method"
] = "digital temperature sensor model DS18B20 from Maxim Integrated Products, Inc."
df_hills["durationOpen"] = 0
df_hills["durationMeasured"] = 30 * 24
df_hills["error"] = 0.0625
df_all = pd.concat((df_all, df_hills[needed_cols]), ignore_index=True)
# %% Achim Dye-2
from datetime import datetime
print("Loading Achim Dye-2")
# loading temperature data
df = pd.read_csv("Data/Achim/CR1000_PT100.txt", header=None)
df.columns = [ "time_matlab", "temp_1", "temp_2", "temp_3", "temp_4", "temp_5", "temp_6", "temp_7", "temp_8"]
df["time"] = pd.to_datetime(
[
datetime.fromordinal(int(matlab_datenum))
+ timedelta(days=matlab_datenum % 1)
- timedelta(days=366)
for matlab_datenum in df.time_matlab
]
)
df = df.set_index("time")
df = df.resample("D").mean().drop(columns="time_matlab")
# loading surface height data
df_surf = pd.read_csv("Data/Achim/CR1000_SR50.txt", header=None)
df_surf.columns = ["time_matlab", "sonic_m", "height_above_upgpr"]
df_surf["time"] = pd.to_datetime(
[
datetime.fromordinal(int(matlab_datenum))
+ timedelta(days=matlab_datenum % 1)
- timedelta(days=366)
for matlab_datenum in df_surf.time_matlab
]
)
df_surf = df_surf.set_index("time")
df_surf = (
df_surf.resample("D").mean().drop(columns=["time_matlab", "height_above_upgpr"])
)
# loading surface height data from firncover
filepath = os.path.join("Data/FirnCover/FirnCoverData_2.0_2021_07_30.h5")
sites = ["Summit", "KAN-U", "NASA-SE", "Crawford", "EKT", "Saddle", "EastGrip", "DYE-2"]
_, sonic_df, _, _, _ = ftl.load_metadata(filepath, sites)
sonic_df = sonic_df.xs("DYE-2", level="sitename").reset_index()
sonic_df = sonic_df.set_index("date").drop(columns="delta").resample("D").mean()
sonic_df = pd.concat((sonic_df, df_surf.loc[sonic_df.index[-1] :] - 1.83))
plt.figure()
sonic_df.sonic_m.plot()
df_surf.sonic_m.plot()
sonic_df = sonic_df.resample("D").mean()
df["surface_height"] = -(
sonic_df.loc[df.index[0] : df.index[-1]] - sonic_df.loc[df.index[0]]
).values
depth = 3.4 - np.array([3, 2, 1, 0, -1, -2, -4, -6])
temp_label = ["temp_" + str(i + 1) for i in range(len(depth))]
depth_label = ["depth_" + str(i + 1) for i in range(len(depth))]
for i in range(len(depth)):
df[depth_label[i]] = (
depth[i] + df["surface_height"].values - df["surface_height"].iloc[0]
)
df.loc["2018-05-18":, "depth_1"] = df.loc["2018-05-18":, "depth_1"].values - 1.5
df.loc["2018-05-18":, "depth_2"] = df.loc["2018-05-18":, "depth_2"].values - 1.84
# ds = xr.open_dataset('Data/Achim/T_firn_DYE-2_16.nc')
# df = ds.to_dataframe()
# df = df.reset_index(0).groupby('level').resample('D').mean()
# df.reset_index(0,inplace=True, drop=True)
# df.reset_index(inplace=True)
# df_d = pd.DataFrame()
# df_d['date'] = df.loc[df['level']==1,'time']
# for i in range(1,9):
# df_d['rtd'+str(i)] = df.loc[df['level']==i,'Firn temperature'].values
# for i in range(1,9):
# df_d['depth_'+str(i)] = df.loc[df['level']==i,'depth'].values
# df.to_csv('Heilig_Dye-2_thermistor.csv')
df_achim = ftl.interpolate_temperature(
df.index, df[depth_label].values, df[temp_label].values, title="Dye-2 Achim"
)
df_achim = df_achim.set_index("date").resample("M").mean().reset_index()
df_achim["site"] = "DYE-2"
df_achim["latitude"] = 66.4800
df_achim["longitude"] = -46.2789
df_achim["elevation"] = 2165.0
df_achim["depthOfTemperatureObservation"] = 10
df_achim[
"note"
] = "interpolated at 10 m, monthly mean, using surface height from FirnCover station"
df_achim[
"reference"
] = "Heilig, A., Eisen, O., MacFerrin, M., Tedesco, M., and Fettweis, X.: Seasonal monitoring of melt and accumulation within the deep percolation zone of the Greenland Ice Sheet and comparison with simulations of regional climate modeling, The Cryosphere, 12, 1851–1866, https://doi.org/10.5194/tc-12-1851-2018, 2018. "
df_achim["reference_short"] = "Heilig et al. (2018)"
df_achim["method"] = "thermistors"
df_achim["durationOpen"] = 0
df_achim["durationMeasured"] = 30 * 24
df_achim["error"] = 0.25
df_all = pd.concat((df_all, df_achim[needed_cols]), ignore_index=True)
# %% Camp Century Climate
print("Loading Camp Century data")
df = pd.read_csv("Data/Camp Century Climate/data_long.txt", sep=",", header=None)
df = df.rename(columns={0: "date"})
df["date"] = pd.to_datetime(df.date)
df[df == -999] = np.nan
df = df.set_index("date").resample("D").first()
df = df.iloc[:, :-2]
df_promice = pd.read_csv(
"C:/Users/bav/OneDrive - Geological survey of Denmark and Greenland/Code/PROMICE/PROMICE-AWS-toolbox/out/v03_L3/CEN_hour_v03_L3.txt",
sep="\t",
)
df_promice[df_promice == -999] = np.nan
df_promice = df_promice.rename(columns={"time": "date"})
df_promice["date"] = pd.to_datetime(df_promice.date)
df_promice = df_promice.set_index("date").resample("D").first()
df_promice = df_promice["SurfaceHeight_summary(m)"]
df_cen2 = pd.read_csv('Data/Camp Century Climate/CEN2_day.csv')
df_cen2['time'] = pd.to_datetime(df_cen2.time, utc=True)
df_cen2 = df_cen2.set_index('time')[['z_boom_l']].resample('D').first()
df_cen2["SurfaceHeight_summary(m)"] = 2.1130 - df_cen2.z_boom_l + 1.9
df_cen2.loc[:'2021-08-24',"SurfaceHeight_summary(m)"] = np.nan
df_cen2.loc['2022-06-17':,"SurfaceHeight_summary(m)"] =df_cen2.loc['2022-06-17':,"SurfaceHeight_summary(m)"] + 0.85
df_promice = pd.concat((df_promice, df_cen2["SurfaceHeight_summary(m)"] ))
df_promice = df_promice.resample('D').mean().interpolate()
temp_label = ["T_" + str(i + 1) for i in range(len(df.columns))]
depth_label = ["depth_" + str(i + 1) for i in range(len(df.columns))]
df["surface_height"] = df_promice.loc[df.index[0].strftime('%Y-%m-%d'):df.index[-1].strftime('%Y-%m-%d')].values
depth = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 53, 58, 63, 68, 73]
for i in range(len(temp_label)):
df = df.rename(columns={i + 1: temp_label[i]})
df[depth_label[i]] = (
depth[i] + df["surface_height"].values - df["surface_height"].iloc[0]
)
df_10 = ftl.interpolate_temperature(