Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ITCPG.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Stuermer
ITCPG.jl
Commits
1cb56523
Commit
1cb56523
authored
4 years ago
by
Julian Stürmer
Browse files
Options
Downloads
Patches
Plain Diff
Add functions for visualizing hurricane impacts
parent
669f4623
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/PlotImpact.jl
+76
-0
76 additions, 0 deletions
src/PlotImpact.jl
with
76 additions
and
0 deletions
src/PlotImpact.jl
0 → 100644
+
76
−
0
View file @
1cb56523
#* Functions for plotting hurricane impacts modelled in Impact.jl
#*------------------------------------------------------------------------------
function
plothist_tl_failures
(
γ_values
::
Array
{
Float64
,
1
},
N_runs
::
Int64
,
rstep
=
20
;
# number of realizations that were saved together
datapath
=
""
,
# path to folder containing different γ scans
plotpath
=
""
# where to save the plot
)
N_γ
=
length
(
γ_values
)
# number of given γ values
mean_Nf_arr
=
zeros
(
N_γ
)
# array for mean number of line failures
σ_arr
=
zeros
(
N_γ
)
# array for standard deviations
### Go through γ values and plot the respective histogram
for
i
in
1
:
N_γ
mean_Nf
,
σ
=
plothist_tl_failures
(
γ_values
[
i
],
N_runs
,
rstep
,
datapath
=
datapath
,
plotpath
=
plotpath
)
mean_Nf_arr
[
i
]
=
mean_Nf
# save mean number of failures
σ_arr
[
i
]
=
σ
# save standard deviation
end
return
mean_Nf_arr
,
σ_arr
end
function
plothist_tl_failures
(
γ
::
Float64
,
N_runs
::
Int64
,
rstep
=
20
;
# number of realizations that were saved together
datapath
::
String
,
# path to folder containing data files
plotpath
::
String
# where to save the plot
)
Nf
=
zeros
(
Int64
,
N_runs
)
# array for number of failures
### Read data and save the number of failures that occured in each run
for
i
in
rstep
:
rstep
:
N_runs
res
=
load
(
datapath
*
"gamma
$
γ/"
*
"results_
$
γ"
*
"_
$
i.jld2"
,
"result"
)
for
j
in
1
:
rstep
Nf
[
i
-
rstep
+
j
]
=
length
(
res
[
j
])
end
end
### Plot a historgram of the number of failures
N_bins
=
maximum
(
Nf
)
-
minimum
(
Nf
)
# number of bins
n
,
bins
,
patches
=
plt
[
:
hist
](
Nf
,
bins
=
N_bins
,
edgecolor
=
"k"
)
### Calculate mean number of failures and standard deviation
mean_Nf
=
round
(
mean!
([
1.
],
Nf
)[
1
],
digits
=
1
)
σ
=
round
(
std
(
Nf
,
mean
=
mean_Nf
),
digits
=
1
)
### Legend with γ, mean number of failures and standard deviation
mlines
=
pyimport
(
"matplotlib.lines"
)
no_marker
=
mlines
.
Line2D
([],
[],
ls
=
"None"
)
plt
.
legend
(
[
no_marker
for
i
in
1
:
4
],
[
L"γ = "
*
"
$
γ"
,
L"N_r = "
*
"
$
N_runs"
,
L"
\b
ar{N}_\mathrm{f}
\a
pprox"
*
"
$
mean_Nf"
,
L"\sigma_\mathrm{f}
\a
pprox"
*
"
$
σ"
],
handletextpad
=
0
,
handlelength
=
0
)
### Axes labels
plt
.
xlabel
(
"Number of line failures "
*
L"N_\mathrm{f}"
)
plt
.
ylabel
(
"Frequency"
)
### Save and close figure
figpath
=
plotpath
*
"Texas_hist_tl_failures_gamma
$
γ.png"
plt
.
savefig
(
figpath
,
bbox_inches
=
"tight"
)
plt
.
clf
()
return
mean_Nf
,
σ
end
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