Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-sims
csst_msc_sim
Commits
dec10f3e
Commit
dec10f3e
authored
Oct 25, 2024
by
Wei Chengliang
Browse files
update style-PEP8
parent
f9c38528
Pipeline
#7094
failed with stage
in 0 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
observation_sim/psf/PSFInterp.py
View file @
dec10f3e
...
@@ -19,7 +19,7 @@ NPSF = 900 # ***# 30*30
...
@@ -19,7 +19,7 @@ NPSF = 900 # ***# 30*30
PixSizeInMicrons
=
5.
# ***# in microns
PixSizeInMicrons
=
5.
# ***# in microns
##
# find neighbors-KDtree
##
#
# find neighbors-KDtree
#
def
findNeighbors
(
tx
,
ty
,
px
,
py
,
dr
=
0.1
,
dn
=
1
,
OnlyDistance
=
True
):
def
findNeighbors
(
tx
,
ty
,
px
,
py
,
dr
=
0.1
,
dn
=
1
,
OnlyDistance
=
True
):
"""
"""
find nearest neighbors by 2D-KDTree
find nearest neighbors by 2D-KDTree
...
@@ -40,9 +40,9 @@ def findNeighbors(tx, ty, px, py, dr=0.1, dn=1, OnlyDistance=True):
...
@@ -40,9 +40,9 @@ def findNeighbors(tx, ty, px, py, dr=0.1, dn=1, OnlyDistance=True):
dataq
=
[]
dataq
=
[]
rr
=
dr
rr
=
dr
if
OnlyDistance
==
True
:
if
OnlyDistance
is
True
:
dataq
=
tree
.
query_ball_point
([
tx
,
ty
],
rr
)
dataq
=
tree
.
query_ball_point
([
tx
,
ty
],
rr
)
if
OnlyDistance
==
False
:
if
OnlyDistance
is
False
:
while
len
(
dataq
)
<
dn
:
while
len
(
dataq
)
<
dn
:
dataq
=
tree
.
query_ball_point
([
tx
,
ty
],
rr
)
dataq
=
tree
.
query_ball_point
([
tx
,
ty
],
rr
)
rr
+=
dr
rr
+=
dr
...
@@ -51,7 +51,7 @@ def findNeighbors(tx, ty, px, py, dr=0.1, dn=1, OnlyDistance=True):
...
@@ -51,7 +51,7 @@ def findNeighbors(tx, ty, px, py, dr=0.1, dn=1, OnlyDistance=True):
dataq
=
np
.
array
(
dataq
)[
ddSortindx
[
0
:
dn
]]
dataq
=
np
.
array
(
dataq
)[
ddSortindx
[
0
:
dn
]]
return
dataq
return
dataq
##
# find neighbors-hoclist#
##
# find neighbors-hoclist#
def
hocBuild
(
partx
,
party
,
nhocx
,
nhocy
,
dhocx
,
dhocy
):
def
hocBuild
(
partx
,
party
,
nhocx
,
nhocy
,
dhocx
,
dhocy
):
...
@@ -139,7 +139,7 @@ def findNeighbors_hoclist(px, py, tx=None, ty=None, dn=4, hoc=None, hoclist=None
...
@@ -139,7 +139,7 @@ def findNeighbors_hoclist(px, py, tx=None, ty=None, dn=4, hoc=None, hoclist=None
return
neigh
return
neigh
##
# PSF-IDW#
##
# PSF-IDW#
def
psfMaker_IDW
(
px
,
py
,
PSFMat
,
cen_col
,
cen_row
,
IDWindex
=
2
,
OnlyNeighbors
=
True
,
hoc
=
None
,
hoclist
=
None
,
PSFCentroidWgt
=
False
):
def
psfMaker_IDW
(
px
,
py
,
PSFMat
,
cen_col
,
cen_row
,
IDWindex
=
2
,
OnlyNeighbors
=
True
,
hoc
=
None
,
hoclist
=
None
,
PSFCentroidWgt
=
False
):
"""
"""
psf interpolation by IDW
psf interpolation by IDW
...
@@ -163,7 +163,7 @@ def psfMaker_IDW(px, py, PSFMat, cen_col, cen_row, IDWindex=2, OnlyNeighbors=Tru
...
@@ -163,7 +163,7 @@ def psfMaker_IDW(px, py, PSFMat, cen_col, cen_row, IDWindex=2, OnlyNeighbors=Tru
npsf
=
PSFMat
[:,
:,
:].
shape
[
0
]
npsf
=
PSFMat
[:,
:,
:].
shape
[
0
]
psfWeight
=
np
.
zeros
([
npsf
])
psfWeight
=
np
.
zeros
([
npsf
])
if
OnlyNeighbors
==
True
:
if
OnlyNeighbors
is
True
:
if
hoc
is
None
:
if
hoc
is
None
:
neigh
=
findNeighbors
(
px
,
py
,
cen_col
,
cen_row
,
neigh
=
findNeighbors
(
px
,
py
,
cen_col
,
cen_row
,
dr
=
5.
,
dn
=
4
,
OnlyDistance
=
False
)
dr
=
5.
,
dn
=
4
,
OnlyDistance
=
False
)
...
@@ -175,7 +175,7 @@ def psfMaker_IDW(px, py, PSFMat, cen_col, cen_row, IDWindex=2, OnlyNeighbors=Tru
...
@@ -175,7 +175,7 @@ def psfMaker_IDW(px, py, PSFMat, cen_col, cen_row, IDWindex=2, OnlyNeighbors=Tru
neighFlag
[
neigh
]
=
1
neighFlag
[
neigh
]
=
1
for
ipsf
in
range
(
npsf
):
for
ipsf
in
range
(
npsf
):
if
OnlyNeighbors
==
True
:
if
OnlyNeighbors
is
True
:
if
neighFlag
[
ipsf
]
!=
1
:
if
neighFlag
[
ipsf
]
!=
1
:
continue
continue
...
@@ -195,7 +195,7 @@ def psfMaker_IDW(px, py, PSFMat, cen_col, cen_row, IDWindex=2, OnlyNeighbors=Tru
...
@@ -195,7 +195,7 @@ def psfMaker_IDW(px, py, PSFMat, cen_col, cen_row, IDWindex=2, OnlyNeighbors=Tru
psfMaker
=
np
.
zeros
([
ngy
,
ngx
],
dtype
=
np
.
float32
)
psfMaker
=
np
.
zeros
([
ngy
,
ngx
],
dtype
=
np
.
float32
)
for
ipsf
in
range
(
npsf
):
for
ipsf
in
range
(
npsf
):
if
OnlyNeighbors
==
True
:
if
OnlyNeighbors
is
True
:
if
neighFlag
[
ipsf
]
!=
1
:
if
neighFlag
[
ipsf
]
!=
1
:
continue
continue
...
@@ -208,7 +208,7 @@ def psfMaker_IDW(px, py, PSFMat, cen_col, cen_row, IDWindex=2, OnlyNeighbors=Tru
...
@@ -208,7 +208,7 @@ def psfMaker_IDW(px, py, PSFMat, cen_col, cen_row, IDWindex=2, OnlyNeighbors=Tru
return
psfMaker
return
psfMaker
##
# define PSFInterp#
##
# define PSFInterp#
class
PSFInterp
(
PSFModel
):
class
PSFInterp
(
PSFModel
):
def
__init__
(
self
,
chip
,
npsf
=
NPSF
,
PSF_data
=
None
,
PSF_data_file
=
None
,
PSF_data_prefix
=
""
,
sigSpin
=
0
,
psfRa
=
0.15
,
HocBuild
=
False
,
LOG_DEBUG
=
False
):
def
__init__
(
self
,
chip
,
npsf
=
NPSF
,
PSF_data
=
None
,
PSF_data_file
=
None
,
PSF_data_prefix
=
""
,
sigSpin
=
0
,
psfRa
=
0.15
,
HocBuild
=
False
,
LOG_DEBUG
=
False
):
self
.
LOG_DEBUG
=
LOG_DEBUG
self
.
LOG_DEBUG
=
LOG_DEBUG
...
@@ -223,7 +223,7 @@ class PSFInterp(PSFModel):
...
@@ -223,7 +223,7 @@ class PSFInterp(PSFModel):
self
.
iccd
=
int
(
chip
.
getChipLabel
(
chipID
=
chip
.
chipID
))
self
.
iccd
=
int
(
chip
.
getChipLabel
(
chipID
=
chip
.
chipID
))
# self.iccd = chip.chip_name
# self.iccd = chip.chip_name
if
PSF_data_file
==
None
:
if
PSF_data_file
is
None
:
print
(
'Error - PSF_data_file is None'
)
print
(
'Error - PSF_data_file is None'
)
sys
.
exit
()
sys
.
exit
()
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment