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
0d5930cd
Commit
0d5930cd
authored
May 08, 2015
by
eric pellegrini
Browse files
docstringed new configurator classes
parent
33aab3bb
Changes
10
Hide whitespace changes
Inline
Side-by-side
MDANSE/Framework/Configurators/AtomSelectionConfigurator.py
View file @
0d5930cd
...
...
@@ -176,16 +176,19 @@ class AtomSelectionConfigurator(IConfigurator):
def
get_information
(
self
):
'''
Returns some informations
about this configurator
.
Returns some informations
the atom selection
.
:return: the information about th
is configurator
:return: the information about th
e atom selection.
:rtype: str
'''
if
not
self
.
has_key
(
"n_selected_atoms"
):
return
"No configured yet"
info
=
[]
info
.
append
(
"Number of selected atoms:%d
\n
"
%
self
[
"n_selected_atoms"
])
info
.
append
(
"Level of selection:%s
\n
"
%
self
[
"level"
])
info
.
append
(
"Number of selected groups:%d
\n
"
%
self
[
"n_groups"
])
info
.
append
(
"Selected elements:%s
\n
"
%
self
[
"contents"
].
keys
())
info
.
append
(
"Number of selected atoms:%d"
%
self
[
"n_selected_atoms"
])
info
.
append
(
"Level of selection:%s"
%
self
[
"level"
])
info
.
append
(
"Number of selected groups:%d"
%
self
[
"n_groups"
])
info
.
append
(
"Selected elements:%s"
%
self
[
"contents"
].
keys
())
return
""
.
join
(
info
)
\ No newline at end of file
return
"
\n
"
.
join
(
info
)
\ No newline at end of file
MDANSE/Framework/Configurators/AtomTransmutationConfigurator.py
View file @
0d5930cd
...
...
@@ -52,7 +52,7 @@ class AtomTransmutationConfigurator(IConfigurator):
* Drag a molecular viewer on it,
* Drag into the Molecular Viewer the Atom transmutation plugin
:note: this configurator depends on 'trajectory' and 'atom_selection' configurators to be
properly
configured
:note: this configurator depends on 'trajectory' and 'atom_selection' configurators to be configured
"""
type
=
'atom_transmutation'
...
...
@@ -138,11 +138,14 @@ class AtomTransmutationConfigurator(IConfigurator):
def
get_information
(
self
):
'''
Returns some informations
about this configurator
.
Returns some informations
the atoms selected for being transmutated
.
:return: the information about th
is configurator
:return: the information about th
e atoms selected for being transmutated.
:rtype: str
'''
if
not
self
.
has_key
(
"value"
):
return
"Not configured yet"
if
self
[
"value"
]
is
None
:
return
"No atoms selected for deuteration"
...
...
MDANSE/Framework/Configurators/ComplexNumberConfigurator.py
View file @
0d5930cd
...
...
@@ -48,9 +48,9 @@ class ComplexNumberConfigurator(IConfigurator):
:param name: the name of the configurator as it will be appear in the configuration
:type name: str
:param mini: the minimum modulus
of
the input value. If None, no restriction
in
the
modulus
minimum.
:param mini: the minimum modulus
allowed for
the input value. If None, no restriction
for
the minimum.
:type mini: float or None
:param maxi: the maximum modulus
of
the input value. If None, no restriction
in
the
modulus
maximum.
:param maxi: the maximum modulus
allowed for
the input value. If None, no restriction
for
the maximum.
:type maxi: float or None
:param choices: the list of complex numbers allowed for the input value. If None, any value will be allowed.
:type choices: list of complex or None
...
...
@@ -69,9 +69,9 @@ class ComplexNumberConfigurator(IConfigurator):
'''
Configure an input value.
:param configuration: the current configuration
:param configuration: the current configuration
.
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the input
value
:param value: the input
complex number.
:type value: complex
'''
...
...
@@ -94,9 +94,9 @@ class ComplexNumberConfigurator(IConfigurator):
@
property
def
mini
(
self
):
'''
Returns the minimum value allowed for an input
value of this configurato
r.
Returns the minimum value allowed for an input
complex numbe
r.
:return: the minimum value allowed for
an input va
lu
e
of
this configurator
:return: the minimum value allowed for
the modu
lu
s
of
an input complex number.
:rtype: float or None
'''
...
...
@@ -105,9 +105,9 @@ class ComplexNumberConfigurator(IConfigurator):
@
property
def
maxi
(
self
):
'''
Returns the maximum value allowed for
an input value of this configurato
r.
Returns the maximum value allowed for
the modulus of an input complex numbe
r.
:return: the maximum value allowed for an input
value of this configurator
:return: the maximum value allowed for an input
complex number.
:rtype: float or None
'''
...
...
@@ -116,9 +116,9 @@ class ComplexNumberConfigurator(IConfigurator):
@
property
def
choices
(
self
):
'''
Returns the list of floats allowed for an input
value of this configurato
r.
Returns the list of floats allowed for an input
complex numbe
r.
:return: the choices allowed for an input
value of this configurator
:return: the choices allowed for an input
complex number.
:rtype: list of floats or None
'''
...
...
MDANSE/Framework/Configurators/FloatConfigurator.py
View file @
0d5930cd
...
...
@@ -45,13 +45,13 @@ class FloatConfigurator(IConfigurator):
'''
Initializes the configurator.
:param name: the name of the configurator as it will be appear in the configuration
:param name: the name of the configurator as it will be appear in the configuration
.
:type name: str
:param mini: the minimum value
of
the input value. If None, no restriction
in
the
modulus
minimum.
:param mini: the minimum value
allowed for
the input value. If None, no restriction
for
the minimum.
:type mini: float or None
:param maxi: the maximum value
of
the input value. If None, no restriction
in
the
modulus
maximum.
:param maxi: the maximum value
allowed for
the input value. If None, no restriction
for
the maximum.
:type maxi: float or None
:param choices: the list of
complex number
s allowed for the input value. If None, any value will be allowed.
:param choices: the list of
float
s allowed for the input value. If None, any value will be allowed.
:type choices: list of float or None
'''
...
...
@@ -96,9 +96,9 @@ class FloatConfigurator(IConfigurator):
@
property
def
mini
(
self
):
'''
Returns the minimum value allowed for an input
value of this configurator
.
Returns the minimum value allowed for an input
float
.
:return: the minimum value allowed for an input
value of this configurator
:return: the minimum value allowed for an input
float.
:rtype: float or None
'''
...
...
@@ -107,9 +107,9 @@ class FloatConfigurator(IConfigurator):
@
property
def
maxi
(
self
):
'''
Returns the maximum value allowed for an input
value of this configurator
.
Returns the maximum value allowed for an input
float
.
:return: the maximum value allowed for an input
value of this configurator
:return: the maximum value allowed for an input
float.
:rtype: float or None
'''
...
...
@@ -118,9 +118,9 @@ class FloatConfigurator(IConfigurator):
@
property
def
choices
(
self
):
'''
Returns the list of floats allowed for an input
value of this configurator
.
Returns the list of floats allowed for an input
float
.
:return: the choices allowed for an input
value of this configurator
:return: the choices allowed for an input
float.
:rtype: list of floats or None
'''
...
...
MDANSE/Framework/Configurators/InputDirectoryConfigurator.py
View file @
0d5930cd
...
...
@@ -27,17 +27,19 @@
'''
Created on Mar 30, 2015
@author:
p
ellegrini
@author:
Eric C. P
ellegrini
'''
import
os
from
MDANSE
import
PLATFORM
from
MDANSE.Framework.Configurators.IConfigurator
import
IConfigurator
,
ConfiguratorError
from
MDANSE.Framework.Configurators.IConfigurator
import
IConfigurator
class
InputDirectoryConfigurator
(
IConfigurator
):
"""
This Configurator allows to set as input an (existing) directory.
This Configurator allows to set an input directory.
The directory will be created at configuration time if it does not exist.
"""
type
=
"input_directory"
...
...
@@ -45,14 +47,27 @@ class InputDirectoryConfigurator(IConfigurator):
_default
=
os
.
getcwd
()
def
configure
(
self
,
configuration
,
value
):
'''
Configure an input directory.
:param configuration: the current configuration.
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the input directory.
:type value: str
'''
value
=
PLATFORM
.
get_path
(
value
)
if
not
os
.
path
.
exists
(
value
):
raise
ConfiguratorError
(
'invalid type for input value'
,
self
)
PLATFORM
.
create_directory
(
value
)
self
[
'value'
]
=
value
def
get_information
(
self
):
'''
Returns some informations about this configurator.
:return: the information about this configurator
:rtype: str
'''
return
"Input directory: %r"
%
self
[
'value'
]
\ No newline at end of file
MDANSE/Framework/Configurators/InputFileConfigurator.py
View file @
0d5930cd
...
...
@@ -27,7 +27,7 @@
'''
Created on Mar 30, 2015
@author:
p
ellegrini
@author:
Eric C. P
ellegrini
'''
import
os
...
...
@@ -37,42 +37,64 @@ from MDANSE.Framework.Configurators.IConfigurator import IConfigurator, Configur
class
InputFileConfigurator
(
IConfigurator
):
"""
This Configurator allows to set a
s
input
any existing
file.
This Configurator allows to set a
n
input file.
"""
type
=
'input_file'
_default
=
""
def
__init__
(
self
,
name
,
checkExistence
=
True
,
wildcard
=
"All files|*.*"
,
**
kwargs
):
def
__init__
(
self
,
name
,
wildcard
=
"All files|*.*"
,
**
kwargs
):
'''
Initializes the configurator object.
:param name: the name of the configurator as it will be appear in the configuration.
:type name: str
:param wildcard: the wildcard used to filter the file. This will be used in MDANSE GUI when
browsing for the input file.
:type wildcard: str
'''
# The base class constructor.
IConfigurator
.
__init__
(
self
,
name
,
**
kwargs
)
self
.
_checkExistence
=
checkExistence
self
.
_wildcard
=
wildcard
def
configure
(
self
,
configuration
,
value
):
if
self
.
checkExistence
:
value
=
PLATFORM
.
get_path
(
value
)
if
not
os
.
path
.
exists
(
value
):
raise
ConfiguratorError
(
"the input file %r does not exist."
%
value
,
self
)
'''
Configure an input file.
:param configuration: the current configuration.
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the input file.
:type value: str
'''
value
=
PLATFORM
.
get_path
(
value
)
if
not
os
.
path
.
exists
(
value
):
raise
ConfiguratorError
(
"the input file %r does not exist."
%
value
,
self
)
self
[
"value"
]
=
value
self
[
"filename"
]
=
value
@
property
def
checkExistence
(
self
):
return
self
.
_checkExistence
@
property
def
wildcard
(
self
):
'''
Returns the wildcard used to filter the input file.
:return: the wildcard used to filter the input file.
:rtype: str
'''
return
self
.
_wildcard
def
get_information
(
self
):
'''
Returns some informations about this configurator.
:return: the information about this configurator
:rtype: str
'''
return
"Input file: %r"
%
self
[
"value"
]
\ No newline at end of file
MDANSE/Framework/Configurators/InstrumentResolutionConfigurator.py
View file @
0d5930cd
...
...
@@ -27,7 +27,7 @@
'''
Created on Mar 30, 2015
@author:
p
ellegrini
@author:
Eric C. P
ellegrini
'''
import
numpy
...
...
@@ -37,17 +37,45 @@ from MDANSE.Framework.Configurators.IConfigurator import IConfigurator, Configur
class
InstrumentResolutionConfigurator
(
IConfigurator
):
"""
This configurator allow to set a simulated instrument resolution.
Clicking on the SET button open a widget allowing to select one function into
a set of basics, and to parameterized it, then the resulting kernel will be
automatically sampled and convoluted with the signal.
This configurator allows to set an instrument resolution.
The instrument resolution will be used in frequency-dependant analysis (e.g. the vibrational density
of states) when performing the fourier transform of its time-dependant counterpart. This allow to
convolute of the signal with a resolution function to have a better match with experimental spectrum.
In MDANSE, the instrument resolution are defined in frequency (energy) space and are internally
inverse-fourier-transformed to get a time-dependant version. This time-dependant resolution function will then
be multiplied by the time-dependant signal to get the resolution effect according to the Fourier Transform theorem:
.. math:: TF(f(t) * r(t)) = F(\omega) \conv R(\omega) = G(\omega)
where f(t) and r(t) are respectively the time-dependant signal and instrument resolution and
F(\omega) and R(\omega) are their corresponding spectrum. Hence, G(\omega) represents the signal
convoluted by the instrument resolution and, as such, represents the quantity to be compared directly with
experimental results.
An instrument resolution is represented in MDANSE by a kernel function and a sets of parameters for this function.
MDANSE currently supports the aussian, lorentzian, square, triangular and pseudo-voigt kernels.
:note: this configurator depends on the 'frame' configurator to be configured
"""
type
=
"instrument_resolution"
_default
=
(
'gaussian'
,
{
'mu'
:
0.0
,
'sigma'
:
0.0001
})
def
configure
(
self
,
configuration
,
value
):
'''
Configure the instrument resolution.
:param configuration: the current configuration
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the instrument resolution. It must be input as a 2-tuple where the 1st element is the instrument resolution
kernel and the 2nd element is a dictionary that stores the parameters for this kernel.
is a string representing one of the supported instrument resolution
:type value: 2-tuple
'''
framesCfg
=
configuration
[
self
.
_dependencies
[
'frames'
]]
...
...
@@ -87,6 +115,26 @@ You should change your resolution function settings to make it sharper.''',self)
self
[
"time_window"
]
=
resolution
.
timeWindow
self
[
"kernel"
]
=
kernel
self
[
"parameters"
]
=
parameters
def
get_information
(
self
):
'''
Returns some informations the instrument resolution.
return
"None yet"
\ No newline at end of file
:return: the information the instrument resolution.
:rtype: str
'''
if
not
self
.
has_key
(
"kernel"
):
return
"No configured yet"
info
=
[
"Instrument resolution kernel:"
%
self
[
"kernel"
]]
if
self
[
"parameters"
]:
info
.
append
(
"Parameters:"
)
for
k
,
v
in
self
[
"parameters"
]:
info
.
append
(
"%s = %s"
%
(
k
,
v
))
info
=
"
\n
"
.
join
(
info
)
return
info
\ No newline at end of file
MDANSE/Framework/Configurators/IntegerConfigurator.py
View file @
0d5930cd
...
...
@@ -34,7 +34,7 @@ from MDANSE.Framework.Configurators.IConfigurator import IConfigurator, Configur
class
IntegerConfigurator
(
IConfigurator
):
"""
This Configurator allow to input an
I
nteger
Value
.
This Configurator allow
s
to input an
i
nteger.
"""
type
=
'integer'
...
...
@@ -42,6 +42,18 @@ class IntegerConfigurator(IConfigurator):
_default
=
0
def
__init__
(
self
,
name
,
mini
=
None
,
maxi
=
None
,
choices
=
None
,
**
kwargs
):
'''
Initializes the configurator.
:param name: the name of the configurator as it will be appear in the configuration.
:type name: str
:param mini: the minimum value allowed for the input value. If None, no restriction for the minimum.
:type mini: int or None
:param maxi: the maximum value allowed for the input value. If None, no restriction for the maximum.
:type maxi: int or None
:param choices: the list of integers allowed for the input value. If None, any value will be allowed.
:type choices: int-list or None
'''
# The base class constructor.
IConfigurator
.
__init__
(
self
,
name
,
**
kwargs
)
...
...
@@ -53,6 +65,14 @@ class IntegerConfigurator(IConfigurator):
self
.
_choices
=
choices
if
choices
is
not
None
else
[]
def
configure
(
self
,
configuration
,
value
):
'''
Configure an integer value.
:param configuration: the current configuration.
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the integer to be configured.
:type value: int
'''
try
:
value
=
int
(
value
)
...
...
@@ -75,19 +95,43 @@ class IntegerConfigurator(IConfigurator):
@
property
def
mini
(
self
):
'''
Returns the minimum value allowed for an input integer.
:return: the minimum value allowed for an input value integer.
:rtype: int or None
'''
return
self
.
_mini
@
property
def
maxi
(
self
):
'''
Returns the maximum value allowed for an input integer.
:return: the maximum value allowed for an input value integer.
:rtype: int or None
'''
return
self
.
_maxi
@
property
def
choices
(
self
):
'''
Returns the list of integers allowed for an input float.
:return: the choices allowed for an input float.
:rtype: int-list or None
'''
return
self
.
_choices
def
get_information
(
self
):
'''
Returns some informations about this configurator.
:return: the information about this configurator
:rtype: str
'''
return
"Value: %r"
%
self
[
"value"
]
\ No newline at end of file
MDANSE/Framework/Configurators/NetCDFInputFileConfigurator.py
View file @
0d5930cd
...
...
@@ -55,18 +55,17 @@ class NetCDFInputFileConfigurator(InputFileConfigurator):
InputFileConfigurator
.
configure
(
self
,
configuration
,
value
)
if
self
.
checkExistence
:
try
:
self
[
'instance'
]
=
NetCDFFile
(
self
[
'value'
],
'r'
)
except
IOError
:
raise
ConfiguratorError
(
"can not open %r NetCDF file for reading"
%
self
[
'value'
])
try
:
self
[
'instance'
]
=
NetCDFFile
(
self
[
'value'
],
'r'
)
except
IOError
:
raise
ConfiguratorError
(
"can not open %r NetCDF file for reading"
%
self
[
'value'
])
for
v
in
self
.
_variables
:
try
:
self
[
v
]
=
self
[
'instance'
].
variables
[
v
]
except
KeyError
:
raise
ConfiguratorError
(
"the variable %r was not found in %r NetCDF file"
%
(
v
,
self
[
"value"
]))
for
v
in
self
.
_variables
:
try
:
self
[
v
]
=
self
[
'instance'
].
variables
[
v
]
except
KeyError
:
raise
ConfiguratorError
(
"the variable %r was not found in %r NetCDF file"
%
(
v
,
self
[
"value"
]))
@
property
def
variables
(
self
):
...
...
MDANSE/Framework/Jobs/McStasVirtualInstrument.py
View file @
0d5930cd
...
...
@@ -94,11 +94,9 @@ class McStasVirtualInstrument(IJob):
settings
[
'frames'
]
=
(
'frames'
,
{
"dependencies"
:{
'trajectory'
:
'trajectory'
}})
settings
[
'sample_coh'
]
=
(
'netcdf_input_file'
,
{
"widget"
:
'input_file'
,
"label"
:
'nMoldyn Coherent Structure Factor'
,
"checkExistence"
:
True
,
"variables"
:[
'q'
,
'frequency'
,
's(q,f)_total'
]})
settings
[
'sample_inc'
]
=
(
'netcdf_input_file'
,
{
"widget"
:
'input_file'
,
"label"
:
'nMoldyn Incoherent Structure Factor'
,
"checkExistence"
:
True
,
"variables"
:[
'q'
,
'frequency'
,
's(q,f)_total'
]})
settings
[
'temperature'
]
=
(
'float'
,
{
"default"
:
298.0
})
settings
[
'instrument'
]
=
(
'mcstas_instrument'
,{
"label"
:
'mcstas instrument'
})
...
...
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