forked from ledm/bgc-val
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeReport.py
executable file
·1729 lines (1545 loc) · 58.3 KB
/
makeReport.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/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:: makeReport
:platform: Unix
:synopsis: A script to produce an html5 document summarising a jobs performance.
.. moduleauthor:: Lee de Mora <[email protected]>
"""
#####
# Load Standard Python modules:
from glob import glob
from sys import argv
import os
import shutil
#####
# Load specific local code:
from UKESMpython import folder, shouldIMakeFile, round_sig
from html5 import html5Tools, htmltables
from bgcvaltools.pftnames import getLongName
from timeseries.analysis_level0 import analysis_level0, analysis_level0_insitu
from paths import imagedir
def copytree(src, dst, symlinks=False, ignore=None):
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
try:
shutil.copytree(s, d, symlinks, ignore)
except:
pass
else:
try:
shutil.copy2(s, d)
except:
pass
def addImageToHtml(fn, imagesfold, reportdir, debug=True):
#####
# Note that we use three paths here.
# fn: The original file path relative to here
# newfn: The location of the new copy of the file relative to here
# relfn: The location of the new copy relative to the index.html
newfn = imagesfold + os.path.basename(fn)
relfn = newfn.replace(reportdir, './')
if not os.path.exists(newfn):
if debug: print("cp", fn, newfn)
shutil.copy2(fn, newfn)
else:
####
# Check if the newer file is the same one from images.
if os.path.getmtime(fn) == os.path.getmtime(newfn): return relfn
####
# Check if file is newer than the one in images.
if shouldIMakeFile(
fn,
newfn,
):
if debug: print("removing old file", fn)
os.remove(newfn)
shutil.copy2(fn, newfn)
if debug: print("cp", fn, newfn)
return relfn
def html5Maker(
jobID='u-ab749',
reportdir='reports/tmp',
year='*',
clean=False,
doZip=False,
physicsOnly=False,
):
if clean:
#####
# Delete old files
print("Removing old files from:", reportdir)
try:
shutil.rmtree(reportdir)
except:
pass
reportdir = folder(reportdir)
year = str(year)
####
# Copy all necceasiry objects and templates to the report location:
print("Copying html and js assets to", reportdir)
copytree('html5/html5Assets', reportdir)
indexhtmlfn = reportdir + "index.html"
try:
os.rename(reportdir + 'index-template.html', indexhtmlfn)
except:
pass
imagesfold = folder(reportdir + 'images/')
def newImageLocation(fn):
return imagesfold + os.path.basename(fn)
#####
#
descriptionText = 'Validation of the job: ' + jobID
if year != '*': descriptionText += ', in the year: ' + year
html5Tools.writeDescription(
indexhtmlfn,
descriptionText,
)
#####
# Two switches to turn on Summary section, and groups of plots of field and region.
Level0 = True
Level1 = True
Level1Regional = True
Level1Profiles = True
level2Horizontal = True
level2Physics = False
summarySections = False
level3OMZ = False
Level3Salinity = False
regionMap = True
#####
# A list of caveats linked to specific datasets or regions, or jobs.
ListofCaveats, ListofCaveats_regions = {}, {}
ListofCaveats[
'ExportRatio'] = 'Note that there is no historic data set for this variable.'
ListofCaveats[
'Iron'] = 'Note that there is no suitable historic data set for this variable.'
ListofCaveats[
'MLD'] = 'Note that the Model MLD is calculated with based on a sigma_0 difference of 0.01 with the surface where as data uses as \
sigma_0 difference of +/- 0.2 degrees from a depth on 10m.'
ListofCaveats[
'Nitrate'] = 'Note that MEDUSA uses Dissolved Inorganic Nitrogen (DIN) rather than nitrate. We assume that non-nitrate parts of DIN are of relatively minor importance and so assume that WOA nitrate is comparable to model DIN.'
ListofCaveats[
'TotalDust'] = "This field has the Mediterranean, Red, Caspian, Black and Baltic seas excluded in both the model and data."
if jobID == 'u-ad371':
ListofCaveats[
'Chlorophyll_cci'] = 'Note that the Non-diatom chlorophyll failed in run:' + jobID
ListofCaveats[
'IntegratedPrimaryProduction_OSU'] = 'Note that the Non-diatom chlorophyll does not contribute to IntPP in this run:' + jobID
if Level0:
# Level 0 metrics
# x 1. Globally integrated primary production
# x 2. Global average export fraction (i.e. globally integrated export / globally integrated primary production)
# x 3. Globally integrated CO2 flux
# x 4. Globally averaged surface DIN concentration
# x 5. Globally averaged surface silicic acid concentration
# x 6. Globally averaged surface DIC concentration
# 7. Globally averaged surface alkalinity concentration
# 8-11. As 4-7, but for the surface Southern Ocean [*]
# x 12. AMOC
# x 13. Drake transport
# 14-15. Volume of the Arctic / Antarctic sea-ice
# 16-17. Extent of the Arctic / Antarctic sea-ice
SectionTitle = 'Level 0'
href = 'level0-table'
table_data = []
Description = 'A set of metrics to describe the state of the run.'
Caption = ''
realData_dict = {
'TotalIntegratedPrimaryProduction': 'Target: 40-60',
'ExportRatio': 'Target: 0.15 - 0.25',
'TotalAirSeaFluxCO2': 'Target: -0.1 - 0.1',
'Nitrate': '',
'Silicate': '',
'DIC': '',
'Alkalinity': '',
'AMOC_26N': 'Target: 10-20',
'DrakePassageTransport': '136.7 ± 7.8 ', # ± is +/-
'NorthernTotalIceExtent': '14.9 ± 0.3',
'SouthernTotalIceExtent': '19.8 ± 0.6',
'TotalOMZVolume': '',
}
realData_source = {
'TotalIntegratedPrimaryProduction': '',
'ExportRatio': '',
'TotalAirSeaFluxCO2': '',
'Nitrate': 'World Ocean Atlas',
'Silicate': 'World Ocean Atlas',
'DIC': 'GLODAP',
'Alkalinity': '',
'AMOC_26N': '',
'DrakePassageTransport':
'Cunningham, S. A., S. G. Alderson, B. A. King, and M. A. Brandon (2003), Transport and variability of the Antarctic Circumpolar Current in Drake Passage, J. Geophys. Res., 108, 8084, doi:10.1029/2001JC001147, C5.',
'NorthernTotalIceExtent':
'HadISST: Rayner, N. A.; et al (2003) Global analyses of sea surface temperature, sea ice, and night marine air temperature since the late nineteenth century J. Geophys. Res.Vol. 108, No. D14, 4407 10.1029/2002JD002670',
'SouthernTotalIceExtent':
'HadISST: Rayner, N. A.; et al (2003) Global analyses of sea surface temperature, sea ice, and night marine air temperature since the late nineteenth century J. Geophys. Res.Vol. 108, No. D14, 4407 10.1029/2002JD002670',
'TotalOMZVolume': 'World Ocean Atlas',
}
units_dict = {
'TotalIntegratedPrimaryProduction': 'Gt/yr',
'ExportRatio': '', # no units
'TotalAirSeaFluxCO2': 'Pg C/yr',
'Nitrate': 'mmol N/m³', # ³ is superscript 3
'Silicate': 'mmol Si/m³',
'DIC': 'mmol C/m³',
'Alkalinity': 'meq/m³',
'AMOC_26N': 'Sv',
'DrakePassageTransport': 'Sv',
'NorthernTotalIceExtent':
'x 1E6 km²', # ² is superscript 2
'SouthernTotalIceExtent': 'x 1E6 km²',
'TotalOMZVolume': 'm³',
}
fields = [
'TotalIntegratedPrimaryProduction',
'ExportRatio',
'TotalAirSeaFluxCO2',
'Nitrate',
'Silicate',
'DIC',
'Alkalinity',
'TotalOMZVolume',
'AMOC_26N',
'DrakePassageTransport',
'NorthernTotalIceExtent',
'SouthernTotalIceExtent',
]
physFields = [
'AMOC_26N',
'DrakePassageTransport',
'NorthernTotalIceExtent',
'SouthernTotalIceExtent',
]
timestrs = []
for field in fields:
if physicsOnly and field not in physFields: continue
if field in [
'Nitrate', 'Silicate', 'DIC', 'Alkalinity', 'Temperature',
'Salinity'
]:
for (r, l, m) in [('Global', 'Surface', 'mean'),
('SouthernOcean', 'Surface', 'mean'),
('AtlanticSOcean', 'Surface', 'mean')]:
#####
# Data column:
try:
rdata = realData_dict[field]
except:
rdata = ''
if rdata == '':
rdata = analysis_level0_insitu(jobID=jobID,
field=field,
region=r,
layer=l,
metric=m)
if rdata == False: rdata = ''
else: rdata = round_sig(rdata, 4)
try:
u = ' ' + units_dict[field]
except:
u = ''
try:
source = realData_source[field]
except:
source = ''
datcol = str(rdata) + u
name, mdata, timestr = analysis_level0(jobID=jobID,
field=field,
region=r,
layer=l,
metric=m)
longname = getLongName(name, debug=1)
if False in [name, mdata, timestr]:
table_data.append([longname, '', datcol])
continue
if timestr not in timestrs: timestrs.append(timestr)
modcol = str(round_sig(mdata, 4)) + u
table_data.append([longname, modcol, datcol])
if len(source):
Caption += '<br><b>' + getLongName(
field) + '</b>: The data was taken from: ' + source
else:
#####
# Data column:
try:
rdata = realData_dict[field]
except:
rdata = ''
if rdata == '':
rdata = analysis_level0_insitu(jobID=jobID,
field=field,
region='regionless',
layer='layerless',
metric='metricless')
if rdata == False: rdata = ''
else: rdata = round_sig(rdata, 4)
try:
u = ' ' + units_dict[field]
except:
u = ''
try:
source = realData_source[field]
except:
source = ''
datcol = str(rdata) + u
name, mdata, timestr = analysis_level0(
jobID=jobID,
field=field,
) #region='regionless', layer='layerless', metric='metricless')
longname = getLongName(name, debug=1)
if False in [name, mdata, timestr]:
table_data.append([longname, '', datcol])
continue
if timestr not in timestrs: timestrs.append(timestr)
longname = getLongName(name, debug=1)
modcol = str(round_sig(mdata, 4)) + u
# Caption+= '<br><b>'+longname+':</b> Model is the mean of the range '+timestr +'. '+\
# 'The data was taken from: '+source
table_data.append([longname, modcol, datcol])
if len(source):
Caption += '<br><b>' + longname + '</b>: The data was taken from: ' + source
if len(timestrs):
Caption += '<br><b> Model</b> is the mean of the annual means in the range ' + timestrs[
0] + '. '
l0htmltable = htmltables.table(
table_data,
header_row=['Property', 'Model', 'Data'],
col_align=['left', 'center', 'center'],
)
html5Tools.AddTableSection(indexhtmlfn,
href,
SectionTitle,
Description=Description,
Caption=Caption,
tablehtml=l0htmltable)
if Level1:
level1Fields = [
'TotalIntegratedPrimaryProduction',
'ExportRatio',
'AirSeaFluxCO2',
'Nitrate',
'DIC',
'pH',
'Alkalinity',
'Chlorophyll',
'Chlorophyll_cci',
'DiaFrac',
'TotalDust',
#'DiatomChlorophyll',
#'NonDiatomChlorophyll',
'TotalOMZVolume',
'Temperature',
'GlobalMeanTemperature',
'IcelessMeanSST',
'Salinity',
'GlobalMeanSalinity',
'TotalIceArea',
'TotalIceExtent',
'DrakePassageTransport',
'AMOC_26N',
'ADRC_26N',
'ZonalCurrent',
'MeridionalCurrent',
'VerticalCurrent',
'MLD',
'MaxMonthlyMLD',
'MinMonthlyMLD'
]
lev1physFields = [
'Temperature',
'GlobalMeanTemperature',
'IcelessMeanSST',
'Salinity',
'GlobalMeanSalinity',
'TotalIceArea',
'TotalIceExtent',
'WeddelIceExtent',
'DrakePassageTransport',
'AMOC_26N',
'ADRC_26N',
'MIZ',
'ZonalCurrent',
'MeridionalCurrent',
'VerticalCurrent',
'MLD',
'MaxMonthlyMLD',
'MinMonthlyMLD',
]
SectionTitle = 'Level 1'
hrefs = []
Titles = {}
SidebarTitles = {}
Descriptions = {}
FileLists = {}
#region = 'Global'
for key in level1Fields:
#print "Make Report\tLevel 1:",key
if physicsOnly and key not in lev1physFields: continue
#print "Make Report\tLevel 1:",key
#####
# href is the name used for the html
href = 'L1' + key + '-global'
hrefs.append(href)
#print "Make Report\tLevel 1:",key, href
#####
# Title is the main header, SidebarTitles is the side bar title.
Titles[href] = getLongName(key)
SidebarTitles[href] = getLongName(key)
#print "Make Report\tLevel 1:",key, Titles[href]
#####
# Descriptions is a small sub-header
desc = ''
if key in list(ListofCaveats.keys()):
desc += ListofCaveats[key] + '\n'
#if region in ListofCaveats_regions.keys(): desc +=ListofCaveats_regions[key]+'\n'
Descriptions[href] = desc
#print "Make Report\tLevel 1:",key, desc
#####
# A list of files to put in this group.
FileLists[href] = {}
#####
# Determine the list of files:
vfiles = glob(imagedir + '/' + jobID +
'/timeseries/*/percentiles*' + key + '*' +
'Global*10-90pc.png')
#vfiles.extend(glob(imagedir+'/'+jobID+'/timeseries/*/profile*'+key+'*'+region+'*median.png'))
#vfiles.extend(glob(imagedir+'/'+jobID+'/timeseries/*/Sum*'+key+'*'+region+'*sum.png'))
vfiles.extend(
glob(imagedir + '/' + jobID + '/timeseries/*/sum*' + key +
'*' + 'Global*sum.png'))
vfiles.extend(
glob(imagedir + '/' + jobID + '/timeseries/*/mean*' + key +
'*' + 'Global*mean.png'))
vfiles.extend(
glob(imagedir + '/' + jobID + '/timeseries/*/*' + key + '*' +
'regionless*metricless.png'))
#####
# Exceptions:
if key in [
'AirSeaFluxCO2',
]:
vfiles.extend(
glob(
imagedir + '/' + jobID +
'/timeseries/*/sum*NoCaspianAirSeaFluxCO2_ignoreCaspian_layerless_sum.png'
))
#vfiles.extend(glob(imagedir+'/'+jobID+'/P2Pplots/*/*'+key+'*/*/*'+region+'*'+key+'*'+year+'*hist.png'))
#vfiles.extend(glob(imagedir+'/'+jobID+'/P2Pplots/*/*'+key+'*/*/*'+region+'*'+key+'*'+year+'*robinquad.png'))
#vfiles.extend(glob(imagedir+'/'+jobID+'/P2Pplots/*/*'+key+'*/*/*'+region+'*'+key+'*'+year+'*scatter.png'))
#vfiles.extend(glob(imagedir+'/'+jobID+'/Targets/'+year+'/*'+key+'*/BGCVal/*.png'))
#####
# Create plot headers for each file.
for fn in vfiles:
#####
# Copy image to image folder and return relative path.
relfn = addImageToHtml(fn, imagesfold, reportdir)
####
# WOA fields that also produce transects, etc.
if key in [
'Nitrate', 'Silicate', 'Temperature', 'Salinity',
'Oxygen', 'DIC', 'Alkalinity'
] and fn.lower().find('surface') < 0:
continue
if key in ['ExportRatio'] and fn.find('_' + key) < 0:
continue # make sure it's the global one, not the local one.
#####
# Create custom title by removing extra bits.
#title = filenameToTitle(relfn)
FileLists[href][relfn] = html5Tools.fnToTitle(relfn)
print("Adding ", relfn, "to script")
#print "Make Report\tLevel 1:",key, FileLists[href]
html5Tools.AddSubSections(
indexhtmlfn,
hrefs,
SectionTitle,
SidebarTitles=SidebarTitles, #
Titles=Titles,
Descriptions=Descriptions,
FileLists=FileLists)
if Level1Regional:
l1regions = [
'Global',
'SouthernOcean',
'AtlanticSOcean',
'NorthernSubpolarAtlantic',
'NorthernSubpolarPacific',
'Equator10',
'ArcticOcean',
'Remainder',
'ignoreInlandSeas',
]
regionalFields = [
'AirSeaFluxCO2',
'Nitrate',
'Silicate',
'Iron',
'IntegratedPrimaryProduction_OSU',
'Chlorophyll',
'Chlorophyll_cci',
'pH',
'DiaFrac',
'Dust',
#'DiatomChlorophyll',
#'NonDiatomChlorophyll',
'OMZThickness',
'OMZMeanDepth',
'Temperature',
'Salinity',
'ZonalCurrent',
'MeridionalCurrent',
'VerticalCurrent',
'MaxMonthlyMLD',
'MinMonthlyMLD',
#'TotalIceArea'
]
physregionalFields = [
'Temperature',
'Salinity',
'TotalIceArea',
'TotalIceExtent',
'ZonalCurrent',
'MeridionalCurrent',
'VerticalCurrent',
'MaxMonthlyMLD',
'MinMonthlyMLD',
]
SectionTitle = 'Level 1 - regional'
hrefs = []
Titles = {}
SidebarTitles = {}
Descriptions = {}
FileLists = {}
FileOrder = {}
for key in regionalFields:
if physicsOnly and key not in physregionalFields: continue
#if key not in ['Alkalinity','Nitrate']: continue
href = 'L1region' + key #+'-'+region
desc = ''
if key in list(ListofCaveats.keys()):
desc += ListofCaveats[key] + '\n'
#if region in ListofCaveats_regions.keys(): desc +=ListofCaveats_regions[key]+'\n'
hrefs.append(href)
Titles[href] = getLongName(key)
SidebarTitles[href] = getLongName(key)
Descriptions[href] = desc
FileLists[href] = {}
FileOrder[href] = {}
#####
# Determine the list of files:
# It preferentially plots
vfiles = []
for region in l1regions:
regfiles = glob(imagedir + '/' + jobID +
'/timeseries/*/percentiles*' + key + '*' +
region + '*10-90pc.png')
print(
"Adding",
imagedir + '/' + jobID + '/timeseries/*/percentiles*' +
key + '*' + region + '*10-90pc.png')
vfiles.extend(regfiles)
if len(regfiles): continue
vfiles.extend(
glob(imagedir + '/' + jobID + '/timeseries/*/mean*' + key +
'*' + region + '*mean.png'))
print(
"Adding", imagedir + '/' + jobID + '/timeseries/*/mean*' +
key + '*' + region + '*mean.png')
#####
# Create plot headers for each file.
count = 0
for fn in vfiles:
#####
# Skip transects, they'll be added below.
if fn.find('Transect') > -1: continue
#if fn.lower().find('surface')<0 or fn.lower().find('layerless')<0:continue
#####
# Copy image to image folder and return relative path.
relfn = addImageToHtml(fn, imagesfold, reportdir)
#####
# Create custom title by removing extra bits.
title = html5Tools.fnToTitle(relfn)
FileLists[href][relfn] = title
FileOrder[href][count] = relfn
count += 1
print("Adding ", relfn, "to script")
html5Tools.AddSubSections(
indexhtmlfn,
hrefs,
SectionTitle,
SidebarTitles=SidebarTitles, #
Titles=Titles,
Descriptions=Descriptions,
FileLists=FileLists,
FileOrder=FileOrder)
if Level1Profiles:
#for plottype in ['profile','profilehov']: # with Hovs
for plottype in [
'profile',
]: # without hovs.
l1regions = [
'Global',
'SouthernOcean',
'AtlanticSOcean',
'NorthernSubpolarAtlantic',
'NorthernSubpolarPacific',
'Equator10',
'ArcticOcean',
'Remainder',
'ignoreInlandSeas',
]
regionalFields = [
'Nitrate',
'Silicate',
'Iron',
'DIC',
'Chlorophyll',
'pH',
'Alkalinity',
'Oxygen',
'Temperature',
'Salinity',
'ZonalCurrent',
'MeridionalCurrent',
'VerticalCurrent',
]
physregionalFields = [
'Temperature',
'Salinity',
'ZonalCurrent',
'MeridionalCurrent',
'VerticalCurrent',
]
if plottype == 'profile': SectionTitle = 'Level 1 - Profiles'
if plottype == 'profilehov':
SectionTitle = 'Level 1 - Hovmoeller plots'
hrefs = []
Titles = {}
SidebarTitles = {}
Descriptions = {}
FileLists = {}
FileOrder = {}
for key in regionalFields:
if physicsOnly and key not in physregionalFields: continue
#if key not in ['Alkalinity','Nitrate']: continue
href = 'L1' + plottype + '-' + key #+'-'+region
desc = ''
if key in list(ListofCaveats.keys()):
desc += ListofCaveats[key] + '\n'
#if region in ListofCaveats_regions.keys(): desc +=ListofCaveats_regions[key]+'\n'
hrefs.append(href)
Titles[href] = getLongName(key)
SidebarTitles[href] = getLongName(key)
Descriptions[href] = desc
FileLists[href] = {}
FileOrder[href] = {}
#####
# Determine the list of files:
vfiles = []
for region in l1regions:
#vfiles.extend(glob(imagedir+'/'+jobID+'/timeseries/*/percentiles*'+key+'*'+region+'*10-90pc.png'))
if plottype == 'profile':
vfiles.extend(
glob(imagedir + '/' + jobID +
'/timeseries/*/profile_*' + key + '*' +
region + '*mean.png'))
if plottype == 'profilehov':
vfiles.extend(
glob(imagedir + '/' + jobID +
'/timeseries/*/profilehov_*' + key + '*' +
region + '*mean.png'))
#####
# Create plot headers for each file.
count = 0
for fn in vfiles:
#####
# Skip transects, they'll be added below.
if fn.find('Transect') > -1: continue
#if fn.lower().find('surface')<0:continue
#####
# Copy image to image folder and return relative path.
relfn = addImageToHtml(fn, imagesfold, reportdir)
#####
# Create custom title by removing extra bits.
title = html5Tools.fnToTitle(relfn)
FileLists[href][relfn] = title
FileOrder[href][count] = relfn
count += 1
print("Adding ", relfn, "to script")
html5Tools.AddSubSections(
indexhtmlfn,
hrefs,
SectionTitle,
SidebarTitles=SidebarTitles, #
Titles=Titles,
Descriptions=Descriptions,
FileLists=FileLists,
FileOrder=FileOrder)
if level2Horizontal:
l2Fields = [
'Nitrate',
'Silicate',
'DIC',
'pH',
'Alkalinity',
'Oxygen',
'Chlorophyll_cci',
#'TotalIntegratedPrimaryProduction',
'IntegratedPrimaryProduction_OSU',
'AirSeaFluxCO2',
'Dust',
#'TotalOMZVolume',
#'TotalAirSeaFluxCO2' ,
'Temperature',
'Salinity',
'MLD',
'ZonalCurrent',
'MeridionalCurrent',
'VerticalCurrent',
]
physl2Fields = [
'Temperature',
'Salinity',
'MLD',
'ZonalCurrent',
'MeridionalCurrent',
'VerticalCurrent',
]
hrefs = []
Titles = {}
SidebarTitles = {}
Descriptions = {}
FileLists = {}
SectionTitle = 'Level 2'
region = 'Global'
slices = [
'Surface',
'1000m',
'Transect',
]
FileOrder = {}
for key in l2Fields:
if physicsOnly and key not in physl2Fields: continue
#if key not in ['Alkalinity','Nitrate']: continue
href = 'l2-' + key + '-' + region
desc = ''
if key in list(ListofCaveats.keys()):
desc += ListofCaveats[key] + '\n'
if region in list(ListofCaveats_regions.keys()):
desc += ListofCaveats_regions[key] + '\n'
hrefs.append(href)
Titles[href] = getLongName(region) + ' ' + getLongName(key)
SidebarTitles[href] = getLongName(key)
Descriptions[href] = desc
FileLists[href] = {}
FileOrder[href] = {}
#####
# Determine the list of files:
vfiles = []
#vfiles = glob(imagedir+'/'+jobID+'/timeseries/*/percentiles*'+key+'*'+region+'*10-90pc.png')
#vfiles.extend(glob(imagedir+'/'+jobID+'/timeseries/*/profile*'+key+'*'+region+'*median.png'))
#vfiles.extend(glob(imagedir+'/'+jobID+'/timeseries/*/Sum*'+key+'*'+region+'*sum.png'))
#vfiles.extend(glob(imagedir+'/'+jobID+'/P2Pplots/*/*'+key+'*/*/*'+region+'*'+key+'*'+year+'*hist.png'))
for s in slices:
if s in [
'Surface',
'1000m',
]:
print(
"looking for", imagedir + '/' + jobID +
'/P2Pplots/*/*' + key + '*/*/*' + s + '*' + region +
'*' + key + '*' + year + '*robinquad.png')
vfiles.extend(
glob(imagedir + '/' + jobID + '/P2Pplots/*/*' + key +
'*/*/*' + s + '*' + region + '*' + key + '*' +
year + '*robinquad.png'))
vfiles.extend(
glob(imagedir + '/' + jobID + '/P2Pplots/*/*' + key +
'*/*/*' + s + '*' + region + '*' + key + '*' +
year + '*robinquad-cartopy.png'))
if s in [
'Transect',
]:
vfiles.extend(
glob(imagedir + '/' + jobID + '/P2Pplots/*/*' + key +
'*Transect/*/*' + s + '*' + region + '*' + key +
'*' + year + '*transect.png'))
if key in [
'Chlorophyll_cci',
'IntegratedPrimaryProduction_OSU',
'AirSeaFluxCO2',
'MLD',
]:
vfiles.extend(
glob(imagedir + '/' + jobID + '/P2Pplots/*/*' + key +
'*/*/*' + region + '*' + key + '*' + year +
'*robinquad.png'))
vfiles.extend(
glob(imagedir + '/' + jobID + '/P2Pplots/*/*' + key +
'*/*/*' + region + '*' + key + '*' + year +
'*robinquad-cartopy.png'))
#####
# Create plot headers for each file.
count = 0
for fn in vfiles:
#####
# Skip transects, they'll be added below.
#if fn.find('Transect') >-1: continue
#####
# Copy image to image folder and return relative path.
relfn = addImageToHtml(fn, imagesfold, reportdir)
#####
# Create custom title by removing extra bits.
title = html5Tools.fnToTitle(relfn)
FileLists[href][relfn] = title
FileOrder[href][count] = relfn
count += 1
print("Adding ", relfn, "to script")
html5Tools.AddSubSections(
indexhtmlfn,
hrefs,
SectionTitle,
SidebarTitles=SidebarTitles, #
Titles=Titles,
Descriptions=Descriptions,
FileLists=FileLists,
FileOrder=FileOrder)
if level2Physics:
l2Fields = [
'Temperature',
'Salinity',
'MLD',
'ZonalCurrent',
'MeridionalCurrent',
'VerticalCurrent',
]
hrefs = []
Titles = {}
SidebarTitles = {}
Descriptions = {}
FileLists = {}
SectionTitle = 'Level 2 - Physics'
region = 'Global'
slices = [
'Surface',
'1000m',
'Transect',
]
FileOrder = {}
for key in sorted(l2Fields):
#if key not in ['Alkalinity','Nitrate']: continue
href = 'l2p-' + key + '-' + region
desc = ''
if key in list(ListofCaveats.keys()):
desc += ListofCaveats[key] + '\n'
if region in list(ListofCaveats_regions.keys()):
desc += ListofCaveats_regions[key] + '\n'
hrefs.append(href)
Titles[href] = getLongName(region) + ' ' + getLongName(key)
SidebarTitles[href] = getLongName(key)
Descriptions[href] = desc
FileLists[href] = {}
FileOrder[href] = {}
#####
# Determine the list of files:
vfiles = []
#vfiles = glob(imagedir+'/'+jobID+'/timeseries/*/percentiles*'+key+'*'+region+'*10-90pc.png')
#vfiles.extend(glob(imagedir+'/'+jobID+'/timeseries/*/profile*'+key+'*'+region+'*median.png'))
#vfiles.extend(glob(imagedir+'/'+jobID+'/timeseries/*/Sum*'+key+'*'+region+'*sum.png'))
#vfiles.extend(glob(imagedir+'/'+jobID+'/P2Pplots/*/*'+key+'*/*/*'+region+'*'+key+'*'+year+'*hist.png'))
for s in slices:
if s in [
'Surface',
'1000m',
]:
vfiles.extend(
glob(imagedir + '/' + jobID + '/P2Pplots/*/*' + key +
'*/*/*' + s + '*' + region + '*' + key + '*' +
year + '*robinquad.png'))
vfiles.extend(
glob(imagedir + '/' + jobID + '/P2Pplots/*/*' + key +
'*/*/*' + s + '*' + region + '*' + key + '*' +
year + '*robinquad-cartopy.png'))
if s in [
'Transect',
]:
vfiles.extend(
glob(imagedir + '/' + jobID + '/P2Pplots/*/*' + key +
'*Transect/*/*' + s + '*' + region + '*' + key +
'*' + year + '*transect.png'))
if key in [
'Chlorophyll_cci',
'IntegratedPrimaryProduction_OSU',
'AirSeaFluxCO2',
'MLD',
]:
vfiles.extend(
glob(imagedir + '/' + jobID + '/P2Pplots/*/*' + key +
'*/*/*' + region + '*' + key + '*' + year +
'*robinquad.png'))
vfiles.extend(
glob(imagedir + '/' + jobID + '/P2Pplots/*/*' + key +
'*/*/*' + region + '*' + key + '*' + year +
'*robinquad-cartopy.png'))
#####
# Create plot headers for each file.
count = 0
for fn in vfiles: