-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_all_fgd.pro
2826 lines (2198 loc) · 70.1 KB
/
plot_all_fgd.pro
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
pro pa
;;;;;;;;;;
read_mod=1
read_proxy=1
make_zon_plots=1 ; plot zonal mean ensemble mean [default=0 or 1]
make_map_plots=1 ; plot maps ensemble mean [default=0 or 1;=1 for TS]
make_map_mod_plots=0 ; plot maps of each individual model [default=0]
make_gmt_plots=0 ; plot gmst [default=0 or 1]
rev_lgm=0 ; re-reverse LGM [default=0;=1 for TS]
all_proxies=0 ; plot all proxies [default=0;=1 for TS]
make_nodata=0 ; plot maps without data [default=0;=1 for TS version B]
latlonlabels=0 ; label lats/lons [default=0;=1 for TS]
make_csv_map=1
make_csv_gmt=0
;;;;;;;;;;
;;;;;;;;;;
; becasue IDL default plot sizes get overwritten when using met-idl
; routines, and I can't figure out how to re-set them.
if (make_gmt_plots eq 1) then begin
make_map_plots=0
endif
;;;;;;;;;;
make_pdf=0
make_png=0
do_checks=0 ; plot extra lines on zonal mean plots [default=0]
do_tcheck=0 ; plot old and new values of historical obs [default=0]
do_mod_leg=0 ; plot model names on model zonal mean lines [default=0]
plot_names_gmt=0 ; plot model names on gmst plot [default=0]
do_dots=1 ; plot circles at centre of assessed obs of GMST [default=1]
;;;;;;;;;;
;;;;;;;;;;
nlim_count=5
;;;;;;;
problem_missing=[-1,-1,-1]
; no missing data
pl_data_sat='salzmann'
;pl_data_sst='dowsett'
;pl_data_sst='pliovar'
pl_data_sst='pliovar_erin_pangaea'
lg_data_sat='bartlein'
;lg_data_sat_add=''
lg_data_sat_add='cleator'
;lg_data_sst='tierney-2019-grid'
lg_data_sst='tierney-2020-grid'
;lg_data_sst='tierney-2020'
eo_data_all='inglis'
do_opp=0 ; =1 to overplot SAT on SST and vice-versa
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; definitions and names
ntime=3
; ** change ntime
timnames=strarr(ntime)
timnames(0:ntime-1)=['pl','lg','eo']
timnameslong=strarr(ntime)
timnameslong(0:ntime-1)=['MPWP','LGM','EECO']
mipnames=strarr(ntime)
mipnames(0:ntime-1)=['PlioMIP','PMIP4','DeepMIP']
; ** change ntime
fact_mod_sign=fltarr(ntime)
fact_mod_sign(*)=[1,-1,1]
name_sign=strarr(ntime)
name_sign(*)=''
if (rev_lgm eq 1) then begin
fact_mod_sign(1)=fact_mod_sign(1)*(-1)
name_sign(1)='_-1'
make_zon_plots=0
make_gmt_plots=0
endif
; ** change ntime
topofile=strarr(ntime)
topovar=strarr(ntime)
topofile(0:ntime-1)=['pl_mask/Plio_enh_topo_v1.0_regrid.nc','lg_mask/peltier_ice4g_orog_21_regrid.nc','eo_mask/herold_etal_eocene_topo_1x1.nc']
topovar(0:ntime-1)=['p4_topo','orog','topo']
; ** change ntime
; ** change nmod
nmod=intarr(ntime)
nmod(0:ntime-1)=[17,9,7]
nmodmax=max(nmod)
; ** change ntime
; ** change nmod
modnames=strarr(ntime,nmodmax)
modnames(0,0:nmod(0)-1)=['CCSM4','CCSM4-UoT','CCSM4-Utrecht','CESM1.2','CESM2.0','COSMOS','EC-Earth3.3','GISS-E2-1-G','HadCM3','HadGEM3','IPSL-CM6A-LR','IPSLCM5A','IPSLCM5A2','MIROC4m','MRI-CGCM2.3','NorESM-L','NorESM1-F']
modnames(1,0:nmod(1)-1)=['MPI-ESM1-2-LR','AWIESM1','AWIESM2','CESM1_2','CESM2_1','INM-CM4-8','IPSLCM5A2','MIROC-ES2L','UofT-CCSM4']
modnames(2,0:nmod(2)-1)=['CESM1.2_CAM5-deepmip_stand_6xCO2','COSMOS-landveg_r2413-deepmip_sens_4xCO2','GFDL_CM2.1-deepmip_stand_6xCO2','GFDL_CM2.1-deepmip_sens_4xCO2','INM-CM4-8-deepmip_stand_6xCO2','NorESM1_F-deepmip_sens_4xCO2','CESM2.1slab_3x']
; ** change ntime
extenszon=strarr(ntime)
extensmap=strarr(ntime)
extenszon(0:ntime-1)=['','','_forzon']
extensmap(0:ntime-1)=['','','_formap']
; ** change ntime
; ** change nmod
modcol=intarr(ntime,nmodmax)
modcol(0,0:nmod(0)-1)=[1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3]
modcol(1,0:nmod(1)-1)=[1,2,3,4,5,6,7,1,2]
modcol(2,0:nmod(2)-1)=[1,2,3,4,5,6,7]
nvar=2
; ** change ntime
varname=strarr(ntime,nvar)
varname(0,0:nvar-1)=['tas','tos']
varname(1,0:nvar-1)=['tas','tos']
varname(2,0:nvar-1)=['tas','tos']
varnamelong=strarr(nvar)
varnamelong(0:nvar-1)=['NearSurfaceTemperature','SST']
varnameshort=strarr(nvar)
varnameshort(0:nvar-1)=['tas','tos']
varnametitle=strarr(nvar)
varnametitle(0:nvar-1)=['SAT','SST']
; ** change ntime
varnamemod=strarr(ntime,nmodmax,nvar)
varnamemod(0,0:nmod(0)-1,0)='tas'
varnamemod(0,0:nmod(0)-1,1)='tos'
varnamemod(1,0:nmod(1)-1,0)='tas'
varnamemod(1,0:nmod(1)-1,1)='tos'
varnamemod(2,0:nmod(2)-1,0)='tas'
varnamemod(2,0:nmod(2)-1,1)='tos'
; ** change ntime and nmod
exist_data=intarr(ntime,nmodmax,nvar)
exist_data(0,0:nmod(0)-1,*)=1 ; all plio exist
exist_data(1,0:nmod(1)-1,*)=1 ; all LGM exist
exist_data(2,0:nmod(2)-1,*)=1 ; all eocene exist
; ** change ntime and nmod
plot_zon=intarr(ntime,nmodmax)
plot_zon(0,0:nmod(0)-1)=1 ; plot all plio zon
plot_zon(1,0:nmod(1)-1)=1 ; plot all LGM zon
plot_zon(2,0:nmod(2)-1)=[1,1,1,1,1,0,0] ; don't plot eocene CESM2 or NorESM zon
nx=360
ny=180
lats=fltarr(ny)
lons=fltarr(nx)
lons=findgen(nx)
lats=-89.5+findgen(ny)
latsedge=fltarr(ny+1)
latsedge=-90+findgen(ny+1)
weight_lat=fltarr(ny)
for j=0,ny-1 do begin
weight_lat(j)=(sin(latsedge(j+1)*2*!pi/360.0)-sin(latsedge(j)*2*!pi/360.0))
endfor
weight_lat(0:ny-1)=weight_lat(0:ny-1)/total(weight_lat(0:ny-1),/NAN)
; ** change ntime
; y-scale for zonal mean plot
my_yrange5=intarr(ntime,nvar,2)
my_yrange5(0,0,*)=[-5,20]
my_yrange5(1,0,*)=[-5,20]
my_yrange5(2,0,*)=[-10,55]
my_yrange5(0,1,*)=[-3,13]
my_yrange5(1,1,*)=[-3,13]
my_yrange5(2,1,*)=[-10,40]
; ** change ntime
temp_min_e=fltarr(ntime,nvar)
temp_max_e=fltarr(ntime,nvar)
nnstep=fltarr(ntime,nvar)
my_ndecs=intarr(ntime,nvar)
my_ncols=20
;;;;;
if (my_ncols eq 21) then begin
; colour for sat map
temp_min_e(*,0)=[-19,-19,-19]
temp_max_e(*,0)=[19,19,19]
nnstep(*,0)=[2,2,2]
my_ndecs(*,0)=[1,1,1]
; colour for sst map
temp_min_e(*,1)=[-4.75,-4.75,-19]
temp_max_e(*,1)=[4.75,4.75,19]
nnstep(*,1)=[0.5,0.5,2]
my_ndecs(*,1)=[2,2,1]
endif
if (my_ncols eq 20) then begin
; colour for sat map
temp_min_e(*,0)=[-18,-18,-18]
temp_max_e(*,0)=[18,18,18]
nnstep(*,0)=[2,2,2]
my_ndecs(*,0)=[1,1,1]
; colour for sst map
temp_min_e(*,1)=[-4.5,-4.5,-18]
temp_max_e(*,1)=[4.5,4.5,18]
nnstep(*,1)=[0.5,0.5,2]
my_ndecs(*,1)=[2,2,1]
endif
legendline=[-45,-35]
legendtext=-30
linestyle_mod=0
linestyle_band=2
name_all=''
if (all_proxies eq 1) then begin
name_all='_allproxies'
endif
;;;;;
;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Now read in the model data...
if (read_mod eq 1) then begin
mod_map=fltarr(nx,ny,nmodmax,ntime,nvar)
modmean_map=fltarr(nx,ny,ntime,nvar)
modaver_map=fltarr(nx,ny,ntime,nvar)
ensmean_map=fltarr(nx,ny,ntime,nvar)
ensmean_mask=fltarr(nx,ny,ntime,nvar)
ensaver_map=fltarr(nx,ny,ntime,nvar)
ensaver_mask=fltarr(nx,ny,ntime,nvar)
ensmean_zon=fltarr(ny,ntime,nvar)
ensmean_zon_check1=fltarr(ny,ntime,nvar)
ensmean_zon_check2=fltarr(ny,ntime,nvar)
ensaver_zon=fltarr(ny,ntime,nvar)
ensaver_zon_check1=fltarr(ny,ntime,nvar)
ensaver_zon_check2=fltarr(ny,ntime,nvar)
mod_zon=fltarr(ny,nmodmax,ntime,nvar)
topo_map=fltarr(nx,ny,ntime)
mod_gmt=fltarr(nmodmax,ntime,nvar)
dummy_zon=fltarr(ny)
dummy_map=fltarr(nx,ny)
for t=0,ntime-1 do begin
for v=0,nvar-1 do begin
for m=0,nmod(t)-1 do begin
if (exist_data(t,m,v) eq 1) then begin
; read individual models zonal mean (mod_zon(j,m,t,v))
print,modnames(t,m)
filenamex=timnames(t)+'_mod/mod_'+modnames(t,m)+'_'+timnames(t)+'-pi'+'_'+varnamelong(v)+'_zonmean.nc'
print,filenamex
id1=ncdf_open(filenamex)
ncdf_varget,id1,varnamemod(t,m,v),dummy_zon
; check for missing values
missing_value=-9999.99
aa=ncdf_varinq(id1,varnamemod(t,m,v))
natts=aa.Natts
for x=0,natts-1 do begin
bb=ncdf_attname(id1,varnamemod(t,m,v),x)
;print,bb
if (bb eq 'missing_value') then begin
ncdf_attget,id1,varnamemod(t,m,v),'missing_value',missing_value
;print,'missing is:',missing_value
endif
endfor
i = WHERE(dummy_zon EQ missing_value, count)
IF (count GT 0) THEN dummy_zon[i] = !VALUES.F_NAN
mod_zon(*,m,t,v)=fact_mod_sign(t)*dummy_zon
ncdf_close,id1
; calculate global mean (N.B. not correct for SST as mean of zonal mean)
mod_gmt(m,t,v)=total(mod_zon(*,m,t,v)*weight_lat(*),/nan)*fact_mod_sign(t)
; read individual model maps (mod_map(i,j,m,t,v))
filenamex=timnames(t)+'_mod/mod_'+modnames(t,m)+'_'+varnamelong(v)+'_'+timnames(t)+'-pi.nc'
print,filenamex
id1=ncdf_open(filenamex)
ncdf_varget,id1,varname(t,v),dummy_map
; check for missing values
missing_value=-9999.99
aa=ncdf_varinq(id1,varname(t,v))
natts=aa.Natts
for x=0,natts-1 do begin
bb=ncdf_attname(id1,varname(t,v),x)
;print,bb
if (bb eq 'missing_value') then begin
ncdf_attget,id1,varname(t,v),'missing_value',missing_value
;print,'missing is:',missing_value
endif
endfor
i = WHERE(dummy_map EQ missing_value, count)
IF (count GT 0) THEN dummy_map[i] = !VALUES.F_NAN
mod_map(*,*,m,t,v)=fact_mod_sign(t)*dummy_map
ncdf_close,id1
endif else begin
mod_zon(*,m,t,v)=!VALUES.F_NAN
mod_gmt(m,t,v)=!VALUES.F_NAN
endelse
endfor ; end m
; read ensemble mean zonal mean ensmean_zon(j,j,v)
filenamex=timnames(t)+'_mod/ensmean_'+timnames(t)+'-pi'+'_'+varnamelong(v)+'_zonmean'+extenszon(t)+'.nc'
print,filenamex
id1=ncdf_open(filenamex)
ncdf_varget,id1,varname(t,v),dummy_zon
; check for missing values
missing_value=-9999.99
aa=ncdf_varinq(id1,varname(t,v))
natts=aa.Natts
for x=0,natts-1 do begin
bb=ncdf_attname(id1,varname(t,v),x)
;print,bb
if (bb eq 'missing_value') then begin
ncdf_attget,id1,varname(t,v),'missing_value',missing_value
;print,'missing is:',missing_value
endif
endfor
i = WHERE(dummy_zon EQ missing_value, count)
IF (count GT 0) THEN dummy_zon[i] = !VALUES.F_NAN
ensmean_zon(*,t,v)=fact_mod_sign(t)*dummy_zon
ncdf_close,id1
; read ensemble aver zonal mean ensaver_zon(j,j,v)
filenamex=timnames(t)+'_mod/ensavg_'+timnames(t)+'-pi'+'_'+varnamelong(v)+'_zonmean'+extenszon(t)+'.nc'
print,filenamex
id1=ncdf_open(filenamex)
ncdf_varget,id1,varname(t,v),dummy_zon
; check for missing values
missing_value=-9999.99
aa=ncdf_varinq(id1,varname(t,v))
natts=aa.Natts
for x=0,natts-1 do begin
bb=ncdf_attname(id1,varname(t,v),x)
;print,bb
if (bb eq 'missing_value') then begin
ncdf_attget,id1,varname(t,v),'missing_value',missing_value
;print,'missing is:',missing_value
endif
endfor
i = WHERE(dummy_zon EQ missing_value, count)
IF (count GT 0) THEN dummy_zon[i] = !VALUES.F_NAN
ensaver_zon(*,t,v)=fact_mod_sign(t)*dummy_zon
ncdf_close,id1
; read ensemble mean map
filenamex=timnames(t)+'_mod/ensmean_'+timnames(t)+'-pi'+'_'+varnamelong(v)+extensmap(t)+'.nc'
print,filenamex
id1=ncdf_open(filenamex)
ncdf_varget,id1,varname(t,v),dummy_map
; check for missing values
missing_value=-9999.99
aa=ncdf_varinq(id1,varname(t,v))
natts=aa.Natts
for x=0,natts-1 do begin
bb=ncdf_attname(id1,varname(t,v),x)
;print,bb
if (bb eq 'missing_value') then begin
ncdf_attget,id1,varname(t,v),'missing_value',missing_value
;print,'missing is:',missing_value
endif
endfor
i = WHERE(dummy_map EQ missing_value, count)
IF (count GT 0) THEN dummy_map[i] = !VALUES.F_NAN
ensmean_map(*,*,t,v)=fact_mod_sign(t)*dummy_map
ensmean_mask(*,*,t,v)=1.0-finite(dummy_map)
ncdf_close,id1
; read ensemble aver map
filenamex=timnames(t)+'_mod/ensavg_'+timnames(t)+'-pi'+'_'+varnamelong(v)+extensmap(t)+'.nc'
print,filenamex
id1=ncdf_open(filenamex)
ncdf_varget,id1,varname(t,v),dummy_map
; check for missing values
missing_value=-9999.99
aa=ncdf_varinq(id1,varname(t,v))
natts=aa.Natts
for x=0,natts-1 do begin
bb=ncdf_attname(id1,varname(t,v),x)
;print,bb
if (bb eq 'missing_value') then begin
ncdf_attget,id1,varname(t,v),'missing_value',missing_value
;print,'missing is:',missing_value
endif
endfor
i = WHERE(dummy_map EQ missing_value, count)
IF (count GT 0) THEN dummy_map[i] = !VALUES.F_NAN
ensaver_map(*,*,t,v)=fact_mod_sign(t)*dummy_map
ensaver_mask(*,*,t,v)=1.0-finite(dummy_map)
ncdf_close,id1
endfor
filenamex=topofile(t)
print,filenamex
id1=ncdf_open(filenamex)
ncdf_varget,id1,topovar(t),dummy_map
topo_map(*,*,t)=dummy_map
ncdf_close,id1
endfor
; now produce some checks:
print,'making checks'
for v=0,nvar-1 do begin
for t=0,ntime-1 do begin
; calculate zonal means from models
for y=0,ny-1 do begin
ensmean_zon_check1(y,t,v)=mean(mod_zon(y,where(plot_zon(t,0:nmod(t)-1) eq 1),t,v),/NAN)
ensmean_zon_check2(y,t,v)=mean(ensmean_map(0:nx-1,y,t,v),/NAN)
ensaver_zon_check1(y,t,v)=mean(mod_zon(y,where(plot_zon(t,0:nmod(t)-1) eq 1),t,v),/NAN) ; [same as ensmean_zon_check1 - correct?]
ensaver_zon_check2(y,t,v)=mean(ensaver_map(0:nx-1,y,t,v),/NAN)
endfor
endfor
endfor
ensmean_mean=fltarr(ntime,nvar)
for v=0,nvar-1 do begin
for t=0,ntime-1 do begin
ensmean_mean(t,v)=total(ensmean_zon(*,t,v)*weight_lat(*),/nan)*fact_mod_sign(t)
endfor
endfor
for v=0,nvar-1 do begin
for t=0,ntime-1 do begin
for y=0,ny-1 do begin
for x=0,nx-1 do begin
; calculate mean map from models
modmean_map(x,y,t,v)=mean(mod_map(x,y,where(plot_zon(t,0:nmod(t)-1) eq 1),t,v),/NAN)
modaver_map(x,y,t,v)=mean(mod_map(x,y,where(plot_zon(t,0:nmod(t)-1) eq 1),t,v))
endfor
endfor
endfor
endfor
endif ; end read_mod
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Now read in the proxy data...
if (read_proxy eq 1) then begin
ndatamax=1000
ndata=intarr(ntime,nvar)
missing_err=2.0
if (eo_data_all eq 'inglis') then begin
ndata(2,0)=47
ndata(2,1)=19
ndataing=intarr(nvar)
ndataing(0)=80
ndataing(1)=27
endif
if (pl_data_sat eq 'salzmann') then begin
ndata(0,0)=8
endif
if (pl_data_sst eq 'dowsett') then begin
ndata(0,1)=37
endif
if (pl_data_sst eq 'pliovar') then begin
ndata(0,1)=23
endif
if (pl_data_sst eq 'pliovar_erin_pangaea') then begin
ndata(0,1)=32
endif
if (lg_data_sat eq 'bartlein') then begin
ndata(1,0)=98
endif
if (lg_data_sst eq 'tierney-2019-grid') then begin
ndata(1,1)=200
endif
if (lg_data_sst eq 'tierney-2020-grid') then begin
ndata(1,1)=227
endif
if (lg_data_sst eq 'tierney-2020') then begin
ndata(1,1)=512
endif
lons_d=fltarr(ndatamax,ntime,nvar)
lats_d=fltarr(ndatamax,ntime,nvar)
temps_d=fltarr(ndatamax,ntime,nvar)
errs_d=fltarr(2,ndatamax,ntime,nvar)
temps_m_aver=fltarr(ndatamax,ntime,nvar)
temps_m_mean=fltarr(ndatamax,ntime,nvar)
lons_m_aver=fltarr(ndatamax,ntime,nvar)
lons_m_mean=fltarr(ndatamax,ntime,nvar)
lats_m_aver=fltarr(ndatamax,ntime,nvar)
lats_m_mean=fltarr(ndatamax,ntime,nvar)
;;;;;;
; Eocene
if (eo_data_all eq 'inglis') then begin
nrows_d=209
all_lons=fltarr(nrows_d)
all_lats=fltarr(nrows_d)
all_temps=fltarr(nrows_d)
all_times=strarr(nrows_d)
all_vars=fltarr(nrows_d)
all_vars_tmp=strarr(nrows_d)
all_v2=fltarr(nrows_d)
all_upper=fltarr(nrows_d)
all_lower=fltarr(nrows_d)
row_temp=strarr(1)
close,2
openr,2,'/home/bridge/ggdjl/ipcc_ar6/patterns/fgd/eo_data/Hollis_2019_DeepMIP_compilation_Inglis.csv'
;print,'STARTING READ'
readf,2,row_temp
for i=0,nrows_d-1 do begin
readf,2,row_temp
data_row=strsplit(row_temp,',',/extract,/preserve_null)
all_lons(i)=data_row(7) ; mantle
all_lats(i)=data_row(6) ; mantle
all_temps(i)=data_row(11)
all_times(i)=data_row(1)
all_vars_tmp(i)=data_row(2)
all_v2(i)=data_row(20) ; needed for for most recent Hollis file
all_upper(i)=data_row(17)
all_lower(i)=data_row(16)
endfor
close,2
all_vars=0*(all_vars_tmp eq 'lat')+1*(all_vars_tmp eq 'sst')
this_index=(all_times eq 'eeco')
; no-frosty:
this_index=this_index*(all_v2 eq 1)
this_index_sst=this_index*(all_vars eq 1)
this_index_sat=this_index*(all_vars eq 0)
ncolumns_sst=total(this_index_sst)
ncolumns_sat=total(this_index_sat)
if (ncolumns_sat ne ndataing(0)) then begin
print,'unepxected N',ncolumns_sat,ndataing(0)
stop
endif
if (ncolumns_sst ne ndataing(1)) then begin
print,'unepxected N',ncolumns_sst,ndataing(1)
stop
endif
my_deepmip_err=5.0
lons_d_ing=fltarr(ndatamax,nvar)
lats_d_ing=fltarr(ndatamax,nvar)
temps_d_ing=fltarr(ndatamax,nvar)
errs_d_ing=fltarr(2,ndatamax,nvar)
lons_d_ing(0:ndataing(0)-1,0)=all_lons(where(this_index_sat))
lons_d_ing(0:ndataing(1)-1,1)=all_lons(where(this_index_sst))
lats_d_ing(0:ndataing(0)-1,0)=all_lats(where(this_index_sat))
lats_d_ing(0:ndataing(1)-1,1)=all_lats(where(this_index_sst))
temps_d_ing(0:ndataing(0)-1,0)=all_temps(where(this_index_sat))+273.15 ; degrees K
temps_d_ing(0:ndataing(1)-1,1)=all_temps(where(this_index_sst))
this_upper=all_upper(where(this_index_sat)) ; degrees C
this_upper=(this_upper+273.15)*(this_upper ne -999.9) + (this_upper eq -999.9)*(temps_d_ing(0:ndataing(0)-1,0)+my_deepmip_err) ; degrees K
this_lower=all_lower(where(this_index_sat)) ; degrees C
this_lower=(this_lower+273.15)*(this_lower ne -999.9) + (this_lower eq -999.9)*(temps_d_ing(0:ndataing(0)-1,0)-my_deepmip_err) ; degrees K
errs_d_ing(0,0:ndataing(0)-1,0)=this_upper-temps_d_ing(0:ndataing(0)-1,0);+273.15 ; delta plus
errs_d_ing(1,0:ndataing(0)-1,0)=temps_d_ing(0:ndataing(0)-1,0)-this_lower;-273.15 ; delta minus
this_upper=all_upper(where(this_index_sst))
this_upper=this_upper*(this_upper ne -999.9) + (this_upper eq -999.9)*(temps_d_ing(0:ndataing(1)-1,1)+my_deepmip_err)
this_lower=all_lower(where(this_index_sst))
this_lower=this_lower*(this_lower ne -999.9) + (this_lower eq -999.9)*(temps_d_ing(0:ndataing(1)-1,1)-my_deepmip_err)
errs_d_ing(0,0:ndataing(1)-1,1)=this_upper-temps_d_ing(0:ndataing(1)-1,1) ; delta plus
errs_d_ing(1,0:ndataing(1)-1,1)=temps_d_ing(0:ndataing(1)-1,1)-this_lower ; delta minus
; check for duplicates
; errs_d, lons_d, lats_d, temps_d
t=2
for v=0,1 do begin
xx=0
for d=0,ndataing(v)-1 do begin
matching=(lons_d_ing(d,v) eq lons_d_ing(0:ndataing(v)-1,v) and lats_d_ing(d,v) eq lats_d_ing(0:ndataing(v)-1,v))
count_dd=total(matching)
match_dd=where(matching eq 1)
if (count_dd ne 1) then begin
if (temps_d_ing(d,v) ne 1e30) then begin
new_temp=mean(temps_d_ing(match_dd,v))
;print,t,v,d,count_dd,lons_d_ing(d,v),lats_d_ing(d,v),temps_d_ing(d,v),new_temp
new_errs_0=mean(errs_d_ing(0,match_dd,v))
new_errs_1=mean(errs_d_ing(1,match_dd,v))
lons_d(xx,t,v)=lons_d_ing(d,v)
lats_d(xx,t,v)=lats_d_ing(d,v)
temps_d(xx,t,v)=new_temp
errs_d(0,xx,t,v)=new_errs_0
errs_d(1,xx,t,v)=new_errs_1
temps_d_ing(match_dd,v)=1e30
xx=xx+1
endif
endif else begin
lons_d(xx,t,v)=lons_d_ing(d,v)
lats_d(xx,t,v)=lats_d_ing(d,v)
temps_d(xx,t,v)=temps_d_ing(d,v)
errs_d(0,xx,t,v)=errs_d_ing(0,d,v)
errs_d(1,xx,t,v)=errs_d_ing(1,d,v)
xx=xx+1
endelse
endfor
print,'ndata is: ',t,v,xx
if (xx ne ndata(t,v)) then begin
print,'unepxected N',xx,ndata(t,v)
stop
endif
endfor
; now find the preind temperatures at these sites.
filenamencp='eo_data/air.2m_ann_tmp_remapbil_zonmean_enlarge.nc'
varname='air'
print,filenamencp
id1=ncdf_open(filenamencp)
ncdf_varget,id1,varname,dummy_ncp
ncdf_varget,id1,'longitude',lons_ncp
ncdf_varget,id1,'latitude',lats_ncp
missing_value=-9999.99
aa=ncdf_varinq(id1,varname)
natts=aa.Natts
for x=0,natts-1 do begin
bb=ncdf_attname(id1,varname,x)
;print,bb
if (bb eq 'missing_value') then begin
ncdf_attget,id1,varname,'missing_value',missing_value
;print,'mising is:',missing_value
endif
if (bb eq '_FillValue') then begin
ncdf_attget,id1,varname,'_FillValue',missing_value1
;print,'mising1 is:',missing_value1
endif
endfor
ncdf_close,id1
ncp_tmp=dummy_ncp
i = WHERE(dummy_ncp EQ missing_value, count)
IF (count GT 0) THEN ncp_tmp[i] = !VALUES.F_NAN
i = WHERE(dummy_ncp EQ missing_value1, count)
IF (count GT 0) THEN ncp_tmp[i] = !VALUES.F_NAN
; Now locate nearest temperature for data points
for d=0,ndataing(0)-1 do begin
find_lonlat,nx,ny,lons_ncp,lats_ncp,lons_d(d,2,0),lats_d(d,2,0),ncp_tmp,xindex,yindex
;print,'adjusting for preind: ',d
;print,temps_d(d,2,0)
;print,lons_d(d,2,0),lats_d(d,2,0)
;print,lons_ncp(xindex),lats_ncp(yindex)
;print,ncp_tmp(xindex,yindex)
temps_d(d,2,0)=temps_d(d,2,0)-ncp_tmp(xindex,yindex)
;print,temps_d(d,2,0)
endfor
filenamehad='eo_data/HadISST_sst_ycdo_remapbil_zonmean_enlarge.nc'
varname='sst'
print,filenamehad
id1=ncdf_open(filenamehad)
ncdf_varget,id1,varname,dummy_had
ncdf_varget,id1,'longitude',lons_had
ncdf_varget,id1,'latitude',lats_had
missing_value=-9999.99
aa=ncdf_varinq(id1,varname)
natts=aa.Natts
for x=0,natts-1 do begin
bb=ncdf_attname(id1,varname,x)
;print,bb
if (bb eq 'missing_value') then begin
ncdf_attget,id1,varname,'missing_value',missing_value
;print,'mising is:',missing_value
endif
if (bb eq '_FillValue') then begin
ncdf_attget,id1,varname,'_FillValue',missing_value1
;print,'mising1 is:',missing_value1
endif
endfor
ncdf_close,id1
had_tmp=dummy_had
i = WHERE(dummy_had EQ missing_value, count)
IF (count GT 0) THEN had_tmp[i] = !VALUES.F_NAN
i = WHERE(dummy_had EQ missing_value1, count)
IF (count GT 0) THEN had_tmp[i] = !VALUES.F_NAN
; Now locate nearest temperature for data points
for d=0,ndata(2,1)-1 do begin
find_lonlat,nx,ny,lons_had,lats_had,lons_d(d,2,1),lats_d(d,2,1),had_tmp,xindex,yindex
;print,'adjusting for preind: ',d
;print,temps_d(d,2,1)
;print,lons_d(d,2,1),lats_d(d,2,1)
;print,lons_had(xindex),lats_had(yindex)
;print,had_tmp(xindex,yindex)
temps_d(d,2,1)=temps_d(d,2,1)-had_tmp(xindex,yindex)
;print,temps_d(d,2,1)
endfor
endif ; end inglis
;;;;;
if (pl_data_sst eq 'dowsett') then begin
; PLIOCENE:
row_temp=''
row_head=''
close,2
openr,2,'/home/bridge/ggdjl/ipcc_ar6/patterns/sod/pl_data/cs_mp_sst_data_30k_plusNOAA_djl.csv'
readf,2,row_head
;print,row_head
for i=0,ndata(0,1)-1 do begin
readf,2,row_temp
data_row=strsplit(row_temp,',',/extract,/preserve_null)
;print,'We are: ',i
;print,data_row
;print,size(data_row)
lons_d(i,0,1)=data_row(2)
lats_d(i,0,1)=data_row(1)
; This is for HadISST:
;temps_d(i,0,1)=data_row(12)
; This is for NOAAERSST5:
temps_d(i,0,1)=data_row(14)
if (data_row(5) ne 999) then begin
errs_d(0,i,0,1)=data_row(5)
errs_d(1,i,0,1)=data_row(5)
endif else begin
errs_d(0,i,0,1)=missing_err
errs_d(1,i,0,1)=missing_err
endelse
endfor
close,2
endif
if (pl_data_sst eq 'pliovar') then begin
; PLIOCENE:
row_temp=''
row_head=''
close,2
openr,2,'/home/bridge/ggdjl/ipcc_ar6/patterns/sod/pl_data/PlioVAR-KM5c_T_only_-_for_DanIPCC_djl.csv'
readf,2,row_head
;print,row_head
xx=0
for i=0,32 do begin
readf,2,row_temp
data_row=strsplit(row_temp,',',/extract,/preserve_null)
;print,'We are: ',i
;print,data_row
;print,size(data_row)
if (data_row(19) ne '') then begin
lons_d(xx,0,1)=data_row(1)
lats_d(xx,0,1)=data_row(2)
; This is for alkenone Bayesian:
temps_d(xx,0,1)=data_row(19)
errs_d(0,xx,0,1)=data_row(5)
errs_d(1,xx,0,1)=data_row(5)
xx=xx+1
endif
endfor
close,2
if (xx ne ndata(0,1)) then begin
print,'unexpcted N',xx,ndata(0,1)-1
stop
endif
endif
if (pl_data_sst eq 'pliovar_erin_pangaea') then begin
names_d=strarr(100)
; PLIOCENE:
row_temp=''
row_head=strarr(98)
close,2
openr,2,'/home/bridge/ggdjl/ipcc_ar6/patterns/fgd/pl_data/PlioVAR-KM5c_T_jess.tab'
readf,2,row_head
;print,row_head
xx=0
for i=0,31 do begin
;print,'We are i: ',i
readf,2,row_temp
data_row=strsplit(row_temp,string(9B),/extract,/preserve_null)
;print,data_row
ss=size(data_row)
if (ss(1) ne 20) then begin
print,'wrong row-length'
stop
endif
if (data_row(13) ne '' or data_row(15) ne '') then begin
names_d(xx)=data_row(1)
lons_d(xx,0,1)=data_row(3)
lats_d(xx,0,1)=data_row(2)
if (data_row(13) ne '' and data_row(15) eq '') then begin
temps_d(xx,0,1)=data_row(13)
endif
if (data_row(15) ne '' and data_row(13) eq '') then begin
temps_d(xx,0,1)=data_row(15)
endif
if (data_row(13) ne '' and data_row(15) ne '') then begin
temps_d(xx,0,1)=( (1.0*data_row(13)) + (1.0*data_row(15)) ) /2.0
print,'duplication!'
print,names_d(xx)
print,data_row(13)
print,data_row(15)
print,temps_d(xx,0,1)
endif
;errs_d(0,xx,0,1)=missing_err
;errs_d(1,xx,0,1)=missing_err
xx=xx+1
;print,'We are xx: ',xx
endif
endfor
close,2
if (xx ne ndata(0,1)) then begin
print,'unexpected N',xx,ndata(0,1)
stop
endif
; Now read in Jess's uncertainties
; for old or new data (change in site 609)
jess_file='new'
;jess_file='orig'
; first mg/ca
n_j1=12
row_temp=strarr(1)
close,2
openr,2,'/home/bridge/ggdjl/ipcc_ar6/patterns/fgd/pl_data/PlioVar_mgca_'+jess_file+'_unix_erin.csv'
print,'STARTING READ Jess'
print,'mg/ca'
; file created by manually removing ^M symbols (dos2unix didn't
; work...), and then changing names of sites to match those in
; Pangaea: odp131 -> u1313 ; odp603 -> dsdp603 ; remove odp590 ; added
; comment on 603
names_j1=strarr(n_j1)
lats_j1=fltarr(n_j1)
lons_j1=fltarr(n_j1)
temps_j1=fltarr(n_j1)
err_j1=fltarr(n_j1)
readf,2,row_temp
;print,'header: '+row_temp
for i=0,n_j1-1 do begin
readf,2,row_temp
data_row=strsplit(row_temp,',',/extract,/preserve_null)
;print,data_row
names_j1(i)=data_row(0)
print,names_j1(i)
lats_j1(i)=data_row(1)
lons_j1(i)=data_row(2)
temps_j1(i)=data_row(8)
err_j1(i)=data_row(9)
endfor
close,2
print,'matching mg/ca:'
for i=0,n_j1-1 do begin
print,names_j1(i)
jj=strmatch(names_d,names_j1(i),/FOLD_CASE)
;print,jj
;print,where(jj eq 1)
if (total(jj) ne 1) then begin
print,'Mg/Ca: too many or no names matching: ',total(where(jj eq 1))
stop
endif
if (abs(lats_j1(i)-lats_d(where(jj eq 1),0,1)) gt 0.05) then begin
print,'Mg/Ca: lons not matching ',lats_j1(i),lats_d(where(jj eq 1),0,1)
stop
endif
if (abs(lons_j1(i)-lons_d(where(jj eq 1),0,1)) gt 0.05) then begin
print,'Mg/Ca: lons not matching ',lons_j1(i),lons_d(where(jj eq 1),0,1)
stop
endif
print,names_d(where(jj eq 1)),temps_j1(i),temps_d(where(jj eq 1),0,1),lats_j1(i),lats_d(where(jj eq 1),0,1),lons_j1(i),lons_d(where(jj eq 1),0,1)
endfor
print,'end matching mg/ca'
; now uk37
n_j2=23
row_temp=strarr(1)
close,2
openr,2,'/home/bridge/ggdjl/ipcc_ar6/patterns/fgd/pl_data/PlioVar_uk_new_unix.csv'
print,'STARTING READ Jess'
print,'uk37'
names_j2=strarr(n_j2)
lats_j2=fltarr(n_j2)
lons_j2=fltarr(n_j2)
temps_j2=fltarr(n_j2)
err_j2=fltarr(n_j2)
readf,2,row_temp
;print,'header: '+row_temp
for i=0,n_j2-1 do begin
readf,2,row_temp
data_row=strsplit(row_temp,',',/extract,/preserve_null)