Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
f44d8758
Commit
f44d8758
authored
Dec 05, 2019
by
Martin Reinecke
Browse files
start adjusting demos
parent
d166c586
Pipeline
#64980
failed with stages
in 8 minutes and 36 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
demos/bench_gridder.py
View file @
f44d8758
...
@@ -31,9 +31,9 @@ for ii in range(10, 26):
...
@@ -31,9 +31,9 @@ for ii in range(10, 26):
vis
=
ift
.
from_global_data
(
visspace
,
vis
)
vis
=
ift
.
from_global_data
(
visspace
,
vis
)
op
=
GM
.
getFull
().
adjoint
op
=
GM
.
getFull
().
adjoint
t1
=
time
()
t1
=
time
()
op
(
img
).
to_global_data
()
op
(
img
).
val
t2
=
time
()
t2
=
time
()
op
.
adjoint
(
vis
).
to_global_data
()
op
.
adjoint
(
vis
).
val
t3
=
time
()
t3
=
time
()
print
(
t2
-
t1
,
t3
-
t2
)
print
(
t2
-
t1
,
t3
-
t2
)
N0s
.
append
(
N
)
N0s
.
append
(
N
)
...
...
demos/getting_started_1.py
View file @
f44d8758
...
@@ -42,7 +42,7 @@ def make_random_mask():
...
@@ -42,7 +42,7 @@ def make_random_mask():
# Random mask for spherical mode
# Random mask for spherical mode
mask
=
ift
.
from_random
(
'pm1'
,
position_space
)
mask
=
ift
.
from_random
(
'pm1'
,
position_space
)
mask
=
(
mask
+
1
)
/
2
mask
=
(
mask
+
1
)
/
2
return
mask
.
to_global_data
()
return
mask
.
val
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
@@ -95,7 +95,7 @@ if __name__ == '__main__':
...
@@ -95,7 +95,7 @@ if __name__ == '__main__':
# and harmonic transformaion
# and harmonic transformaion
# Masking operator to model that parts of the field have not been observed
# Masking operator to model that parts of the field have not been observed
mask
=
ift
.
Field
.
from_
global_data
(
position_space
,
mask
)
mask
=
ift
.
Field
.
from_
arr
(
position_space
,
mask
)
Mask
=
ift
.
MaskOperator
(
mask
)
Mask
=
ift
.
MaskOperator
(
mask
)
# The response operator consists of
# The response operator consists of
...
...
demos/getting_started_2.py
View file @
f44d8758
...
@@ -40,7 +40,7 @@ def exposure_2d():
...
@@ -40,7 +40,7 @@ def exposure_2d():
exposure
[:,
x_shape
*
4
//
5
:
x_shape
]
*=
.
1
exposure
[:,
x_shape
*
4
//
5
:
x_shape
]
*=
.
1
exposure
[:,
x_shape
//
2
:
x_shape
*
3
//
2
]
*=
3.
exposure
[:,
x_shape
//
2
:
x_shape
*
3
//
2
]
*=
3.
return
ift
.
Field
.
from_
global_data
(
position_space
,
exposure
)
return
ift
.
Field
.
from_
arr
(
position_space
,
exposure
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
@@ -94,8 +94,8 @@ if __name__ == '__main__':
...
@@ -94,8 +94,8 @@ if __name__ == '__main__':
lamb
=
R
(
sky
)
lamb
=
R
(
sky
)
mock_position
=
ift
.
from_random
(
'normal'
,
domain
)
mock_position
=
ift
.
from_random
(
'normal'
,
domain
)
data
=
lamb
(
mock_position
)
data
=
lamb
(
mock_position
)
data
=
np
.
random
.
poisson
(
data
.
to_global_data
()
.
astype
(
np
.
float64
))
data
=
np
.
random
.
poisson
(
data
.
val
.
astype
(
np
.
float64
))
data
=
ift
.
Field
.
from_
global_data
(
d_space
,
data
)
data
=
ift
.
Field
.
from_
arr
(
d_space
,
data
)
likelihood
=
ift
.
PoissonianEnergy
(
data
)(
lamb
)
likelihood
=
ift
.
PoissonianEnergy
(
data
)(
lamb
)
# Settings for minimization
# Settings for minimization
...
...
demos/getting_started_mf.py
View file @
f44d8758
...
@@ -40,7 +40,7 @@ class SingleDomain(ift.LinearOperator):
...
@@ -40,7 +40,7 @@ class SingleDomain(ift.LinearOperator):
def
apply
(
self
,
x
,
mode
):
def
apply
(
self
,
x
,
mode
):
self
.
_check_input
(
x
,
mode
)
self
.
_check_input
(
x
,
mode
)
return
ift
.
from_global_data
(
self
.
_tgt
(
mode
),
x
.
to_global_data
()
)
return
ift
.
from_global_data
(
self
.
_tgt
(
mode
),
x
.
val
)
def
random_los
(
n_los
):
def
random_los
(
n_los
):
...
...
demos/multi_amplitudes_consistency.py
View file @
f44d8758
...
@@ -9,12 +9,12 @@ def testAmplitudesConsistency(seed, sspace):
...
@@ -9,12 +9,12 @@ def testAmplitudesConsistency(seed, sspace):
sc
=
ift
.
StatCalculator
()
sc
=
ift
.
StatCalculator
()
for
s
in
samples
:
for
s
in
samples
:
sc
.
add
(
op
(
s
.
extract
(
op
.
domain
)))
sc
.
add
(
op
(
s
.
extract
(
op
.
domain
)))
return
sc
.
mean
.
to_global_data
(),
sc
.
var
.
sqrt
().
to_global_data
()
return
sc
.
mean
.
val
,
sc
.
var
.
sqrt
().
val
np
.
random
.
seed
(
seed
)
np
.
random
.
seed
(
seed
)
offset_std
=
.
1
offset_std
=
.
1
intergated_fluct_std0
=
.
003
intergated_fluct_std0
=
.
003
intergated_fluct_std1
=
0.1
intergated_fluct_std1
=
0.1
nsam
=
1000
nsam
=
1000
...
@@ -32,7 +32,7 @@ def testAmplitudesConsistency(seed, sspace):
...
@@ -32,7 +32,7 @@ def testAmplitudesConsistency(seed, sspace):
offset_std
,
_
=
stats
(
fa
.
amplitude_total_offset
,
samples
)
offset_std
,
_
=
stats
(
fa
.
amplitude_total_offset
,
samples
)
intergated_fluct_std0
,
_
=
stats
(
fa
.
average_fluctuation
(
0
),
samples
)
intergated_fluct_std0
,
_
=
stats
(
fa
.
average_fluctuation
(
0
),
samples
)
intergated_fluct_std1
,
_
=
stats
(
fa
.
average_fluctuation
(
1
),
samples
)
intergated_fluct_std1
,
_
=
stats
(
fa
.
average_fluctuation
(
1
),
samples
)
slice_fluct_std0
,
_
=
stats
(
fa
.
slice_fluctuation
(
0
),
samples
)
slice_fluct_std0
,
_
=
stats
(
fa
.
slice_fluctuation
(
0
),
samples
)
slice_fluct_std1
,
_
=
stats
(
fa
.
slice_fluctuation
(
1
),
samples
)
slice_fluct_std1
,
_
=
stats
(
fa
.
slice_fluctuation
(
1
),
samples
)
...
@@ -54,7 +54,7 @@ def testAmplitudesConsistency(seed, sspace):
...
@@ -54,7 +54,7 @@ def testAmplitudesConsistency(seed, sspace):
print
(
"Expected integrated fluct. frequency Std: "
+
print
(
"Expected integrated fluct. frequency Std: "
+
str
(
intergated_fluct_std1
))
str
(
intergated_fluct_std1
))
print
(
"Estimated integrated fluct. frequency Std: "
+
str
(
fluct_freq
))
print
(
"Estimated integrated fluct. frequency Std: "
+
str
(
fluct_freq
))
print
(
"Expected slice fluct. space Std: "
+
print
(
"Expected slice fluct. space Std: "
+
str
(
slice_fluct_std0
))
str
(
slice_fluct_std0
))
print
(
"Estimated slice fluct. space Std: "
+
str
(
sl_fluct_space
))
print
(
"Estimated slice fluct. space Std: "
+
str
(
sl_fluct_space
))
...
@@ -65,8 +65,8 @@ def testAmplitudesConsistency(seed, sspace):
...
@@ -65,8 +65,8 @@ def testAmplitudesConsistency(seed, sspace):
print
(
"Expected total fluct. Std: "
+
str
(
tot_flm
))
print
(
"Expected total fluct. Std: "
+
str
(
tot_flm
))
print
(
"Estimated total fluct. Std: "
+
str
(
fluct_total
))
print
(
"Estimated total fluct. Std: "
+
str
(
fluct_total
))
np
.
testing
.
assert_allclose
(
offset_std
,
zm_std_mean
,
rtol
=
0.5
)
np
.
testing
.
assert_allclose
(
offset_std
,
zm_std_mean
,
rtol
=
0.5
)
np
.
testing
.
assert_allclose
(
intergated_fluct_std0
,
fluct_space
,
rtol
=
0.5
)
np
.
testing
.
assert_allclose
(
intergated_fluct_std0
,
fluct_space
,
rtol
=
0.5
)
np
.
testing
.
assert_allclose
(
intergated_fluct_std1
,
fluct_freq
,
rtol
=
0.5
)
np
.
testing
.
assert_allclose
(
intergated_fluct_std1
,
fluct_freq
,
rtol
=
0.5
)
...
@@ -74,7 +74,7 @@ def testAmplitudesConsistency(seed, sspace):
...
@@ -74,7 +74,7 @@ def testAmplitudesConsistency(seed, sspace):
np
.
testing
.
assert_allclose
(
slice_fluct_std0
,
sl_fluct_space
,
rtol
=
0.5
)
np
.
testing
.
assert_allclose
(
slice_fluct_std0
,
sl_fluct_space
,
rtol
=
0.5
)
np
.
testing
.
assert_allclose
(
slice_fluct_std1
,
sl_fluct_freq
,
rtol
=
0.5
)
np
.
testing
.
assert_allclose
(
slice_fluct_std1
,
sl_fluct_freq
,
rtol
=
0.5
)
fa
=
ift
.
CorrelatedFieldMaker
.
make
(
offset_std
,
.
1
,
''
)
fa
=
ift
.
CorrelatedFieldMaker
.
make
(
offset_std
,
.
1
,
''
)
fa
.
add_fluctuations
(
fsspace
,
intergated_fluct_std1
,
1.
,
3.1
,
1.
,
.
5
,
.
1
,
fa
.
add_fluctuations
(
fsspace
,
intergated_fluct_std1
,
1.
,
3.1
,
1.
,
.
5
,
.
1
,
-
4
,
1.
,
'freq'
)
-
4
,
1.
,
'freq'
)
...
@@ -87,7 +87,7 @@ def testAmplitudesConsistency(seed, sspace):
...
@@ -87,7 +87,7 @@ def testAmplitudesConsistency(seed, sspace):
print
(
"Forced slice fluct. space Std: "
+
str
(
m
))
print
(
"Forced slice fluct. space Std: "
+
str
(
m
))
print
(
"Expected slice fluct. Std: "
+
str
(
em
))
print
(
"Expected slice fluct. Std: "
+
str
(
em
))
np
.
testing
.
assert_allclose
(
m
,
em
,
rtol
=
0.5
)
np
.
testing
.
assert_allclose
(
m
,
em
,
rtol
=
0.5
)
assert
op
.
target
[
0
]
==
sspace
assert
op
.
target
[
0
]
==
sspace
assert
op
.
target
[
1
]
==
fsspace
assert
op
.
target
[
1
]
==
fsspace
...
...
demos/polynomial_fit.py
View file @
f44d8758
...
@@ -36,7 +36,7 @@ def polynomial(coefficients, sampling_points):
...
@@ -36,7 +36,7 @@ def polynomial(coefficients, sampling_points):
if
not
(
isinstance
(
coefficients
,
ift
.
Field
)
if
not
(
isinstance
(
coefficients
,
ift
.
Field
)
and
isinstance
(
sampling_points
,
np
.
ndarray
)):
and
isinstance
(
sampling_points
,
np
.
ndarray
)):
raise
TypeError
raise
TypeError
params
=
coefficients
.
to_global_data
()
params
=
coefficients
.
val
out
=
np
.
zeros_like
(
sampling_points
)
out
=
np
.
zeros_like
(
sampling_points
)
for
ii
in
range
(
len
(
params
)):
for
ii
in
range
(
len
(
params
)):
out
+=
params
[
ii
]
*
sampling_points
**
ii
out
+=
params
[
ii
]
*
sampling_points
**
ii
...
@@ -71,7 +71,7 @@ class PolynomialResponse(ift.LinearOperator):
...
@@ -71,7 +71,7 @@ class PolynomialResponse(ift.LinearOperator):
def
apply
(
self
,
x
,
mode
):
def
apply
(
self
,
x
,
mode
):
self
.
_check_input
(
x
,
mode
)
self
.
_check_input
(
x
,
mode
)
val
=
x
.
to_global_data_rw
()
val
=
x
.
val
.
copy
()
if
mode
==
self
.
TIMES
:
if
mode
==
self
.
TIMES
:
# FIXME Use polynomial() here
# FIXME Use polynomial() here
out
=
self
.
_mat
.
dot
(
val
)
out
=
self
.
_mat
.
dot
(
val
)
...
@@ -136,9 +136,8 @@ plt.savefig('fit.png')
...
@@ -136,9 +136,8 @@ plt.savefig('fit.png')
plt
.
close
()
plt
.
close
()
# Print parameters
# Print parameters
mean
=
sc
.
mean
.
to_global_data
()
mean
=
sc
.
mean
.
val
sigma
=
np
.
sqrt
(
sc
.
var
.
to_global_data
())
sigma
=
np
.
sqrt
(
sc
.
var
.
val
)
if
ift
.
dobj
.
master
:
for
ii
in
range
(
len
(
mean
)):
for
ii
in
range
(
len
(
mean
)):
print
(
'Coefficient x**{}: {:.2E} +/- {:.2E}'
.
format
(
ii
,
mean
[
ii
],
print
(
'Coefficient x**{}: {:.2E} +/- {:.2E}'
.
format
(
ii
,
mean
[
ii
],
sigma
[
ii
]))
sigma
[
ii
]))
nifty6/version.py
View file @
f44d8758
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
# 2) we can import it in setup.py for the same reason
# 2) we can import it in setup.py for the same reason
# 3) we can import it into your module module
# 3) we can import it into your module module
__version__
=
'
5
.0.0'
__version__
=
'
6
.0.0'
def
gitversion
():
def
gitversion
():
...
...
Write
Preview
Supports
Markdown
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