xarray-contrib/xarray-simlab

run step executed at specified times/steps only

jeanbraun opened this issue · 2 comments

Hello @benbovy. Is it possible to perform a run_step only at times/steps specified by a given clock? As an example, I need to compute an analytical solution to compare to a numerical solution. It is quite computationally demanding so I only want to compute it at the time steps given by an "out" clock and not the master clock.

Yes, it is possible, using on_demand variables.

Those variables have their own method, decorated with @my_var.compute, so each time they are accessed as attribute, the code within those methods is executed and a value is returned.

Then you could add those variables as output_vars in xsimlab.create_setup or Dataset.xsimlab.update_vars with any clock coordinate or None.

There is an example here.

@jeanbraun does on_demand variables fit your use case?

I'm going to close this issue, but feel free to re-open it if that's not the case.