Index: wflow-py/wflow/wf_netcdfio.py =================================================================== diff -u -raf5c39b352c0046cc325e955dae7b0fc2854e038 -ra60252674c7e7ee5a5f6016dd1117b6e6593bda8 --- wflow-py/wflow/wf_netcdfio.py (.../wf_netcdfio.py) (revision af5c39b352c0046cc325e955dae7b0fc2854e038) +++ wflow-py/wflow/wf_netcdfio.py (.../wf_netcdfio.py) (revision a60252674c7e7ee5a5f6016dd1117b6e6593bda8) @@ -449,6 +449,16 @@ self.fstep = 0 self.lstep = self.fstep + self.maxsteps + self.datetime = self.dataset.variables['time'][:] + if hasattr(self.dataset.variables['time'],'units'): + self.timeunits=self.dataset.variables['time'].units + else: + self.timeunits ='Seconds since 1970-01-01 00:00:00' + if hasattr(self.dataset.variables['time'], 'calendar'): + self.calendar= self.dataset.variables['time'].calendar + else: + self.calendar ='gregorian' + self.datetimelist=netCDF4.num2date(self.datetime,self.timeunits, calendar=self.calendar) try: self.x = self.dataset.variables['x'][:] @@ -502,14 +512,15 @@ - def gettimestep(self, timestep, logging, var='P', shifttime=False): + def gettimestep(self, timestep, logging, tsdatetime=None, var='P', shifttime=False): """ Gets a map for a single timestep. reads data in blocks assuming sequential access :var timestep: framework timestep (1-based) :var logging: python logging object :var var: variable to get from the file :var shifttime: is True start at 1 in the NC file (instead of 0) + :var tsdatetime: Assumed date/time of this timestep window = data[dpos,latidx.min():latidx.max()+1,lonidx.min():lonidx.max()+1] @@ -519,6 +530,10 @@ else: ncindex = timestep - 1 + if tsdatetime != None: + if tsdatetime != self.datetimelist[ncindex]: + logging.warn("Date/time does not match. Wanted " + str(tsdatetime) + " got " + str(self.datetimelist[ncindex])) + if self.alldat.has_key(var): if ncindex == self.lstep: # Read new block of data in mem logging.debug("reading new netcdf data block starting at: " + str(ncindex))