4
4
Date: 08/30/22 12:44 PM
5
5
Author: Demian D. Gomez
6
6
7
- Script to close the StationInfo of a station that has not been collecting data for X time
7
+ Script to close the StationInfo of a station that
8
+ has not been collecting data for X time
8
9
"""
9
10
10
11
import argparse
11
12
12
13
from pgamit import pyDate
13
- from pgamit import pyOptions
14
14
from pgamit import dbConnection
15
15
from pgamit import pyStationInfo
16
16
from pgamit import Utils
20
20
21
21
22
22
def main ():
23
- parser = argparse .ArgumentParser (description = 'Close an opened station information record for a station using the'
24
- 'last available RINEX file date time' )
25
-
26
- parser .add_argument ('stnlist' , type = str , nargs = '+' , metavar = 'all|net.stnm' ,
27
- help = "List of networks/stations to process given in [net].[stnm] format or just [stnm] "
28
- "(separated by spaces; if [stnm] is not unique in the database, all stations with that "
29
- "name will be processed). Use keyword 'all' to process all stations in the database. "
30
- "If [net].all is given, all stations from network [net] will be processed. "
31
- "Alternatively, a file with the station list can be provided." )
23
+ parser = argparse .ArgumentParser (
24
+ description = '''Close an opened station information record for a
25
+ station using the last available RINEX file date time''' )
26
+
27
+ parser .add_argument ('stnlist' , type = str , nargs = '+' ,
28
+ metavar = 'all|net.stnm' ,
29
+ help = '''List of networks/stations to process given
30
+ in [net].[stnm] format or just [stnm]
31
+ (separated by spaces; if [stnm] is not unique
32
+ in the database, all stations with that
33
+ name will be processed). Use keyword 'all'
34
+ to process all stations in the database.
35
+ If [net].all is given, all stations from
36
+ network [net] will be processed.
37
+ Alternatively, a file with the station
38
+ list can be provided.''' )
32
39
33
40
args = parser .parse_args ()
34
41
@@ -38,21 +45,29 @@ def main():
38
45
stnlist .sort (key = stationID )
39
46
40
47
for stn in stnlist :
41
- fd = cnn .query_float ('SELECT max("ObservationFYear") FROM rinex '
42
- 'WHERE "NetworkCode" = \' %s\' AND "StationCode" = \' %s\' '
48
+ fd = cnn .query_float ('''SELECT max("ObservationFYear") FROM rinex
49
+ WHERE "NetworkCode" = \' %s\'
50
+ AND "StationCode" = \' %s\' '''
43
51
% (stn ['NetworkCode' ], stn ['StationCode' ]))
44
52
45
53
dd = fd [0 ][0 ]
46
54
47
55
if not dd :
48
- print (' -- No RINEX files found for %s.%s' % (stn ['NetworkCode' ], stn ['StationCode' ]))
56
+ print (' -- No RINEX files found for %s.%s'
57
+ % (stn ['NetworkCode' ], stn ['StationCode' ]))
49
58
else :
50
- print (' -- Closing station information for %s.%s using %.3f from last RINEX file'
59
+ print (''' -- Closing station information for %s.%s
60
+ using %.3f from last RINEX file'''
51
61
% (stn ['NetworkCode' ], stn ['StationCode' ], dd ))
52
62
53
- stninfo = pyStationInfo .StationInfo (cnn , stn ['NetworkCode' ], stn ['StationCode' ])
54
- record = pyStationInfo .StationInfoRecord (stn ['NetworkCode' ], stn ['StationCode' ], stninfo .records [- 1 ])
55
- # change the time to the end of the day to avoid problems with GAMIT and other
63
+ stninfo = pyStationInfo .StationInfo (cnn ,
64
+ stn ['NetworkCode' ],
65
+ stn ['StationCode' ])
66
+ record = pyStationInfo .StationInfoRecord (stn ['NetworkCode' ],
67
+ stn ['StationCode' ],
68
+ stninfo .records [- 1 ])
69
+ # change the time to the end of the day
70
+ # to avoid problems with GAMIT and other
56
71
# RINEX files (with different end times)
57
72
date = pyDate .Date (fyear = dd )
58
73
date .hour = 23
0 commit comments