Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Persefone.jl
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Persefone
Persefone.jl
Commits
eb8515d8
Commit
eb8515d8
authored
8 months ago
by
xo30xoqa
Browse files
Options
Downloads
Patches
Plain Diff
Minor additions to utils.jl
parent
0366f200
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/output.jl
+1
-1
1 addition, 1 deletion
src/core/output.jl
src/core/utils.jl
+16
-0
16 additions, 0 deletions
src/core/utils.jl
with
17 additions
and
1 deletion
src/core/output.jl
+
1
−
1
View file @
eb8515d8
...
...
@@ -257,7 +257,7 @@ function visualiseoutput(model::SimulationModel) #XXX remove this? (#81)
CairoMakie
.
activate!
()
# make sure we're using Cairo
for
o
in
keys
(
model
.
dataoutputs
)
output
=
model
.
dataoutputs
[
o
]
isnothing
(
output
.
plotfunction
)
&&
continue
(
output
.
frequency
==
"never"
||
isnothing
(
output
.
plotfunction
)
)
&&
continue
figure
=
output
.
plotfunction
(
model
)
isnothing
(
figure
)
?
continue
:
save
(
joinpath
(
@param
(
core
.
outdir
),
o
*
"."
*
@param
(
core
.
figureformat
)),
figure
)
...
...
This diff is collapsed.
Click to expand it.
src/core/utils.jl
+
16
−
0
View file @
eb8515d8
...
...
@@ -46,16 +46,19 @@ end
# Allows writing `(August, 2)` instead of `AnnualDate(August, 2)` where an AnnualDate is expected.
AnnualDate
(
ad
::
Tuple
{
Int64
,
Int64
})
=
AnnualDate
(
ad
...
)
Base
.
convert
(
::
Type
{
AnnualDate
},
ad
::
Tuple
{
Int64
,
Int64
})
=
AnnualDate
(
ad
)
Base
.
convert
(
::
Type
{
Tuple
{
Int64
,
Int64
}},
ad
::
AnnualDate
)
=
(
ad
.
month
,
ad
.
day
)
# allow creating AnnualDates from a string of the format "8 August"
AnnualDate
(
ad
::
String
)
=
AnnualDate
(
Date
(
ad
,
dateformat
"d U"
))
Base
.
convert
(
::
Type
{
AnnualDate
},
ad
::
String
)
=
AnnualDate
(
ad
)
Base
.
tryparse
(
::
Type
{
AnnualDate
},
ad
::
String
)
=
AnnualDate
(
ad
)
# Interface with Dates
AnnualDate
(
date
::
Date
)
=
AnnualDate
(
month
(
date
),
day
(
date
))
Base
.
convert
(
::
Type
{
AnnualDate
},
ad
::
Date
)
=
AnnualDate
(
ad
)
Dates
.
month
(
ad
::
AnnualDate
)
=
ad
.
month
Dates
.
day
(
ad
::
AnnualDate
)
=
ad
.
day
Dates
.
monthday
(
ad
::
AnnualDate
)
=
(
ad
.
month
,
ad
.
day
)
Date
(
year
::
Int64
,
ad
::
AnnualDate
)
=
Date
(
year
,
ad
.
month
,
ad
.
day
)
# Comparison between AnnualDates and with Dates
...
...
@@ -167,6 +170,19 @@ function bounds(x::Number; max::Number=Inf, min::Number=0)
x
end
"""
cycle!(vector, n=1)
Move the first element of the vector to the end, repeat n times.
"""
function
cycle!
(
v
::
AbstractVector
,
n
::
Int64
=
1
)
for
i
in
1
:
n
push!
(
v
,
v
[
1
])
deleteat!
(
v
,
1
)
end
v
end
"""
@areaof(npixels)
...
...
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