Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LINC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Container Registry
Model registry
Operate
Environments
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ResearchAndDevelopment
LINC
Commits
6938d209
Commit
6938d209
authored
1 year ago
by
David Rafferty
Browse files
Options
Downloads
Patches
Plain Diff
Adjust merge to exclude duplicate components
parent
f7271dda
No related branches found
No related tags found
1 merge request
!171
Adjust merge to exclude duplicate components
Pipeline
#61577
passed
1 year ago
Stage: versioning
Stage: build
Stage: tests
Stage: docs
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/merge_skymodels.py
+28
-6
28 additions, 6 deletions
scripts/merge_skymodels.py
steps/merge_skymodels.cwl
+17
-0
17 additions, 0 deletions
steps/merge_skymodels.cwl
with
45 additions
and
6 deletions
scripts/merge_skymodels.py
+
28
−
6
View file @
6938d209
...
@@ -5,12 +5,28 @@ Append a LOFAR skymodel to an existing one
...
@@ -5,12 +5,28 @@ Append a LOFAR skymodel to an existing one
import
os
,
logging
import
os
,
logging
import
lsmtool
import
lsmtool
import
numpy
########################################################################
########################################################################
def
main
(
inmodel1
,
inmodel2
,
outmodel
=
'
output.skymodel
'
):
def
main
(
inmodel1
,
inmodel2
,
outmodel
=
'
output.skymodel
'
,
radius
=
30
/
3600
,
keep
=
'
from2
'
):
"""
Merge two LOFAR skymodel text files.
Parameters
----------
inmodel1 : str
Name (path) of input model #1
inmodel2 : str
Name (path) of input model #2
outmodel : str, optional
Name (path) of output merged model
radius : float, optional
Matching radius in degrees for determining duplicates
keep : str, optional
When duplicates are found, keep those from model #1 (
'
from1
'
) or from
model #2 (
'
from2
'
)
"""
logging
.
info
(
'
Reading
'
+
inmodel1
)
logging
.
info
(
'
Reading
'
+
inmodel1
)
s1
=
lsmtool
.
load
(
inmodel1
)
s1
=
lsmtool
.
load
(
inmodel1
)
logging
.
info
(
'
Reading
'
+
inmodel2
)
logging
.
info
(
'
Reading
'
+
inmodel2
)
...
@@ -22,7 +38,10 @@ def main(inmodel1, inmodel2, outmodel = 'output.skymodel'):
...
@@ -22,7 +38,10 @@ def main(inmodel1, inmodel2, outmodel = 'output.skymodel'):
s2
.
group
(
'
single
'
)
s2
.
group
(
'
single
'
)
logging
.
info
(
'
Adding skymodel
'
+
inmodel2
+
'
to
'
+
inmodel1
)
logging
.
info
(
'
Adding skymodel
'
+
inmodel2
+
'
to
'
+
inmodel1
)
s1
.
concatenate
(
s2
,
inheritPatches
=
True
)
# The following call will merge the two models, identifing (by position) duplicate
# sources/components that are present in both
s1
.
concatenate
(
s2
,
matchBy
=
'
position
'
,
radius
=
radius
,
keep
=
keep
)
s1
.
setPatchPositions
()
s1
.
setPatchPositions
()
s1
.
write
(
outmodel
)
s1
.
write
(
outmodel
)
...
@@ -36,11 +55,14 @@ if __name__ == '__main__':
...
@@ -36,11 +55,14 @@ if __name__ == '__main__':
parser
.
add_argument
(
'
--inmodel1
'
,
type
=
str
,
default
=
None
,
help
=
'
input/output skymodel.
'
)
parser
.
add_argument
(
'
--inmodel1
'
,
type
=
str
,
default
=
None
,
help
=
'
input/output skymodel.
'
)
parser
.
add_argument
(
'
--inmodel2
'
,
type
=
str
,
default
=
None
,
help
=
'
skymodel to append
'
)
parser
.
add_argument
(
'
--inmodel2
'
,
type
=
str
,
default
=
None
,
help
=
'
skymodel to append
'
)
parser
.
add_argument
(
'
--outmodel
'
,
type
=
str
,
default
=
'
output.skymodel
'
,
help
=
'
output skymodel name
'
)
parser
.
add_argument
(
'
--outmodel
'
,
type
=
str
,
default
=
'
output.skymodel
'
,
help
=
'
output skymodel name
'
)
parser
.
add_argument
(
'
--radius
'
,
type
=
float
,
default
=
30
/
3600
,
help
=
'
matching radius in degrees
'
)
parser
.
add_argument
(
'
--keep
'
,
type
=
str
,
default
=
'
from2
'
,
help
=
'
keep duplicates from model 1 or 2
'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
format_stream
=
logging
.
Formatter
(
"
%(asctime)s
\033
[1m %(levelname)s:
\033
[0m %(message)s
"
,
"
%Y-%m-%d %H:%M:%S
"
)
format_stream
=
logging
.
Formatter
(
"
%(asctime)s
\033
[1m %(levelname)s:
\033
[0m %(message)s
"
,
"
%Y-%m-%d %H:%M:%S
"
)
format_file
=
logging
.
Formatter
(
"
%(asctime)s %(levelname)s: %(message)s
"
,
"
%Y-%m-%d %H:%M:%S
"
)
format_file
=
logging
.
Formatter
(
"
%(asctime)s %(levelname)s: %(message)s
"
,
"
%Y-%m-%d %H:%M:%S
"
)
logging
.
root
.
setLevel
(
logging
.
INFO
)
logging
.
root
.
setLevel
(
logging
.
INFO
)
main
(
inmodel1
=
os
.
path
.
expandvars
(
args
.
inmodel1
),
inmodel2
=
os
.
path
.
expandvars
(
args
.
inmodel2
),
outmodel
=
os
.
path
.
expandvars
(
args
.
outmodel
))
main
(
inmodel1
=
os
.
path
.
expandvars
(
args
.
inmodel1
),
inmodel2
=
os
.
path
.
expandvars
(
args
.
inmodel2
),
outmodel
=
os
.
path
.
expandvars
(
args
.
outmodel
),
radius
=
args
.
radius
,
keep
=
args
.
keep
)
This diff is collapsed.
Click to expand it.
steps/merge_skymodels.cwl
+
17
−
0
View file @
6938d209
...
@@ -29,6 +29,23 @@ inputs:
...
@@ -29,6 +29,23 @@ inputs:
prefix: --outmodel=
prefix: --outmodel=
separate: false
separate: false
shellQuote: false
shellQuote: false
- id: radius
type: float?
default: 0.00833
inputBinding:
prefix: --radius=
separate: false
shellQuote: false
doc: Matching radius in degrees for identifying duplicate components
- id: keep
type: string?
default: 'from2'
inputBinding:
prefix: --keep=
separate: false
shellQuote: false
doc: Keep duplicate components from model 1 or model 2
outputs:
outputs:
- id: skymodel_out
- id: skymodel_out
type: File
type: File
...
...
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