'Convert 4D data array to CSV
I have a 4D data array that I want to save as a csv file, so I can compare it to another csv file that I have, generating an dispersion graph. I have seen that it is fairly easy to convert a 1D or 2D data array to a csv file, the trouble is to do it with a 4D array.
Another solution would be to drop 2 dimensions but I don't know if that is okay or if it would harm the file.
Here is the array that I'm having trouble with:
<xarray.DataArray 'rate' (time: 2, z: 1, y: 971, x: 1315)> dask.array<stack, shape=(2, 1, 971, 1315), dtype=float64, chunksize=(1, 1, 971, 1315), chunktype=numpy.ndarray>
Coordinates:
- time (time) datetime64[ns] 2022-04-03 2022-04-04
- x (x) float64 -63.64 -63.62 -63.6 -63.58 ... -37.4 -37.38 -37.36
- y (y) float64 -36.46 -36.44 -36.42 -36.4 ... -17.1 -17.08 -17.06
- z (z) float64 0.0
Thanks in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
