Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WindEnergyToolbox
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
toolbox
WindEnergyToolbox
Commits
cd59846b
Commit
cd59846b
authored
8 years ago
by
David Verelst
Browse files
Options
Downloads
Patches
Plain Diff
prepost.misc: add hist_centers2edges convenience method
parent
3876bfa0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wetb/prepost/misc.py
+21
-0
21 additions, 0 deletions
wetb/prepost/misc.py
with
21 additions
and
0 deletions
wetb/prepost/misc.py
+
21
−
0
View file @
cd59846b
...
...
@@ -769,6 +769,13 @@ def check_df_dict(df_dict):
"""
Verify if the dictionary that needs to be transferred to a Pandas DataFrame
makes sense
Returns
-------
collens : dict
Dictionary with df_dict keys as keys, len(df_dict[key]) as column.
In other words: the length of each column (=rows) of the soon to be df.
"""
collens
=
{}
for
col
,
values
in
df_dict
.
items
():
...
...
@@ -978,6 +985,20 @@ def histfit(hist, bin_edges, xnew):
return
shape_out
,
scale_out
,
pdf_fit
def
hist_centers2edges
(
centers
):
"""
Given the centers of bins, return its edges and bin widths.
"""
binw_c
=
centers
[
1
:]
-
centers
[:
-
1
]
edges
=
np
.
ndarray
((
len
(
centers
)
+
1
,))
edges
[
0
]
=
centers
[
0
]
-
binw_c
[
0
]
/
2.0
edges
[
-
1
]
=
centers
[
-
1
]
+
binw_c
[
-
1
]
/
2.0
edges
[
1
:
-
1
]
=
centers
[
1
:]
-
binw_c
/
2.0
binw_e
=
edges
[
1
:]
-
edges
[:
-
1
]
return
edges
,
binw_e
def
df_dict_check_datatypes
(
df_dict
):
"""
there might be a mix of strings and numbers now, see if we can have
...
...
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