Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
astro
astrotools
Commits
6f42437e
Commit
6f42437e
authored
Jan 23, 2020
by
teresa.bister
Browse files
[simulations] revert unnesserary fix
parent
41f1a7fc
Pipeline
#232022
failed with stages
in 4 minutes and 42 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
astrotools/simulations.py
View file @
6f42437e
...
...
@@ -111,7 +111,6 @@ class BaseSimulation:
self
.
crs
[
_key
]
=
self
.
crs
[
_key
][
sets_ids
,
shuffle_ids
]
sets_ids_3d
=
np
.
repeat
(
np
.
arange
(
3
),
np
.
prod
(
self
.
shape
)).
reshape
((
3
,)
+
self
.
shape
)
self
.
crs
[
'vecs'
]
=
self
.
crs
[
'vecs'
][
sets_ids_3d
,
sets_ids
,
np
.
stack
([
shuffle_ids
]
*
3
)]
self
.
signal_label_shuffled
=
self
.
signal_label
[
sets_ids
,
shuffle_ids
]
class
ObservedBound
(
BaseSimulation
):
...
...
@@ -423,10 +422,7 @@ class ObservedBound(BaseSimulation):
self
.
convert_pixel
(
convert_all
=
True
)
if
shuffle
:
self
.
shuffle_events
()
self
.
crs
[
'signal_label'
]
=
self
.
signal_label_shuffled
self
.
signal_label
=
self
.
signal_label_shuffled
else
:
self
.
crs
[
'signal_label'
]
=
self
.
signal_label
self
.
crs
[
'signal_label'
]
=
self
.
signal_label
return
self
.
crs
def
convert_pixel
(
self
,
keyword
=
'vecs'
,
convert_all
=
False
):
...
...
@@ -590,10 +586,7 @@ class SourceBound(BaseSimulation):
"""
if
shuffle
:
self
.
shuffle_events
()
self
.
crs
[
'signal_label'
]
=
self
.
signal_label_shuffled
self
.
signal_label
=
self
.
signal_label_shuffled
else
:
self
.
crs
[
'signal_label'
]
=
self
.
signal_label
self
.
crs
[
'signal_label'
]
=
self
.
signal_label
return
self
.
crs
def
_prepare_arrival_matrix
(
self
,
library_path
):
...
...
@@ -995,7 +988,7 @@ class SourceGeometry:
# maximum radius for one source per cosmic ray (isotropy condition)
self
.
rmax
=
(
3
*
n_src
/
4
/
np
.
pi
/
source_density
)
**
(
1
/
3.
)
self
.
sources
=
coord
.
rand_vec
((
self
.
nsets
,
n_src
))
# shape (3, nsets, n_src)
# random radius in volume (r
²
distribution)
# random radius in volume (r
^2
distribution)
self
.
distances
=
self
.
rmax
*
(
np
.
random
.
random
((
self
.
nsets
,
n_src
)))
**
(
1
/
3.
)
# shape (nsets, n_src)
self
.
source_fluxes
=
1
/
self
.
distances
**
2
elif
isinstance
(
source_density
,
np
.
ndarray
):
...
...
test/test_simulations.py
View file @
6f42437e
...
...
@@ -299,7 +299,7 @@ class TestObservedBound(unittest.TestCase):
sim
.
set_sources
(
src_vecs
[:,
np
.
newaxis
])
sim
.
arrival_setup
(
fsig
=
0.1
)
crs
=
sim
.
get_data
(
convert_all
=
Tru
e
,
shuffle
=
True
)
crs
=
sim
.
get_data
(
convert_all
=
Fals
e
,
shuffle
=
True
)
self
.
assertTrue
(
np
.
all
(
src_pix
==
crs
[
'pixel'
][
sim
.
signal_label
]))
self
.
assertTrue
(
np
.
all
(
src_pix
==
crs
[
'pixel'
][
crs
[
'signal_label'
].
astype
(
bool
)]))
...
...
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