Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
3adbed88
Commit
3adbed88
authored
4 years ago
by
Wuttke, Joachim
Committed by
Wuttke, Joachim
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
sample, sim as args; new fct run_and_plot
parent
cbb09945
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Core/Export/SimulationToPython.cpp
+3
-12
3 additions, 12 deletions
Core/Export/SimulationToPython.cpp
Wrap/Python/plot_utils.py
+4
-0
4 additions, 0 deletions
Wrap/Python/plot_utils.py
devtools/code/normalize-usercode.py
+1
-2
1 addition, 2 deletions
devtools/code/normalize-usercode.py
with
8 additions
and
14 deletions
Core/Export/SimulationToPython.cpp
+
3
−
12
View file @
3adbed88
...
...
@@ -385,7 +385,7 @@ std::string defineGISASSimulation(const GISASSimulation* simulation) {
std
::
ostringstream
result
;
result
<<
defineGISASBeam
(
*
simulation
);
result
<<
defineDetector
(
simulation
);
result
<<
indent
()
<<
"simulation = ba.GISASSimulation(beam,
get_
sample
()
, detector)
\n
"
;
result
<<
indent
()
<<
"simulation = ba.GISASSimulation(beam, sample, detector)
\n
"
;
result
<<
defineDetectorResolutionFunction
(
simulation
);
result
<<
defineDetectorPolarizationAnalysis
(
simulation
);
result
<<
defineParameterDistributions
(
simulation
);
...
...
@@ -424,7 +424,7 @@ std::string defineSpecularSimulation(const SpecularSimulation* simulation) {
std
::
string
defineSimulate
(
const
ISimulation
*
simulation
)
{
std
::
ostringstream
result
;
result
<<
"def get_simulation(sample
=get_sample()
):
\n
"
;
result
<<
"def get_simulation(sample):
\n
"
;
if
(
auto
gisas
=
dynamic_cast
<
const
GISASSimulation
*>
(
simulation
))
result
<<
defineGISASSimulation
(
gisas
);
else
if
(
auto
offspec
=
dynamic_cast
<
const
OffSpecularSimulation
*>
(
simulation
))
...
...
@@ -435,21 +435,12 @@ std::string defineSimulate(const ISimulation* simulation) {
ASSERT
(
0
);
result
<<
" return simulation
\n\n\n
"
;
result
<<
"def run_simulation():
\n
"
" simulation = get_simulation()
\n
"
" simulation.runSimulation()
\n
"
" return simulation.result()
\n\n\n
"
;
return
result
.
str
();
}
const
std
::
string
defineMain
=
"if __name__ == '__main__':
\n
"
" result = run_simulation()
\n
"
" if len(sys.argv)>=2:
\n
"
" ba.IntensityDataIOFactory.writeSimulationResult(result, sys.argv[1])
\n
"
" else:
\n
"
" ba.plot_simulation_result(result)
\n
"
;
" ba.run_and_plot(get_simulation(get_sample()))
\n
"
;
}
// namespace
...
...
This diff is collapsed.
Click to expand it.
Wrap/Python/plot_utils.py
+
4
−
0
View file @
3adbed88
...
...
@@ -212,3 +212,7 @@ def plot_simulation_result(result, **kwargs):
plt
.
tight_layout
()
if
not
(
postpone_show
):
plt
.
show
()
def
run_and_plot
(
simulation
):
simulation
.
runSimulation
()
ba
.
plot_simulation_result
(
simulation
.
result
())
This diff is collapsed.
Click to expand it.
devtools/code/normalize-usercode.py
+
1
−
2
View file @
3adbed88
...
...
@@ -43,8 +43,7 @@ def retrieve_simulation(ti, fname):
ns
=
{}
exec
(
c
,
ns
)
globals
().
update
(
ns
)
s
=
get_simulation
()
s
.
setSample
(
get_sample
())
s
=
get_simulation
(
get_sample
())
return
s
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment