forked from GC-Hg/HgBenchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_total_seasalthg.pro
102 lines (70 loc) · 2.72 KB
/
get_total_seasalthg.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
function get_total_seasalthg, FileName=FileName, $
Months=Months, $
GridInfoOut=GridInfoOut, $
Total=Total, $
PerDay=PerDay, $
noCheck=noCheck, $
_Extra=_Extra
; Get total Hg2 uptake into seasalt aerosols
; Return the result as ug/m2
;=======================================
; Setup
;=======================================
if ( not Keyword_set( FileName ) ) then $
FileName = '~/runs/HgBr.v8-01-01/ctm.bpch.stdOx'
if ( not Keyword_set( Months ) ) then $
Months = indgen( 12 )+1
; Convert kg to ug
kg2ug = 1d9
; Convert kg to Mg
kg2Mg = 1d-3
; Convert molec to kg
molec2kg = 0.201 / 6.02d23
; keyword to return result at ug/m2/d
PerDay= keyword_set( PerDay )
; We require 12 monthly entries, unless noCheck is True
doCheck = ~keyword_set( noCheck )
;=======================================
; Extract GEOS-Chem Data
;=======================================
SeasaltHg = 0d0
SumDeltaTd = 0d0
nFiles=n_elements( FileName )
for F=0L, nFiles-1L do begin
; Sea-salt Hg2 uptake, kg
ctm_get_data, DataInfo, 'PL-HG2-$', FileName=FileName[F], Tracer=4
getmodelandgridinfo, DataInfo[0], ModelInfo, GridInfo
; Get grid area [m2]
area_m2 = ctm_boxsize( GridInfo, /m2 )
; Number of time steps in the DataInfo structures (should all be same)
n_times = n_elements( DataInfo )
; check whether there are 12 times in the file (assume they are months)
if ( n_times ne 12 and (doCheck) ) then $
message, 'File does not contain 12 monthly means'
for iMonth=0L, n_times-1L do begin
; Total only requested months
tmp = where( Months eq iMonth+1, ct )
if (ct ge 1) then begin
; Start and end times of data entry [hr]
tau0 = DataInfo[iMonth].Tau0
tau1 = DataInfo[iMonth].Tau1
; Elapsed time during data collection [d]
deltaTd = (Tau1-Tau0) / 24.
; Total time elapsed during all [d]
SumDeltaTd = SumDeltaTd + deltaTd
; Calculate Dry Dep [ug/m2/yr]
SeasaltHg = SeasaltHg + $
*(DataInfo[iMonth].Data) * kg2ug / area_m2
endif
endfor
endfor
; Total Wet dep, kg
Total = total( SeasaltHg * area_m2 / kg2ug )
; Average over files
SeasaltHg = SeasaltHg / nFiles
; Return dep per day if requested
if ( PerDay ) then begin
SeasaltHg = SeasaltHg / ( float(SumDeltaTd) / float(nFiles) )
endif
return, SeasaltHg
end