Skip to content
Snippets Groups Projects
Commit 64ea7dd9 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

Merge branch 'demos' of gitlab.mpcdf.mpg.de:ift/nifty-dev into demos

parents eb20869a 7e893d25
No related branches found
No related tags found
No related merge requests found
...@@ -22,13 +22,13 @@ if __name__ == '__main__': ...@@ -22,13 +22,13 @@ if __name__ == '__main__':
# Choose problem geometry and masking # Choose problem geometry and masking
# # One dimensional regular grid # One dimensional regular grid
# position_space = ift.RGSpace([1024]) position_space = ift.RGSpace([1024])
# mask = np.ones(position_space.shape) mask = np.ones(position_space.shape)
# Two dimensional regular grid with chess mask # # Two dimensional regular grid with chess mask
position_space = ift.RGSpace([128,128]) # position_space = ift.RGSpace([128,128])
mask = make_chess_mask() # mask = make_chess_mask()
# # Sphere with half of its locations randomly masked # # Sphere with half of its locations randomly masked
# position_space = ift.HPSpace(128) # position_space = ift.HPSpace(128)
......
...@@ -19,10 +19,10 @@ def get_2D_exposure(): ...@@ -19,10 +19,10 @@ def get_2D_exposure():
if __name__ == '__main__': if __name__ == '__main__':
# ABOUT THIS CODE # ABOUT THIS CODE
np.random.seed(42) np.random.seed(41)
# Set up the position space of the signal # Set up the position space of the signal
#
# # One dimensional regular grid with uniform exposure # # One dimensional regular grid with uniform exposure
# position_space = ift.RGSpace(1024) # position_space = ift.RGSpace(1024)
# exposure = np.ones(position_space.shape) # exposure = np.ones(position_space.shape)
...@@ -84,5 +84,6 @@ if __name__ == '__main__': ...@@ -84,5 +84,6 @@ if __name__ == '__main__':
# Plot results # Plot results
result_sky = sky.at(H.position).value result_sky = sky.at(H.position).value
##PLOTTING
...@@ -3,6 +3,7 @@ from nifty5.library.los_response import LOSResponse ...@@ -3,6 +3,7 @@ from nifty5.library.los_response import LOSResponse
from nifty5.library.amplitude_model import make_amplitude_model from nifty5.library.amplitude_model import make_amplitude_model
from nifty5.library.smooth_sky import make_correlated_field from nifty5.library.smooth_sky import make_correlated_field
import numpy as np import numpy as np
from scipy.io import loadmat
def get_random_LOS(n_los): def get_random_LOS(n_los):
...@@ -11,9 +12,9 @@ def get_random_LOS(n_los): ...@@ -11,9 +12,9 @@ def get_random_LOS(n_los):
return starts, ends return starts, ends
if __name__ == '__main__': if __name__ == '__main__':
np.random.seed(41) ### ABOUT THIS TUTORIAL
np.random.seed(42)
position_space = ift.RGSpace([128,128]) position_space = ift.RGSpace([128,128])
# Setting up an amplitude model # Setting up an amplitude model
...@@ -33,14 +34,13 @@ if __name__ == '__main__': ...@@ -33,14 +34,13 @@ if __name__ == '__main__':
correlated_field_h = Amp * xi correlated_field_h = Amp * xi
correlated_field = ht(correlated_field_h) correlated_field = ht(correlated_field_h)
# # alternatively to the block above one can do: # # alternatively to the block above one can do:
# correlated_field, _ = make_correlated_field(position_space,A) # correlated_field, _ = make_correlated_field(position_space, A)
# apply some nonlinearity # apply some nonlinearity
signal = ift.PointwisePositiveTanh(correlated_field) signal = ift.PointwisePositiveTanh(correlated_field)
# Building the Line of Sight response # Building the Line of Sight response
LOS_starts, LOS_ends = get_random_LOS(1000) LOS_starts, LOS_ends = get_random_LOS(100)
R = LOSResponse(position_space, starts=LOS_starts, ends=LOS_ends) R = LOSResponse(position_space, starts=LOS_starts, ends=LOS_ends)
# build signal response model and model likelihood # build signal response model and model likelihood
signal_response = R(signal) signal_response = R(signal)
# specify noise # specify noise
...@@ -73,7 +73,7 @@ if __name__ == '__main__': ...@@ -73,7 +73,7 @@ if __name__ == '__main__':
ift.plot([ A.at(MOCK_POSITION).value], name='power.pdf') ift.plot([ A.at(MOCK_POSITION).value], name='power.pdf')
# number of samples used to estimate the KL # number of samples used to estimate the KL
N_samples = 10 N_samples = 20
for i in range(5): for i in range(5):
H = H.at(position) H = H.at(position)
samples = [H.curvature.draw_sample(from_inverse=True) for _ in range(N_samples)] samples = [H.curvature.draw_sample(from_inverse=True) for _ in range(N_samples)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment