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
10
Issues
10
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
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
51f49206
Commit
51f49206
authored
Sep 09, 2017
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjustments for new plotter
parent
d89a5670
Pipeline
#18002
passed with stage
in 4 minutes and 47 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
49 deletions
+31
-49
demos/critical_filtering.py
demos/critical_filtering.py
+4
-8
demos/log_normal_wiener_filter.py
demos/log_normal_wiener_filter.py
+17
-29
demos/paper_demos/cartesian_wiener_filter.py
demos/paper_demos/cartesian_wiener_filter.py
+7
-8
demos/wiener_filter_via_curvature.py
demos/wiener_filter_via_curvature.py
+3
-4
No files found.
demos/critical_filtering.py
View file @
51f49206
import
numpy
as
np
import
nifty2go
as
ift
import
plotly.graph_objs
as
go
import
plotly.offline
as
pl
np
.
random
.
seed
(
42
)
#np.seterr(all="raise",under="ignore")
def
plot_parameters
(
m
,
t
,
p
,
p_d
):
x
=
ift
.
log
(
t
.
domain
[
0
].
kindex
)
m
=
fft
.
adjoint_times
(
m
)
m
=
m
.
val
.
real
t
=
t
.
val
.
real
p
=
p
.
val
.
real
p_d
=
p_d
.
val
.
real
pl
.
plot
([
go
.
Heatmap
(
z
=
m
)],
filename
=
'map.html'
,
auto_open
=
False
)
pl
.
plot
([
go
.
Scatter
(
x
=
x
,
y
=
t
),
go
.
Scatter
(
x
=
x
,
y
=
p
),
go
.
Scatter
(
x
=
x
,
y
=
p_d
)],
filename
=
"t.html"
,
auto_open
=
False
)
ift
.
plotting
.
plot
(
m
.
real
,
name
=
'map.pdf'
)
#
pl.plot([go.Scatter(x=x, y=t), go.Scatter(x=x, y=p),
#
go.Scatter(x=x, y=p_d)], filename="t.html", auto_open=False)
class
AdjointFFTResponse
(
ift
.
LinearOperator
):
...
...
@@ -90,7 +86,7 @@ if __name__ == "__main__":
realized_power
=
ift
.
log
(
sh
.
power_analyze
(
binbounds
=
p_space
.
binbounds
))
data_power
=
ift
.
log
(
fft
(
d
).
power_analyze
(
binbounds
=
p_space
.
binbounds
))
d_data
=
d
.
val
.
real
pl
.
plot
([
go
.
Heatmap
(
z
=
d_data
)],
filename
=
'data.html'
,
auto_open
=
False
)
ift
.
plotting
.
plot
(
d
.
real
,
name
=
"data.pdf"
)
IC1
=
ift
.
DefaultIterationController
(
verbose
=
True
,
iteration_limit
=
100
)
minimizer1
=
ift
.
RelaxedNewton
(
IC1
)
...
...
demos/log_normal_wiener_filter.py
View file @
51f49206
...
...
@@ -18,7 +18,7 @@ if __name__ == "__main__":
# Setting up the geometry |\label{code:wf_geometry}|
L
=
2.
# Total side-length of the domain
N_pixels
=
128
# Grid resolution (pixels per axis)
#signal_space = RGSpace([N_pixels, N_pixels], distances=L/N_pixels)
#signal_space =
ift.
RGSpace([N_pixels, N_pixels], distances=L/N_pixels)
signal_space
=
ift
.
HPSpace
(
16
)
harmonic_space
=
signal_space
.
get_default_codomain
()
fft
=
ift
.
FFTOperator
(
harmonic_space
,
target
=
signal_space
)
...
...
@@ -53,39 +53,27 @@ if __name__ == "__main__":
minimizer2
=
ift
.
RelaxedNewton
(
controller
=
ctrl2
)
minimizer3
=
ift
.
SteepestDescent
(
controller
=
ctrl2
)
print
type
(
energy
.
value
)
me1
=
minimizer1
(
energy
)
#me1 = minimizer1(energy)
me2
=
minimizer2
(
energy
)
me3
=
minimizer3
(
energy
)
#
me3 = minimizer3(energy)
m1
=
fft
(
me1
[
0
].
position
)
#
m1 = fft(me1[0].position)
m2
=
fft
(
me2
[
0
].
position
)
m3
=
fft
(
me3
[
0
].
position
)
#
m3 = fft(me3[0].position)
# Probing the variance
#class Proby(ift.DiagonalProberMixin, ift.Prober): pass
#proby = Proby(signal_space, probe_count=100)
#proby(lambda z: fft(wiener_curvature.inverse_times(fft.inverse_times(z))))
#sm = SmoothingOperator(signal_space, sigma=0.02)
#variance = sm(proby.diagonal.weight(-1))
#Plotting #|\label{code:wf_plotting}|
#plotter = plotting.RG2DPlotter(color_map=plotting.colormaps.PlankCmap())
plotter
=
ift
.
plotting
.
HealpixPlotter
(
color_map
=
ift
.
plotting
.
colormaps
.
PlankCmap
())
ift
.
plotting
.
plot
(
mock_signal
.
real
,
name
=
'mock_signal.pdf'
,
colormap
=
"plasma"
,
xlabel
=
"Pixel Index"
,
ylabel
=
"Pixel Index"
)
ift
.
plotting
.
plot
(
ift
.
Field
(
signal_space
,
val
=
np
.
log
(
data
.
val
.
real
).
reshape
(
signal_space
.
shape
)),
name
=
"log_of_data.pdf"
,
colormap
=
"plasma"
,
xlabel
=
"Pixel Index"
,
ylabel
=
"Pixel Index"
)
#ift.plotting.plot(m1.real,name='m_LBFGS.pdf', colormap="plasma",xlabel="Pixel Index",ylabel="Pixel Index")
ift
.
plotting
.
plot
(
m2
.
real
,
name
=
'm_Newton.pdf'
,
colormap
=
"plasma"
,
xlabel
=
"Pixel Index"
,
ylabel
=
"Pixel Index"
)
#ift.plotting.plot(m3.real,name='m_SteepestDescent.pdf', colormap="plasma",xlabel="Pixel Index",ylabel="Pixel Index")
plotter
.
figure
.
xaxis
=
ift
.
plotting
.
Axis
(
label
=
'Pixel Index'
)
plotter
.
figure
.
yaxis
=
ift
.
plotting
.
Axis
(
label
=
'Pixel Index'
)
# Probing the variance
class
Proby
(
ift
.
DiagonalProberMixin
,
ift
.
Prober
):
pass
proby
=
Proby
(
signal_space
,
probe_count
=
1
)
proby
(
lambda
z
:
fft
(
me2
[
0
].
curvature
.
inverse_times
(
fft
.
adjoint_times
(
z
))))
plotter
.
plot
.
zmax
=
5
;
plotter
.
plot
.
zmin
=
-
5
#plotter(variance, path = 'variance.html')
# #plotter.plot.zmin = exp(mock_signal.min());
# plotter(mock_signal.real, path='mock_signal.html')
# plotter(Field(signal_space, val=np.log(data.val.get_full_data().real).reshape(signal_space.shape)),
# path = 'log_of_data.html')
#
plotter
(
m1
.
real
,
path
=
'm_LBFGS.html'
)
plotter
(
m2
.
real
,
path
=
'm_Newton.html'
)
plotter
(
m3
.
real
,
path
=
'm_SteepestDescent.html'
)
#
sm
=
ift
.
FFTSmoothingOperator
(
signal_space
,
sigma
=
0.02
)
variance
=
sm
(
proby
.
diagonal
.
weight
(
-
1
))
ift
.
plotting
.
plot
(
variance
,
name
=
'variance.pdf'
)
demos/paper_demos/cartesian_wiener_filter.py
View file @
51f49206
...
...
@@ -58,7 +58,7 @@ if __name__ == "__main__":
diagonal
=
mock_power
.
power_synthesize
(
spaces
=
(
0
,
1
),
mean
=
1
,
std
=
0
,
real_signal
=
False
)
**
2
#
diagonal = diagonal.real
diagonal
=
diagonal
.
real
S
=
ift
.
DiagonalOperator
(
domain
=
(
harmonic_space_1
,
harmonic_space_2
),
diagonal
=
diagonal
)
...
...
@@ -101,20 +101,19 @@ if __name__ == "__main__":
# Probing the variance
class
Proby
(
ift
.
DiagonalProberMixin
,
ift
.
Prober
):
pass
proby
=
Proby
((
signal_space_1
,
signal_space_2
),
probe_count
=
100
)
proby
=
Proby
((
signal_space_1
,
signal_space_2
),
probe_count
=
2
,
ncpu
=
2
)
proby
(
lambda
z
:
fft
(
wiener_curvature
.
inverse_times
(
fft
.
inverse_times
(
z
))))
# sm = SmoothingOperator(signal_space, sigma=0.02)
# variance = sm(proby.diagonal.weight(-1))
variance
=
proby
.
diagonal
.
weight
(
-
1
)
plot_space
=
ift
.
RGSpace
((
N_pixels_1
,
N_pixels_2
))
plotter
=
plotting
.
RG2DPlotter
(
color_map
=
plotting
.
colormaps
.
PlankCmap
())
plotter
.
figure
.
xaxis
=
ift
.
plotting
.
Axis
(
label
=
'Pixel Index'
)
plotter
.
figure
.
yaxis
=
ift
.
plotting
.
Axis
(
label
=
'Pixel Index'
)
plotter
.
plot
.
zmin
=
0.
plotter
.
plot
.
zmax
=
3.
sm
=
ift
.
FFTSmoothingOperator
(
plot_space
,
sigma
=
0.03
)
ift
.
plotting
.
plot
(
ift
.
log
(
ift
.
sqrt
(
sm
(
ift
.
Field
(
plot_space
,
val
=
variance
.
val
.
real
)))),
name
=
'uncertainty.pdf'
,
zmin
=
0.
,
zmax
=
3.
,
title
=
"Uncertainty map"
,
xlabel
=
"x"
)
ift
.
plotting
.
plot
(
ift
.
Field
(
plot_space
,
val
=
mock_signal
.
val
.
real
),
name
=
'mock_signal.pdf'
)
ift
.
plotting
.
plot
(
ift
.
Field
(
plot_space
,
val
=
data
.
val
.
real
),
name
=
'data.pdf'
)
ift
.
plotting
.
plot
(
ift
.
Field
(
plot_space
,
val
=
m
.
val
.
real
),
name
=
'map.pdf'
)
exit
()
plotter
(
ift
.
log
(
ift
.
sqrt
(
sm
(
ift
.
Field
(
plot_space
,
val
=
variance
.
val
.
real
)))),
path
=
'uncertainty.html'
)
plotter
.
plot
.
zmin
=
np
.
real
(
mock_signal
.
min
());
...
...
demos/wiener_filter_via_curvature.py
View file @
51f49206
...
...
@@ -66,8 +66,7 @@ if __name__ == "__main__":
m
=
wiener_curvature
.
inverse_times
(
j
)
m_s
=
fft
(
m
)
ift
.
plotting
.
plot
(
mock_signal
.
real
,
"mock_signal.pdf"
)
ift
.
plotting
.
plot
(
mock_power
.
real
,
"power.pdf"
)
ift
.
plotting
.
plot
(
mock_signal
.
real
,
name
=
"mock_signal.pdf"
)
ift
.
plotting
.
plot
(
ift
.
Field
(
signal_space
,
val
=
data
.
val
.
real
.
reshape
(
signal_space
.
shape
)),
"data.pdf"
)
ift
.
plotting
.
plot
(
m_s
.
real
,
"map.pdf"
)
val
=
data
.
val
.
real
.
reshape
(
signal_space
.
shape
)),
name
=
"data.pdf"
)
ift
.
plotting
.
plot
(
m_s
.
real
,
name
=
"map.pdf"
)
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