Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
MDANSE
Commits
3d499bc2
Commit
3d499bc2
authored
May 21, 2015
by
eric pellegrini
Browse files
docstring new configurators
parent
0d85a952
Changes
6
Hide whitespace changes
Inline
Side-by-side
MDANSE/Framework/Configurators/FloatConfigurator.py
View file @
3d499bc2
...
...
@@ -33,9 +33,9 @@ Created on Mar 30, 2015
from
MDANSE.Framework.Configurators.IConfigurator
import
IConfigurator
,
ConfiguratorError
class
FloatConfigurator
(
IConfigurator
):
"""
'''
This Configurator allows to input a float.
"""
'''
type
=
'float'
...
...
MDANSE/Framework/Configurators/InputDirectoryConfigurator.py
View file @
3d499bc2
...
...
@@ -36,11 +36,11 @@ from MDANSE import PLATFORM
from
MDANSE.Framework.Configurators.IConfigurator
import
IConfigurator
class
InputDirectoryConfigurator
(
IConfigurator
):
"""
This Configurator allows to set an input directory.
'''
This Configurator allows to set an input directory.
The directory will be created at configuration time if it does not exist.
"""
:attention:
The directory will be created at configuration time if it does not exist.
'''
type
=
"input_directory"
...
...
MDANSE/Framework/Configurators/InterpolationOrderConfigurator.py
View file @
3d499bc2
...
...
@@ -37,9 +37,15 @@ class InterpolationOrderConfigurator(SingleChoiceConfigurator):
"""
This configurator allows to input the interpolation order to be applied when deriving velocities
from atomic coordinates.
The value should be higher than 0 if velocities are not provided with the trajectory.
:note: this configurator depends on 'trajectory' configurator to be configured
The allowed value are 'no interpolation','1st order','2nd order','3rd order','4th order' or '5th order', the former
one will not interpolate the velocities from atomic coordinates but will directly use the velocities stored in the
trajectory file.
:attention: it is of paramount importance for the trajectory to be sampled with a very low time step to get accurate
velocities interpolated from atomic coordinates.
:note: this configurator depends on 'trajectory' configurator to be configured.
"""
type
=
"interpolation_order"
...
...
MDANSE/Framework/Configurators/McStasInstrumentConfigurator.py
View file @
3d499bc2
...
...
@@ -33,5 +33,8 @@ Created on Mar 30, 2015
from
MDANSE.Framework.Configurators.InputFileConfigurator
import
InputFileConfigurator
class
McStasInstrumentConfigurator
(
InputFileConfigurator
):
"""
This configurator allows to input a McStas executable file
"""
type
=
"mcstas_instrument"
MDANSE/Framework/Configurators/McStasOptionsConfigurator.py
View file @
3d499bc2
...
...
@@ -37,12 +37,23 @@ from MDANSE import PLATFORM
from
MDANSE.Framework.Configurators.IConfigurator
import
IConfigurator
,
ConfiguratorError
class
McStasOptionsConfigurator
(
IConfigurator
):
"""
This configurator allows to input the McStas options that will be used to run a McStas executable file.
"""
type
=
"mcstas_options"
_default
=
{
"ncount"
:
10000
,
"dir"
:
os
.
path
.
join
(
os
.
getcwd
(),
"mcstas_output"
,
time
.
strftime
(
"%d.%m.%Y-%H:%M:%S"
,
time
.
localtime
()))}
def
configure
(
self
,
configuration
,
value
):
'''
Configure the McStas options.
:param configuration: the current configuration.
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the McStas options.
:type value: dict
'''
options
=
self
.
_default
.
copy
()
...
...
@@ -54,6 +65,7 @@ class McStasOptionsConfigurator(IConfigurator):
tmp
=
[
''
]
for
k
,
v
in
options
.
items
():
if
k
==
"dir"
:
# If the output directory already exists, defines a 'unique' output directory name because otherwise McStas throws.
if
os
.
path
.
exists
(
v
):
v
=
self
.
_default
[
'dir'
]
self
[
"mcstas_output_directory"
]
=
v
...
...
@@ -69,5 +81,11 @@ class McStasOptionsConfigurator(IConfigurator):
self
[
"value"
]
=
tmp
def
get_information
(
self
):
'''
Returns the McStas options as they would be input when using McStas in command line mode.
return
"McStas command line options:%s"
%
self
[
"value"
]
\ No newline at end of file
:return: the McStas command-line options.
:rtype: str
'''
return
"McStas command line options: %s"
%
self
[
"value"
]
\ No newline at end of file
MDANSE/Framework/Configurators/McStasParametersConfigurator.py
View file @
3d499bc2
...
...
@@ -36,15 +36,23 @@ import subprocess
from
MDANSE.Framework.Configurators.IConfigurator
import
IConfigurator
class
McStasParametersConfigurator
(
IConfigurator
):
"""
This configurator allows to
set in a string form the McStas command-line input parameters
.
"""
'''
This configurator allows to
input the McStas instrument parameters that will be used to run a McStas executable file
.
'''
type
=
"instrument_parameters"
_mcStasTypes
=
{
'double'
:
float
,
'int'
:
int
,
'string'
:
str
}
def
__init__
(
self
,
name
,
exclude
=
None
,
**
kwargs
):
'''
Initializes the configurator.
:param name: the name of the configurator as it will be appear in the configuration.
:type name: str
:param exclude: the parameters that exclude when building the McStas instrument parameters list.
:type exclude: list of str
'''
# The base class constructor.
IConfigurator
.
__init__
(
self
,
name
,
**
kwargs
)
...
...
@@ -52,6 +60,14 @@ class McStasParametersConfigurator(IConfigurator):
self
.
_exclude
=
exclude
if
exclude
is
not
None
else
[]
def
configure
(
self
,
configuration
,
value
):
'''
Configure the McStas instrument parameters command line.
:param configuration: the current configuration.
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the McStas instrument parameters.
:type value: dict
'''
instrConfig
=
configuration
[
self
.
_dependencies
[
'instrument'
]]
...
...
@@ -71,9 +87,21 @@ class McStasParametersConfigurator(IConfigurator):
@
property
def
exclude
(
self
):
'''
Returns the McStas instrument parameters to exclude from the McStas command-line.
:return: the McStas instrument parameters to exclude from the McStas command-line.
:rtype: list of str
'''
return
self
.
_exclude
def
get_information
(
self
):
'''
Returns the McStas parameters as they would be input when using McStas in command line mode.
:return: the McStas command-line parameters.
:rtype: str
'''
return
"McStas command line parameters:%s"
%
self
[
"value"
]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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