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
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
82beea3c
Commit
82beea3c
authored
Jan 30, 2019
by
Torsten Ensslin
Committed by
Martin Reinecke
Jan 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Demo optimization te
parent
c8016819
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
17 deletions
+21
-17
demos/getting_started_2.py
demos/getting_started_2.py
+6
-6
demos/getting_started_3.py
demos/getting_started_3.py
+15
-11
No files found.
demos/getting_started_2.py
View file @
82beea3c
...
...
@@ -43,22 +43,22 @@ def exposure_2d():
if
__name__
==
'__main__'
:
# FIXME All random seeds to 42
np
.
random
.
seed
(
4
1
)
np
.
random
.
seed
(
4
2
)
# Choose space on which the signal field is defined
mode
=
2
mode
=
1
if
mode
==
0
:
# One-dimensional regular grid with uniform exposure
# One-dimensional regular grid with uniform exposure
of 10
position_space
=
ift
.
RGSpace
(
1024
)
exposure
=
ift
.
Field
.
full
(
position_space
,
1.
)
exposure
=
ift
.
Field
.
full
(
position_space
,
1
0
.
)
elif
mode
==
1
:
# Two-dimensional regular grid with inhomogeneous exposure
position_space
=
ift
.
RGSpace
([
512
,
512
])
exposure
=
exposure_2d
()
else
:
# Sphere with uniform exposure
# Sphere with uniform exposure
of 100
position_space
=
ift
.
HPSpace
(
128
)
exposure
=
ift
.
Field
.
full
(
position_space
,
1.
)
exposure
=
ift
.
Field
.
full
(
position_space
,
1
00
.
)
# Define harmonic space and harmonic transform
harmonic_space
=
position_space
.
get_default_codomain
()
...
...
demos/getting_started_3.py
View file @
82beea3c
...
...
@@ -17,8 +17,12 @@
############################################################
# Non-linear tomography
# The data is integrated lines of sight
# Random lines (set mode=0), radial lines (mode=1)
#
# The signal is a sigmoid-normal distributed field.
# The data is the field integrated along lines of sight that are
# randomly (set mode=0) or radially (mode=1) distributed
#
# Demo takes a while to compute
#############################################################
import
numpy
as
np
...
...
@@ -28,22 +32,22 @@ import nifty5 as ift
def
random_los
(
n_los
):
starts
=
list
(
np
.
random
.
uniform
(
0
,
1
,
(
n_los
,
2
)).
T
)
ends
=
list
(
0.5
+
0
*
np
.
random
.
uniform
(
0
,
1
,
(
n_los
,
2
)).
T
)
ends
=
list
(
np
.
random
.
uniform
(
0
,
1
,
(
n_los
,
2
)).
T
)
return
starts
,
ends
def
radial_los
(
n_los
):
starts
=
list
(
np
.
random
.
uniform
(
0
,
1
,
(
n_los
,
2
)).
T
)
ends
=
list
(
np
.
random
.
uniform
(
0
,
1
,
(
n_los
,
2
)).
T
)
ends
=
list
(
0.5
+
0
*
np
.
random
.
uniform
(
0
,
1
,
(
n_los
,
2
)).
T
)
return
starts
,
ends
if
__name__
==
'__main__'
:
np
.
random
.
seed
(
420
)
np
.
random
.
seed
(
420
)
# picked for a nice field realization
# Choose between random line-of-sight response (mode=
1
) and radial lines
# of sight (mode=
2
)
mode
=
1
# Choose between random line-of-sight response (mode=
0
) and radial lines
# of sight (mode=
1
)
mode
=
0
position_space
=
ift
.
RGSpace
([
128
,
128
])
harmonic_space
=
position_space
.
get_default_codomain
()
...
...
@@ -62,8 +66,8 @@ if __name__ == '__main__':
# Power-law part of spectrum:
'sm'
:
-
5
,
# preferred power-law slope
'sv'
:
.
5
,
# low variance of power-law slope
'im'
:
.
4
,
# y-intercept mean
'iv'
:
.
3
# relatively high
y-intercept variance
'im'
:
0
,
# y-intercept mean, in-/decrease for more/less contrast
'iv'
:
.
3
#
y-intercept variance
}
A
=
ift
.
SLAmplitude
(
**
dct
)
...
...
@@ -79,7 +83,7 @@ if __name__ == '__main__':
signal
=
ift
.
sigmoid
(
correlated_field
)
# Build the line-of-sight response and define signal response
LOS_starts
,
LOS_ends
=
random_los
(
100
)
if
mode
==
1
else
radial_los
(
100
)
LOS_starts
,
LOS_ends
=
random_los
(
100
)
if
mode
==
0
else
radial_los
(
100
)
R
=
ift
.
LOSResponse
(
position_space
,
starts
=
LOS_starts
,
ends
=
LOS_ends
)
signal_response
=
R
(
signal
)
...
...
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