Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LSMTool
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
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
ResearchAndDevelopment
LSMTool
Commits
b6d51ba5
Commit
b6d51ba5
authored
5 years ago
by
David Rafferty
Browse files
Options
Downloads
Patches
Plain Diff
Add weighting option
parent
8af260a7
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lsmtool/operations/group.py
+13
-3
13 additions, 3 deletions
lsmtool/operations/group.py
lsmtool/skymodel.py
+13
-8
13 additions, 8 deletions
lsmtool/skymodel.py
with
26 additions
and
11 deletions
lsmtool/operations/group.py
+
13
−
3
View file @
b6d51ba5
...
@@ -58,7 +58,7 @@ def run(step, parset, LSM):
...
@@ -58,7 +58,7 @@ def run(step, parset, LSM):
return
result
return
result
def
group
(
LSM
,
algorithm
,
targetFlux
=
None
,
numClusters
=
100
,
FWHM
=
None
,
def
group
(
LSM
,
algorithm
,
targetFlux
=
None
,
weightBySize
=
False
,
numClusters
=
100
,
FWHM
=
None
,
threshold
=
0.1
,
applyBeam
=
False
,
root
=
'
Patch
'
,
pad_index
=
False
,
method
=
'
mid
'
,
threshold
=
0.1
,
applyBeam
=
False
,
root
=
'
Patch
'
,
pad_index
=
False
,
method
=
'
mid
'
,
facet
=
""
,
byPatch
=
False
,
kernelSize
=
0.1
,
nIterations
=
100
,
lookDistance
=
0.2
,
facet
=
""
,
byPatch
=
False
,
kernelSize
=
0.1
,
nIterations
=
100
,
lookDistance
=
0.2
,
groupingDistance
=
0.01
):
groupingDistance
=
0.01
):
...
@@ -92,8 +92,13 @@ def group(LSM, algorithm, targetFlux=None, numClusters=100, FWHM=None,
...
@@ -92,8 +92,13 @@ def group(LSM, algorithm, targetFlux=None, numClusters=100, FWHM=None,
own
own
targetFlux : str or float, optional
targetFlux : str or float, optional
Target flux for tessellation (the total flux of each tile will be close
Target flux for tessellation (the total flux of each tile will be close
to this value). The target flux can be specified as either a float in Jy
to this value) and voronoi algorithms. The target flux can be specified
or as a string with units (e.g.,
'
25.0 mJy
'
)
as either a float in Jy or as a string with units (e.g.,
'
25.0 mJy
'
)
weightBySize : bool, optional
If True, fluxes are weighted by patch size (as mean size / size) when
the targetFlux criterion is applied. Patches with sizes below the mean
(flux-weighted) size are upweighted and those above the mean are
downweighted
numClusters : int, optional
numClusters : int, optional
Number of clusters for clustering. Sources are grouped around the
Number of clusters for clustering. Sources are grouped around the
numClusters brightest sources
numClusters brightest sources
...
@@ -252,6 +257,11 @@ def group(LSM, algorithm, targetFlux=None, numClusters=100, FWHM=None,
...
@@ -252,6 +257,11 @@ def group(LSM, algorithm, targetFlux=None, numClusters=100, FWHM=None,
dirs_names
=
[]
dirs_names
=
[]
names
=
LSM
.
getPatchNames
()
names
=
LSM
.
getPatchNames
()
fluxes
=
LSM
.
getColValues
(
'
I
'
,
aggregate
=
'
sum
'
,
units
=
units
,
applyBeam
=
applyBeam
)
fluxes
=
LSM
.
getColValues
(
'
I
'
,
aggregate
=
'
sum
'
,
units
=
units
,
applyBeam
=
applyBeam
)
if
weightBySize
:
sizes
=
LSM
.
getPatchSizes
(
weight
=
True
,
applyBeam
=
applyBeam
)
meanSize
=
np
.
mean
(
sizes
)
weights
=
meanSize
/
sizes
fluxes
*=
weights
for
name
,
flux
in
zip
(
names
,
fluxes
):
for
name
,
flux
in
zip
(
names
,
fluxes
):
if
flux
>=
targetFlux
:
if
flux
>=
targetFlux
:
dirs_names
.
append
(
name
)
dirs_names
.
append
(
name
)
...
...
This diff is collapsed.
Click to expand it.
lsmtool/skymodel.py
+
13
−
8
View file @
b6d51ba5
...
@@ -1986,7 +1986,7 @@ class SkyModel(object):
...
@@ -1986,7 +1986,7 @@ class SkyModel(object):
operations
.
remove
.
remove
(
self
,
filterExpression
,
aggregate
=
aggregate
,
operations
.
remove
.
remove
(
self
,
filterExpression
,
aggregate
=
aggregate
,
applyBeam
=
applyBeam
,
useRegEx
=
useRegEx
,
force
=
force
)
applyBeam
=
applyBeam
,
useRegEx
=
useRegEx
,
force
=
force
)
def
group
(
self
,
algorithm
,
targetFlux
=
None
,
numClusters
=
100
,
FWHM
=
None
,
def
group
(
self
,
algorithm
,
targetFlux
=
None
,
weightBySize
=
False
,
numClusters
=
100
,
FWHM
=
None
,
threshold
=
0.1
,
applyBeam
=
False
,
root
=
'
Patch
'
,
pad_index
=
False
,
threshold
=
0.1
,
applyBeam
=
False
,
root
=
'
Patch
'
,
pad_index
=
False
,
method
=
'
mid
'
,
facet
=
""
,
byPatch
=
False
,
kernelSize
=
0.1
,
method
=
'
mid
'
,
facet
=
""
,
byPatch
=
False
,
kernelSize
=
0.1
,
nIterations
=
100
,
lookDistance
=
0.2
,
groupingDistance
=
0.01
):
nIterations
=
100
,
lookDistance
=
0.2
,
groupingDistance
=
0.01
):
...
@@ -2000,17 +2000,17 @@ class SkyModel(object):
...
@@ -2000,17 +2000,17 @@ class SkyModel(object):
algorithm : str
algorithm : str
Algorithm to use for grouping:
Algorithm to use for grouping:
-
'
single
'
=> all sources are grouped into a single patch
-
'
single
'
=> all sources are grouped into a single patch
-
'
every
'
=> every source gets a separate patch
-
'
every
'
=> every source gets a separate patch
named
'
source_patch
'
-
'
cluster
'
=> SAGECAL clustering algorithm that groups sources into
-
'
cluster
'
=> SAGECAL clustering algorithm that groups sources into
specified number of clusters (specified by the numClusters parameter)
.
specified number of clusters (specified by the numClusters parameter)
-
'
tessellate
'
=> group into tiles whose total flux approximates
-
'
tessellate
'
=> group into tiles whose total flux approximates
the target flux (specified by the targetFlux parameter)
.
the target flux (specified by the targetFlux parameter)
-
'
threshold
'
=> group by convolving the sky model with a Gaussian beam
-
'
threshold
'
=> group by convolving the sky model with a Gaussian beam
and then thresholding to find islands of emission (NOTE: all sources
and then thresholding to find islands of emission (NOTE: all sources
are currently considered to be point sources of flux unity)
are currently considered to be point sources of flux unity)
-
'
facet
'
=> group by facets using as an input a fits file. It requires
-
'
facet
'
=> group by facets using as an input a fits file. It requires
the use of the additional parameter
'
facet
'
to enter the name of the
the use of the additional parameter
'
facet
'
to enter the name of the
fits file
(NOTE: This method is experimental)
.
fits file.
-
'
voronoi
'
=> given a previously grouped sky model, voronoi tesselate
-
'
voronoi
'
=> given a previously grouped sky model, voronoi tesselate
using the patch positions for patches above the target flux (specified
using the patch positions for patches above the target flux (specified
by the targetFlux parameter)
by the targetFlux parameter)
...
@@ -2020,8 +2020,13 @@ class SkyModel(object):
...
@@ -2020,8 +2020,13 @@ class SkyModel(object):
own
own
targetFlux : str or float, optional
targetFlux : str or float, optional
Target flux for tessellation (the total flux of each tile will be close
Target flux for tessellation (the total flux of each tile will be close
to this value). The target flux can be specified as either a float in Jy
to this value) and voronoi algorithms. The target flux can be specified
or as a string with units (e.g.,
'
25.0 mJy
'
)
as either a float in Jy or as a string with units (e.g.,
'
25.0 mJy
'
)
weightBySize : bool, optional
If True, fluxes are weighted by patch size (as mean size / size) when
the targetFlux criterion is applied. Patches with sizes below the mean
(flux-weighted) size are upweighted and those above the mean are
downweighted
numClusters : int, optional
numClusters : int, optional
Number of clusters for clustering. Sources are grouped around the
Number of clusters for clustering. Sources are grouped around the
numClusters brightest sources.
numClusters brightest sources.
...
@@ -2070,7 +2075,7 @@ class SkyModel(object):
...
@@ -2070,7 +2075,7 @@ class SkyModel(object):
>>>
s
.
group
(
'
tessellate
'
,
targetFlux
=
30.0
)
>>>
s
.
group
(
'
tessellate
'
,
targetFlux
=
30.0
)
"""
"""
operations
.
group
.
group
(
self
,
algorithm
,
targetFlux
=
targetFlux
,
operations
.
group
.
group
(
self
,
algorithm
,
targetFlux
=
targetFlux
,
weightBySize
=
weightBySize
numClusters
=
numClusters
,
FWHM
=
FWHM
,
threshold
=
threshold
,
numClusters
=
numClusters
,
FWHM
=
FWHM
,
threshold
=
threshold
,
applyBeam
=
applyBeam
,
root
=
root
,
pad_index
=
pad_index
,
applyBeam
=
applyBeam
,
root
=
root
,
pad_index
=
pad_index
,
method
=
method
,
facet
=
facet
,
byPatch
=
byPatch
,
method
=
method
,
facet
=
facet
,
byPatch
=
byPatch
,
...
...
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