import netCDF4
import numpy as np
def start_stop(url,tvar):
nc = netCDF4.Dataset(url)
ncv = nc.variables
time_var = ncv[tvar]
first = netCDF4.num2date(time_var[0],time_var.units)
last = netCDF4.num2date(time_var[-1],time_var.units)
print(first.strftime('%Y-%b-%d %H:%M'))
print(last.strftime('%Y-%b-%d %H:%M'))
url='http://hfrnet.ucsd.edu/thredds/dodsC/HFR/USWC/6km/hourly/RTV/HFRADAR,_US_West_Coast,_6km_Resolution,_Hourly_RTV_best.ncd'
tvar='time'
start_stop(url,tvar)
2011-Oct-01 00:00 2016-Aug-12 16:00
nc = netCDF4.Dataset(url)
ncv = nc.variables
t = ncv[tvar][:]
print(ncv[tvar].units)
hours since 2011-10-01T00:00:00Z
Calculate the average time step
print np.mean(np.diff(t))
1.00136131061
So we have time steps of about 1 hour
Now calculate the unique time steps
print(np.unique(np.diff(t)).data)
[ 1. 2. 3. 6. 9. 10. 14. 19.]
So there are gaps of 2, 3, 6, 9, 10, 14 and 19 hours in the otherwise hourly data