Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ift
NIFTy
Commits
82beea3c
Commit
82beea3c
authored
6 years ago
by
Torsten Ensslin
Committed by
Martin Reinecke
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Demo optimization te
parent
c8016819
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
demos/getting_started_2.py
+6
-6
6 additions, 6 deletions
demos/getting_started_2.py
demos/getting_started_3.py
+15
-11
15 additions, 11 deletions
demos/getting_started_3.py
with
21 additions
and
17 deletions
demos/getting_started_2.py
+
6
−
6
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
()
...
...
This diff is collapsed.
Click to expand it.
demos/getting_started_3.py
+
15
−
11
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
)
...
...
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