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
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
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
497f33ff
Commit
497f33ff
authored
Apr 11, 2019
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'NIFTy_5' into gridder_mr
parents
9cd9b9ad
214244d7
Pipeline
#46741
passed with stages
in 8 minutes and 36 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
20 deletions
+13
-20
demos/getting_started_1.py
demos/getting_started_1.py
+13
-20
No files found.
demos/getting_started_1.py
View file @
497f33ff
...
...
@@ -45,13 +45,6 @@ def make_random_mask():
return
mask
.
to_global_data
()
def
mask_to_nan
(
mask
,
field
):
# Set masked pixels to nan for plotting
masked_data
=
field
.
local_data
.
copy
()
masked_data
[
mask
.
local_data
==
0
]
=
np
.
nan
return
ift
.
from_local_data
(
field
.
domain
,
masked_data
)
if
__name__
==
'__main__'
:
np
.
random
.
seed
(
42
)
...
...
@@ -64,7 +57,7 @@ if __name__ == '__main__':
if
mode
==
0
:
# One-dimensional regular grid
position_space
=
ift
.
RGSpace
([
1024
])
mask
=
np
.
one
s
(
position_space
.
shape
)
mask
=
np
.
zero
s
(
position_space
.
shape
)
elif
mode
==
1
:
# Two-dimensional regular grid with checkerboard mask
position_space
=
ift
.
RGSpace
([
128
,
128
])
...
...
@@ -101,23 +94,22 @@ if __name__ == '__main__':
# Build instrument response consisting of a discretization, mask
# and harmonic transformaion
# Data is defined on a geometry-free space, thus the geometry is removed
GR
=
ift
.
GeometryRemover
(
position_space
)
# Masking operator to model that parts of the field have not been observed
mask
=
ift
.
Field
.
from_global_data
(
position_space
,
mask
)
Mask
=
ift
.
Diagonal
Operator
(
mask
)
Mask
=
ift
.
Mask
Operator
(
mask
)
# The response operator consists of
# - a
n
harmonic transform (to get to image space)
# - a harmonic transform (to get to image space)
# - the application of the mask
# - the removal of geometric information
# The removal of geometric information is included in the MaskOperator
# it can also be implemented with a GeometryRemover
# Operators can be composed either with parenthesis
R
=
GR
(
Mask
(
HT
)
)
R
=
Mask
(
HT
)
# or with @
R
=
GR
@
Mask
@
HT
R
=
Mask
@
HT
data_space
=
G
R
.
target
data_space
=
R
.
target
# Set the noise covariance N
noise
=
5.
...
...
@@ -144,16 +136,17 @@ if __name__ == '__main__':
filename
=
"getting_started_1_mode_{}.png"
.
format
(
mode
)
if
rg
and
len
(
position_space
.
shape
)
==
1
:
plot
.
add
(
[
HT
(
MOCK_SIGNAL
),
GR
.
adjoint
(
data
),
[
HT
(
MOCK_SIGNAL
),
Mask
.
adjoint
(
data
),
HT
(
m
)],
label
=
[
'Mock signal'
,
'Data'
,
'Reconstruction'
],
alpha
=
[
1
,
.
3
,
1
])
plot
.
add
(
mask_to_nan
(
mask
,
HT
(
m
-
MOCK_SIGNAL
)),
title
=
'Residuals'
)
plot
.
add
(
Mask
.
adjoint
(
Mask
(
HT
(
m
-
MOCK_SIGNAL
)
)),
title
=
'Residuals'
)
plot
.
output
(
nx
=
2
,
ny
=
1
,
xsize
=
10
,
ysize
=
4
,
name
=
filename
)
else
:
plot
.
add
(
HT
(
MOCK_SIGNAL
),
title
=
'Mock Signal'
)
plot
.
add
(
mask_to_nan
(
mask
,
(
GR
(
Mask
)).
adjoint
(
data
)
),
title
=
'Data'
)
plot
.
add
(
Mask
.
adjoint
(
data
),
title
=
'Data'
)
plot
.
add
(
HT
(
m
),
title
=
'Reconstruction'
)
plot
.
add
(
mask_to_nan
(
mask
,
HT
(
m
-
MOCK_SIGNAL
)),
title
=
'Residuals'
)
plot
.
add
(
Mask
.
adjoint
(
Mask
(
HT
(
m
)
-
HT
(
MOCK_SIGNAL
))),
title
=
'Residuals'
)
plot
.
output
(
nx
=
2
,
ny
=
2
,
xsize
=
10
,
ysize
=
10
,
name
=
filename
)
print
(
"Saved results as '{}'."
.
format
(
filename
))
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