Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
MDANSE
Commits
173dd9ab
Commit
173dd9ab
authored
Apr 07, 2015
by
eric pellegrini
Browse files
test
parent
b0c87cff
Changes
31
Hide whitespace changes
Inline
Side-by-side
MDANSE/Core/Configurable.py
View file @
173dd9ab
...
...
@@ -57,6 +57,8 @@ class Configurable(object):
self
.
_configuration
=
{}
self
.
_parameters
=
{}
self
.
_configured
=
False
def
__getitem__
(
self
,
name
):
...
...
@@ -74,6 +76,11 @@ class Configurable(object):
return
self
.
_configuration
.
setdefault
(
name
,{})
@
property
def
parameters
(
self
):
return
self
.
_parameters
def
setup
(
self
,
parameters
):
'''
Setup the configuration according to a set of input parameters.
...
...
@@ -84,6 +91,7 @@ class Configurable(object):
# Cleans the previous configuration
self
.
_configuration
.
clear
()
self
.
_parameters
.
clear
()
self
.
_configured
=
False
...
...
@@ -101,6 +109,7 @@ class Configurable(object):
else
:
raise
ConfigurationError
(
"Invalid type for configuration parameters"
)
self
.
_parameters
=
parameters
toBeConfigured
=
set
(
self
.
configurators
.
keys
())
configured
=
set
()
...
...
MDANSE/Framework/AtomSelectionParser.py
0 → 100644
View file @
173dd9ab
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Mar 27, 2015
@author: pellegrini
'''
import
operator
from
MDANSE
import
REGISTRY
from
MDANSE.Core.Error
import
Error
from
MDANSE.Externals.pyparsing.pyparsing
import
delimitedList
,
oneOf
,
opAssoc
,
operatorPrecedence
,
printables
,
Forward
,
OneOrMore
,
Optional
,
Word
from
MDANSE.Framework.UserDefinable
import
UserDefinable
class
AtomSelectionParserError
(
Error
):
pass
class
AtomSelectionParser
(
UserDefinable
):
def
__init__
(
self
,
trajectory
):
UserDefinable
.
__init__
(
self
,
trajectory
.
filename
)
self
.
_universe
=
trajectory
.
universe
def
operator_and
(
self
,
token
):
token
[
0
][
1
]
=
"&"
return
" "
.
join
(
token
[
0
])
def
operator_not
(
self
,
token
):
return
'REGISTRY[%r]["all"](universe).select() - %s'
%
(
"selector"
,
token
[
0
][
1
])
def
operator_or
(
self
,
token
):
token
[
0
][
1
]
=
"|"
return
" "
.
join
(
token
[
0
])
def
parse_arguments
(
self
,
token
):
return
"(%s)"
%
str
(
token
)
def
parse_expression
(
self
,
token
):
return
""
.
join
([
str
(
t
)
for
t
in
token
])
def
parse_keyword
(
self
,
token
):
return
'REGISTRY[%r]["%s"](universe).select'
%
(
"selector"
,
token
[
0
])
def
parse_selection_expression
(
self
,
expression
):
expression
=
expression
.
replace
(
"("
,
"( "
)
expression
=
expression
.
replace
(
")"
,
" )"
)
linkers
=
oneOf
([
"and"
,
"&"
,
"or"
,
"|"
,
"not"
,
"~"
],
caseless
=
True
)
keyword
=
oneOf
(
REGISTRY
[
"selector"
].
keys
(),
caseless
=
True
).
setParseAction
(
self
.
parse_keyword
)
arguments
=
Optional
(
~
linkers
+
delimitedList
(
Word
(
printables
,
excludeChars
=
","
),
combine
=
False
)).
setParseAction
(
self
.
parse_arguments
)
selector
=
OneOrMore
((
keyword
+
arguments
))
grammar
=
Forward
()
grammar
<<
selector
.
setParseAction
(
self
.
parse_expression
)
grammar
=
operatorPrecedence
(
grammar
,
[(
oneOf
([
"and"
,
"&"
],
caseless
=
True
),
2
,
opAssoc
.
LEFT
,
self
.
operator_and
),
(
oneOf
([
"not"
,
"~"
],
caseless
=
True
),
1
,
opAssoc
.
RIGHT
,
self
.
operator_not
),
(
oneOf
([
"or"
,
"|"
]
,
caseless
=
True
),
2
,
opAssoc
.
LEFT
,
self
.
operator_or
)],
lpar
=
"("
,
rpar
=
")"
)
try
:
parsedExpression
=
grammar
.
transformString
(
expression
)
namespace
=
{
"REGISTRY"
:
REGISTRY
,
"universe"
:
self
.
_universe
}
selection
=
eval
(
parsedExpression
,
namespace
)
except
:
raise
AtomSelectionParserError
(
"%r is not a valid selection string expression"
%
expression
)
selection
=
sorted
(
selection
,
key
=
operator
.
attrgetter
(
"index"
))
return
selection
def
parse
(
self
,
expression
=
None
):
self
.
_definition
.
clear
()
if
expression
is
None
:
expression
=
"all()"
# Perfom the actual selection.
selection
=
self
.
parse_selection_expression
(
expression
)
if
not
selection
:
raise
AtomSelectionParserError
(
"No atoms matched the selection %r."
%
expression
)
self
.
_definition
[
"expression"
]
=
expression
self
.
_definition
[
"indexes"
]
=
[
at
.
index
for
at
in
selection
]
return
self
.
_definition
\ No newline at end of file
MDANSE/Framework/AtomTransmutationParser.py
0 → 100644
View file @
173dd9ab
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Mar 27, 2015
@author: pellegrini
'''
from
MDANSE.Framework.AtomSelectionParser
import
AtomSelectionParser
class
AtomTransmutationParser
(
AtomSelectionParser
):
def
parse
(
self
,
element
,
expression
=
None
):
AtomSelectionParser
.
parse
(
self
,
expression
)
self
.
_definition
[
"element"
]
=
element
\ No newline at end of file
MDANSE/Framework/Configurable.py
View file @
173dd9ab
...
...
@@ -62,13 +62,13 @@ class Configurable(object):
self
.
_configuration
=
{}
configurators
=
getattr
(
self
,
"configurators"
,
()
)
configurators
=
getattr
(
self
,
"configurators"
,
{}
)
if
not
isinstance
(
configurators
,
_abcoll
.
Sequence
):
raise
ConfigurationError
(
"Invalid type for configurators: must be a
sequence
-like object"
)
if
not
isinstance
(
configurators
,
_abcoll
.
Mapping
):
raise
ConfigurationError
(
"Invalid type for configurators: must be a
mapping
-like object"
)
self
.
_configurators
=
{}
for
name
,
typ
,
kwds
in
configurators
:
for
name
,
(
typ
,
kwds
)
in
configurators
.
items
()
:
try
:
self
.
_configurators
[
name
]
=
REGISTRY
[
"configurator"
][
typ
](
name
,
**
kwds
)
# Any kind of error has to be caught
...
...
@@ -177,14 +177,14 @@ class Configurable(object):
:rtype: str
'''
configurators
=
getattr
(
cls
,
"configurators"
,
()
)
configurators
=
getattr
(
cls
,
"configurators"
,
{}
)
if
not
isinstance
(
configurators
,
_abcoll
.
Sequence
):
raise
ConfigurationError
(
"Invalid type for configurators: must be a
sequence
-like object"
)
if
not
isinstance
(
configurators
,
_abcoll
.
Mapping
):
raise
ConfigurationError
(
"Invalid type for configurators: must be a
mapping
-like object"
)
doclist
=
[]
for
name
,
typ
,
kwds
in
configurators
:
for
name
,
(
typ
,
kwds
)
in
configurators
.
items
()
:
cfg
=
REGISTRY
[
"configurator"
][
typ
](
name
,
**
kwds
)
doclist
.
append
({
'Configurator'
:
name
,
'Default value'
:
repr
(
cfg
.
default
),
'Description'
:
str
(
cfg
.
__doc__
)})
...
...
@@ -253,13 +253,13 @@ class Configurable(object):
:rtype: dict
'''
configurators
=
getattr
(
cls
,
"configurators"
,
()
)
configurators
=
getattr
(
cls
,
"configurators"
,
{}
)
if
not
isinstance
(
configurators
,
_abcoll
.
Sequence
):
raise
ConfigurationError
(
"Invalid type for configurators: must be a
sequence
-like object"
)
if
not
isinstance
(
configurators
,
_abcoll
.
Mapping
):
raise
ConfigurationError
(
"Invalid type for configurators: must be a
mapping
-like object"
)
params
=
collections
.
OrderedDict
()
for
name
,
typ
,
kwds
in
configurators
:
for
name
,
(
typ
,
kwds
)
in
configurators
.
items
()
:
cfg
=
REGISTRY
[
"configurator"
][
typ
](
name
,
**
kwds
)
params
[
name
]
=
cfg
.
default
...
...
MDANSE/Framework/Configurators/AtomSelectionConfigurator.py
View file @
173dd9ab
...
...
@@ -37,7 +37,7 @@ import numpy
from
MDANSE.Framework.UserDefinables.UserDefinitions
import
USER_DEFINITIONS
from
MDANSE.Framework.Configurators.IConfigurator
import
IConfigurator
,
ConfiguratorError
from
MDANSE.Framework.
Selectors.
SelectionParser
import
SelectionParser
from
MDANSE.Framework.
Atom
SelectionParser
import
Atom
SelectionParser
# The granularities at which the selection will be performed
LEVELS
=
collections
.
OrderedDict
()
...
...
@@ -79,10 +79,9 @@ class AtomSelectionConfigurator(IConfigurator):
if
ud
is
not
None
:
self
.
update
(
ud
)
else
:
parser
=
SelectionParser
(
trajConfig
[
"instance"
].
universe
)
expression
,
selection
=
parser
(
value
,
True
)
self
[
"expression"
]
=
expression
self
[
"indexes"
]
=
numpy
.
array
(
selection
,
dtype
=
numpy
.
int32
)
parser
=
AtomSelectionParser
(
trajConfig
[
"instance"
])
parser
.
parse
(
value
)
self
.
update
(
parser
.
definition
)
self
[
"n_selected_atoms"
]
=
len
(
self
[
"indexes"
])
atoms
=
sorted
(
trajConfig
[
"universe"
].
atomList
(),
key
=
operator
.
attrgetter
(
'index'
))
...
...
@@ -128,7 +127,7 @@ class AtomSelectionConfigurator(IConfigurator):
self
.
set_contents
()
def
set_contents
(
self
):
self
[
"contents"
]
=
collections
.
OrderedDict
()
self
[
'index_to_symbol'
]
=
collections
.
OrderedDict
()
for
i
,
group
in
enumerate
(
self
[
"elements"
]):
...
...
@@ -140,9 +139,8 @@ class AtomSelectionConfigurator(IConfigurator):
self
[
"contents"
][
k
]
=
numpy
.
array
(
v
)
self
[
"n_atoms_per_element"
]
=
dict
([(
k
,
len
(
v
))
for
k
,
v
in
self
[
"contents"
].
items
()])
self
[
'n_selected_elements'
]
=
len
(
self
[
"contents"
])
def
get_information
(
self
):
info
=
[]
...
...
MDANSE/Framework/Configurators/AtomTransmutationConfigurator.py
View file @
173dd9ab
...
...
@@ -33,7 +33,7 @@ Created on Mar 30, 2015
from
MDANSE
import
ELEMENTS
from
MDANSE.Framework.UserDefinables.UserDefinitions
import
USER_DEFINITIONS
from
MDANSE.Framework.Configurators.IConfigurator
import
IConfigurator
,
ConfiguratorError
from
MDANSE.Framework.
Selectors.Selec
tionParser
import
Selec
tionParser
from
MDANSE.Framework.
AtomTransmuta
tionParser
import
AtomTransmuta
tionParser
class
AtomTransmutationConfigurator
(
IConfigurator
):
"""
...
...
@@ -62,14 +62,15 @@ class AtomTransmutationConfigurator(IConfigurator):
trajConfig
=
configuration
[
self
.
_dependencies
[
'trajectory'
]]
parser
=
Selec
tionParser
(
trajConfig
[
"
univers
e"
])
parser
=
AtomTransmuta
tionParser
(
trajConfig
[
"
instanc
e"
])
# If the input value is a dictionary, it must have a selection string or a python script as key and the element
# to be transmutated to as value
if
isinstance
(
value
,
dict
):
for
expression
,
element
in
value
.
items
():
expression
,
selection
=
parser
.
select
(
expression
,
True
)
self
.
transmutate
(
configuration
,
selection
,
element
)
parser
.
parse
(
element
,
expression
)
definition
=
parser
.
definition
self
.
transmutate
(
configuration
,
definition
[
"indexes"
],
definition
[
"element"
])
# Otherwise, it must be a list of strings that will be found as user-definition keys
elif
isinstance
(
value
,(
list
,
tuple
)):
...
...
@@ -100,7 +101,7 @@ class AtomTransmutationConfigurator(IConfigurator):
else
:
self
[
"atom_selection"
][
"elements"
][
pos
]
=
[
element
]
configuration
.
configurators
[
self
.
_dependencies
[
'atom_selection'
]].
set_contents
(
configuration
)
configuration
[
self
.
_dependencies
[
'atom_selection'
]].
set_contents
()
def
get_information
(
self
):
...
...
MDANSE/Framework/Configurators/InstrumentResolutionConfigurator.py
View file @
173dd9ab
...
...
@@ -65,11 +65,13 @@ class InstrumentResolutionConfigurator(IConfigurator):
kernel
,
parameters
=
value
kernelCls
=
REGISTRY
[
"instrumentresolution"
][
kernel
]
kernelCls
=
REGISTRY
[
"instrument
_
resolution"
][
kernel
]
resolution
=
kernelCls
()
resolution
.
set_kernel
(
self
[
"frequencies"
],
self
[
"time_step"
],
parameters
)
resolution
.
setup
(
parameters
)
resolution
.
set_kernel
(
self
[
"frequencies"
],
self
[
"time_step"
])
dmax
=
resolution
.
timeWindow
.
max
()
-
1
...
...
MDANSE/Framework/Configurators/QVectorsConfigurator.py
View file @
173dd9ab
...
...
@@ -57,9 +57,9 @@ class QVectorsConfigurator(IConfigurator):
else
:
generator
,
parameters
=
value
generator
=
REGISTRY
[
"q_vectors"
][
generator
](
trajConfig
[
"instance"
]
.
universe
)
generator
.
configure
(
parameters
)
data
=
generator
.
run
()
generator
=
REGISTRY
[
"q_vectors"
][
generator
](
trajConfig
[
"instance"
])
generator
.
setup
(
parameters
)
data
=
generator
.
generate
()
if
not
data
:
raise
ConfiguratorError
(
"no Q vectors could be generated"
,
self
)
...
...
MDANSE/Framework/
Handlers/
InstrumentResolutions/GaussianResolution.py
→
MDANSE/Framework/InstrumentResolutions/GaussianResolution.py
View file @
173dd9ab
...
...
@@ -30,9 +30,10 @@ Created on Mar 30, 2015
@author: pellegrini
'''
import
collections
import
numpy
from
MDANSE.Framework.Configurators.ConfiguratorsDict
import
ConfiguratorsDict
from
MDANSE.Framework.InstrumentResolutions.IInstrumentResolution
import
IInstrumentResolution
class
GaussianInstrumentResolution
(
IInstrumentResolution
):
...
...
@@ -41,12 +42,10 @@ class GaussianInstrumentResolution(IInstrumentResolution):
type
=
'gaussian'
configurators
=
Configurators
Dict
()
configurators
.
add_item
(
'mu'
,
'float'
,
default
=
0.0
)
configurators
.
add_item
(
'sigma'
,
'float'
,
default
=
1.0
)
configurators
=
collections
.
Ordered
Dict
()
configurators
[
'mu'
]
=
(
'float'
,
{
"
default
"
:
0.0
}
)
configurators
[
'sigma'
]
=
(
'float'
,
{
"
default
"
:
1.0
}
)
__doc__
+=
configurators
.
build_doc
()
def
set_kernel
(
self
,
frequencies
,
dt
):
mu
=
self
.
_configuration
[
"mu"
][
"value"
]
...
...
MDANSE/Framework/
Handlers/
InstrumentResolutions/IInstrumentResolution.py
→
MDANSE/Framework/InstrumentResolutions/IInstrumentResolution.py
View file @
173dd9ab
...
...
@@ -33,8 +33,8 @@ Created on Mar 30, 2015
import
abc
from
MDANSE
import
REGISTRY
from
MDANSE.Core.Configurable
import
Configurable
from
MDANSE.Core.Error
import
Error
from
MDANSE.Framework.Configurable
import
Configurable
class
InstrumentResolutionError
(
Error
):
pass
...
...
MDANSE/Framework/
Handlers/
InstrumentResolutions/IdealResolution.py
→
MDANSE/Framework/InstrumentResolutions/IdealResolution.py
View file @
173dd9ab
...
...
@@ -30,9 +30,10 @@ Created on Mar 30, 2015
@author: pellegrini
'''
import
collections
import
numpy
from
MDANSE.Framework.Configurators.ConfiguratorsDict
import
ConfiguratorsDict
from
MDANSE.Framework.InstrumentResolutions.IInstrumentResolution
import
IInstrumentResolution
class
IdealInstrumentResolution
(
IInstrumentResolution
):
...
...
@@ -41,9 +42,7 @@ class IdealInstrumentResolution(IInstrumentResolution):
type
=
'ideal'
configurators
=
ConfiguratorsDict
()
__doc__
+=
configurators
.
build_doc
()
configurators
=
collections
.
OrderedDict
()
def
set_kernel
(
self
,
frequencies
,
dt
):
...
...
MDANSE/Framework/
Handlers/
InstrumentResolutions/LorentzianResolution.py
→
MDANSE/Framework/InstrumentResolutions/LorentzianResolution.py
View file @
173dd9ab
...
...
@@ -30,9 +30,10 @@ Created on Mar 30, 2015
@author: pellegrini
'''
import
collections
import
numpy
from
MDANSE.Framework.Configurators.ConfiguratorsDict
import
ConfiguratorsDict
from
MDANSE.Framework.InstrumentResolutions.IInstrumentResolution
import
IInstrumentResolution
class
LorentzianInstrumentResolution
(
IInstrumentResolution
):
...
...
@@ -42,11 +43,9 @@ class LorentzianInstrumentResolution(IInstrumentResolution):
type
=
'lorentzian'
configurators
=
ConfiguratorsDict
()
configurators
.
add_item
(
'mu'
,
'float'
,
default
=
0.0
)
configurators
.
add_item
(
'sigma'
,
'float'
,
default
=
1.0
)
__doc__
+=
configurators
.
build_doc
()
configurators
=
collections
.
OrderedDict
()
configurators
[
'mu'
]
=
(
'float'
,
{
"default"
:
0.0
})
configurators
[
'sigma'
]
=
(
'float'
,
{
"default"
:
1.0
})
def
set_kernel
(
self
,
frequencies
,
dt
):
...
...
MDANSE/Framework/
Handlers/
InstrumentResolutions/PseudoVoigtResolution.py
→
MDANSE/Framework/InstrumentResolutions/PseudoVoigtResolution.py
View file @
173dd9ab
...
...
@@ -30,9 +30,10 @@ Created on Mar 30, 2015
@author: pellegrini
'''
import
collections
import
numpy
from
MDANSE.Framework.Configurators.ConfiguratorsDict
import
ConfiguratorsDict
from
MDANSE.Framework.InstrumentResolutions.IInstrumentResolution
import
IInstrumentResolution
class
PseudoVoigtInstrumentResolution
(
IInstrumentResolution
):
...
...
@@ -41,15 +42,13 @@ class PseudoVoigtInstrumentResolution(IInstrumentResolution):
type
=
'pseudo-voigt'
configurators
=
Configurators
Dict
()
configurators
.
add_item
(
'eta'
,
'float'
,
mini
=
0.0
,
maxi
=
1.0
,
default
=
0.5
)
configurators
.
add_item
(
'mu_lorentzian'
,
'float'
,
default
=
0.0
)
configurators
.
add_item
(
'sigma_lorentzian'
,
'float'
,
default
=
1.0
)
configurators
.
add_item
(
'mu_gaussian'
,
'float'
,
default
=
0.0
)
configurators
.
add_item
(
'sigma_gaussian'
,
'float'
,
default
=
1.0
)
configurators
=
collections
.
Ordered
Dict
()
configurators
[
'eta'
]
=
(
'float'
,
{
"
mini
"
:
0.0
,
"
maxi
"
:
1.0
,
"
default
"
:
0.5
}
)
configurators
[
'mu_lorentzian'
]
=
(
'float'
,
{
"
default
"
:
0.0
}
)
configurators
[
'sigma_lorentzian'
]
=
(
'float'
,
{
"
default
"
:
1.0
}
)
configurators
[
'mu_gaussian'
]
=
(
'float'
,
{
"
default
"
:
0.0
}
)
configurators
[
'sigma_gaussian'
]
=
(
'float'
,
{
"
default
"
:
1.0
}
)
__doc__
+=
configurators
.
build_doc
()
def
set_kernel
(
self
,
frequencies
,
dt
):
eta
=
self
.
_configuration
[
"eta"
][
"value"
]
...
...
MDANSE/Framework/
Handlers/
InstrumentResolutions/SquareResolution.py
→
MDANSE/Framework/InstrumentResolutions/SquareResolution.py
View file @
173dd9ab
...
...
@@ -30,9 +30,10 @@ Created on Mar 30, 2015
@author: pellegrini
'''
import
collections
import
numpy
from
MDANSE.Framework.Configurators.ConfiguratorsDict
import
ConfiguratorsDict
from
MDANSE.Framework.InstrumentResolutions.IInstrumentResolution
import
IInstrumentResolution
class
SquareInstrumentResolution
(
IInstrumentResolution
):
...
...
@@ -41,12 +42,10 @@ class SquareInstrumentResolution(IInstrumentResolution):
type
=
'square'
configurators
=
Configurators
Dict
()
configurators
.
add_item
(
'mu'
,
'float'
,
default
=
0.0
)
configurators
.
add_item
(
'sigma'
,
'float'
,
default
=
1.0
)
configurators
=
collections
.
Ordered
Dict
()
configurators
[
'mu'
]
=
(
'float'
,
{
"
default
"
:
0.0
}
)
configurators
[
'sigma'
]
=
(
'float'
,
{
"
default
"
:
1.0
}
)
__doc__
+=
configurators
.
build_doc
()
def
set_kernel
(
self
,
frequencies
,
dt
):
mu
=
self
.
_configuration
[
"mu"
][
"value"
]
...
...
MDANSE/Framework/
Handlers/
InstrumentResolutions/TriangularResolution.py
→
MDANSE/Framework/InstrumentResolutions/TriangularResolution.py
View file @
173dd9ab
...
...
@@ -30,9 +30,10 @@ Created on Mar 30, 2015
@author: pellegrini
'''
import
collections
import
numpy
from
MDANSE.Framework.Configurators.ConfiguratorsDict
import
ConfiguratorsDict
from
MDANSE.Framework.InstrumentResolutions.IInstrumentResolution
import
IInstrumentResolution
class
TriangularInstrumentResolution
(
IInstrumentResolution
):
...
...
@@ -41,12 +42,10 @@ class TriangularInstrumentResolution(IInstrumentResolution):
type
=
'triangular'
configurators
=
Configurators
Dict
()
configurators
.
add_item
(
'mu'
,
'float'
,
default
=
0.0
)
configurators
.
add_item
(
'sigma'
,
'float'
,
default
=
1.0
)
configurators
=
collections
.
Ordered
Dict
()
configurators
[
'mu'
]
=
(
'float'
,
{
"
default
"
:
0.0
}
)
configurators
[
'sigma'
]
=
(
'float'
,
{
"
default
"
:
1.0
}
)
__doc__
+=
configurators
.
build_doc
()
def
set_kernel
(
self
,
frequencies
,
dt
):
mu
=
self
.
_configuration
[
"mu"
][
"value"
]
...
...
MDANSE/Framework/
Handlers/
InstrumentResolutions/__init__.py
→
MDANSE/Framework/InstrumentResolutions/__init__.py
View file @
173dd9ab
File moved
MDANSE/Framework/Jobs/DynamicIncoherentStructureFactor.py
0 → 100644
View file @
173dd9ab
import
collections
import
numpy
from
MDANSE
import
ELEMENTS
,
REGISTRY
from
MDANSE.Framework.Jobs.IJob
import
IJob
from
MDANSE.Mathematics.Arithmetic
import
weight
from
MDANSE.Mathematics.Signal
import
correlation
,
get_spectrum
from
MDANSE.MolecularDynamics.Trajectory
import
read_atoms_trajectory
class
DynamicIncoherentStructureFactor
(
IJob
):
"""
Computes the dynamic incoherent structure factor for a set of atoms.
"""
type
=
'disf'
label
=
"Dynamic Incoherent Structure Factor"
category
=
(
'Scattering'
,)
ancestor
=
"mmtk_trajectory"
configurators
=
collections
.
OrderedDict
()
configurators
[
'trajectory'
]
=
(
'mmtk_trajectory'
,{})
configurators
[
'frames'
]
=
(
'frames'
,
{
"dependencies"
:{
'trajectory'
:
'trajectory'
}})
configurators
[
'instrument_resolution'
]
=
(
'instrument_resolution'
,{
"dependencies"
:{
'trajectory'
:
'trajectory'
,
'frames'
:
'frames'
}})
configurators
[
'q_vectors'
]
=
(
'q_vectors'
,{
"dependencies"
:{
'trajectory'
:
'trajectory'
}})
configurators
[
'atom_selection'
]
=
(
'atom_selection'
,{
"dependencies"
:{
'trajectory'
:
'trajectory'
,
'grouping_level'
:
'grouping_level'
}})
configurators
[
'grouping_level'
]
=
(
'grouping_level'
,{})
configurators
[
'transmutated_atoms'
]
=
(
'atom_transmutation'
,{
"dependencies"
:{
'trajectory'
:
'trajectory'
,
'atom_selection'
:
'atom_selection'
}})
configurators
[
'projection'
]
=
(
'projection'
,
{
"label"
:
"project coordinates"
})
configurators
[
'weights'
]
=
(
'weights'
,{
"default"
:
"b_incoherent"
})