-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVolcat_example.py
124 lines (57 loc) · 1.6 KB
/
Volcat_example.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
#!/usr/bin/env python
# coding: utf-8
# In[4]:
# In[5]:
import glob
import datetime
import os
import sys
# In[13]:
import volcat
import xarray as xr
# In[14]:
# replace with directory of volcat files.
tdir = '/hysplit3/alicec/projects/karymsky/volcat2/pc_corrected/'
# In[15]:
os.path.exists(tdir)
# In[48]:
# get all VOLCAT Files between two dates
drange = None
d1 = datetime.datetime(2021,11,3,8)
d2 = datetime.datetime(2021,11,3,9)
flist = glob.glob(tdir + '*nc')
das = volcat.get_volcat_list(tdir,flist=None,verbose=True, daterange=[d1,d2])
# In[49]:
print(len(das))
# In[50]:
# just open one volcat file with xarray
dset = xr.open_dataset(flist[10],engine='netcdf4')
# In[51]:
dset.ash_mass_loading.isel(time=0).plot.pcolormesh(x='longitude',y='latitude')
# In[52]:
# get dataframe with info from all the files.
df = volcat.get_volcat_name_df(tdir)
# In[53]:
print(df)
# In[54]:
das
# In[55]:
# add the files into one data-array with a time axis
dset = volcat.combine_regridded(das)
# In[56]:
# perform the time averaging (only on the mass loading field)
dset_averaged = dset.ash_mass_loading.mean(dim='time')
# In[57]:
# plot
dset_averaged.plot.pcolormesh(x='longitude',y='latitude')
# In[ ]:
# mass loading
# array with total mass from each time period
# THis is directly from the volcat files which come with total mass
total_mass=[]
for d in das:
total_mass.append(float(d.ash_mass_loading_total_mass.values))
# another way which multiplies area by mass loading
# field in data array must be in g/m2.
# returns mass in Tg
volcat.check_total_mass(dset_averaged)