Hi,

I have the following dataset:

<xarray.DataArray 'tp_climatology_mean' (dayofyear: 366, lat: 21, lon: 21)>
[161406 values with dtype=float32]
Coordinates:
    realization  int64 ...
  * lat          (lat) float64 -2.0 -1.9 -1.8 -1.7 -1.6 ... -0.3 -0.2 -0.1 0.0
  * lon          (lon) float64 34.0 34.1 34.2 34.3 34.4 ... 35.7 35.8 35.9 36.0
  * dayofyear    (dayofyear) int64 1 2 3 4 5 6 7 ... 360 361 362 363 364 365 366
Attributes:
    units:    m

Would it be possible to find the dayofyear where the value is smallest/largest for each grid cell? I can find the minimum/maximum value but I can't find the day of this value.

Thank you.


4 Comments

  1. Hi Sophie,

    You should be able to identify the index of the minimum values for each grid cell using ct.cube.argmin.

    You can either get the index or the coordinate value (time) at which the minimum is reached by using the keyword 'coords'.

    Let me know if you need any further help.

    Regards.

    Vivien

  2. Hi Vivien,

    Thank you! This is helping a lot.

    Kind regards,

    Sophie

  3. Hi Vivien,


    I have a follow up question on this topic. I am now trying to plot these coordinate values on a map. However, I am getting the following error: 'NoneType' object is not subscriptable.

    This is the link to the script: https://cds.climate.copernicus.eu/toolbox-editor/56145/working-onset-small-grid


    Do you know how I can solve this?


    Kind regards,

    Sophie

    1. Hi Sophie,

      Thank you  again for flagging this issue up. I have managed to reproduce the error and will investigate and try to resolve this bug.

      Best regards.

      Vivien