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
34e18224
Commit
34e18224
authored
5 years ago
by
Mattia Mancini
Browse files
Options
Downloads
Patches
Plain Diff
SSB-47
: Refactor read method
parent
03852c5d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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_specification.py
+20
-20
20 additions, 20 deletions
...tionCommon/lib/datacontainers/holography_specification.py
with
20 additions
and
20 deletions
CAL/CalibrationCommon/lib/datacontainers/holography_specification.py
+
20
−
20
View file @
34e18224
...
...
@@ -113,24 +113,22 @@ def list_bsf_files_in_path(path):
matched_path_list
=
glob
(
bsf_files_path_pattern
)
matched_file_path_list
=
list
(
filter
(
lambda
path_i
:
os
.
path
.
isfile
(
path_i
),
matched_path_list
))
matched_file_name_list
=
list
(
map
(
lambda
path_i
:
os
.
path
.
basename
(
path_i
),
matched_file_path_list
))
holography_beam_specification
=
create_hs_list_from_name_list_and_path
(
matched_file_name_list
,
path
)
holography_beam_specification
=
create_hs_list_from_name_list_and_path
(
matched_file_path_list
)
logger
.
info
(
"
Loading holography beam specifications were successfully loaded from
\"
%s
\"
.
"
,
path
)
return
holography_beam_specification
def
create_hs_list_from_name_list_and_path
(
name
_list
,
path
):
return
[
HolographySpecification
(
name
,
path
)
for
name
in
name
_list
]
def
create_hs_list_from_name_list_and_path
(
path
_list
):
return
[
HolographySpecification
.
read_file
(
path
)
for
path
in
path
_list
]
def
is_holography_specification_file_name
(
name
):
return
re
.
match
(
HolographySpecification
.
hs_name_pattern
,
name
)
is
not
None
def
extract_id_date_comment_from_name
(
name
):
def
extract_id_date_comment_from_
file
name
(
name
):
match
=
re
.
match
(
HolographySpecification
.
hs_name_pattern
,
name
)
date
=
match
.
group
(
'
date
'
)
hs_id
=
int
(
match
.
group
(
'
id
'
))
...
...
@@ -229,18 +227,16 @@ class HolographySpecification(object):
"""
hs_name_pattern
=
r
'
Holog-(?P<date>\d{8})-(?P<comment>.*)-(?P<id>\d{3}).txt
'
def
__init__
(
self
,
filename
,
path
):
def
__init__
(
self
,
path
):
"""
Construct the holography specification object and extracts id date and comment from
the file name (see HolographySpecification.extract_id_date_comment_from_name)
:param filename: file name of the holography specification
:type filename: str
:param path: path of the holography specification file
:type path: str
"""
self
.
path
=
os
.
path
.
join
(
path
,
filename
)
self
.
name
=
filename
self
.
id
,
self
.
date
,
self
.
comment
=
extract_id_date_comment_from_name
(
file
name
)
self
.
path
=
path
self
.
name
=
os
.
path
.
basename
(
path
)
self
.
id
,
self
.
date
,
self
.
comment
=
extract_id_date_comment_from_
file
name
(
self
.
name
)
self
.
reference_station_names
=
None
self
.
target_station_names
=
None
self
.
station_specification_map
=
defaultdict
(
list
)
...
...
@@ -268,13 +264,17 @@ class HolographySpecification(object):
"""
return
self
.
station_specification_map
[
station_name
]
def
read_file
(
self
):
logger
.
debug
(
"
Reading holography file
\"
%s
\"
...
"
,
self
.
path
)
lines
=
self
.
_read_lines
()
self
.
_parse_header
(
lines
[
0
])
self
.
_parse_lines
(
lines
[
1
:])
self
.
_update_class_attributes
()
logger
.
debug
(
"
Reading holography file
\"
%s
\"
done.
"
,
self
.
path
)
@staticmethod
def
read_file
(
path
):
spec
=
HolographySpecification
(
path
)
logger
.
debug
(
"
Reading holography file
\"
%s
\"
...
"
,
spec
.
path
)
lines
=
spec
.
_read_lines
()
spec
.
_parse_header
(
lines
[
0
])
spec
.
_parse_lines
(
lines
[
1
:])
spec
.
_update_class_attributes
()
logger
.
debug
(
"
Reading holography file
\"
%s
\"
done.
"
,
spec
.
path
)
return
spec
def
_read_lines
(
self
):
with
open
(
self
.
path
,
'
r
'
)
as
fstream_in
:
...
...
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