Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port MaxEnt from fortran #14675

Merged
merged 23 commits into from Jan 13, 2016
Merged

Conversation

raquelalvarezbanos
Copy link
Contributor

Fixes #12683

This is a first version of MaxEnt. There are many things that can be improved and are likely to be changed.

No mention in the release notes for the moment.

@raquelalvarezbanos raquelalvarezbanos added the Framework Issues and pull requests related to components in the Framework label Dec 2, 2015
@raquelalvarezbanos raquelalvarezbanos added this to the Release 3.6 milestone Dec 2, 2015
@raquelalvarezbanos
Copy link
Contributor Author

Example script with some of the cases I've tested:

from math import pi, sin, cos
from random import random

# Create a test workspace
X = []
Y = []
E = []
N = 200
w = 3
for i in range(0,N):
       x = 2*pi*i/N
       X.append(x)
       Y.append(sin(w*x))
       #Y.append(cos(w*x))
       #Y.append(sin(2*w*x)+(random()-0.5)*0.2)
       #Y.append(cos(2*w*x)+(random()-0.5)*0.2)
       #Y.append(sin(w*x)-0.5*cos(2*w*x))
       #Y.append(cos(w*x)+cos(2*w*x)+(random()-0.5)*0.5)
       E.append(0.1)

CreateWorkspace(OutputWorkspace='ws',DataX=X,DataY=Y,DataE=E,NSpec=1)
MaxEnt(InputWorkspace='ws', EvolChi='EvolChi', EvolAngle='EvolAngle',ReconstructedImage='image',ReconstructedData='data',chiTarget=N,Background=0.001)

@raquelalvarezbanos
Copy link
Contributor Author

More tests (this time instead of starting with sine/cosine-like functions we try to reconstruct Fourier coefficients):

X = []
Y = []
E = []
N = 200

for i in range(0,N):
       x = ((i-N/2) *1./N)
       X.append(x)
       Y.append(0)
       E.append(0.001)

# One Fourier coefficient
suffix = 'One'
Y[5] = Y[195] = 0.85
CreateWorkspace(OutputWorkspace='ws'+suffix,DataX=X,DataY=Y,DataE=E,NSpec=1)
MaxEnt(InputWorkspace='ws'+suffix, EvolChi='EvolChi'+suffix, EvolAngle='EvolAngle'+suffix,ReconstructedImage='image'+suffix,ReconstructedData='data'+suffix,chiTarget=N,Background=0.0001)

# Two Fourier coefficients
suffix = 'Two'
Y[5] = Y[195] = 0.85
Y[10] = Y[190] = 0.85
CreateWorkspace(OutputWorkspace='ws'+suffix,DataX=X,DataY=Y,DataE=E,NSpec=1)
MaxEnt(InputWorkspace='ws'+suffix, EvolChi='EvolChi'+suffix, EvolAngle='EvolAngle'+suffix,ReconstructedImage='image'+suffix,ReconstructedData='data'+suffix,chiTarget=N,Background=0.0001)

# Three Fourier coefficients
suffix = 'Three'
Y[5] = Y[195] = 0.85
Y[10] = Y[190] = 0.85
Y[20] = Y[180] = 0.85
CreateWorkspace(OutputWorkspace='ws'+suffix,DataX=X,DataY=Y,DataE=E,NSpec=1)
MaxEnt(InputWorkspace='ws'+suffix, EvolChi='EvolChi'+suffix, EvolAngle='EvolAngle'+suffix,ReconstructedImage='image'+suffix,ReconstructedData='data'+suffix,chiTarget=N,Background=0.0001)

# Five Fourier coefficients
suffix = 'Five'
Y[5] = Y[195] = 0.85
Y[10] = Y[190] = 0.85
Y[20] = Y[180] = 0.85
Y[12] = Y[188] = 0.90
Y[14] = Y[186] = 0.90
CreateWorkspace(OutputWorkspace='ws'+suffix,DataX=X,DataY=Y,DataE=E,NSpec=1)
MaxEnt(InputWorkspace='ws'+suffix, EvolChi='EvolChi'+suffix, EvolAngle='EvolAngle'+suffix,ReconstructedImage='image'+suffix,ReconstructedData='data'+suffix,chiTarget=N,Background=0.0001)

@raquelalvarezbanos
Copy link
Contributor Author

Real muon dataset:

Load(Filename=r'MUSR00022725.nxs', OutputWorkspace='MUSR00022725')
CropWorkspace(InputWorkspace='MUSR00022725', OutputWorkspace='MUSR00022725', XMin=0.11, XMax=1.6, EndWorkspaceIndex=0)
RemoveExpDecay(InputWorkspace='MUSR00022725', OutputWorkspace='MUSR00022725')
Rebin(InputWorkspace='MUSR00022725', OutputWorkspace='MUSR00022725', Params='0.016')
MaxEnt(InputWorkspace='MUSR00022725', EvolChi='evolChi', EvolAngle='evolAngle', ReconstructedImage='image', ReconstructedData='data',Background=0.005,ChiTarget=250)
# To compare MaxEnt to FFT
FFT(InputWorkspace='MUSR00022725', OutputWorkspace='MUSR00022725FFT')

Anders-Markvardsen added a commit that referenced this pull request Jan 13, 2016
@Anders-Markvardsen Anders-Markvardsen merged commit ed99bdc into master Jan 13, 2016
@Anders-Markvardsen Anders-Markvardsen deleted the 12683_Port_MaxEnt_from_Fortran branch January 13, 2016 09:18
@Anders-Markvardsen
Copy link
Member

Works with the example provided.

Clear code to read including choice of method/attribute names and code documentation. Clear algorithm documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework Issues and pull requests related to components in the Framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants