Index: wflow-py/wflow/wf_netcdfio.py =================================================================== diff -u -r4143969ebd6b276284ea6e4198ee693bd6ab506a -r2be60229fcd380064e761636569c4611a665d8d8 --- wflow-py/wflow/wf_netcdfio.py (.../wf_netcdfio.py) (revision 4143969ebd6b276284ea6e4198ee693bd6ab506a) +++ wflow-py/wflow/wf_netcdfio.py (.../wf_netcdfio.py) (revision 2be60229fcd380064e761636569c4611a665d8d8) @@ -408,9 +408,7 @@ """ if hasattr(self, "nc_trg"): if self.bufferdirty: - self.logger.warn( - "Finishing before expected run-length exceeded. Buffer not flushed" - ) + self.logger.warning("Finishing before expected run-length exceeded. Buffer not flushed") self.nc_trg.sync() self.nc_trg.close() @@ -719,10 +717,9 @@ self.alldat[var] = self.dataset.variables[var] except: self.alldat.pop(var, None) - logging.warn( - "Variable " + var + " not found in netcdf file: " + netcdffile - ) + logging.warning("Variable " + var + " not found in netcdf file: " + netcdffile) + 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 @@ -750,34 +747,18 @@ ncindex = self.datetimelist.size - 1 if tsdatetime != None: - if tsdatetime.replace(tzinfo=None) != self.datetimelist[ncindex].replace( - tzinfo=None - ): - logging.warn( - "Date/time does not match. Wanted " - + str(tsdatetime) - + " got " - + str(self.datetimelist[ncindex]) - ) + if tsdatetime.replace(tzinfo=None) != self.datetimelist[ncindex].replace(tzinfo=None): + logging.warning("Date/time does not match. Wanted " + str(tsdatetime) + " got " + str(self.datetimelist[ncindex])) import bisect pos = bisect.bisect_left( self.datetimelist, tsdatetime.replace(tzinfo=None) ) if pos >= self.datetimelist.size: - pos = self.datetimelist.size - 1 - logging.warn( - "No matching date/time found using last date/time again..." - ) + pos = self.datetimelist.size -1 + logging.warning("No matching date/time found using last date/time again...") self.offset = pos - ncindex - logging.warn( - "Adjusting to the date/time at index and setting offset: " - + str(pos) - + ":" - + str(self.offset) - + ":" - + str(self.datetimelist[pos]) - ) + logging.warning("Adjusting to the date/time at index and setting offset: " + str(pos) + ":" + str(self.offset) + ":" + str(self.datetimelist[pos])) ncindex = pos @@ -933,9 +914,7 @@ ] except: self.alldat.pop(var, None) - logging.warn( - "Variable " + var + " not found in netcdf file: " + netcdffile - ) + logging.warning("Variable " + var + " not found in netcdf file: " + netcdffile) def gettimestep(self, timestep, logging, var="P", tsdatetime=None): """ @@ -949,25 +928,11 @@ if var in self.dataset.variables: if tsdatetime != None: - if tsdatetime.replace(tzinfo=None) != self.datetimelist[ - ncindex - ].replace(tzinfo=None): - logging.warn( - "Date/time of state (" - + var - + " in " - + self.fname - + ")does not match. Wanted " - + str(tsdatetime) - + " got " - + str(self.datetimelist[ncindex]) - ) + if tsdatetime.replace(tzinfo=None) != self.datetimelist[ncindex].replace(tzinfo=None): + logging.warning("Date/time of state (" + var + " in " + self.fname + ")does not match. Wanted " + str(tsdatetime) + " got " + str(self.datetimelist[ncindex])) - np_step = self.dataset.variables[var][ - ncindex, - self.latidx.min() : self.latidx.max() + 1, - self.lonidx.min() : self.lonidx.max() + 1, - ] + np_step = self.dataset.variables[var][ncindex, self.latidx.min():self.latidx.max() + 1, + self.lonidx.min():self.lonidx.max() + 1] miss = float(self.dataset.variables[var]._FillValue) return numpy2pcr(Scalar, np_step, miss), True