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
672f7ec5
Commit
672f7ec5
authored
5 years ago
by
Mattia Mancini
Browse files
Options
Downloads
Patches
Plain Diff
SSB-47
: checking speed without reading data
parent
fcb0eb7b
No related branches found
Branches containing commit
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/holography_dataset.py
+50
-18
50 additions, 18 deletions
...alibrationCommon/lib/datacontainers/holography_dataset.py
with
50 additions
and
18 deletions
CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py
+
50
−
18
View file @
672f7ec5
import
logging
import
logging
import
os
import
os
import
h5py
import
h5py
from
lofar.calibration.common.datacontainers.holography_observation
import
HolographyObservation
from
.holography_dataset_definitions
import
*
from
.holography_dataset_definitions
import
*
from
.holography_specification
import
HolographySpecification
from
.holography_specification
import
HolographySpecification
from
.holography_observation
import
HolographyObservation
logger
=
logging
.
getLogger
(
__file__
)
logger
=
logging
.
getLogger
(
__file__
)
...
@@ -544,13 +542,52 @@ class HolographyDataset():
...
@@ -544,13 +542,52 @@ class HolographyDataset():
@staticmethod
@staticmethod
def
load_from_file
(
path
):
def
load_from_file
(
path
):
"""
"""
It r
ead
s
a holography dataset from an HDF5 file and returns a
R
ead a holography dataset from an HDF5 file and returns a
HolographyDataset class
HolographyDataset class
:param path: path to file
:param path: path to file
:return: the read dataset
:return: the read dataset
"""
"""
f
=
None
f
=
None
try
:
result
,
f
=
HolographyDataset
.
open_holography_file
(
path
)
result
.
data
=
dict
()
for
reference_station
in
f
[
"
CROSSCORRELATION
"
].
keys
():
for
frequency
in
f
[
"
CROSSCORRELATION
"
][
reference_station
].
keys
():
for
beamlet
in
f
[
"
CROSSCORRELATION
"
][
reference_station
][
frequency
].
keys
():
if
reference_station
not
in
result
.
data
:
result
.
data
[
reference_station
]
=
dict
()
if
frequency
not
in
result
.
data
[
reference_station
]:
result
.
data
[
reference_station
][
frequency
]
=
dict
()
result
.
data
[
reference_station
][
frequency
][
beamlet
]
=
numpy
.
array
(
f
[
"
CROSSCORRELATION
"
][
reference_station
][
frequency
][
beamlet
])
if
'
/DERIVED_DATA
'
in
f
:
result
.
derived_data
=
HolographyDataset
.
_read_grouped_data
(
f
,
'
/DERIVED_DATA
'
)
except
Exception
as
e
:
logger
.
exception
(
"
Cannot read the Holography Data Set data from the HDF5 file
\"
%s
\"
.
"
"
This is the exception that was thrown: %s
"
,
path
,
e
)
raise
e
finally
:
if
f
is
not
None
:
f
.
close
()
return
result
@staticmethod
def
open_holography_file
(
path
:
str
):
"""
Opens the Holography HDF file for access and returns the Holography Dataset and
it
'
s file descriptor
:param path: path to file
:return: the read dataset
:rtype: List[HolographyDataset, h5py.File]
"""
f
=
None
if
not
os
.
path
.
exists
(
path
):
if
not
os
.
path
.
exists
(
path
):
raise
FileNotFoundError
(
path
)
raise
FileNotFoundError
(
path
)
...
@@ -584,32 +621,26 @@ class HolographyDataset():
...
@@ -584,32 +621,26 @@ class HolographyDataset():
result
.
ra_dec
[
frequency
][
beamlet
]
=
numpy
.
array
(
f
[
"
RA_DEC
"
][
frequency
][
beamlet
])
result
.
ra_dec
[
frequency
][
beamlet
]
=
numpy
.
array
(
f
[
"
RA_DEC
"
][
frequency
][
beamlet
])
beamlets
=
set
()
beamlets
=
set
()
result
.
data
=
dict
()
for
reference_station
in
f
[
"
CROSSCORRELATION
"
].
keys
():
for
reference_station
in
f
[
"
CROSSCORRELATION
"
].
keys
():
for
frequency
in
f
[
"
CROSSCORRELATION
"
][
reference_station
].
keys
():
for
frequency
in
f
[
"
CROSSCORRELATION
"
][
reference_station
].
keys
():
for
beamlet
in
f
[
"
CROSSCORRELATION
"
][
reference_station
][
frequency
].
keys
():
for
beamlet
in
f
[
"
CROSSCORRELATION
"
][
reference_station
][
frequency
].
keys
():
beamlets
.
add
(
int
(
beamlet
))
beamlets
.
add
(
int
(
beamlet
))
if
reference_station
not
in
result
.
data
:
result
.
data
[
reference_station
]
=
dict
()
result
.
data
=
f
[
'
CROSSCORRELATION
'
]
if
frequency
not
in
result
.
data
[
reference_station
]:
result
.
data
[
reference_station
][
frequency
]
=
dict
()
result
.
data
[
reference_station
][
frequency
][
beamlet
]
=
numpy
.
array
(
f
[
"
CROSSCORRELATION
"
][
reference_station
][
frequency
][
beamlet
])
result
.
central_beamlets
=
HolographyDataset
.
_read_grouped_data
(
f
,
HDS_CENTRAL_BEAMLETS
)
result
.
central_beamlets
=
HolographyDataset
.
_read_grouped_data
(
f
,
HDS_CENTRAL_BEAMLETS
)
if
'
/DERIVED_DATA
'
in
f
:
if
'
/DERIVED_DATA
'
in
f
:
result
.
derived_data
=
HolographyDataset
.
_read_grouped_data
(
f
,
'
/DERIVED_DATA
'
)
result
.
derived_data
=
f
[
'
/DERIVED_DATA
'
]
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
exception
(
logger
.
exception
(
"
Cannot read the Holography Data Set data from the HDF5 file
\"
%s
\"
. This is the exception that was thrown: %s
"
,
"
Cannot read the Holography Data Set data from the HDF5 file
\"
%s
\"
.
"
"
This is the exception that was thrown: %s
"
,
path
,
e
)
path
,
e
)
raise
e
raise
e
finally
:
if
f
is
not
None
:
f
.
close
()
return
result
return
result
,
f
def
store_to_file
(
self
,
path
):
def
store_to_file
(
self
,
path
):
"""
"""
...
@@ -679,7 +710,8 @@ class HolographyDataset():
...
@@ -679,7 +710,8 @@ class HolographyDataset():
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
exception
(
logger
.
exception
(
"
Cannot write the Holography Data Set data to the HDF5 file
\"
%s
\"
. This is the exception that was thrown: %s
"
,
"
Cannot write the Holography Data Set data to the HDF5 file
\"
%s
\"
.
"
"
This is the exception that was thrown: %s
"
,
path
,
e
)
path
,
e
)
raise
e
raise
e
finally
:
finally
:
...
...
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