Skip to content

Commit

Permalink
2.3.2 release (#32)
Browse files Browse the repository at this point in the history
* Enhanced fast insert handling some common transmission errors

* Viewer modified to support for 2 observed properties on the same chart

* correcting bug when one of the obsprop are not present in a procedure

* changed significant figures (now 4) for water discharge vp

* Added utility script to apply retroactively the quality index

* improved register procedure script

* small correction

* add check on describeSensor request

* Added possibility to keep seconds with sts datalogger

* dev
  • Loading branch information
mantonovic authored Nov 5, 2018
1 parent 72dea23 commit 38bb9cc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ services/demo
_build/
docs/_build/
acquisition/
.vscode
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.1
2.3.2
7 changes: 4 additions & 3 deletions scripts/converter/sts.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ def parse(self, fileObj, fileName):
data, self.config["tz"])

# Removing seconds from date
data = datetime(
data.year, data.month, data.day, data.hour,
data.minute, 0, tzinfo=data.tzinfo)
if 'rmseconds' not in self.config or self.config['rmseconds'] is True:
data = datetime(
data.year, data.month, data.day, data.hour,
data.minute, 0, tzinfo=data.tzinfo)

self.setEndPosition(data)
self.addObservation(
Expand Down
31 changes: 23 additions & 8 deletions scripts/istsos2csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,25 @@
isoop = "urn:ogc:def:parameter:x-istsos:1.0:time:iso8601"


def makeFile(res, procedure, op, path):
def makeFile(res, procedure, op, path, qi, filename):
text = res.text
text = text.replace("%s," % procedure, "")
lines = text.split('\n')
print('Lines: %s' % len(lines))
if lines[-1] == '':
del lines[-1]
tmpOp = op.replace("x-ist::", "x-istsos:1.0:")
lines[0] = "%s,%s,%s:qualityIndex" % (isoop, tmpOp, tmpOp)
if qi == 'True':
lines[0] = "%s,%s,%s:qualityIndex" % (isoop, tmpOp, tmpOp)
else:
lines[0] = "%s,%s" % (isoop, tmpOp)
if len(lines) > 1:
datenumber = iso.parse_datetime(lines[-1].split(",")[0])
print "File: %s/%s_%s.dat" % (
path, procedure, datetime.datetime.strftime(
path, filename, datetime.datetime.strftime(
datenumber, "%Y%m%d%H%M%S%f"))
out_file = open("%s/%s_%s.dat" % (
path, procedure, datetime.datetime.strftime(
path, filename, datetime.datetime.strftime(
datenumber, "%Y%m%d%H%M%S%f")), "w")
out_file.write("\n".join(lines))
out_file.close()
Expand All @@ -78,6 +82,12 @@ def execute(args, logger=None):
url = args['url']

procedure = args['procedure']

if 'filename' in args and args['filename'] is not None:
filename = args['filename']
else:
filename = procedure

observedProperty = args['op']

begin = iso.parse_datetime(args['begin'])
Expand All @@ -91,7 +101,7 @@ def execute(args, logger=None):
password = None
if 'password' in args:
password = args['password']
if auth and password:
if user and password:
auth = HTTPBasicAuth(user, password)

qi = 'True'
Expand All @@ -116,7 +126,6 @@ def execute(args, logger=None):
if (end-begin) > step:
tmpEnd = tmpBegin + step

print params

while tmpEnd <= end:
print ("%s - %s") % (tmpBegin, tmpEnd)
Expand All @@ -130,7 +139,7 @@ def execute(args, logger=None):

res = req.get("%s?%s" % (url, urllib.urlencode(params)), auth=auth)

makeFile(res, procedure, observedProperty, d)
makeFile(res, procedure, observedProperty, d, qi, filename)
tmpBegin = tmpEnd
tmpEnd = tmpBegin + step

Expand All @@ -147,7 +156,7 @@ def execute(args, logger=None):
iso.datetime_isoformat(tmpEnd))

res = req.get("%s?%s" % (url, urllib.urlencode(params)), auth=auth)
makeFile(res, procedure, observedProperty, d)
makeFile(res, procedure, observedProperty, d, qi, filename)

print " %s ************************** " % iso.datetime_isoformat(
end)
Expand Down Expand Up @@ -198,6 +207,12 @@ def execute(args, logger=None):
dest='procedure',
help='Procedure name')

parser.add_argument(
'-f',
action='store',
dest='filename',
help='filename')

parser.add_argument(
'-o',
action='store',
Expand Down
3 changes: 2 additions & 1 deletion walib/sqlschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@
INSERT INTO observed_properties VALUES ('river-discharge', 'urn:ogc:def:parameter:x-istsos:1.0:river:water:discharge', '', NULL, 7);
INSERT INTO observed_properties VALUES ('soil-evapotranspiration', 'urn:ogc:def:parameter:x-istsos:1.0:meteo:soil:evapotranspiration', '', NULL, 8);
INSERT INTO observed_properties VALUES ('air-heatindex', 'urn:ogc:def:parameter:x-istsos:1.0:meteo:air:heatindex', '', NULL, 9);
SELECT pg_catalog.setval('obs_pr_id_opr_seq', 9, true);
INSERT INTO observed_properties VALUES ('ground-water-height', 'urn:ogc:def:parameter:x-istsos:1.0:ground:water:height', '', NULL, 10);
SELECT pg_catalog.setval('obs_pr_id_opr_seq', 10, true);
--=====================================
-- ADDING UNIT OF MEASURES
Expand Down

0 comments on commit 38bb9cc

Please sign in to comment.