add tmp file write/read step#358
Conversation
|
@erikvansebille, initial experimentation shows that the tmp file performance fix is indeed a simple implementation and substantially improves actual computation performance, but the tradeoff here is a slow-down by the fact that VirtualShip, in most cases, calls to global datasets from In the case of e.g. a Drifter simulation the A def _via_tmp_ds(self, ds) -> xr.Dataset:
"""Create and re-load a temporary local dataset."""
tmpdir = tempfile.TemporaryDirectory()
tmp_fpath = Path(tmpdir.name).joinpath("tmp.nc")
# reduce dataset to smaller spatial window to reduce filesize
HALO_DEGREES = 20.0 # TODO ...arbitrary but want a healthy buffer for drifters
ds_minimised = ds.sel(
lat=slice(self.min_lat - HALO_DEGREES, self.max_lat + HALO_DEGREES),
lon=slice(self.min_lon - HALO_DEGREES, self.max_lon + HALO_DEGREES),
)
ds_minimised.to_netcdf(tmp_fpath)
del ds, ds_minimised
return xr.open_dataset(tmp_fpath)I'll experiment further with file size reduction strategies (e.g. at the Of course the motivation for calling to global datasets in the first place was to avoid any risk of out of bounds errors so that will also be a priority. |
Following up on this, the file writing speeds don't appear to be overwhelmingly tied to the the spatial extent of the requested ds, in fact they appear more sensitive to the temporal extent (perhaps to do with chunking strategy somewhere on the Performance for other instruments, such as CTDs and Argo Floats, is pretty good relative to using Parcels v3 though. So, overall, it's promising and it appears that it's just Drifters which slow down (a bit but not massively) relative to v3. |
|
I think it would probably be a good idea to reduce the file sizes for Drifter simulations, even if just tmp files, because ~6GB global datasets feel a bit unnecessary and potentially problematic. Even adding a generous spatial buffer (+/- 30 degrees) would reduce the size substantially whilst avoiding out of bounds errors in nearly all cases. This would effectively create a hard limit on lifetimes (velocity dependent) but perhaps a necessary (temporary) trade-off for now. Also, at least this wouldn't crash the simulations, as of #348... What do you think @erikvansebille? |
DRAFT
This PR implements a write-to-tmp files step, to improve performance for Parcels v4 fieldset ingestion combined with copernicusmarine streaming (i.e. #357).