Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
EveryBeam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mattia Mancini
EveryBeam
Compare revisions
master to extend-add_beaminfo-script
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
mancini/EveryBeam
Select target project
No results found
extend-add_beaminfo-script
Select Git revision
Branches
1493-extend-python-bindings
28-add-scripts-for-manual-comparison-of-everybeam-s-oskar-model-implementations-and-oskar
46-add-stationresponse-comparison-for-oskar-trigger-pipeline
activate-oskar-pybindings
ast-1111-add-vector-bindings
ast-1325-prototype-ska-beam-model-interface
ast-1384-fix-sorted-frequencies-check-sphericalharmonicsresponse-1
ast-1386-create-default-element
ast-1387-createxxxresponse
ast-1416-oskar-ska-sdp-func-1
ast-1493-implement-response-dishpoint-1
ast-1527-spack
ast-645-add-beam-normalisation-mode-jm
ast-645-add-beam-normalisation-mode-preapplied
ast-865-ncp-fix
ast-919-readthedocs
ast-973-add-test-for-lobes-coefficients
coordinate_transform_via_erfa
debugging-ci-newer-pip
disable-element-beam-1
extend-add_beaminfo-script
extend-telescope-interface-to-support-dp3
fix-eigen
jakob/test-oskar
just-testing
lobes
lobes-investigation
lobes-se607-1
master
ncp_check
ncp_fix
random-fixes
stub-delta-geometric-response
submodulesync
test-schaapcommon
tilebeam-arrayresponse-timer
vdtol-oskar-stationresponse
vdtol-oskar-stationresponse1
workaround-wsclean-issue-83
Tags
v0.1.0
v0.1.1
v0.1.2
v0.1.3
v0.2.0
v0.3.0
v0.3.1
v0.4.0
v0.5.1
v0.5.2
v0.5.3
v0.5.4
v0.5.5
v0.5.6
v0.5.7
54 results
Swap
Target
RD/EveryBeam
Select target project
RD/EveryBeam
zhang/EveryBeam
sweijen/EveryBeam
mancini/EveryBeam
rozendaal/every-beam-refactor
5 results
master
Select Git revision
Branches
1493-extend-python-bindings
28-add-scripts-for-manual-comparison-of-everybeam-s-oskar-model-implementations-and-oskar
46-add-stationresponse-comparison-for-oskar-trigger-pipeline
add-test-for-squared-mueller-matrices
ast-1111-add-vector-bindings
ast-1325-prototype-ska-beam-model-interface
ast-1384-fix-sorted-frequencies-check-sphericalharmonicsresponse-1
ast-1384-remove-element-index-argument
ast-1386-create-default-element
ast-1416-oskar-ska-sdp-func-1
ast-1493-implement-response-dishpoint-1
ast-1509-fix-polarization-orientation-in-gridded-response
ast-1600-fix-beam-for-meerkat-ska-mid
ast-1644-temp-fix
ast-645-add-beam-normalisation-mode-preapplied
ast-973-add-test-for-lobes-coefficients
disable-element-beam-1
extend-add_beaminfo-script
initialize_telescope_class_without_ms
just-testing
lobes
lobes-investigation
master
mwa_python_wrapper
readthedocs-c++17
rtd-ubuntu24-plucky
stub-delta-geometric-response
tilebeam-arrayresponse-timer
Tags
v0.1.0
v0.1.1
v0.1.2
v0.1.3
v0.2.0
v0.3.0
v0.3.1
v0.4.0
v0.5.1
v0.5.2
v0.5.3
v0.5.4
v0.5.5
v0.5.6
v0.5.7
v0.5.8
v0.6.0
v0.6.1
v0.6.2
v0.7.0
v0.7.1
v0.7.2
50 results
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source
1
Add support for more varieties of the telescope model (.tm)
· cf288a2c
Bas van der Tol
authored
Nov 12, 2020
cf288a2c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/misc/add_beaminfo.py
+35
-21
35 additions, 21 deletions
scripts/misc/add_beaminfo.py
with
35 additions
and
21 deletions
scripts/misc/add_beaminfo.py
View file @
cf288a2c
...
@@ -10,12 +10,15 @@ from numpy.linalg import norm
...
@@ -10,12 +10,15 @@ from numpy.linalg import norm
import
numpy
as
np
import
numpy
as
np
import
logging
import
logging
import
sys
import
sys
import
os
from
glob
import
glob
def
read_telescope_center
(
oskar_telescope_dir
:
str
):
def
read_telescope_center
(
oskar_telescope_dir
:
str
):
"""
Read telescope center from OSKAR metadata and convert to ITRF
"""
"""
Read telescope center from OSKAR metadata and convert to ITRF
"""
# separator is either comma or whitespace, plus any extra whitespace
oskar_telescope_center
=
pd
.
read_csv
(
f
"
{
oskar_telescope_dir
}
/position.txt
"
,
oskar_telescope_center
=
pd
.
read_csv
(
f
"
{
oskar_telescope_dir
}
/position.txt
"
,
header
=
None
,
sep
=
"
"
)
header
=
None
,
sep
=
"
[,\s]\s*
"
)
if
len
(
oskar_telescope_center
.
columns
)
==
2
:
if
len
(
oskar_telescope_center
.
columns
)
==
2
:
oskar_telescope_center
[
"
Height
"
]
=
[
0.
]
oskar_telescope_center
[
"
Height
"
]
=
[
0.
]
...
@@ -24,8 +27,22 @@ def read_telescope_center(oskar_telescope_dir: str):
...
@@ -24,8 +27,22 @@ def read_telescope_center(oskar_telescope_dir: str):
telescope_center_itrf
=
geo
.
xyz_from_geographic
(
np
.
deg2rad
(
oskar_telescope_center
[
"
Lon
"
][
0
]),
telescope_center_itrf
=
geo
.
xyz_from_geographic
(
np
.
deg2rad
(
oskar_telescope_center
[
"
Lon
"
][
0
]),
np
.
deg2rad
(
oskar_telescope_center
[
"
Lat
"
][
0
]),
np
.
deg2rad
(
oskar_telescope_center
[
"
Lat
"
][
0
]),
oskar_telescope_center
[
"
Height
"
][
0
])
oskar_telescope_center
[
"
Height
"
][
0
])
return
telescope_center_itrf
normal_vector_ellipsoid
=
geo
.
normal_vector_ellipsoid
(
np
.
deg2rad
(
oskar_telescope_center
[
"
Lon
"
][
0
]),
np
.
deg2rad
(
oskar_telescope_center
[
"
Lat
"
][
0
]))
local_to_itrf_projection_matrix
=
geo
.
projection_matrix
(
telescope_center_itrf
,
normal_vector_ellipsoid
)
return
telescope_center_itrf
,
local_to_itrf_projection_matrix
def
read_element_locations
(
oskar_layout_file
:
str
):
# separator is either comma or whitespace, plus any extra whitespace
element_locations
=
pd
.
read_csv
(
oskar_layout_file
,
header
=
None
,
sep
=
"
[,\s]\s*
"
)
if
len
(
element_locations
.
columns
)
==
2
:
element_locations
[
"
Z
"
]
=
np
.
zeros_like
(
element_locations
[
0
])
return
element_locations
def
fix_antenna
(
oskar_ms_name
:
str
,
telescope_center_itrf
:
np
.
array
):
def
fix_antenna
(
oskar_ms_name
:
str
,
telescope_center_itrf
:
np
.
array
):
"""
Make POSITION in ::ANTENNA subtable absolute
"""
"""
Make POSITION in ::ANTENNA subtable absolute
"""
...
@@ -93,29 +110,26 @@ def add_phased_array_table(oskar_ms_name: str):
...
@@ -93,29 +110,26 @@ def add_phased_array_table(oskar_ms_name: str):
def
fill_phased_array
(
oskar_ms_name
:
str
,
oskar_telescope_dir
:
str
):
def
fill_phased_array
(
oskar_ms_name
:
str
,
oskar_telescope_dir
:
str
):
"""
Fill the ::PHASED_ARRAY subtable with info from the OSKAR directory
"""
"""
Fill the ::PHASED_ARRAY subtable with info from the OSKAR directory
"""
element_locations
=
pd
.
read_csv
(
f
"
{
oskar_telescope_dir
}
/station/layout.txt
"
,
header
=
None
,
sep
=
"
"
)
if
len
(
element_locations
.
columns
)
==
2
:
element_locations
[
"
Z
"
]
=
np
.
zeros_like
(
element_locations
[
0
])
oskar_telescope_center
=
pd
.
read_csv
(
f
"
{
oskar_telescope_dir
}
/position.txt
"
,
header
=
None
,
sep
=
"
"
)
oskar_telescope_center
.
columns
=
[
"
Lon
"
,
"
Lat
"
]
telescope_center_itrf
=
read_telescope_center
(
oskar_telescope_dir
)
normal_vector_ellipsoid
=
geo
.
normal_vector_ellipsoid
(
np
.
deg2rad
(
oskar_telescope_center
[
"
Lon
"
][
0
]),
telescope_center_itrf
,
local_to_itrf_projection_matrix
=
read_telescope_center
(
oskar_telescope_dir
)
np
.
deg2rad
(
oskar_telescope_center
[
"
Lat
"
][
0
]))
local_to_itrf_projection_matrix
=
geo
.
projection_matrix
(
telescope_center_itrf
,
element_layout_file
=
f
"
{
oskar_telescope_dir
}
/station/layout.txt
"
normal_vector_ellipsoid
)
if
os
.
path
.
exists
(
element_layout_file
):
element_locations
=
read_element_locations
(
element_layout_file
)
element_locations_itrf
=
local_to_itrf_projection_matrix
@
element_locations
.
to_numpy
().
T
nr_pol
=
2
nr_pol
=
2
all_unflagged
=
np
.
zeros
((
nr_pol
,
element_locations_itrf
.
shape
[
1
]))
phasedarraytable
=
pt
.
table
(
f
"
{
oskar_ms_name
}
::PHASED_ARRAY
"
,
readonly
=
False
,
ack
=
False
)
phasedarraytable
=
pt
.
table
(
f
"
{
oskar_ms_name
}
::PHASED_ARRAY
"
,
readonly
=
False
,
ack
=
False
)
for
stationnr
in
range
(
len
(
phasedarraytable
)):
oskar_station_dirs
=
sorted
(
glob
(
f
"
{
oskar_telescope_dir
}
/station*
"
))
for
stationnr
,
oskar_station_dir
in
enumerate
(
oskar_station_dirs
):
element_layout_file
=
f
"
{
oskar_station_dir
}
/layout.txt
"
print
(
element_layout_file
)
if
os
.
path
.
exists
(
element_layout_file
):
element_locations
=
read_element_locations
(
element_layout_file
)
element_locations_itrf
=
local_to_itrf_projection_matrix
@
element_locations
.
to_numpy
().
T
all_unflagged
=
np
.
zeros
((
nr_pol
,
element_locations_itrf
.
shape
[
1
]))
phasedarraytable
.
putcell
(
"
COORDINATE_AXES
"
,
stationnr
,
local_to_itrf_projection_matrix
.
T
)
phasedarraytable
.
putcell
(
"
COORDINATE_AXES
"
,
stationnr
,
local_to_itrf_projection_matrix
.
T
)
phasedarraytable
.
putcell
(
"
ELEMENT_OFFSET
"
,
stationnr
,
element_locations_itrf
)
phasedarraytable
.
putcell
(
"
ELEMENT_OFFSET
"
,
stationnr
,
element_locations_itrf
)
phasedarraytable
.
putcell
(
"
ELEMENT_FLAG
"
,
stationnr
,
all_unflagged
)
phasedarraytable
.
putcell
(
"
ELEMENT_FLAG
"
,
stationnr
,
all_unflagged
)
...
@@ -127,7 +141,7 @@ def fill_phased_array(oskar_ms_name: str, oskar_telescope_dir: str):
...
@@ -127,7 +141,7 @@ def fill_phased_array(oskar_ms_name: str, oskar_telescope_dir: str):
def
main
(
oskar_ms_name
:
str
,
oskar_telescope_dir
:
str
):
def
main
(
oskar_ms_name
:
str
,
oskar_telescope_dir
:
str
):
"""
Add beam info to OSKAR generated MeasurementSet
"""
"""
Add beam info to OSKAR generated MeasurementSet
"""
telescope_center_itrf
=
read_telescope_center
(
oskar_telescope_dir
)
telescope_center_itrf
,
_
=
read_telescope_center
(
oskar_telescope_dir
)
fix_antenna
(
oskar_ms_name
,
telescope_center_itrf
)
fix_antenna
(
oskar_ms_name
,
telescope_center_itrf
)
add_array_center
(
oskar_ms_name
,
telescope_center_itrf
)
add_array_center
(
oskar_ms_name
,
telescope_center_itrf
)
add_phased_array_table
(
oskar_ms_name
)
add_phased_array_table
(
oskar_ms_name
)
...
...
This diff is collapsed.
Click to expand it.