-
Notifications
You must be signed in to change notification settings - Fork 1
/
analysis_timeseries.py
executable file
·3345 lines (2646 loc) · 139 KB
/
analysis_timeseries.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
#!/usr/bin/env python
#####!/usr/bin/python
#
# Copyright 2015, Plymouth Marine Laboratory
#
# This file is part of the bgc-val library.
#
# bgc-val is free software: you can redistribute it and/or modify it
# under the terms of the Revised Berkeley Software Distribution (BSD) 3-clause license.
# bgc-val is distributed in the hope that it will be useful, but
# without any warranty; without even the implied warranty of merchantability
# or fitness for a particular purpose. See the revised BSD license for more details.
# You should have received a copy of the revised BSD license along with bgc-val.
# If not, see <http://opensource.org/licenses/BSD-3-Clause>.
#
# Address:
# Plymouth Marine Laboratory
# Prospect Place, The Hoe
# Plymouth, PL1 3DH, UK
#
# Email:
#
"""
.. module:: analysis_timeseries
:platform: Unix
:synopsis: A script to produce analysis for time series.
.. moduleauthor:: Lee de Mora <[email protected]>
"""
import matplotlib as mpl
mpl.use('Agg')
#####
# Load Standard Python modules:
from sys import argv,exit
from os.path import exists
from calendar import month_name
from socket import gethostname
from glob import glob
from scipy.interpolate import interp1d
import numpy as np
import os,sys
from getpass import getuser
#####
# Load specific local code:
import UKESMpython as ukp
from timeseries import timeseriesAnalysis
from timeseries import profileAnalysis
from timeseries import timeseriesTools as tst
from bgcvaltools.mergeMonthlyFiles import mergeMonthlyFiles,meanDJF
from bgcvaltools.AOU import AOU
from bgcvaltools.dataset import dataset
#####
# User defined set of paths pointing towards the datasets.
import paths
#####
# Biogeochemistry keys
bgcKeys = []
if True:
bgcKeys.append('N') # WOA Nitrate
bgcKeys.append('Si') # WOA Siliate
bgcKeys.append('O2') # WOA Oxygen
bgcKeys.append('Alk') # Glodap Alkalinity
bgcKeys.append('DIC') # Globap tCO2
bgcKeys.append('AirSeaFluxCO2') # Air Sea Flux
bgcKeys.append('TotalAirSeaFluxCO2') # Total global air sea flux
bgcKeys.append('IntPP_OSU') # OSU Integrated primpary production
bgcKeys.append('PP_OSU') # OSU Integrated primpary production
# bgcKeys.append('LocalExportRatio') # Export ratio (no data)
# bgcKeys.append('GlobalExportRatio') # Export ratio (no data)
bgcKeys.append('TotalOMZVolume') # Total Oxygen Minimum zone Volume
# bgcKeys.append('OMZThickness') # Oxygen Minimum Zone Thickness
# bgcKeys.append('OMZMeanDepth') # Oxygen Minimum Zone mean depth
bgcKeys.append('VolumeMeanOxygen') # Volune Mean regional oxygen concentation
# bgcKeys.append('AOU') # Apparent Oxygen Usage
bgcKeys.append('Iron') # Iron
bgcKeys.append('Dust') # Dust
# bgcKeys.append('TotalDust') # Total Dust
# bgcKeys.append('DiaFrac') # Diatom Fraction
# bgcKeys.append('DTC') # Detrital carbon
bgcKeys.append('CHL') # Total Chlorophyll
# bgcKeys.append('DMS_ARAN') # Total Chlorophyll
bgcKeys.append('pH')
bgcKeysDict = {i:n for i,n in enumerate(bgcKeys)}
#####
# Physical keys
physKeys = []
if True:
physKeys.append('Temperature') # WOA Temperature
#physKeys.append('VolWeightedT') # Volume weighted WOA Temperature
physKeys.append('GlobalMeanTemperature') # Global Mean Temperature
physKeys.append('GlobalMeanTemperature_700')
physKeys.append('GlobalMeanTemperature_2000')
physKeys.append('VolumeMeanTemperature') # Global Mean Temperature
physKeys.append('GlobalMeanSalinity') # Global Mean Salinity
# physKeys.append('IcelessMeanSST') # Global Mean Surface Temperature with no ice
physKeys.append('Salinity') # WOA Salinity
physKeys.append('MLD') # iFERMER Mixed Layer Depth
# physKeys.append('TotalIceArea') # work in progress
# physKeys.append('NorthernTotalIceArea') # work in progress
# physKeys.append('SouthernTotalIceArea') # work in progress
# physKeys.append('WeddelTotalIceArea')
physKeys.append('TotalIceExtent') # work in progress
physKeys.append('NorthernTotalIceExtent') # work in progress
physKeys.append('SouthernTotalIceExtent') # work in progress
# physKeys.append('WeddelIceExent') # work in progress
#physKeys.append('NorthernMIZArea')
#physKeys.append('SouthernMIZArea')
#physKeys.append('TotalMIZArea')
# physKeys.append('NorthernMIZfraction')
# physKeys.append('SouthernMIZfraction')
# physKeys.append('TotalMIZfraction')
physKeys.append('DrakePassageTransport') # DrakePassageTransport
# physKeys.append('AMOC_32S') # AMOC 32S
physKeys.append('AMOC_26N') # AMOC 26N
# physKeys.append('AMOC_26N_nomexico') # AMOC 26N
# physKeys.append('ADRC_26N') # ADRC 26N
# physKeys.append('ZonalCurrent') # Zonal Veloctity
# physKeys.append('MeridionalCurrent') # Meridional Veloctity
# physKeys.append('VerticalCurrent') # Vertical Veloctity
# physKeys.append('FreshwaterFlux') # Freshwater flux
# physKeys.append('sowaflup') # Net Upward Water Flux
# physKeys.append('soicecov') # Ice fraction
#####
# unused:
# physKeys.append('MaxMonthlyMLD') # MLD Monthly max
# physKeys.append('MinMonthlyMLD') # MLD Monthly min
# physKeys.append('HeatFlux')
physKeys.append('TotalHeatFlux')
physKeys.append('scvoltot')
physKeys.append('soga')
physKeys.append('thetaoga')
# physKeys.append('WindStress') # Wind Stress
# physKeys.append('sohefldo') # Net downward Water Flux
# physKeys.append('sofmflup') # Water flux due to freezing/melting
# physKeys.append('sosfldow') # Downward salt flux
# physKeys.append('sossheig') # Sea surface height
physKeysDict = {i:n for i,n in enumerate(physKeys)}
fastKeys = []
if True:
fastKeys.append('N') # WOA Nitrate
fastKeys.append('Si') # WOA Siliate
fastKeys.append('O2') # WOA Oxygen
fastKeys.append('Alk') # Glodap Alkalinity
fastKeys.append('DIC') # Globap tCO2
fastKeys.append('AirSeaFluxCO2') # Air Sea Flux
fastKeys.append('TotalAirSeaFluxCO2') # Total global air sea flux
fastKeys.append('IntPP_OSU') # OSU Integrated primpary production
fastKeys.append('PP_OSU') # OSU Integrated primpary production
# fastKeys.append('TotalOMZVolume') # Total Oxygen Minimum zone Volume
fastKeys.append('VolumeMeanOxygen') # Volune Mean regional oxygen concentation
fastKeys.append('Iron') # Iron
fastKeys.append('Dust') # Dust
fastKeys.append('CHL') # Total Chlorophyll
fastKeys.append('pH')
fastKeys.append('Temperature') # WOA Temperature
fastKeys.append('GlobalMeanTemperature') # Global Mean Temperature
fastKeys.append('GlobalMeanTemperature_700')
fastKeys.append('GlobalMeanTemperature_2000')
fastKeys.append('VolumeMeanTemperature') # Global Mean Temperature
fastKeys.append('GlobalMeanSalinity') # Global Mean Salinity
fastKeys.append('Salinity') # WOA Salinity
fastKeys.append('MLD') # iFERMER Mixed Layer Depth
fastKeys.append('TotalIceExtent') # work in progress
fastKeys.append('NorthernTotalIceExtent') # work in progress
fastKeys.append('SouthernTotalIceExtent') # work in progress
fastKeys.append('DrakePassageTransport') # DrakePassageTransport
fastKeys.append('AMOC_26N') # AMOC 26N
fastKeys.append('FreshwaterFlux') # Freshwater flux
fastKeys.append('sowaflup') # Net Upward Water Flux
fastKeys.append('TotalHeatFlux')
fastKeys.append('scvoltot')
fastKeys.append('soga')
fastKeys.append('thetaoga')
#####
# Level 1 keys
level1Keys = []
level1Keys.extend(physKeys)
level1Keys.extend(bgcKeys)
level1KeysDict = {i:n for i,n in enumerate(level1Keys)}
#####
# The important keys
keymetricsfirstKeys = [
'TotalAirSeaFluxCO2',
# 'NoCaspianAirSeaFluxCO2',
# 'IntPP_OSU',
# 'GlobalExportRatio',
# 'TotalIceExtent',
# 'NorthernTotalIceExtent',
# 'SouthernTotalIceExtent',
'DrakePassageTransport',
'AMOC_26N',
'GlobalMeanTemperature',
#'GlobalMeanSalinity',
]
keymetricsfirstDict = {i:n for i,n in enumerate(keymetricsfirstKeys)}
def listModelDataFiles(jobID, filekey, datafolder, annual):
print "listing model data files:\njobID:\t",jobID, '\nfile key:\t',filekey,'\ndata folder:\t', datafolder, '\nannual flag:\t',annual
if annual:
print "listing model data files:",datafolder+jobID+"/"+jobID+"o_1y_*_"+filekey+".nc"
return sorted(glob(datafolder+jobID+"/"+jobID+"o_1y_*_"+filekey+".nc"))
else:
print "listing model data files:",datafolder+jobID+"/"+jobID+"o_1m_*_"+filekey+".nc"
return sorted(glob(datafolder+jobID+"/"+jobID+"o_1m_*_"+filekey+".nc"))
def analysis_timeseries(jobID = "u-ab671",
clean = 0,
annual = True,
strictFileCheck = True,
analysisSuite = 'all',
regions = 'all',
):
"""
The role of this code is to produce time series analysis.
The jobID is the monsoon/UM job id and it looks for files with a specific format
The clean flag allows you to start the analysis without loading previous data.
The annual flag means that we look at annual (True) or monthly (False) data.
The strictFileCheck switch checks that the data/model netcdf files exist.
It fails if the switch is on and the files no not exist.
analysisSuite chooses a set of fields to look at.
regions selects a list of regions, default is 'all', which is the list supplied by Andy Yool.
:param jobID: the jobID
:param clean: deletes old images if true
:param annual: Flag for monthly or annual model data.
:param strictFileCheck: CStrickt check for model and data files. Asserts if no files are found.
:param analysisSuite: Which data to analyse, ie level1, physics only, debug, etc
:param regions:
"""
#print "analysis_p2p:", jobID,clean, annual,strictFileCheck,analysisSuite,regions
#assert 0
#####
# Switches:
# These are some booleans that allow us to choose which analysis to run.
# This lets up give a list of keys one at a time, or in parrallel.
if type(analysisSuite) == type(['Its','A','list!']):
analysisKeys = analysisSuite
#####
# Switches:
# These are some preset switches to run in series.
if type(analysisSuite) == type('Its_A_string'):
analysisKeys = []
if analysisSuite.lower() in ['keymetricsfirst',]:
analysisKeys.extend(keymetricsfirstKeys)
if analysisSuite.lower() in ['level1',]:
analysisKeys.extend(level1Keys)
if analysisSuite.lower() in ['fast',]:
analysisKeys.extend(fastKeys)
if analysisSuite.lower() in ['bgc',]:
analysisKeys.extend(bgcKeys)
if analysisSuite.lower() in ['physics',]:
analysisKeys.extend(physKeys)
if analysisSuite.lower() in ['level3',]:
analysisKeys.append('DMS_ARAN') # DMS Aranami Tsunogai
if analysisSuite.lower() in ['spinup',]:
analysisKeys.append('O2') # WOA Oxygen
analysisKeys.append('DIC') # work in progress
analysisKeys.append('Alk') # Glodap Alkalinity
analysisKeys.append('Iron') # work in progress
analysisKeys.append('N') # WOA Nitrate
analysisKeys.append('Si') # WOA Nitrate
analysisKeys.append('Temperature') # # WOA Temperature
analysisKeys.append('Salinity') # # WOA Salinity
if analysisSuite.lower() in ['salinity',]:
analysisKeys.append('Salinity') # # WOA Salinity
if analysisSuite.lower() in ['debug',]:
#analysisKeys.append('AirSeaFlux') # work in progress
#analysisKeys.append('TotalAirSeaFluxCO2') # work in progress
#analysisKeys.append('NoCaspianAirSeaFluxCO2') # work in progress
#analysisKeys.append('TotalOMZVolume') # work in progress
#analysisKeys.append('TotalOMZVolume50') # work in progress
#analysisKeys.append('OMZMeanDepth') # work in progress
#analysisKeys.append('OMZThickness') # Oxygen Minimum Zone Thickness
#analysisKeys.append('TotalOMZVolume') # work in progress
#analysisKeys.append('O2') # WOA Oxygen
#analysisKeys.append('AOU') # Apparent Oxygen Usage
#analysisKeys.append('WindStress') # Wind Stress
#analysisKeys.append('Dust') # Dust
#analysisKeys.append('TotalDust') # Total Dust
#analysisKeys.append('TotalDust_nomask')
#analysisKeys.append('DIC') # work in progress
#analysisKeys.append('DrakePassageTransport') # DrakePassageTransport
#analysisKeys.append('TotalIceArea') # work in progress
#analysisKeys.append('CHN')
#analysisKeys.append('CHD')
#analysisKeys.append('CHL')
#analysisKeys.append('pH')
#analysisKeys.append('Alk') # Glodap Alkalinity
#if jobID in ['u-am004','u-am005']:
# analysisKeys.append('DMS_ANDR') # DMS Anderson
#else: analysisKeys.append('DMS_ARAN') # DMS Aranami Tsunogai
#analysisKeys.append('DiaFrac') # work in progress
#analysisKeys.append('Iron') # work in progress
#analysisKeys.append('DTC') # work in progress
#analysisKeys.append('Iron') # work in progress
#analysisKeys.append('N') # WOA Nitrate
#analysisKeys.append('Si') # WOA Nitrate
#analysisKeys.append('IntPP_OSU') # OSU Integrated primpary production
#analysisKeys.append('Chl_CCI')
#analysisKeys.append('CHL_MAM')
#analysisKeys.append('CHL_JJA')
#analysisKeys.append('CHL_SON')
#analysisKeys.append('CHL_DJF')
#analysisKeys.append('GC_CHL_MAM')
#analysisKeys.append('GC_CHL_JJA')
#analysisKeys.append('GC_CHL_SON')
#analysisKeys.append('GC_CHL_DJF')
#####
# Physics switches:
analysisKeys.append('Temperature') # # WOA Temperature
# analysisKeys.append('HeatFlux')
# analysisKeys.append('TotalHeatFlux')
# analysisKeys.append('scvoltot')
# analysisKeys.append('soga')
# analysisKeys.append('thetaoga')
# analysisKeys.append('scalarHeatContent')
#analysisKeys.append('VolumeMeanTemperature')#
# analysisKeys.append('GlobalMeanTemperature_700')
# analysisKeys.append('GlobalMeanTemperature_2000')
# analysisKeys.append('WeddelIceExent')
#analysisKeys.append('Salinity') # WOA Salinity
# analysisKeys.append('MLD') # MLD
#analysisKeys.append('MaxMonthlyMLD') # MLD
#analysisKeys.append('MinMonthlyMLD')
#analysisKeys.append('NorthernTotalIceArea') # work in progress
#analysisKeys.append('SouthernTotalIceArea') # work in progress
#analysisKeys.append('WeddelTotalIceArea')
# analysisKeys.append('NorthernMIZArea')
# analysisKeys.append('SouthernMIZArea')
# analysisKeys.append('TotalMIZArea')
#analysisKeys.append('NorthernMIZfraction')
#analysisKeys.append('SouthernMIZfraction')
#analysisKeys.append('TotalMIZfraction')
#analysisKeys.append('TotalIceArea') # work in progress
#analysisKeys.append('TotalIceExtent') # work in progress
#analysisKeys.append('NorthernTotalIceExtent') # work in progress
#analysisKeys.append('SouthernTotalIceExtent') # work in progress
#analysisKeys.append('AMOC_32S') # AMOC 32S
#analysisKeys.append('AMOC_26N') # AMOC 26N
#analysisKeys.append('AMOC_26N_nomexico')
#analysisKeys.append('ADRC_26N') # AMOC 26N
# analysisKeys.append('ERSST') # Global Surface Mean Temperature
#analysisKeys.append('VolumeMeanOxygen')
# analysisKeys.append('GlobalMeanTemperature') # Global Mean Temperature#
# analysisKeys.append('GlobalMeanSalinity') # Global Mean Salinity
#analysisKeys.append('IcelessMeanSST') # Global Mean Surface Temperature with no ice
#analysisKeys.append('quickSST') # Area Weighted Mean Surface Temperature
#analysisKeys.append('ZonalCurrent') # Zonal Veloctity
#analysisKeys.append('MeridionalCurrent') # Meridional Veloctity
#analysisKeys.append('VerticalCurrent') # Vertical Veloctity
#analysisKeys.append('sowaflup') # Net Upward Water Flux
#analysisKeys.append('sohefldo') # Net downward Water Flux
# analysisKeys.append('sofmflup') # Water flux due to freezing/melting
# analysisKeys.append('sosfldow') # Downward salt flux
# analysisKeys.append('soicecov') # Ice fraction
# analysisKeys.append('sossheig') # Sea surface height
#analysisKeys.append('FreshwaterFlux') # Fresh water flux
#analysisKeys.append('max_soshfldo') # Max short wave radiation.
#####
# Physics switches:
if jobID in ['u-aj588','u-ak900','u-ar538','u-an869','u-ar977',]:
try: analysisKeys.remove('FreshwaterFlux')
except: pass
#####
# Some lists of region.
# This are pre-made lists of regions that can be investigated.
# Note that each analysis below can be given its own set of regions.
layerList = ['Surface',]#'500m','1000m',]
metricList = ['mean',] #'median', '10pc','20pc','30pc','40pc','50pc','60pc','70pc','80pc','90pc','min','max']
if regions == 'all':
regionList = ['Global', 'ignoreInlandSeas',
'SouthernOcean','ArcticOcean','AtlanticSOcean',
'Equator10', 'Remainder',
'NorthernSubpolarAtlantic','NorthernSubpolarPacific',
]
if regions == 'short':
regionList = ['Global','SouthernHemisphere','NorthernHemisphere',]
if analysisSuite.lower() == 'debug':
regionList = ['Global', 'ArcticOcean']
if analysisSuite.lower() in ['spinup', 'salinity',]:
regionList = ['Global', ]
metricList = ['mean', ]
layerList = ['500m', '1000m', '2000m', '4000m']
# Regions from Pierce 1995 - https://doi.org/10.1175/1520-0485(1995)025<2046:CROHAF>2.0.CO;2
PierceRegions = ['Enderby','Wilkes','Ross','Amundsen','Weddel',]
OMZRegions = ['EquatorialPacificOcean','IndianOcean','EquatorialAtlanticOcean']#'Ross','Amundsen','Weddel',]
#if analysisSuite.lower() in ['debug',]:
# regionList = ['Global', 'ArcticOcean',]
#####
# The z_component custom command:
# This flag sets a list of layers and metrics.
# It's not advised to run all the metrics and all the layers, as it'll slow down the analysis.
# if z_component in ['SurfaceOnly',]:
# if z_component in ['FullDepth',]:
# layerList = [0,2,5,10,15,20,25,30,35,40,45,50,55,60,70,]
# metricList = ['mean','median',]
#####
# Location of images directory
# the imagedir is where the analysis images will be saved.
#####
# Location of shelves folder
# The shelve directory is where the intermediate processing files are saved in python's shelve format.
# This allows us to put away a python open to be re-opened later.
# This means that we can interupt the analysis without loosing lots of data and processing time,
# or we can append new simulation years to the end of the analysis without starting from scratch each time.
#shelvedir = ukp.folder('shelves/timeseries/'+jobID)
#####
# Location of data files.
# The first thing that this function does is to check which machine it is being run.
# This is we can run the same code on multiple machines withouht having to make many copies of this file.
# So far, this has been run on the following machines:
# PML
# JASMIN
# Charybdis (Julien's machine at NOCS)
#
# Feel free to add other macihines onto this list, if need be.
machinelocation = ''
#####
# PML
if gethostname().find('pmpc')>-1:
print "analysis-timeseries.py:\tBeing run at PML on ",gethostname()
imagedir = ukp.folder(paths.imagedir+'/'+jobID+'/timeseries')
if annual: WOAFolder = paths.WOAFolder_annual
else: WOAFolder = paths.WOAFolder
#shelvedir = ukp.folder(paths.shelvedir+'/'+jobID+'/timeseries/'+jobID)
shelvedir = ukp.folder(paths.shelvedir+"/timeseries/"+jobID)
#####
# JASMIN
hostname = gethostname()
if hostname.find('ceda.ac.uk')>-1 or hostname.find('jasmin')>-1 or hostname.find('jc.rl.ac.uk') > -1:
print "analysis-timeseries.py:\tBeing run at CEDA on ", hostname
#machinelocation = 'JASMIN'
#try: shelvedir = ukp.folder("/group_workspaces/jasmin2/ukesm/BGC_data/"+getuser()+"/shelves/timeseries/"+jobID)
#except: shelvedir = "/group_workspaces/jasmin2/ukesm/BGC_data/"+getuser()+"/shelves/timeseries/"+jobID
try: shelvedir = ukp.folder("/gws/nopw/j04/ukesm/BGC_data/"+getuser()+"/shelves/timeseries/"+jobID)
except: shelvedir = "/gws/nopw/j04/ukesm/BGC_data/"+getuser()+"/shelves/timeseries/"+jobID
if annual: WOAFolder = paths.WOAFolder_annual
else: WOAFolder = paths.WOAFolder
try: imagedir = ukp.folder(paths.imagedir+'/'+jobID+'/timeseries')
except: imagedir = paths.imagedir+'/'+jobID+'/timeseries'
if gethostname().find('monsoon')>-1:
print "Please set up paths.py"
assert 0
#print "analysis-timeseries.py:\tBeing run at the Met Office on ",gethostname()
#machinelocation = 'MONSOON'
#ObsFolder = "/projects/ukesm/ldmora/BGC-data/"
#ModelFolder = "/projects/ukesm/ldmora/UKESM"
#####
# Location of model files.
#MEDUSAFolder_pref = ukp.folder(ModelFolder)
#####
# Location of data files.
#if annual: WOAFolder = ukp.folder(ObsFolder+"WOA/annual")
#else: WOAFolder = ukp.folder(ObsFolder+"WOA/")
#MAREDATFolder = ObsFolder+"/MAREDAT/MAREDAT/"
#GEOTRACESFolder = ObsFolder+"/GEOTRACES/GEOTRACES_PostProccessed/"
#TakahashiFolder = ObsFolder+"/Takahashi2009_pCO2/"
#MLDFolder = ObsFolder+"/IFREMER-MLD/"
#iMarNetFolder = ObsFolder+"/LestersReportData/"
#GlodapDir = ObsFolder+"/GLODAP/"
#GLODAPv2Dir = ObsFolder+"/GLODAPv2/GLODAPv2_Mapped_Climatologies/"
#OSUDir = ObsFolder+"OSU/"
#CCIDir = ObsFolder+"CCI/"
#orcaGridfn = ModelFolder+'/mesh_mask_eORCA1_wrk.nc'
#####
# Unable to find location of files/data.
if not paths.machinelocation:
print "analysis-timeseries.py:\tFATAL:\tWas unable to determine location of host: ",gethostname()
print "Please set up paths.py, based on Paths/paths_template.py"
assert False
#####
# Because we can never be sure someone won't randomly rename the
# time dimension without saying anything.
# if jobID in ['u-am515','u-am927','u-am064','u-an326',]:
try:
tmpModelFiles = listModelDataFiles(jobID, 'grid_T', paths.ModelFolder_pref, annual)
except:
print "No grid_T Model files available to figure out what naming convention is used."
tmpModelFiles = []
ukesmkeys={}
if len(tmpModelFiles):
nctmp = dataset(tmpModelFiles[0],'r')
nctmpkeys = nctmp.variables.keys()
nctmp.close()
if 'votemper' in nctmpkeys:
ukesmkeys['time'] = 'time_counter'
ukesmkeys['temp3d'] = 'votemper'
ukesmkeys['sst'] = ''
ukesmkeys['sal3d'] = 'vosaline'
ukesmkeys['sss'] = ''
ukesmkeys['v3d'] = 'vomecrty'
ukesmkeys['u3d'] = 'vozocrtx'
ukesmkeys['e3u'] = 'e3u'
ukesmkeys['w3d'] = 'vovecrtz'
#[u'nav_lat', u'nav_lon', u'bounds_nav_lon', u'bounds_nav_lat', u'area', u'deptht', u'deptht_bounds', u'time_centered', u'time_centered_bounds', u'time_counter', u'time_counter_bounds', u'thkcello', u'zos', u'zossq', u'tos_con', u'sos_abs', u'thetaob_con', u'sob_abs', u'thetao_con', u'so_abs', u'somxzint1', u'hfds', u'rsdo', u'sowaflup', u'soicecov', u'ficeberg', u'berg_latent_heat_flux', u'soemp_oce', u'soemp_ice', u'snowpre', u'soprecip', u'fsitherm', u'friver', u'so_erp', u'sfdsi', u'sohflisf', u'sohfcisf', u'sowflisf']
elif 'thetao_con' in nctmpkeys:
ukesmkeys['time'] = 'time_counter'
ukesmkeys['temp3d'] = 'thetao_con'
ukesmkeys['sst'] = 'tos_con'
ukesmkeys['sal3d'] = 'so_abs'
ukesmkeys['sss'] = 'sos_abs'
ukesmkeys['v3d'] = 'vo'
ukesmkeys['u3d'] = 'uo'
ukesmkeys['e3u'] = 'thkcello'
ukesmkeys['w3d'] = 'wo'
ukesmkeys['MLD'] = 'somxzint1'
else:
ukesmkeys['time'] = 'time_centered'
ukesmkeys['temp3d'] = 'thetao'
ukesmkeys['sst'] = 'tos'
ukesmkeys['sal3d'] = 'so'
ukesmkeys['sss'] = 'sos'
ukesmkeys['v3d'] = 'vo'
ukesmkeys['u3d'] = 'uo'
ukesmkeys['e3u'] = 'thkcello'
ukesmkeys['w3d'] = 'wo'
ukesmkeys['MLD'] = 'somxl010'
# else:
# ukesmkeys['time'] = 'time_centered'
# ukesmkeys['temp3d'] = 'thetao'
# ukesmkeys['sst'] = 'tos'
# ukesmkeys['sal3d'] = 'so'
# ukesmkeys['sss'] = 'sos'
# ukesmkeys['v3d'] = 'vo'
# ukesmkeys['u3d'] = 'uo'
# ukesmkeys['e3u'] = 'thkcello'
# ukesmkeys['w3d'] = 'wo'
# ukesmkeys['time'] = 'time_counter'
# ukesmkeys['temp3d'] = 'votemper'
# ukesmkeys['sst'] = ''
# ukesmkeys['sal3d'] = 'vosaline'
# ukesmkeys['sss'] = ''
# ukesmkeys['v3d'] = 'vomecrty'
# ukesmkeys['u3d'] = 'vozocrtx'
# ukesmkeys['e3u'] = 'e3u'
# ukesmkeys['w3d'] = 'vovecrtz'
# if jobID > 'u-am514' and jobID not in ['u-an619','u-an629','u-an631','u-an869', 'u-an908', 'u-an911','u-an989',]:
# # There are other changes here too.
# #####
# # Because we can never be sure someone won't randomly rename the
# # time dimension without saying anything.
# ukesmkeys={}
# ukesmkeys['time'] = 'time_centered'
# ukesmkeys['temp3d'] = 'thetao'
# ukesmkeys['sst'] = 'tos'
# ukesmkeys['sal3d'] = 'so'
# ukesmkeys['sss'] = 'sos'
# ukesmkeys['v3d'] = 'vo'
# ukesmkeys['u3d'] = 'uo'
# ukesmkeys['e3u'] = 'thkcello'
# ukesmkeys['w3d'] = 'wo'
#
# else:
# ukesmkeys={}
# ukesmkeys['time'] = 'time_counter'
# ukesmkeys['temp3d'] = 'votemper'
# ukesmkeys['sst'] = ''
# ukesmkeys['sal3d'] = 'vosaline'
# ukesmkeys['sss'] = ''
# ukesmkeys['v3d'] = 'vomecrty'
# ukesmkeys['u3d'] = 'vozocrtx'
# ukesmkeys['e3u'] = 'e3u'
# ukesmkeys['w3d'] = 'vovecrtz'
#####
# Coordinate dictionairy
# These are python dictionairies, one for each data source and model.
# This is because each data provider seems to use a different set of standard names for dimensions and time.
# The 'tdict' field is short for "time-dictionary".
# This is a dictionary who's indices are the values on the netcdf time dimension.
# The tdict indices point to a month number in python numbering (ie January = 0)
# An example would be, if a netcdf uses the middle day of the month as it's time value:
# tdict = {15:0, 45:1 ...}
timekey = ukesmkeys['time']
medusaCoords = {'t':timekey, 'z':'deptht', 'lat': 'nav_lat', 'lon': 'nav_lon', 'cal': '360_day',} # model doesn't need time dict.
medusaUCoords = {'t':timekey, 'z':'depthu', 'lat': 'nav_lat', 'lon': 'nav_lon', 'cal': '360_day',} # model doesn't need time dict.
medusaVCoords = {'t':timekey, 'z':'depthv', 'lat': 'nav_lat', 'lon': 'nav_lon', 'cal': '360_day',} # model doesn't need time dict.
medusaWCoords = {'t':timekey, 'z':'depthw', 'lat': 'nav_lat', 'lon': 'nav_lon', 'cal': '360_day',} # model doesn't need time dict.
icCoords = {'t':timekey, 'z':'nav_lev', 'lat': 'nav_lat', 'lon': 'nav_lon', 'cal': '360_day',} # model doesn't need time dict.
maredatCoords = {'t':'index_t', 'z':'DEPTH', 'lat': 'LATITUDE', 'lon': 'LONGITUDE', 'cal': 'standard','tdict':ukp.tdicts['ZeroToZero']}
takahashiCoords = {'t':'index_t', 'z':'index_z','lat': 'LAT', 'lon': 'LON', 'cal': 'standard','tdict':ukp.tdicts['ZeroToZero']}
woaCoords = {'t':'index_t', 'z':'depth', 'lat': 'lat', 'lon': 'lon', 'cal': 'standard','tdict':ukp.tdicts['ZeroToZero']}
osuCoords = {'t':'index_t', 'z':'', 'lat': 'latitude', 'lon': 'longitude', 'cal': 'standard','tdict':[] }
glodapCoords = {'t':'index_t', 'z':'depth', 'lat': 'latitude', 'lon': 'longitude', 'cal': 'standard','tdict':[] }
glodapv2Coords = {'t':'time', 'z':'Pressure','lat':'lat', 'lon':'lon', 'cal': '', 'tdict':{0:0,} }
mldCoords = {'t':'index_t', 'z':'index_z','lat':'lat', 'lon': 'lon','cal': 'standard','tdict':ukp.tdicts['ZeroToZero']}
dmsCoords = {'t':'time', 'z':'depth', 'lat':'Latitude', 'lon': 'Longitude','cal': 'standard','tdict':ukp.tdicts['ZeroToZero']}
cciCoords = {'t':'index_t', 'z':'index_z','lat': 'lat', 'lon': 'lon', 'cal': 'standard','tdict':['ZeroToZero'] }
mogcCoords = {'t':'index_t', 'z':'index_z','lat': 'latitude', 'lon': 'longitude', 'cal': 'standard','tdict':ukp.tdicts['ZeroToZero']}
godasCoords = {'t':'index_t', 'z':'level', 'lat': 'lat', 'lon': 'lon', 'cal': 'standard','tdict':['ZeroToZero'] }
# def listModelDataFiles(jobID, filekey, datafolder, annual):
# print "listing model data files:\njobID:\t",jobID, '\nfile key:\t',filekey,'\ndata folder:\t', datafolder, '\nannual flag:\t',annual
# if annual:
# print "listing model data files:",datafolder+jobID+"/"+jobID+"o_1y_*_"+filekey+".nc"
# return sorted(glob(datafolder+jobID+"/"+jobID+"o_1y_*_"+filekey+".nc"))
# else:
# print "listing model data files:",datafolder+jobID+"/"+jobID+"o_1m_*_"+filekey+".nc"
# return sorted(glob(datafolder+jobID+"/"+jobID+"o_1m_*_"+filekey+".nc"))
masknc = dataset(paths.orcaGridfn,'r')
tlandmask = masknc.variables['tmask'][:]
masknc.close()
def applyLandMask(nc,keys):
#### works like no change, but applies a mask.
return np.ma.masked_where(tlandmask==0,nc.variables[keys[0]][:].squeeze())
def applySurfaceMask(nc,keys):
#### works like no change, but applies a mask.
return np.ma.masked_where(tlandmask[0,:,:]==0, nc.variables[keys[0]][:].squeeze())
def applyLandMask1e3(nc,keys):
return applyLandMask(nc,keys)*1000.
#####
# The analysis settings:
# Below here is a list of analysis settings.
# The settings are passed to timeseriesAnalysis using a nested dictionary (called an autovivification, here).
#
# These analysis were switched on or off at the start of the function.
# Each analysis requires:
# model files
# data files
# model and data coordinate dictionaries, (defines above)
# model and data details (a set of instructions of what to analyse:
# name: field name
# vars: variable names in the netcdf
# convert: a function to manipuate the data (ie change units, or add two fields together.
# There are some standard ones in UKESMPython.py, but you can write your own here.
# units: the units after the convert function has been applied.
# layers: which vertical layers to look at (ie, surface, 100m etc...)
# regions: which regions to look at. Can be speficied here, or use a pre-defined list (from above)
# metrics: what metric to look at: mean, median or sum
# model and data source: the name of source of the model/data (for plotting)
# model grid: the model grid, usually eORCA1
# the model grid file: the file path for the model mesh file (contains cell area/volume/masks, etc)
#
# Note that the analysis can be run with just the model, it doesn't require a data file.
# If so, just set to data file to an empty string:
# av[name]['dataFile'] = ''
av = ukp.AutoVivification()
if 'Chl_pig' in analysisKeys:
name = 'Chlorophyll_pig'
av[name]['modelFiles'] = sorted(glob(paths.ModelFolder_pref+jobID+"/"+jobID+"o_1y_*_ptrc_T.nc"))
av[name]['dataFile'] = paths.MAREDATFolder+"MarEDat20121001Pigments.nc"
av[name]['modelcoords'] = medusaCoords
av[name]['datacoords'] = maredatCoords
av[name]['modeldetails'] = {'name': name, 'vars':['CHN','CHD'], 'convert': ukp.sums,'units':'mg C/m^3'}
av[name]['datadetails'] = {'name': name, 'vars':['Chlorophylla',], 'convert': ukp.div1000,'units':'ug/L'}
av[name]['layers'] = layerList
av[name]['regions'] = regionList
av[name]['metrics'] = metricList
av[name]['datasource'] = 'MAREDAT'
av[name]['model'] = 'MEDUSA'
av[name]['modelgrid'] = 'eORCA1'
av[name]['gridFile'] = paths.orcaGridfn
av[name]['Dimensions'] = 3
if 'CHL' in analysisKeys:
name = 'Chlorophyll'
av[name]['modelFiles'] = listModelDataFiles(jobID, 'ptrc_T', paths.ModelFolder_pref, annual)
av[name]['dataFile'] = ''
av[name]['modelcoords'] = medusaCoords
av[name]['datacoords'] = maredatCoords
av[name]['modeldetails'] = {'name': name, 'vars':['CHN','CHD'], 'convert': ukp.sums,'units':'mg C/m^3'}
av[name]['datadetails'] = {'name': '', 'units':''}
av[name]['layers'] = ['Surface','100m','200m',]
av[name]['regions'] = regionList
av[name]['metrics'] = metricList
av[name]['datasource'] = ''
av[name]['model'] = 'MEDUSA'
av[name]['modelgrid'] = 'eORCA1'
av[name]['gridFile'] = paths.orcaGridfn
av[name]['Dimensions'] = 3
if 'Chl_CCI' in analysisKeys:
name = 'Chlorophyll_cci'
#####
# Not that this is the 1 degree resolution dataset, but higher resolution data are also available.
av[name]['modelFiles'] = listModelDataFiles(jobID, 'ptrc_T', paths.ModelFolder_pref, annual)
if annual:
av[name]['dataFile'] = paths.CCIDir+"ESACCI-OC-L3S-OC_PRODUCTS-CLIMATOLOGY-16Y_MONTHLY_1degree_GEO_PML_OC4v6_QAA-annual-fv2.0.nc"
print paths.ModelFolder_pref+"/"+jobID+"o_1y_*_ptrc_T.nc"
else: av[name]['dataFile'] = paths.CCIDir+'ESACCI-OC-L3S-OC_PRODUCTS-CLIMATOLOGY-16Y_MONTHLY_1degree_GEO_PML_OC4v6_QAA-all-fv2.0.nc'
av[name]['modelcoords'] = medusaCoords
av[name]['datacoords'] = cciCoords
av[name]['modeldetails'] = {'name': name, 'vars':['CHN','CHD'], 'convert': ukp.sums,'units':'mg C/m^3'}
av[name]['datadetails'] = {'name': name, 'vars':['chlor_a',], 'convert': ukp.NoChange,'units':'mg C/m^3'}
av[name]['layers'] = ['Surface',] # CCI is surface only, it's a satellite product.
av[name]['regions'] = regionList
av[name]['metrics'] = metricList #['mean','median', ]
av[name]['datasource'] = 'CCI'
av[name]['model'] = 'MEDUSA'
av[name]['modelgrid'] = 'eORCA1'
av[name]['gridFile'] = paths.orcaGridfn
av[name]['Dimensions'] = 2
if 'CHD' in analysisKeys or 'CHN' in analysisKeys:
for name in ['CHD','CHN',]:
if name not in analysisKeys: continue
av[name]['modelFiles'] = listModelDataFiles(jobID, 'ptrc_T', paths.ModelFolder_pref, annual)
av[name]['dataFile'] = ''
av[name]['modelcoords'] = medusaCoords
av[name]['datacoords'] = ''
av[name]['modeldetails'] = {'name': name, 'vars':[name,], 'convert': ukp.NoChange,'units':'mg C/m^3'}
av[name]['datadetails'] = {'name': '', 'units':''}
av[name]['layers'] = ['Surface',]#'100m',] # CCI is surface only, it's a satellite product.
av[name]['regions'] = regionList
av[name]['metrics'] = metricList #['mean','median', ]
av[name]['datasource'] = ''
av[name]['model'] = 'MEDUSA'
av[name]['modelgrid'] = 'eORCA1'
av[name]['gridFile'] = paths.orcaGridfn
av[name]['Dimensions'] = 3
for name in ['CHL_JJA', 'CHL_DJF','CHL_SON','CHL_MAM','GC_CHL_JJA', 'GC_CHL_DJF','GC_CHL_SON','GC_CHL_MAM']:
if name not in analysisKeys: continue
if name in ['CHL_MAM','GC_CHL_MAM']:
monthlyFiles = glob(paths.ModelFolder_pref+'/'+jobID+'/monthlyCHL/'+jobID+'o_1m_????0[345]*_ptrc_T.nc')
if name in ['CHL_JJA','GC_CHL_JJA',]:
monthlyFiles = glob(paths.ModelFolder_pref+'/'+jobID+'/monthlyCHL/'+jobID+'o_1m_????0[678]*_ptrc_T.nc')
if name in ['CHL_SON','GC_CHL_SON',]:
monthlyFiles=[]
for month in ['09','10','11']:
monthlyFiles.extend(glob(paths.ModelFolder_pref+'/'+jobID+'/monthlyCHL/'+jobID+'o_1m_????'+month+'*_ptrc_T.nc'))
if name in ['CHL_DJF','GC_CHL_DJF']:
monthlyFiles=[]
for month in ['12','01','02']:
monthlyFiles.extend(glob(paths.ModelFolder_pref+'/'+jobID+'/monthlyCHL/'+jobID+'o_1m_????'+month+'*_ptrc_T.nc'))
if len(monthlyFiles):
if name in ['CHL_JJA','CHL_SON','CHL_MAM','GC_CHL_JJA','GC_CHL_SON','GC_CHL_MAM']:
chlfiles = mergeMonthlyFiles(monthlyFiles, outfolder='',cal=medusaCoords['cal'], timeAverage=True,expectedNumberOfFiles=3)
if name in ['CHL_DJF', 'GC_CHL_DJF',]:
chlfiles = meanDJF( monthlyFiles, outfolder='',cal=medusaCoords['cal'], timeAverage=True)
def CHL_MODEL(nc,keys):
chl = nc.variables[keys[0]][:,0] + nc.variables[keys[1]][:,0]
chl = np.ma.array(chl)
chl = np.ma.masked_where(chl.mask + (chl>10E10),chl)
return chl
def CHLMAM_Data(nc,keys):
chl = nc.variables[keys[0]][2:5].mean(0).squeeze()
chl = np.ma.array(chl)
chl = np.ma.masked_where(chl.mask + (chl>10E10),chl)
return chl
def CHLJJA_Data(nc,keys):
chl = nc.variables[keys[0]][5:8].mean(0).squeeze()
chl = np.ma.array(chl)
chl = np.ma.masked_where(chl.mask + (chl>10E10),chl)
return chl
def CHLSON_Data(nc,keys):
chl = nc.variables[keys[0]][8:11].mean(0)
chl = np.ma.masked_where(chl.mask + (chl>10E10),chl)
return chl
def CHLDJF_Data(nc,keys):
chl = []
chl.append(nc.variables[keys[0]][0])
chl.append(nc.variables[keys[0]][1])
chl.append(nc.variables[keys[0]][11])
chl = np.ma.array(chl).mean(0)
chl = np.ma.masked_where(chl.mask + (chl>10E10),chl)
return chl
av[name]['modelFiles'] = chlfiles
av[name]['modelcoords'] = medusaCoords
if name[:2] == 'GC':
av[name]['dataFile'] = paths.ObsFolder+'MO-GlobColour/qrclim_globcolour_masked.sea.nc'
av[name]['datacoords'] = mogcCoords
av[name]['datasource'] = 'MO-GlobColour'
chldatakey = 'chl'
else:
av[name]['dataFile'] = paths.CCIDir+'ESACCI-OC-L3S-OC_PRODUCTS-CLIMATOLOGY-16Y_MONTHLY_1degree_GEO_PML_OC4v6_QAA-all-fv2.0.nc'
av[name]['datacoords'] = cciCoords
av[name]['datasource'] = 'CCI'
chldatakey = 'chlor_a'
av[name]['modeldetails'] = {'name': name, 'vars':['CHN','CHD'], 'convert': CHL_MODEL,'units':'mg C/m^3'}
if name in ['CHL_MAM','GC_CHL_MAM']:
av[name]['datadetails'] = {'name': name, 'vars':[chldatakey,], 'convert': CHLMAM_Data,'units':'mg C/m^3'}
av[name]['regions'] = ['Equator10', 'Remainder', 'NorthernSubpolarAtlantic','NorthernSubpolarPacific','Global','SouthernOcean',]#'CCI_MAM']
if name in ['CHL_JJA','GC_CHL_JJA',]:
av[name]['datadetails'] = {'name': name, 'vars':[chldatakey,], 'convert': CHLJJA_Data,'units':'mg C/m^3'}
av[name]['regions'] = ['Equator10', 'Remainder', 'NorthernSubpolarAtlantic','NorthernSubpolarPacific','CCI_JJA','Global','SouthernOcean',]
if name in ['CHL_SON','GC_CHL_SON',]:
av[name]['datadetails'] = {'name': name, 'vars':[chldatakey,], 'convert': CHLSON_Data,'units':'mg C/m^3'}
av[name]['regions'] = ['Equator10', 'Remainder', 'NorthernSubpolarAtlantic','NorthernSubpolarPacific','Global','CCI_SON','SouthernOcean',]
if name in ['CHL_DJF','GC_CHL_DJF']:
av[name]['datadetails'] = {'name': name, 'vars':[chldatakey,], 'convert': CHLDJF_Data,'units':'mg C/m^3'}
av[name]['regions'] = ['Equator10', 'Remainder', 'NorthernSubpolarAtlantic','NorthernSubpolarPacific','CCI_DJF','Global','SouthernOcean',]
av[name]['layers'] = ['Surface',]
av[name]['metrics'] = metricList
av[name]['model'] = 'NEMO'
av[name]['modelgrid'] = 'eORCA1'
av[name]['gridFile'] = paths.orcaGridfn
av[name]['Dimensions'] = 2
else:
print "No monthly CHL files found"
if 'DTC' in analysisKeys:
for name in ['DTC',]:
if name not in analysisKeys: continue
av[name]['modelFiles'] = listModelDataFiles(jobID, 'ptrc_T', paths.ModelFolder_pref, annual)
av[name]['dataFile'] = ''
av[name]['modelcoords'] = medusaCoords
av[name]['datacoords'] = ''
av[name]['modeldetails'] = {'name': name, 'vars':[name,], 'convert': ukp.mul1000,'units':'umol-C/m3'}
av[name]['datadetails'] = {'name': '', 'units':''}
av[name]['layers'] = ['3000m',]#'100m',] # CCI is surface only, it's a satellite product.
av[name]['regions'] = regionList
av[name]['metrics'] = metricList #['mean','median', ]
av[name]['datasource'] = ''
av[name]['model'] = 'MEDUSA'
av[name]['modelgrid'] = 'eORCA1'
av[name]['gridFile'] = paths.orcaGridfn
av[name]['Dimensions'] = 3
if 'DiaFrac' in analysisKeys:
name = 'DiaFrac'
def caldiafrac(nc,keys):
chd = applyLandMask(nc,[keys[0],]).squeeze()
chn = applyLandMask(nc,[keys[1],]).squeeze()
return 100.*chd/(chd+chn)
av[name]['modelFiles'] = listModelDataFiles(jobID, 'ptrc_T', paths.ModelFolder_pref, annual)
av[name]['dataFile'] = ''
av[name]['modelcoords'] = medusaCoords
av[name]['datacoords'] = ''