Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
maoppy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LAM-GRD-public
maoppy
Commits
2ac02eb3
Commit
2ac02eb3
authored
4 years ago
by
FETICK Romain
Browse files
Options
Downloads
Patches
Plain Diff
Add Gaussian PSF
parent
f56044d5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
maoppy/example/fit_muse_simulated_psf.py
+5
-3
5 additions, 3 deletions
maoppy/example/fit_muse_simulated_psf.py
maoppy/psfmodel.py
+26
-0
26 additions, 0 deletions
maoppy/psfmodel.py
with
31 additions
and
3 deletions
maoppy/example/fit_muse_simulated_psf.py
+
5
−
3
View file @
2ac02eb3
...
@@ -19,7 +19,7 @@ from maoppy.instrument import MUSE_NFM
...
@@ -19,7 +19,7 @@ from maoppy.instrument import MUSE_NFM
npix
=
128
# pixel size of PSF
npix
=
128
# pixel size of PSF
wvl
=
600
*
1e-9
# wavelength [m]
wvl
=
600
*
1e-9
# wavelength [m]
flux
=
1e
6
flux
=
1e
5
ron
=
MUSE_NFM
.
ron
ron
=
MUSE_NFM
.
ron
bckgd
=
1.0
bckgd
=
1.0
...
@@ -38,7 +38,8 @@ param = [r0,b,amp,ax,beta]
...
@@ -38,7 +38,8 @@ param = [r0,b,amp,ax,beta]
psf
=
Pmodel
(
param
,
dx
=
0
,
dy
=
0
)
psf
=
Pmodel
(
param
,
dx
=
0
,
dy
=
0
)
image
=
flux
*
psf
+
bckgd
+
ron
*
np
.
random
.
randn
(
npix
,
npix
)
noise
=
ron
*
np
.
random
.
randn
(
npix
,
npix
)
image
=
flux
*
psf
+
bckgd
+
noise
#%% Fit the PSF
#%% Fit the PSF
...
@@ -59,7 +60,8 @@ print("%9s %10.4g %10.4g"%('Bck [e-]',bckgd,bck_fit))
...
@@ -59,7 +60,8 @@ print("%9s %10.4g %10.4g"%('Bck [e-]',bckgd,bck_fit))
print
(
"
%9s %10.2f %10.2f
"
%
(
'
r0 [cm]
'
,
r0
*
100
,
out
.
x
[
0
]
*
100
))
print
(
"
%9s %10.2f %10.2f
"
%
(
'
r0 [cm]
'
,
r0
*
100
,
out
.
x
[
0
]
*
100
))
print
(
"
%9s %10.2f %10.2f
"
%
(
'
A [rad²]
'
,
amp
,
out
.
x
[
2
]))
print
(
"
%9s %10.2f %10.2f
"
%
(
'
A [rad²]
'
,
amp
,
out
.
x
[
2
]))
print
(
31
*
'
-
'
)
print
(
31
*
'
-
'
)
print
(
"
shape RMS error = %.2f%%
"
%
(
100
*
rmserror
(
fitao
,
image
)))
print
(
"
shape + noise RMS error = %.2f%%
"
%
(
100
*
rmserror
(
fitao
,
image
)))
print
(
"
noise RMS error = %.2f%%
"
%
(
np
.
sqrt
(
np
.
sum
(
noise
**
2
))
/
np
.
sum
(
image
)
*
100
))
print
(
31
*
'
-
'
)
print
(
31
*
'
-
'
)
vmin
,
vmax
=
np
.
arcsinh
([
image
.
min
(),
image
.
max
()])
vmin
,
vmax
=
np
.
arcsinh
([
image
.
min
(),
image
.
max
()])
...
...
This diff is collapsed.
Click to expand it.
maoppy/psfmodel.py
+
26
−
0
View file @
2ac02eb3
...
@@ -76,6 +76,7 @@ def psffit(psf,Model,x0,weights=None,dxdy=(0.,0.),flux_bck=(True,True),
...
@@ -76,6 +76,7 @@ def psffit(psf,Model,x0,weights=None,dxdy=(0.,0.),flux_bck=(True,True),
Initial guess for parameters
Initial guess for parameters
weights : numpy.ndarray
weights : numpy.ndarray
Least-square weighting matrix (same size as `psf`)
Least-square weighting matrix (same size as `psf`)
Inverse of the noise
'
s variance
Default: uniform weighting
Default: uniform weighting
dxdy : tuple of two floats
dxdy : tuple of two floats
Eventual guess on PSF shifting
Eventual guess on PSF shifting
...
@@ -354,6 +355,31 @@ class Moffat(ParametricPSF):
...
@@ -354,6 +355,31 @@ class Moffat(ParametricPSF):
super
(
Moffat
,
self
).
tofits
(
param
,
filename
,
*
args
,
keys
=
keys
,
**
kwargs
)
super
(
Moffat
,
self
).
tofits
(
param
,
filename
,
*
args
,
keys
=
keys
,
**
kwargs
)
class
Gaussian
(
ParametricPSF
):
def
__init__
(
self
,
Npix
):
self
.
Npix
=
Npix
bounds_down
=
[
_EPSILON
,
_EPSILON
,
-
np
.
inf
]
bounds_up
=
[
np
.
inf
for
i
in
range
(
3
)]
self
.
bounds
=
(
bounds_down
,
bounds_up
)
self
.
_XY
=
np
.
mgrid
[
0
:
Npix
[
0
],
0
:
Npix
[
1
]]
self
.
_XY
[
1
]
-=
Npix
[
0
]
/
2
self
.
_XY
[
0
]
-=
Npix
[
1
]
/
2
def
__call__
(
self
,
x
,
dx
=
0
,
dy
=
0
):
"""
Parameters
----------
x : list, tuple, numpy.ndarray (len=4)
x[0] - Sigma X
x[1] - Sigma Y
x[2] - Theta
"""
y
=
np
.
concatenate
((
x
,[
dx
,
dy
]))
return
gauss
(
self
.
_XY
,
y
)
def
tofits
(
self
,
param
,
filename
,
*
args
,
keys
=
[
"
SIGMA_X
"
,
"
SIGMA_Y
"
,
"
THETA
"
],
**
kwargs
):
super
(
Moffat
,
self
).
tofits
(
param
,
filename
,
*
args
,
keys
=
keys
,
**
kwargs
)
def
oversample
(
samp
):
def
oversample
(
samp
):
...
...
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