I'm guessing there are a number of ways of doing this - but any guidance appreciated. I have a netcdf file of temperature (x,y,t) and essentially want to return the time rank for each x,y position for each year.
So for example: for the x,y location (1,1) at time=1 I'm comparing the x,y=(1,1) value at time 0 to the end of the file and ranking where time=1 sits. Say it's second highest value at x,y=(1,1) of all the times, then my new array at (1,1,1) would return a value of 2 here.
I've searched to see if cdo can do something like this but haven't been able to find anything: could this be done easily in pandas or xarray?
Managed tp sort it out myself:
import numpy as np
import matplotlib.pyplot as plt
import xarray as xr
sst = xr.open_dataset("/data/sst/oisst/daily/8jun_sst.nc")
test=sst.rank("time")
....which gives me rank along the time axis such that each time slice ends up with the rank of variable along time axis for each x,y position. Much easier than I thought!