This repository has been archived by the owner on Nov 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
rinex.py
79 lines (68 loc) · 2.27 KB
/
rinex.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
# -*- coding: utf-8 -*-
"""
this is my effort to write code that will pick up a RINEX file from unavco
if station is auto, assume the person wants the nav file
Kristine m. Larson
2018 August 20
Updated: April 3, 2019
May 22, 2019 - observation downloads go to $REFL_CODE/Files
should change so that day of year allowed
changed os.system commands to subprocess
"""
import argparse
import subprocess
import sys
import os
import gps as g
parser = argparse.ArgumentParser()
parser.add_argument("station", help="station name ", type=str)
parser.add_argument("year", help="year ", type=int)
parser.add_argument("month", help="month (if day is zero, then this is day of year)", type=int)
parser.add_argument("day", help="day ", type=int)
parser.add_argument("-rate", default=None, type=str, help="low/high (not required)")
args = parser.parse_args()
station = args.station
year = args.year
month = args.month
day = args.day
# if you use day of 0, then month is really the day of year
if day == 0:
doy = month
y, month, day, cyyyy,cdoy, YMD = g.ydoy2useful(year,doy)
if args.rate == None:
rate = 'low'
else:
rate = 'high'
# where Rinex observation files will be stored - to keep them out
# of the code directory
xdir = os.environ['REFL_CODE'] + '/Files/'
if not os.path.exists(xdir):
print('make an output directory')
os.makedirs(xdir)
rinexfile,rinexfiled = g.rinex_name(station, year, month, day)
# compute filename to find out if file exists
doy,cdoy,cyyyy,cyy = g.ymd2doy(year, month, day )
if station == 'auto':
fnameo = station + cdoy + '0.' + cyy + 'n'
else:
fnameo = station + cdoy + '0.' + cyy + 'o'
print('Seeking ', fnameo)
try:
# this is the way Radon said to do it
f1=open(fnameo,'r')
f1.close()
print('rinex file already exists')
except:
print('rinex file does not exist - will try to pick up ')
if station == 'auto':
# this will be stored in the appropriate area
g.getnavfile(year, month, day)
else:
if rate == 'low':
g.rinex_unavco(station, year, month, day)
else:
g.rinex_unavco_highrate(station, year, month, day)
if os.path.exists(rinexfile):
print('retrieved the rinex file - moving to Files directory')
print(xdir + rinexfile)
status = subprocess.call(['mv',rinexfile,xdir])