Mimi Framework

Working with Dates time steps

Sorry to clog this forum. I have another question that is probably excessively simple, but I couldn’t find an answer on GitHub, docs, or this forum.

Is there a way to work with dates that aren’t integers? Here’s a simple example:

using Mimi
import Dates

ti = Dates.Date(2021, 1, 1)
tf = Dates.Date(2049, 12, 31)
Δt = Dates.Day(7)
times = ti:Δt:tf
NT = length(times)

m = Model()

The following does not work

set_dimension!(m, :time, times)

but this does

set_dimension!(m, :time, 1:1:NT)

It’s not a big issue, but it would be cool if explore(m) showed actual times rather than the index of time steps.

Thanks in advance!

No problem at all we are more than happy to get questions and comments @jdossgollin!

This is another thing that has come up before, and it’s a great comment. I know @davidanthoff has brought it up several times and I’m surprised I don’t have an issue up fo it … I’ll write that now and drop the link here.

As of now we don’t have a very clean way of using Dates instead of integers, but we should be able to use the Julia dispatching ability to allow you to use other types in your times dimension without too much trouble. That comes with the caveat that it’s never as simple as I hope it will be :). For now I can (1) add an issue to Mimi about enabling dates, and I can also probably add a keyword argument to explore in the near future that would let you override the time integers with provided Dates. I’ll put that in here Add units to explorer if and when they are provided · Issue #834 · mimiframework/Mimi.jl · GitHub since it’s a similar improvement to the explore function.

1 Like

Allow use of Dates for Time Dimension · Issue #840 · mimiframework/Mimi.jl · GitHub @davidanthoff any other comments here? I think this is something we’ve discussed a lot … worth at least scoping how we could do a first pass on this.

1 Like