IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
corsika
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pranav Sampathkumar
corsika
Commits
ccd7e6e8
Commit
ccd7e6e8
authored
4 years ago
by
Maximilian Reininghaus
Committed by
Maximilian Reininghaus
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
removed append option from save_hist()
parent
c731622e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
corsika/detail/framework/utility/SaveBoostHistogram.inl
+8
-12
8 additions, 12 deletions
corsika/detail/framework/utility/SaveBoostHistogram.inl
corsika/framework/utility/SaveBoostHistogram.hpp
+1
-3
1 addition, 3 deletions
corsika/framework/utility/SaveBoostHistogram.hpp
with
9 additions
and
15 deletions
corsika/detail/framework/utility/SaveBoostHistogram.inl
+
8
−
12
View file @
ccd7e6e8
...
@@ -23,12 +23,9 @@ namespace corsika {
...
@@ -23,12 +23,9 @@ namespace corsika {
template
<
class
Axes
,
class
Storage
>
template
<
class
Axes
,
class
Storage
>
inline
void
save_hist
(
boost
::
histogram
::
histogram
<
Axes
,
Storage
>
const
&
h
,
inline
void
save_hist
(
boost
::
histogram
::
histogram
<
Axes
,
Storage
>
const
&
h
,
std
::
string
const
&
filename
,
SaveMode
mode
)
{
std
::
string
const
&
filename
)
{
unsigned
const
rank
=
h
.
rank
();
unsigned
const
rank
=
h
.
rank
();
// append vs. overwrite
const
std
::
string
mode_str
=
(
mode
==
SaveMode
::
append
?
"a"
:
"w"
);
std
::
vector
<
size_t
>
axes_dims
;
std
::
vector
<
size_t
>
axes_dims
;
axes_dims
.
reserve
(
rank
);
axes_dims
.
reserve
(
rank
);
...
@@ -58,7 +55,7 @@ namespace corsika {
...
@@ -58,7 +55,7 @@ namespace corsika {
ax_edges
.
push_back
(
ax
.
bin
(
ax
.
size
()
-
1
).
upper
());
ax_edges
.
push_back
(
ax
.
bin
(
ax
.
size
()
-
1
).
upper
());
cnpy
::
npz_save
(
filename
,
std
::
string
{
"binedges_"
}
+
std
::
to_string
(
i
),
cnpy
::
npz_save
(
filename
,
std
::
string
{
"binedges_"
}
+
std
::
to_string
(
i
),
ax_edges
.
data
(),
{
ax_edges
.
size
()},
mode_str
);
ax_edges
.
data
(),
{
ax_edges
.
size
()},
"a"
);
}
else
{
}
else
{
axis_types
.
push_back
(
'd'
);
axis_types
.
push_back
(
'd'
);
std
::
vector
<
int64_t
>
bins
;
// we assume that discrete axes have integer bins
std
::
vector
<
int64_t
>
bins
;
// we assume that discrete axes have integer bins
...
@@ -67,14 +64,13 @@ namespace corsika {
...
@@ -67,14 +64,13 @@ namespace corsika {
for
(
int
j
=
0
;
j
<
ax
.
size
();
++
j
)
{
bins
.
push_back
(
ax
.
bin
(
j
).
lower
());
}
for
(
int
j
=
0
;
j
<
ax
.
size
();
++
j
)
{
bins
.
push_back
(
ax
.
bin
(
j
).
lower
());
}
cnpy
::
npz_save
(
filename
,
std
::
string
{
"bins_"
}
+
std
::
to_string
(
i
),
bins
.
data
(),
cnpy
::
npz_save
(
filename
,
std
::
string
{
"bins_"
}
+
std
::
to_string
(
i
),
bins
.
data
(),
{
bins
.
size
()},
mode_str
);
{
bins
.
size
()},
"a"
);
}
}
}
}
cnpy
::
npz_save
(
filename
,
std
::
string
{
"axistypes"
},
axis_types
.
data
(),
{
rank
},
cnpy
::
npz_save
(
filename
,
std
::
string
{
"axistypes"
},
axis_types
.
data
(),
{
rank
},
"a"
);
mode_str
);
cnpy
::
npz_save
(
filename
,
std
::
string
{
"overflow"
},
overflow
.
get
(),
{
rank
},
"a"
);
cnpy
::
npz_save
(
filename
,
std
::
string
{
"overflow"
},
overflow
.
get
(),
{
rank
},
mode_str
);
cnpy
::
npz_save
(
filename
,
std
::
string
{
"underflow"
},
underflow
.
get
(),
{
rank
},
"a"
);
cnpy
::
npz_save
(
filename
,
std
::
string
{
"underflow"
},
underflow
.
get
(),
{
rank
},
mode_str
);
auto
const
prod_axis_size
=
std
::
accumulate
(
axes_dims
.
cbegin
(),
axes_dims
.
cend
(),
auto
const
prod_axis_size
=
std
::
accumulate
(
axes_dims
.
cbegin
(),
axes_dims
.
cend
(),
unsigned
{
1
},
std
::
multiplies
<>
());
unsigned
{
1
},
std
::
multiplies
<>
());
...
@@ -98,9 +94,9 @@ namespace corsika {
...
@@ -98,9 +94,9 @@ namespace corsika {
temp
[
p
]
=
*
x
;
temp
[
p
]
=
*
x
;
}
}
cnpy
::
npz_save
(
filename
,
"data"
,
temp
.
get
(),
axes_dims
,
mode_str
);
cnpy
::
npz_save
(
filename
,
"data"
,
temp
.
get
(),
axes_dims
,
"a"
);
// In Python this array can directly be assigned to a histogram view if that
// In Python this array can directly be assigned to a histogram view if that
// histogram has its axes correspondingly: hist.view(flow=True)[:] = file['data']
// histogram has its axes correspondingly: hist.view(flow=True)[:] = file['data']
}
// namespace corsika
}
// namespace corsika
}
// namespace corsika
}
// namespace corsika
\ No newline at end of file
This diff is collapsed.
Click to expand it.
corsika/framework/utility/SaveBoostHistogram.hpp
+
1
−
3
View file @
ccd7e6e8
...
@@ -12,8 +12,6 @@
...
@@ -12,8 +12,6 @@
namespace
corsika
{
namespace
corsika
{
enum
class
SaveMode
{
overwrite
,
append
};
/**
/**
* This functions saves a boost::histogram into a numpy file. Only rather basic axis
* This functions saves a boost::histogram into a numpy file. Only rather basic axis
* types are supported: regular, variable, integer, category<int>. Only "ordinary" bin
* types are supported: regular, variable, integer, category<int>. Only "ordinary" bin
...
@@ -24,7 +22,7 @@ namespace corsika {
...
@@ -24,7 +22,7 @@ namespace corsika {
*/
*/
template
<
class
Axes
,
class
Storage
>
template
<
class
Axes
,
class
Storage
>
inline
void
save_hist
(
boost
::
histogram
::
histogram
<
Axes
,
Storage
>
const
&
h
,
inline
void
save_hist
(
boost
::
histogram
::
histogram
<
Axes
,
Storage
>
const
&
h
,
std
::
string
const
&
filename
,
SaveMode
mode
=
SaveMode
::
append
);
std
::
string
const
&
filename
);
}
// namespace corsika
}
// namespace corsika
#include
<corsika/detail/framework/utility/SaveBoostHistogram.inl>
#include
<corsika/detail/framework/utility/SaveBoostHistogram.inl>
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