Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alessio Berti
magic-cta-pipe
Commits
5edcd06a
Commit
5edcd06a
authored
Dec 18, 2019
by
Ievgen Vovk
Browse files
Removed the need in MyFunctions module.
parent
68cb9812
Changes
2
Hide whitespace changes
Inline
Side-by-side
train_classifier_rf.py
View file @
5edcd06a
...
...
@@ -16,8 +16,6 @@ from astropy import units as u
from
matplotlib
import
pyplot
,
colors
from
MyFunctions
import
GetHist
def
info_message
(
text
,
prefix
=
'info'
):
"""
...
...
@@ -35,7 +33,19 @@ def info_message(text, prefix='info'):
date_str
=
datetime
.
datetime
.
now
().
strftime
(
"%Y-%m-%dT%H:%M:%S"
)
print
(
f
"(
{
prefix
:
s
}
)
{
date_str
:
s
}
:
{
text
:
s
}
"
)
def
GetHist
(
data
,
bins
=
30
,
range
=
None
,
weights
=
None
):
hs
,
edges
=
scipy
.
histogram
(
data
,
bins
=
bins
,
range
=
range
,
weights
=
weights
)
loc
=
(
edges
[
1
:]
+
edges
[:
-
1
])
/
2
hist
=
{}
hist
[
'Hist'
]
=
hs
hist
[
'X'
]
=
loc
hist
[
'XEdges'
]
=
edges
return
hist
def
evaluate_performance
(
data
,
class0_name
=
'event_class_0'
):
data
=
data
.
dropna
()
...
...
train_energy_rf.py
View file @
5edcd06a
...
...
@@ -24,8 +24,6 @@ from astropy import units as u
from
matplotlib
import
pyplot
,
colors
from
MyFunctions
import
GetHist2D
def
info_message
(
text
,
prefix
=
'info'
):
"""
...
...
@@ -43,7 +41,26 @@ def info_message(text, prefix='info'):
date_str
=
datetime
.
datetime
.
now
().
strftime
(
"%Y-%m-%dT%H:%M:%S"
)
print
(
f
"(
{
prefix
:
s
}
)
{
date_str
:
s
}
:
{
text
:
s
}
"
)
def
GetHist2D
(
x
,
y
,
bins
=
30
,
range
=
None
,
weights
=
None
):
hs
,
xedges
,
yedges
=
scipy
.
histogram2d
(
x
,
y
,
bins
=
bins
,
range
=
range
,
weights
=
weights
)
xloc
=
(
xedges
[
1
:]
+
xedges
[:
-
1
])
/
2
yloc
=
(
yedges
[
1
:]
+
yedges
[:
-
1
])
/
2
xxloc
,
yyloc
=
scipy
.
meshgrid
(
xloc
,
yloc
,
indexing
=
'ij'
)
hist
=
{}
hist
[
'Hist'
]
=
hs
hist
[
'X'
]
=
xloc
hist
[
'Y'
]
=
yloc
hist
[
'XX'
]
=
xxloc
hist
[
'YY'
]
=
yyloc
hist
[
'XEdges'
]
=
xedges
hist
[
'YEdges'
]
=
yedges
return
hist
def
evaluate_performance
(
data
,
energy_name
):
valid_data
=
data
.
dropna
(
subset
=
[
energy_name
])
...
...
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