-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_gflg_description.py
46 lines (34 loc) · 1.27 KB
/
update_gflg_description.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
"""
update_gflg_description.py
Update the gflg description to only include 0 or 1
"""
import netCDF4 as nc
import sys
import os
import datetime as dt
from dateutil.relativedelta import relativedelta
import helper
import glob
START_DATE = dt.datetime(2021, 11, 1)
END_DATE = dt.datetime(2019, 6, 1)
def main():
date = START_DATE
while date >= END_DATE:
emailSubject = '"Starting to update netCDF gflg descriptions"'
emailBody = 'Starting to update netCDF gflg descriptions for {0}'.format(
date.strftime('%Y%m'))
helper.send_email(emailSubject, emailBody)
netcdfDir = date.strftime(helper.NETCDF_DIR_FMT)
fileList = glob.glob(os.path.join(netcdfDir, '*.nc'))
gflgDescription = 'Ground scatter flag for ACF, 1 - ground scatter, 0 - other scatter'
for file in fileList:
fh = nc.Dataset(file, mode='r+')
fh.variables['gflg'].long_name = gflgDescription
fh.close()
emailSubject = '"Finished updated netCDF gflg descriptions"'
emailBody = 'Finished updated netCDF gflg descriptions for {0}'.format(
date.strftime('%Y%m'))
helper.send_email(emailSubject, emailBody)
date -= relativedelta(months=1)
if __name__ == '__main__':
main()