Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NIFTy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
15
Merge Requests
15
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ift
NIFTy
Commits
9f070958
Commit
9f070958
authored
Aug 06, 2018
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
ee45aff1
d7aaaea0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
19 deletions
+27
-19
demos/getting_started_2.py
demos/getting_started_2.py
+3
-3
nifty5/__init__.py
nifty5/__init__.py
+3
-1
nifty5/library/inverse_gamma_model.py
nifty5/library/inverse_gamma_model.py
+19
-13
test/test_models/test_model_gradients.py
test/test_models/test_model_gradients.py
+2
-2
No files found.
demos/getting_started_2.py
View file @
9f070958
...
...
@@ -99,6 +99,6 @@ if __name__ == '__main__':
H
,
convergence
=
minimizer
(
H
)
# Plot results
ift
.
plot
(
sky
(
H
.
position
))
ift
.
plot
_finish
(
)
# FIXME PLOTTING
ift
.
plot
(
sky
(
H
.
position
)
,
title
=
'Reconstruction'
)
ift
.
plot
(
GR
.
adjoint
(
data
),
title
=
'Data'
)
ift
.
plot_finish
(
name
=
'getting_started_2.png'
,
xsize
=
16
,
ysize
=
16
)
nifty5/__init__.py
View file @
9f070958
...
...
@@ -77,7 +77,9 @@ from .plotting.plot import plot, plot_finish
from
.library.amplitude_model
import
AmplitudeModel
from
.library.los_response
import
LOSResponse
# from .library.point_sources import PointSources
#from .library.inverse_gamma_model import InverseGammaModel
from
.library.wiener_filter_curvature
import
WienerFilterCurvature
from
.library.correlated_fields
import
CorrelatedField
# make_mf_correlated_field)
...
...
nifty5/library/
point_sources
.py
→
nifty5/library/
inverse_gamma_model
.py
View file @
9f070958
...
...
@@ -30,28 +30,35 @@ from ..sugar import makeOp
from
..utilities
import
memo
class
PointSources
(
Model
):
def
__init__
(
self
,
position
,
alpha
,
q
):
super
(
PointSources
,
self
).
__init__
(
position
)
class
InverseGammaModel
(
Model
):
def
__init__
(
self
,
position
,
alpha
,
q
,
key
):
super
(
InverseGammaModel
,
self
).
__init__
(
position
)
self
.
_alpha
=
alpha
self
.
_q
=
q
self
.
_key
=
key
@
classmethod
def
make
(
cls
,
actual_position
,
alpha
,
q
,
key
):
pos
=
cls
.
inverseIG
(
actual_position
,
alpha
,
q
)
mf
=
MultiField
.
from_dict
({
key
:
pos
})
return
cls
(
mf
,
alpha
,
q
,
key
)
def
at
(
self
,
position
):
return
self
.
__class__
(
position
,
self
.
_alpha
,
self
.
_q
)
return
self
.
__class__
(
position
,
self
.
_alpha
,
self
.
_q
,
self
.
_key
)
@
property
@
memo
def
value
(
self
):
points
=
self
.
position
[
'points'
].
local_data
points
=
self
.
position
[
self
.
_key
].
local_data
# MR FIXME?!
points
=
np
.
clip
(
points
,
None
,
8.2
)
points
=
Field
.
from_local_data
(
self
.
position
[
'points'
].
domain
,
points
)
points
=
Field
.
from_local_data
(
self
.
position
[
self
.
_key
].
domain
,
points
)
return
self
.
IG
(
points
,
self
.
_alpha
,
self
.
_q
)
@
property
@
memo
def
jacobian
(
self
):
u
=
self
.
position
[
'points'
].
local_data
u
=
self
.
position
[
self
.
_key
].
local_data
inner
=
norm
.
pdf
(
u
)
outer_inv
=
invgamma
.
pdf
(
invgamma
.
ppf
(
norm
.
cdf
(
u
),
self
.
_alpha
,
...
...
@@ -60,19 +67,18 @@ class PointSources(Model):
# FIXME
outer_inv
=
np
.
clip
(
outer_inv
,
1e-20
,
None
)
outer
=
1
/
outer_inv
grad
=
Field
.
from_local_data
(
self
.
position
[
'points'
].
domain
,
grad
=
Field
.
from_local_data
(
self
.
position
[
self
.
_key
].
domain
,
inner
*
outer
)
grad
=
makeOp
(
MultiField
.
from_dict
({
"points"
:
grad
},
grad
=
makeOp
(
MultiField
.
from_dict
({
self
.
_key
:
grad
},
self
.
position
.
_domain
))
return
SelectionOperator
(
grad
.
target
,
'points'
)
*
grad
return
SelectionOperator
(
grad
.
target
,
self
.
_key
)
*
grad
@
staticmethod
def
IG
(
field
,
alpha
,
q
):
foo
=
invgamma
.
ppf
(
norm
.
cdf
(
field
.
local_data
),
alpha
,
scale
=
q
)
return
Field
.
from_local_data
(
field
.
domain
,
foo
)
# MR FIXME: why does this take an np.ndarray instead of a Field?
@
staticmethod
def
inverseIG
(
u
,
alpha
,
q
):
res
=
norm
.
ppf
(
invgamma
.
cdf
(
u
,
alpha
,
scale
=
q
))
return
res
res
=
norm
.
ppf
(
invgamma
.
cdf
(
u
.
local_data
,
alpha
,
scale
=
q
))
return
Field
.
from_local_data
(
u
.
domain
,
res
)
test/test_models/test_model_gradients.py
View file @
9f070958
...
...
@@ -125,8 +125,8 @@ class Model_Tests(unittest.TestCase):
# {'points': S.draw_sample()})
# alpha = 1.5
# q = 0.73
# model = ift.
PointSources(pos, alpha, q
)
# # FIXME All those cdfs and ppfs are not
that
accurate
# model = ift.
InverseGammaModel(pos, alpha, q, 'points'
)
# # FIXME All those cdfs and ppfs are not
very
accurate
# ift.extra.check_value_gradient_consistency(model, tol=1e-5)
#
# @expand(product(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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