NVIDIA / earth2studio

Open-source deep-learning framework for exploring, building and deploying AI weather/climate workflows.
https://nvidia.github.io/earth2studio/
Apache License 2.0
73 stars 23 forks source link

🐛[BUG]: LaggedEnsemble overwrite input data #75

Closed dallasfoster closed 2 months ago

dallasfoster commented 2 months ago

Version

main

On which installation method(s) does this occur?

Source

Describe the issue

In earth2studio.perturbations.lagged, the LaggedEnsemble perturbation strategy overwrite the passed data array,

x[i] = fetch_data(
                source=self.source,
                time=coords["time"] + lag,
                variable=coords["variable"],
                lead_time=coords["lead_time"],
                device=x.device,
            )[0]

This can lead to bugs if the input array is reused in another perturbation strategy. We propose the following fix:

y = torch.clone(x)
        for i, lag in enumerate(self.lags):
            y[i] = fetch_data(
                source=self.source,
                time=coords["time"] + lag,
                variable=coords["variable"],
                lead_time=coords["lead_time"],
                device=y.device,
            )[0]