Skip to content
GitLab
Explore
Sign in
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
10be3fb8
Commit
10be3fb8
authored
5 years ago
by
Mattia Mancini
Browse files
Options
Downloads
Patches
Plain Diff
SSB-47
: loading calibration tables in directory
parent
74748c4e
No related branches found
No related tags found
1 merge request
!44
Merge back holography to master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CAL/CalibrationCommon/lib/datacontainers/calibration_table.py
+22
-4
22 additions, 4 deletions
...CalibrationCommon/lib/datacontainers/calibration_table.py
with
22 additions
and
4 deletions
CAL/CalibrationCommon/lib/datacontainers/calibration_table.py
+
22
−
4
View file @
10be3fb8
...
@@ -5,8 +5,10 @@ from struct import iter_unpack, pack
...
@@ -5,8 +5,10 @@ from struct import iter_unpack, pack
from
typing
import
BinaryIO
from
typing
import
BinaryIO
from
typing
import
List
from
typing
import
List
from
h5py
import
File
from
h5py
import
File
from
dataclasses
import
dataclass
,
asdict
from
os
import
path
from
numpy
import
empty
as
empty_ndarray
,
ndarray
,
fromiter
as
array_from_iter
,
float64
from
dataclasses
import
dataclass
,
asdict
,
field
from
numpy
import
empty
as
empty_ndarray
,
ndarray
,
fromiter
as
array_from_iter
,
float64
,
array_equal
from
glob
import
glob
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -16,6 +18,8 @@ __FREQUENCIES = 512
...
@@ -16,6 +18,8 @@ __FREQUENCIES = 512
__FLOATS_PER_FREQUENCY
=
2
__FLOATS_PER_FREQUENCY
=
2
__N_ANTENNAS_DUTCH
=
96
__N_ANTENNAS_DUTCH
=
96
__N_ANTENNAS_INTERNATIONAL
=
192
__N_ANTENNAS_INTERNATIONAL
=
192
__CALIBRATION_TABLE_FILENAME_PATTERN
=
'
*CalTable-???-???-???_???.dat
'
_ATTRIBUTE_NAME_TO_SERIALIZED_NAME
=
{
_ATTRIBUTE_NAME_TO_SERIALIZED_NAME
=
{
'
observation_station
'
:
'
CalTableHeader.Observation.Station
'
,
'
observation_station
'
:
'
CalTableHeader.Observation.Station
'
,
'
observation_mode
'
:
'
CalTableHeader.Observation.Mode
'
,
'
observation_mode
'
:
'
CalTableHeader.Observation.Mode
'
,
...
@@ -77,7 +81,7 @@ def parse_data(data_buffer):
...
@@ -77,7 +81,7 @@ def parse_data(data_buffer):
return
complex_data
return
complex_data
@dataclass
(
init
=
True
,
repr
=
True
,
frozen
=
True
)
@dataclass
(
init
=
True
,
repr
=
True
,
frozen
=
True
,
eq
=
True
)
class
CalibrationTable
:
class
CalibrationTable
:
observation_station
:
str
observation_station
:
str
observation_mode
:
str
observation_mode
:
str
...
@@ -89,7 +93,7 @@ class CalibrationTable:
...
@@ -89,7 +93,7 @@ class CalibrationTable:
calibration_name
:
str
calibration_name
:
str
calibration_date
:
datetime
calibration_date
:
datetime
calibration_ppsdelay
:
List
[
int
]
calibration_ppsdelay
:
List
[
int
]
data
:
ndarray
data
:
ndarray
=
field
(
compare
=
False
)
comment
:
str
=
''
comment
:
str
=
''
@staticmethod
@staticmethod
...
@@ -131,11 +135,25 @@ class CalibrationTable:
...
@@ -131,11 +135,25 @@ class CalibrationTable:
file_descriptor
[
uri
]
=
self
.
data
file_descriptor
[
uri
]
=
self
.
data
for
key
,
value
in
asdict
(
self
).
items
():
for
key
,
value
in
asdict
(
self
).
items
():
if
key
is
'
data
'
:
if
key
is
'
data
'
:
# skipping field data
continue
continue
file_descriptor
[
uri
].
attrs
[
key
]
=
value
file_descriptor
[
uri
].
attrs
[
key
]
=
value
file_descriptor
.
flush
()
file_descriptor
.
flush
()
def
__eq__
(
self
,
other
):
return
super
().
__eq__
(
other
)
and
array_equal
(
self
.
data
,
other
.
data
)
def
store_to_file
(
self
,
file_path
):
def
store_to_file
(
self
,
file_path
):
with
open
(
file_path
,
'
wb
'
)
as
file_stream
:
with
open
(
file_path
,
'
wb
'
)
as
file_stream
:
self
.
__serialize_header
(
file_stream
)
self
.
__serialize_header
(
file_stream
)
self
.
__serialize_data
(
file_stream
)
self
.
__serialize_data
(
file_stream
)
def
read_calibration_tables_in_directory
(
directory_path
:
str
):
if
not
path
.
isdir
(
directory_path
):
raise
NotADirectoryError
(
directory_path
)
files
=
path
.
join
(
directory_path
,
__CALIBRATION_TABLE_FILENAME_PATTERN
)
return
[
CalibrationTable
.
load_from_file
(
file_path
)
for
file_path
in
glob
(
files
,
recursive
=
False
)]
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