Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
astro
astrotools
Commits
f44b33ab
Commit
f44b33ab
authored
Feb 13, 2020
by
Marcus Wirtz
Browse files
[simulations] Simple check to verify that enough sources n_src were set in SourceBound simulation
parent
6609a346
Pipeline
#241436
passed with stages
in 6 minutes and 18 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
astrotools/simulations.py
View file @
f44b33ab
...
...
@@ -668,6 +668,12 @@ class SourceBound(BaseSimulation):
nrange
=
np
.
tile
(
np
.
arange
(
self
.
ncrs
),
self
.
nsets
).
reshape
(
self
.
shape
)
mask_close
=
nrange
<
nsplit
[
0
][:,
np
.
newaxis
]
# Create mask for CRs inside rmax
source_labels
[
~
mask_close
]
=
-
1
# correct the ones resulting by max(nsplit[0])
# Checks if for all sets there is at least one explicit simulated source WITHOUT cosmic-ray contribution
range_src
=
np
.
arange
(
self
.
universe
.
n_src
)
if
not
np
.
apply_along_axis
(
lambda
x
:
np
.
in1d
(
range_src
,
x
,
invert
=
True
).
any
(),
axis
=
1
,
arr
=
source_labels
).
all
():
print
(
"Warning: too few sources simulated! Set keyword 'n_src' higher."
)
self
.
crs
[
'source_labels'
]
=
source_labels
occ
=
np
.
apply_along_axis
(
lambda
x
:
np
.
bincount
(
x
+
1
)[
x
+
1
],
axis
=
1
,
arr
=
source_labels
)
self
.
signal_label
=
(
occ
>=
2
)
&
(
source_labels
>=
0
)
...
...
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