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
3f9c484a
Commit
3f9c484a
authored
1 year ago
by
Mikhail Svechnikov
Browse files
Options
Downloads
Patches
Plain Diff
upd script
parent
b35602bb
No related branches found
No related tags found
1 merge request
!2081
Repair 'devtools/fakeData/fake-gisas1.py'
Pipeline
#118435
passed
1 year ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
devtools/fakeData/fake-gisas1.py
+23
-16
23 additions, 16 deletions
devtools/fakeData/fake-gisas1.py
with
23 additions
and
16 deletions
devtools/fakeData/fake-gisas1.py
+
23
−
16
View file @
3f9c484a
...
...
@@ -10,47 +10,51 @@ There are, however, some systematic distortions:
"""
import
bornagain
as
ba
from
bornagain
import
deg
,
nm
from
bornagain
import
deg
,
nm
,
ba_plot
as
bp
import
numpy
as
np
mat_vacuum
=
ba
.
Homogeneous
Material
(
"
Vacuum
"
,
0
,
0
)
mat_vacuum
=
ba
.
Refractive
Material
(
"
Vacuum
"
,
0
,
0
)
# nominal material constants are (6e-6, 2e-8) and (6e-4, 2e-8)
mat_substrate
=
ba
.
Homogeneous
Material
(
"
Substrate
"
,
6.3e-6
,
4e-7
)
mat_particle
=
ba
.
Homogeneous
Material
(
"
Particle
"
,
5.8
e-
4
,
2e-7
)
mat_substrate
=
ba
.
Refractive
Material
(
"
Substrate
"
,
6.3e-6
,
4e-7
)
mat_particle
=
ba
.
Refractive
Material
(
"
Particle
"
,
3
e-
5
,
2e-7
)
def
get_sample
(
params
):
h
=
params
[
"
cylinder_height
"
]
r
=
params
[
"
cylinder_radius
"
]
ro
=
params
[
"
surface_density
"
]
ff1
=
ba
.
FormFactor
Cone
(
1.1
*
r
,
h
,
80
*
deg
)
ff2
=
ba
.
FormFactor
TruncatedSpheroid
(
r
,
3.3
*
h
,
2.5
*
h
/
r
,
2.2
*
h
)
ff1
=
ba
.
Cone
(
1.1
*
r
,
h
,
80
*
deg
)
ff2
=
ba
.
TruncatedSpheroid
(
r
,
3.3
*
h
,
2.5
*
h
/
r
,
2.2
*
h
)
layout
=
ba
.
ParticleLayout
()
layout
.
addParticle
(
ba
.
Particle
(
mat_particle
,
ff1
),
.
4
)
layout
.
addParticle
(
ba
.
Particle
(
mat_particle
,
ff2
),
.
6
)
layout
.
setTotalParticleSurfaceDensity
(
ro
)
layer_1
=
ba
.
Layer
(
mat_vacuum
)
layer_1
.
addLayout
(
layout
)
layer_2
=
ba
.
Layer
(
mat_substrate
)
sigma
,
hurst
,
corrLength
=
0.2
*
nm
,
0.3
,
20
*
nm
roughness
=
ba
.
LayerRoughness
(
sigma
,
hurst
,
corrLength
)
sample
=
ba
.
MultiLayer
()
sample
.
addLayer
(
layer_1
)
sample
.
addLayer
(
layer_2
)
sample
.
addLayer
WithTopRoughness
(
layer_2
,
roughness
)
return
sample
def
get_simulation
(
params
):
# nominal beam parameters are 0.1*nm, 0.2*deg
beam
=
ba
.
Beam
(
10
**
params
[
'
lg(intensity)
'
],
0.0993
*
nm
,
ba
.
Direction
(
0.202
*
deg
,
0
))
beam
=
ba
.
Beam
(
10
**
params
[
'
lg(intensity)
'
],
0.0993
*
nm
,
0.202
*
deg
)
# nominal detector x-axis starts from -1.5*deg
det
=
ba
.
SphericalDetector
(
1
0
0
,
-
1.49
*
deg
,
1.5
*
deg
,
1
0
0
,
0
,
3
*
deg
)
det
=
ba
.
SphericalDetector
(
1
2
0
,
-
1.49
*
deg
,
1.5
*
deg
,
1
2
0
,
0
,
3
*
deg
)
sample
=
get_sample
(
params
)
simulation
=
ba
.
GISAS
Simulation
(
beam
,
sample
,
det
)
simulation
=
ba
.
Scattering
Simulation
(
beam
,
sample
,
det
)
if
'
lg(background)
'
in
params
:
simulation
.
setBackground
(
ba
.
ConstantBackground
(
10
**
params
[
'
lg(background)
'
]))
...
...
@@ -60,10 +64,11 @@ def get_simulation(params):
def
model_parameters
():
return
{
'
lg(intensity)
'
:
6
,
'
lg(background)
'
:
0.5
,
'
lg(intensity)
'
:
9
,
'
lg(background)
'
:
1.2
,
'
cylinder_height
'
:
4
*
nm
,
'
cylinder_radius
'
:
5
*
nm
,
'
surface_density
'
:
0.005
}
...
...
@@ -76,14 +81,16 @@ def fake_data():
# Compute model distribution
simulation
=
get_simulation
(
params
)
simulation
.
runSimulation
()
theory
=
simulation
.
result
().
array
()
result
=
simulation
.
simulate
()
bp
.
plot_simulation_result
(
result
)
theory
=
result
.
npArray
()
# Draw noisy data
data
=
np
.
random
.
poisson
(
theory
)
# Save to numpy
np
.
savetxt
(
"
faked-gisas
1
.txt
.gz
"
,
data
)
np
.
savetxt
(
"
faked-gisas.txt
"
,
data
)
if
__name__
==
'
__main__
'
:
...
...
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