-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_ngca.py
67 lines (53 loc) · 1.81 KB
/
get_ngca.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
#!/usr/bin/env python3
""" This script downloads the NGCA from the AWS S3 bucket gda2020-ngca
"""
# Import modules
import argparse
import re
import pysftp
import sys
import os
import shutil
import glob
from ftplib import FTP
from datetime import datetime
# Create an ArgumentParser object
parser = argparse.ArgumentParser(
description='Download the NGCA from the AWS S3 bucket gda2020-ngca.',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# Add the arguments and parse the command line
parser.add_argument('-j', type=str, metavar='JURIS', default='all',
help='Download only the data from JURIS')
parser.add_argument('-v', action='version', version='%(prog)s v1.0')
args = parser.parse_args()
if args.j == 'all':
juris = ['act', 'tas', 'sa', 'vic', 'nt', 'wa', 'qld', 'nsw']
else:
juris = [args.j]
# Compile regular expressions
p1 = re.compile('\w{8}\.\d{2}o$', re.I)
# Move to the NGCA directory
print('* Moving to the NGCA directory')
os.chdir('/home/fedora/ngca/')
# Get today's date in the format YYYYMMDD
today = str(datetime.today())
archiveDate = today[0:10].replace('-','')
# Loop over the jurisdictions
for jur in juris:
print('* Processing ' + jur.upper())
# Create the archive directory and move to it
os.mkdir(jur + '/' + archiveDate)
os.chdir(jur + '/' + archiveDate)
# Download the files
print('* Downloading files')
os.system('aws s3 cp s3://gda2020-ngca/ngca/' + jur.lower() + \
' . --quiet --recursive --include "*"')
# Deleting old data
print('* Deleting old SINEX files and RINEX antenna information files')
os.chdir('../')
for cluster in glob.glob('rinexantls/*'):
os.remove(cluster)
for snxFile in glob.glob('sinexFiles/*') :
os.remove(snxFile)
# Move back up to main directory
os.chdir('../')