I have a netCDF file with 2544 time step (daily, 06-08-2014 to 24-07-2021), I want to find the time step corresponding to the date 25-Aug-2018
What I have tried:
import netCDF4
from netCDF4 import num2date, date2num, date2index
import numpy as np
f=netCDF4.Dataset('/../t.cdf')
times=f.variables['time']
dates = num2date(times[:], times.units)
print(dates.index(datetime.dates(2018, 8, 25)))