Index: wflow-py/wflow/wf_netcdfio.py =================================================================== diff -u -rb0c9e960073cc20f9940d562bb83cea15206b118 -r036ea699f3b9e9fe82ce54ea08b6fc94990408f2 --- wflow-py/wflow/wf_netcdfio.py (.../wf_netcdfio.py) (revision b0c9e960073cc20f9940d562bb83cea15206b118) +++ wflow-py/wflow/wf_netcdfio.py (.../wf_netcdfio.py) (revision 036ea699f3b9e9fe82ce54ea08b6fc94990408f2) @@ -478,10 +478,21 @@ x = _pcrut.pcr2numpy(_pcrut.xcoordinate(_pcrut.boolean(_pcrut.cover(1.0))), NaN)[0, :] y = _pcrut.pcr2numpy(_pcrut.ycoordinate(_pcrut.boolean(_pcrut.cover(1.0))), NaN)[:, 0] - (self.latidx,) = logical_and(self.y >= y.min(), self.y <= y.max()).nonzero() - (self.lonidx,) = logical_and(self.x >= x.min(), self.x <= x.max()).nonzero() + #Get average cell size + acc = diff(x).mean() * 0.25 + if self.flip: + (self.latidx,) = logical_and(self.y[::-1] +acc >= y.min(), self.y[::-1] <= y.max() + acc).nonzero() + (self.lonidx,) = logical_and(self.x + acc >= x.min(), self.x <= x.max() + acc).nonzero() + else: + (self.latidx,) = logical_and(self.y +acc >= y.min(), self.y <= y.max() + acc).nonzero() + (self.lonidx,) = logical_and(self.x +acc >= x.min(), self.x <= x.max() + acc).nonzero() + if len(self.lonidx) != len(x): + logging.error("error in determining X coordinates in netcdf...") + if len(self.latidx) != len(y): + logging.error("error in determining X coordinates in netcdf...") + for var in vars: try: self.alldat[var] = self.dataset.variables[var][self.fstep:self.maxsteps]