8000 Add access to all master clock values in runtime context · Issue #155 · xarray-contrib/xarray-simlab · GitHub
[go: up one dir, main page]

Skip to content
Add access to all master clock values in runtime context #155
Closed
@benbovy

Description

@benbovy

(@jeanbraun's suggestion)

This could be useful, e.g., for vectorized computation of time-dependent values at the initialize stage, e.g.,

@xs.process
class SineForcing:
    amplitude = xs.variable()
    period = xs.variable()

    rate = xs.variable(dims='time')
    
    @xs.runtime(args='master_clock_values')
    def initialize(self, time):
        self.rate = (1 + self.amplitude + self.amplitude * np.sin(1 * np.pi * time / self.period))**5

One big problem, however, is that the rate variable in the example above should ideally have the same dimension label than the master clock dimension, but the latter is undefined (it is only known when running a model). We could define a specific placeholder, but it gets complicated...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0