-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_albany_plots.py
executable file
·77 lines (66 loc) · 2.2 KB
/
get_albany_plots.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
#!/usr/bin/python
import os
import sys
import time
from datetime import timedelta
from datetime import datetime
import shutil
from ftplib import FTP
# User inputs
debug = 1
test = False
baseUrl = 'http://www.atmos.albany.edu/student/mbartolini/research/impacts/images'
tempDir = '/tmp'
catMrrPrefix = 'radar.MRR'
catParsivelPrefix = 'surface.Parsivel'
# Open ftp connection
if test:
ftpCatalogServer = 'ftp.atmos.washington.edu'
ftpCatalogUser = 'anonymous'
ftpCatalogPassword = '[email protected]'
catalogDestDir = 'brodzik/incoming/impacts'
else:
ftpCatalogServer = 'catalog.eol.ucar.edu'
ftpCatalogUser = 'anonymous'
catalogDestDir = '/pub/incoming/catalog/impacts'
if test:
catalogFTP = FTP(ftpCatalogServer,ftpCatalogUser,ftpCatalogPassword)
catalogFTP.cwd(catalogDestDir)
else:
catalogFTP = FTP(ftpCatalogServer,ftpCatalogUser)
catalogFTP.cwd(catalogDestDir)
# Move to tempDir
os.chdir(tempDir)
# get yesterday's date in PST
# cron runs at 2000 PST or 0100 UCT
# images created for prior day
dateStr = datetime.strftime(datetime.now() - timedelta(1), '%Y%m%d')
#dateStr = now.strftime("%Y%m%d")
# ARCHIVE MODE
#dateStr = '20230115'
if debug:
print("dateStr = ", dateStr)
mrrFiles = [catMrrPrefix+'.'+dateStr+'0000.UAlbany_CFAD.png',
catMrrPrefix+'.'+dateStr+'0000.UAlbany_time_ht.png']
parsivelFiles = [catParsivelPrefix+'.'+dateStr+'0000.UAlbany_Parsivel_vs_MRR.png',
catParsivelPrefix+'.'+dateStr+'0000.UAlbany.png',
catParsivelPrefix+'.'+dateStr+'0000.UAlbany_vel_diam_hist.png',
catParsivelPrefix+'.'+dateStr+'0000.UAlbany_psd_rrdbz.png']
for file in mrrFiles:
url = baseUrl+'/mrr/'+file
command = 'wget '+url
os.system(command)
ftpFile = open(os.path.join(tempDir,file),'rb')
catalogFTP.storbinary('STOR '+file,ftpFile)
ftpFile.close()
os.remove(os.path.join(tempDir,file))
for file in parsivelFiles:
url = baseUrl+'/parsivel/'+file
command = 'wget '+url
os.system(command)
ftpFile = open(os.path.join(tempDir,file),'rb')
catalogFTP.storbinary('STOR '+file,ftpFile)
ftpFile.close()
os.remove(os.path.join(tempDir,file))
# Close ftp connection
catalogFTP.quit()