def test_Fstdc_ezgetlalo_KnownValues2(self): """Fstdc_ezgetlalo corners should give known result with known input""" (ni,nj) = self.la.shape grtyp='L' grref='L' (ig1,ig2,ig3,ig4) = Fstdc.cxgaig(grtyp,-69.5,180.0,0.5,0.5) hasAxes = 0 doCorners = 1 (i0,j0) = (0,0) (la2,lo2,cla2,clo2) = Fstdc.ezgetlalo((ni,nj),grtyp,(grref,ig1,ig2,ig3,ig4),(None,None),hasAxes,(i0,j0),doCorners) if numpy.any(self.la!=la2): print("\nLAT Expected:\n",self.la) print("LAT Got:\n",la2) if numpy.any(self.lo!=lo2): print("\nLON Expected:\n",self.lo) print("LON Got:\n",lo2) self.assertFalse(numpy.any(self.la!=la2)) self.assertFalse(numpy.any(self.lo!=lo2)) for ic in range(0,4): if numpy.any(self.cla[ic,...]!=cla2[ic,...]): print("\n",ic,'cla') print("LAT Expected:\n",self.cla[ic,...]) print("LAT Got:\n",cla2[ic,...]) self.assertFalse(numpy.any(self.cla[ic,...]!=cla2[ic,...])) if numpy.any(self.clo[ic,...]!=clo2[ic,...]): print("\n",ic,'clo') print("\nLON Expected:\n",self.clo[ic,...]) print("LON Got:\n",clo2[ic,...]) self.assertFalse(numpy.any(self.clo[ic,...]!=clo2[ic,...]))
def test_Fstdc_ezgetlalo_KnownValues2(self): """Fstdc_ezgetlalo corners should give known result with known input""" (ni,nj) = self.la.shape grtyp='L' grref='L' (ig1,ig2,ig3,ig4) = Fstdc.cxgaig(grtyp,-69.5,180.0,0.5,0.5) hasAxes = 0 doCorners = 1 (i0,j0) = (0,0) (la2,lo2,cla2,clo2) = Fstdc.ezgetlalo((ni,nj),grtyp,(grref,ig1,ig2,ig3,ig4),(None,None),hasAxes,(i0,j0),doCorners) if numpy.any(self.la!=la2): print "\nLAT Expected:\n",self.la print "LAT Got:\n",la2 if numpy.any(self.lo!=lo2): print "\nLON Expected:\n",self.lo print "LON Got:\n",lo2 self.assertFalse(numpy.any(self.la!=la2)) self.assertFalse(numpy.any(self.lo!=lo2)) for ic in range(0,4): if numpy.any(self.cla[ic,...]!=cla2[ic,...]): print "\n",ic,'cla' print "LAT Expected:\n",self.cla[ic,...] print "LAT Got:\n",cla2[ic,...] self.assertFalse(numpy.any(self.cla[ic,...]!=cla2[ic,...])) if numpy.any(self.clo[ic,...]!=clo2[ic,...]): print "\n",ic,'clo' print "\nLON Expected:\n",self.clo[ic,...] print "LON Got:\n",clo2[ic,...] self.assertFalse(numpy.any(self.clo[ic,...]!=clo2[ic,...]))
def test_Fstdc_ezgetlalo_KnownValues2(self): """Fstdc_ezgetlalo corners should give known result with known input""" (ni, nj) = self.la.shape grtyp = "L" grref = "L" (ig1, ig2, ig3, ig4) = Fstdc.cxgaig(grtyp, -89.5, 180.0, 0.5, 0.5) hasAxes = 0 doCorners = 1 (i0, j0) = (0, 0) (la2, lo2, cla2, clo2) = Fstdc.ezgetlalo( (ni, nj), grtyp, (grref, ig1, ig2, ig3, ig4), (None, None), hasAxes, (i0, j0), doCorners ) if numpy.any(self.la != la2): print self.la print la2 if numpy.any(self.lo != lo2): print self.lo print lo2 self.assertFalse(numpy.any(self.la != la2)) self.assertFalse(numpy.any(self.lo != lo2)) for ic in range(0, 4): if numpy.any(self.cla[ic, ...] != cla2[ic, ...]): print ic, "cla" print self.cla[ic, ...] print cla2[ic, ...] self.assertFalse(numpy.any(self.cla[ic, ...] != cla2[ic, ...])) if numpy.any(self.clo[ic, ...] != clo2[ic, ...]): print ic, "clo" print self.clo[ic, ...] print clo2[ic, ...] self.assertFalse(numpy.any(self.clo[ic, ...] != clo2[ic, ...]))
def gridL(self,dlalo=0.5,nij=10): """provide grid and rec values for other tests""" grtyp='L' grref=grtyp la0 = 0.-dlalo*(nij/2.) lo0 = 180.-dlalo*(nij/2.) ig14 = (ig1,ig2,ig3,ig4) = Fstdc.cxgaig(grtyp,la0,lo0,dlalo,dlalo) axes = (None,None) hasAxes = 0 ij0 = (1,1) doCorners = 0 (la,lo) = Fstdc.ezgetlalo((nij,nij),grtyp,(grref,ig1,ig2,ig3,ig4),axes,hasAxes,ij0,doCorners) return (grtyp,ig14,(nij,nij),la,lo)
def test_Fstdc_ezgetlalo_KnownValues(self): """Fstdc_ezgetlalo should give known result with known input""" (ni,nj) = self.la.shape grtyp='L' grref='L' (ig1,ig2,ig3,ig4) = Fstdc.cxgaig(grtyp,-69.5,180.0,0.5,0.5) hasAxes = 0 doCorners = 0 (i0,j0) = (0,0) (la2,lo2) = Fstdc.ezgetlalo((ni,nj),grtyp,(grref,ig1,ig2,ig3,ig4),(None,None),hasAxes,(i0,j0),doCorners) if numpy.any(self.la!=la2): print "\nLAT Expected:\n",self.la print "LAT Got:\n",la2 if numpy.any(self.lo!=lo2): print "\nLON Expected:\n",self.lo print "LON Got:\n",lo2 self.assertFalse(numpy.any(self.la!=la2)) self.assertFalse(numpy.any(self.lo!=lo2))
def test_Fstdc_ezgetlalo_Dieze_KnownValues(self): """Fstdc_ezgetlalo with #-grid should give known result with known input""" (ni,nj) = self.la.shape grtyp='#' grref='L' (ig1,ig2,ig3,ig4) = Fstdc.cxgaig(grref,0.,0.,1.,1.) xaxis = self.lo[:,0].reshape((self.lo.shape[0],1)).copy('FORTRAN') yaxis = self.la[0,:].reshape((1,self.la.shape[1])).copy('FORTRAN') hasAxes = 1 doCorners = 0 (i0,j0) = (2,2) (la2,lo2) = Fstdc.ezgetlalo((ni-1,nj-1),grtyp,(grref,ig1,ig2,ig3,ig4),(xaxis,yaxis),hasAxes,(i0,j0),doCorners) if numpy.any(self.la[1:,1:]!=la2): print "\nLAT Expected:\n",self.la[1:,1:] print "LAT Got:\n",la2 if numpy.any(self.lo[1:,1:]!=lo2): print "\nLON Expected:\n",self.lo[1:,1:] print "LON Got:\n",lo2 self.assertFalse(numpy.any(self.la[1:,1:]!=la2)) self.assertFalse(numpy.any(self.lo[1:,1:]!=lo2))
def test_Fstdc_ezgetlalo_Dieze_KnownValues(self): """Fstdc_ezgetlalo with #-grid should give known result with known input""" (ni,nj) = self.la.shape grtyp='#' grref='L' (ig1,ig2,ig3,ig4) = Fstdc.cxgaig(grref,0.,0.,1.,1.) xaxis = self.lo[:,0].reshape((self.lo.shape[0],1)).copy('FORTRAN') yaxis = self.la[0,:].reshape((1,self.la.shape[1])).copy('FORTRAN') hasAxes = 1 doCorners = 0 (i0,j0) = (2,2) (la2,lo2) = Fstdc.ezgetlalo((ni-1,nj-1),grtyp,(grref,ig1,ig2,ig3,ig4),(xaxis,yaxis),hasAxes,(i0,j0),doCorners) if numpy.any(self.la[1:,1:]!=la2): print("\nLAT Expected:\n",self.la[1:,1:]) print("LAT Got:\n",la2) if numpy.any(self.lo[1:,1:]!=lo2): print("\nLON Expected:\n",self.lo[1:,1:]) print("LON Got:\n",lo2) self.assertFalse(numpy.any(self.la[1:,1:]!=la2)) self.assertFalse(numpy.any(self.lo[1:,1:]!=lo2))
def test_Fstdc_ezgetlalo_KnownValues(self): """Fstdc_ezgetlalo should give known result with known input""" (ni, nj) = self.la.shape grtyp = 'L' grref = 'L' (ig1, ig2, ig3, ig4) = Fstdc.cxgaig(grtyp, -89.5, 180.0, 0.5, 0.5) hasAxes = 0 doCorners = 0 (i0, j0) = (0, 0) (la2, lo2) = Fstdc.ezgetlalo((ni, nj), grtyp, (grref, ig1, ig2, ig3, ig4), (None, None), hasAxes, (i0, j0), doCorners) if numpy.any(self.la != la2): print self.la print la2 if numpy.any(self.lo != lo2): print self.lo print lo2 self.assertFalse(numpy.any(self.la != la2)) self.assertFalse(numpy.any(self.lo != lo2))
def test_Fstdc_ezgetlalo_Dieze_KnownValues(self): """Fstdc_ezgetlalo with #-grid should give known result with known input""" (ni, nj) = self.la.shape grtyp = "#" grref = "L" (ig1, ig2, ig3, ig4) = Fstdc.cxgaig(grref, 0.0, 0.0, 1.0, 1.0) xaxis = self.lo[:, 0].reshape((self.lo.shape[0], 1)).copy("FORTRAN") yaxis = self.la[0, :].reshape((1, self.la.shape[1])).copy("FORTRAN") hasAxes = 1 doCorners = 0 (i0, j0) = (2, 2) (la2, lo2) = Fstdc.ezgetlalo( (ni - 1, nj - 1), grtyp, (grref, ig1, ig2, ig3, ig4), (xaxis, yaxis), hasAxes, (i0, j0), doCorners ) if numpy.any(self.la[1:, 1:] != la2): print self.la[1:, 1:] print la2 if numpy.any(self.lo[1:, 1:] != lo2): print self.lo[1:, 1:] print lo2 self.assertFalse(numpy.any(self.la[1:, 1:] != la2)) self.assertFalse(numpy.any(self.lo[1:, 1:] != lo2))
def test_Fstdc_ezgetlalo_Z_KnownValues(self): """Fstdc_ezgetlalo with Z grid should give known result with known input""" (ni, nj) = self.la.shape grtyp = 'Z' grref = 'L' (ig1, ig2, ig3, ig4) = Fstdc.cxgaig(grref, 0., 0., 1., 1.) xaxis = self.lo[:, 0].reshape((self.lo.shape[0], 1)).copy('FORTRAN') yaxis = self.la[0, :].reshape((1, self.la.shape[1])).copy('FORTRAN') hasAxes = 1 doCorners = 0 (i0, j0) = (0, 0) (la2, lo2) = Fstdc.ezgetlalo( (ni, nj), grtyp, (grref, ig1, ig2, ig3, ig4), (xaxis, yaxis), hasAxes, (i0, j0), doCorners) if numpy.any(self.la != la2): print self.la print la2 if numpy.any(self.lo != lo2): print self.lo print lo2 self.assertFalse(numpy.any(self.la != la2)) self.assertFalse(numpy.any(self.lo != lo2))