coecms / xmhw

Xarray version of Marine Heatwaves code by Eric Olivier
https://xmhw.readthedocs.io/en/latest/
Apache License 2.0
22 stars 10 forks source link

`cell`stacking if data is only 2 dimensional (e.g. time, depth) #64

Open florianboergel opened 1 year ago

florianboergel commented 1 year ago

This must be verified, but I encountered problems when analyzing stational data with a depth dimension. I had to adjust the code like this to make it work

For example, in threshold()


    if point:
        ds["thresh"] = thresh_results[0]
        ds["seas"] = seas_results[0]
    else:
        ds["thresh"] = xr.concat(results[0], dim='cell')
        ds["seas"] = xr.concat(results[1], dim='cell')
        dims = [k for k in ts.cell.coords.keys()]
        if len(dims) == 1: # This would be equal to time and another dimension
            ds = ds.swap_dims({"cell":dims[0]})
            ds = ds.transpose("doy", dims[0])
        else:
            ds = ds.set_xindex(dims)
            ds = ds.unstack(dim='cell')

The same applies to the detect() function.

paolap commented 1 year ago

Can you give me more details? i.e. the data structure, how did you call it and the error message?