Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
RadioObservatory
LOFAR
Commits
9a0c0171
Commit
9a0c0171
authored
6 years ago
by
Auke Klazema
Browse files
Options
Downloads
Patches
Plain Diff
SW-598
: Add username, password, port options to make_antenna_list.py
parent
ea454655
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MAC/Deployment/data/Coordinates/make_antenna_list.py
+73
-25
73 additions, 25 deletions
MAC/Deployment/data/Coordinates/make_antenna_list.py
with
73 additions
and
25 deletions
MAC/Deployment/data/Coordinates/make_antenna_list.py
+
73
−
25
View file @
9a0c0171
#!/usr/bin/env python
#coding: iso-8859-15
import
re
,
sys
,
pgdb
from
copy
import
deepcopy
from
math
import
*
# coding: iso-8859-15
import
re
import
sys
import
pgdb
from
optparse
import
OptionParser
import
getpass
INTRO
=
"""
INTRO
=
"""
Created a file containing all antenna coordinates for the online software.
"""
"""
def
print_help
():
print
"
Usage: make_antenna_list [<stationname>]
"
#
# findStationInfo(stationName)
#
def
find
S
tation
I
nfo
(
station
N
ame
):
def
find
_s
tation
_i
nfo
(
station
_n
ame
):
"""
Return all basic station info (eg. nr RSPboards) from a station.
"""
pattern
=
re
.
compile
(
"
^
"
+
station
N
ame
+
"
[
\t
].*
"
,
re
.
IGNORECASE
|
re
.
MULTILINE
)
pattern
=
re
.
compile
(
"
^
"
+
station
_n
ame
+
"
[
\t
].*
"
,
re
.
IGNORECASE
|
re
.
MULTILINE
)
match
=
pattern
.
search
(
open
(
"
../StaticMetaData/StationInfo.dat
"
).
read
())
if
not
match
:
raise
"
\n
Fatal error:
"
+
station
N
ame
+
"
is not defined in file
'
StationInfo.dat
'"
raise
"
\n
Fatal error:
"
+
station
_n
ame
+
"
is not defined in file
'
StationInfo.dat
'"
return
match
.
group
().
split
()
#
# MAIN
#
if
__name__
==
'
__main__
'
:
if
len
(
sys
.
argv
)
!=
2
:
print_help
()
sys
.
exit
(
0
)
parser
=
OptionParser
(
"
Usage: %prog [options] datafile
"
)
parser
.
add_option
(
"
-D
"
,
"
--database
"
,
dest
=
"
dbName
"
,
type
=
"
string
"
,
default
=
"
coordtest
"
,
help
=
"
Name of StationCoordinates database to use
"
)
parser
.
add_option
(
"
-H
"
,
"
--host
"
,
dest
=
"
dbHost
"
,
type
=
"
string
"
,
default
=
"
dop50
"
,
help
=
"
Hostname of StationCoordinates database
"
)
parser
.
add_option
(
"
-P
"
,
"
--port
"
,
dest
=
"
dbPort
"
,
type
=
"
int
"
,
default
=
"
5432
"
,
help
=
"
Port of StationCoordinates database
"
)
parser
.
add_option
(
"
-U
"
,
"
--user
"
,
dest
=
"
dbUser
"
,
type
=
"
string
"
,
default
=
"
postgres
"
,
help
=
"
Username of StationCoordinates database
"
)
# parse arguments
(
options
,
args
)
=
parser
.
parse_args
()
(
name
,
stationID
,
stnType
,
long
,
lat
,
height
,
nrRSP
,
nrTBB
,
nrLBA
,
nrHBA
,
HBAsplit
,
LBAcal
)
=
findStationInfo
(
sys
.
argv
[
1
])
db
=
pgdb
.
connect
(
user
=
"
postgres
"
,
host
=
"
dop50
"
,
database
=
"
coordtest
"
)
dbName
=
options
.
dbName
dbHost
=
options
.
dbHost
dbPort
=
options
.
dbPort
dbUser
=
options
.
dbUser
if
len
(
args
)
!=
1
:
parser
.
print_help
()
sys
.
exit
(
1
)
filename
=
str
(
args
[
0
])
dbPassword
=
getpass
.
getpass
()
host
=
"
{}:{}
"
.
format
(
dbHost
,
dbPort
)
db
=
pgdb
.
connect
(
user
=
dbUser
,
host
=
host
,
database
=
dbName
,
password
=
dbPassword
)
cursor
=
db
.
cursor
()
(
name
,
stationID
,
stnType
,
long
,
lat
,
height
,
nrRSP
,
nrTBB
,
nrLBA
,
nrHBA
,
HBAsplit
,
LBAcal
)
=
find_station_info
(
filename
)
print
"
#Stn ID Type RSP RCU Pol Position Orientation
"
print
"
%s %s %s %d %d -1 [%s,%s,%s] [0,0,0]
"
%
(
name
,
stationID
,
"
center
"
,
-
1
,
-
1
,
long
,
lat
,
height
)
for
infoType
in
[
'
marker
'
,
'
lba
'
,
'
hba
'
]:
cursor
=
db
.
cursor
()
cursor
.
execute
(
"
select * from get_ref_objects(%s, %s)
"
,
(
sys
.
argv
[
1
]
,
infoType
))
print
"
%s %s %s %d %d -1 [%s,%s,%s] [0,0,0]
"
%
\
(
name
,
stationID
,
"
center
"
,
-
1
,
-
1
,
long
,
lat
,
height
)
for
infoType
in
[
'
marker
'
,
'
lba
'
,
'
hba
'
]:
cursor
.
execute
(
"
select * from get_ref_objects(%s, %s)
"
,
(
filename
,
infoType
))
counter
=
0
while
(
1
):
record
=
cursor
.
fetchone
()
if
record
==
None
:
if
record
is
None
:
break
RSPnr
=
int
(
record
[
2
]
%
100
/
4
)
print
"
%s %s %s%d %d %d x [%s,%s,%s] [0,0,0]
"
%
(
name
,
stationID
,
infoType
,
int
(
record
[
2
])
%
100
,
RSPnr
,
counter
,
record
[
3
],
record
[
4
],
record
[
5
])
print
"
%s %s %s%d %d %d y [%s,%s,%s] [0,0,0]
"
%
(
name
,
stationID
,
infoType
,
int
(
record
[
2
])
%
100
,
RSPnr
,
counter
+
1
,
record
[
3
],
record
[
4
],
record
[
5
])
RSPnr
=
int
(
record
[
2
]
%
100
/
4
)
print
"
%s %s %s%d %d %d x [%s,%s,%s] [0,0,0]
"
%
\
(
name
,
stationID
,
infoType
,
int
(
record
[
2
])
%
100
,
RSPnr
,
counter
,
record
[
3
],
record
[
4
],
record
[
5
])
print
"
%s %s %s%d %d %d y [%s,%s,%s] [0,0,0]
"
%
\
(
name
,
stationID
,
infoType
,
int
(
record
[
2
])
%
100
,
RSPnr
,
counter
+
1
,
record
[
3
],
record
[
4
],
record
[
5
])
counter
=
counter
+
2
db
.
close
()
sys
.
exit
(
1
)
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