sunpy / ndcube

A base package for multi-dimensional contiguous and non-contiguous coordinate-aware arrays.
http://docs.sunpy.org/projects/ndcube/
BSD 2-Clause "Simplified" License
44 stars 48 forks source link

Add a way of setting `.data` #779

Open Cadair opened 1 week ago

Cadair commented 1 week ago

Describe the feature

I frequently have the case when working with DKIST data that I want to in-place compute the dask array, i.e. this:

spatial_avg = visp.rebin((-1, 1, -1), ).squeeze()
spatial_avg._data = spatial_avg.data.compute()

it would be nice if I didn't have to use ._data.

Proposed solution

Add a setter for .data which validates the new array is the same shape as the old array.