Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AossTower
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MetObs
AossTower
Commits
660484b3
Verified
Commit
660484b3
authored
7 years ago
by
David Hoese
Browse files
Options
Downloads
Patches
Plain Diff
Rename symbol keys in ldmp generated records for legacy db insert
parent
1e3fb9b1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aosstower/level_00/legacy_db_insert.py
+33
-1
33 additions, 1 deletion
aosstower/level_00/legacy_db_insert.py
aosstower/level_00/parser.py
+3
-3
3 additions, 3 deletions
aosstower/level_00/parser.py
with
36 additions
and
4 deletions
aosstower/level_00/legacy_db_insert.py
+
33
−
1
View file @
660484b3
...
...
@@ -18,6 +18,38 @@ LOG = logging.getLogger(__name__)
ERR
=
logging
.
getLogger
(
__name__
+
'
.error
'
)
_symbol_record_map
=
(
(
1
,
'
station
'
),
(
2
,
'
year
'
),
(
3
,
'
day
'
),
(
4
,
'
hour_minute
'
),
(
5
,
'
seconds
'
),
(
6
,
'
box_pressure
'
),
(
7
,
'
parosci_air_temp_period
'
),
(
8
,
'
parosci_pressure_period
'
),
(
9
,
'
parosci_air_temp
'
),
(
10
,
'
pressure
'
),
(
11
,
'
parosci_calc_sig
'
),
(
12
,
'
box_rh
'
),
(
13
,
'
box_air_temp
'
),
(
14
,
'
temp2
'
),
(
15
,
'
temp3
'
),
(
16
,
'
temp4
'
),
(
17
,
'
wind_speed
'
),
(
18
,
'
wind_direction
'
),
(
19
,
'
rh_shield_freq
'
),
(
20
,
'
relative_humidity
'
),
(
21
,
'
air_temp_6_3
'
),
(
22
,
'
dewpoint
'
),
(
23
,
'
rtd_shield_freq
'
),
(
24
,
'
air_temp
'
),
(
25
,
'
solar_flux
'
),
(
26
,
'
precipitation
'
),
(
27
,
'
accumulated_precipitation
'
),
(
28
,
'
altimeter
'
),
)
def
configure_logging
(
level
,
logfn
=
None
):
handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
handler
.
setFormatter
(
logging
.
Formatter
(
"
%(asctime)s: %(message)s
"
))
...
...
@@ -74,7 +106,7 @@ def main():
if
args
.
ldmp
:
from
aosstower.level_00.parser
import
ldmp_generator
record_gen
=
ldmp_generator
(
args
.
src
,
args
.
tables
)
record_gen
=
ldmp_generator
(
args
.
src
,
args
.
tables
,
symbol_names
=
[
x
[
1
]
for
x
in
_symbol_record_map
]
)
else
:
src
=
open
(
args
.
src
,
"
r
"
)
record_gen
=
read_frames
(
src
,
tail
=
args
.
tail
)
...
...
This diff is collapsed.
Click to expand it.
aosstower/level_00/parser.py
+
3
−
3
View file @
660484b3
...
...
@@ -215,13 +215,13 @@ def read_frames(source, error_handler=lambda *a: None, tail=False):
error_handler
(
idx
+
1
,
line
,
RuntimeError
(
"
no parser found
"
,
line
))
def
loggernet_to_tower
(
rec_dict
):
def
loggernet_to_tower
(
rec_dict
,
symbol_names
):
"""
Convert loggernet record dictionary to our standard naming
"""
# assume that the next record after the traditional frame is the timestamp
return
_make_frame
(
zip
([
'
timestamp
'
]
+
ParserV1V2
.
names
,
rec_dict
.
values
()),
rename_timestamp
=
True
)
return
_make_frame
(
zip
([
'
timestamp
'
]
+
symbol_
names
,
rec_dict
.
values
()),
rename_timestamp
=
True
)
def
ldmp_generator
(
station_name
,
tables
):
def
ldmp_generator
(
station_name
,
tables
,
symbol_names
=
ParserV1V2
.
names
):
from
metobscommon.archive.loggernet_receiver
import
dict_records
,
ldmp_receiver
receiver
=
ldmp_receiver
()
# This should be generated OrderedDicts
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment