so-wise / weddell_gyre_clusters

Unsupervised classification of Weddell Gyre profiles
MIT License
2 stars 1 forks source link

Calculate most common label in each grid cell #83

Closed DaniJonesOcean closed 2 years ago

DaniJonesOcean commented 2 years ago

This would be a good plot to help us see the overall structure. As confirmed in this Pangeo discussion thread, this is not currently possible with xarray:

https://discourse.pangeo.io/t/using-xhistogram-to-bin-measurements-at-particular-stations/2365

However, it may be possible with scipy. Here are some relevant threads that I found:

https://stackoverflow.com/questions/26971526/rebin-irregularly-gridded-data-to-regular-2d-grid-in-python-using-mean-median

https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.binned_statistic_2d.html

The mode is not yet a standard function in the scipy statistics. This is currently being worked on:

https://github.com/scipy/scipy/issues/14895

However, it looks like one can define a custom function for the mode, which could help us accomplish this.

DaniJonesOcean commented 2 years ago

This doesn't seem to be possible without considerable fuss. Closing for now. We'll go with the mean value, which is a little weird, but it produces okay results.