/[escript]/trunk/downunder/test/python/run_datasources.py
ViewVC logotype

Diff of /trunk/downunder/test/python/run_datasources.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4004 by caltinay, Sun Sep 23 23:24:37 2012 UTC revision 4005 by caltinay, Fri Sep 28 06:09:03 2012 UTC
# Line 56  VMIN=-10000. Line 56  VMIN=-10000.
56  VMAX=10000  VMAX=10000
57  NE_V=15  NE_V=15
58  ALT=0.  ALT=0.
59  PAD_XY=7  PAD_X=7
60  PAD_Z=3  PAD_Y=7
61    
62  class TestERSDataSource(unittest.TestCase):  class TestERSDataSource(unittest.TestCase):
63      def test_ers_with_padding(self):      def test_ers_with_padding(self):
64          source = ERSDataSource(headerfile=ERS_DATA, vertical_extents=(VMIN,VMAX,NE_V), alt_of_data=ALT)          source = ERSDataSource(headerfile=ERS_DATA, vertical_extents=(VMIN,VMAX,NE_V), alt_of_data=ALT)
65          source.setPadding(PAD_XY,PAD_Z)          source.setPadding(PAD_X,PAD_Y)
66          dom=source.getDomain()          dom=source.getDomain()
67          g,s=source.getGravityAndStdDev()          g,s=source.getGravityAndStdDev()
68    
# Line 78  class TestERSDataSource(unittest.TestCas Line 78  class TestERSDataSource(unittest.TestCas
78          #self.assertAlmostEqual(X0, ERS_ORIGIN, msg="Data origin wrong")          #self.assertAlmostEqual(X0, ERS_ORIGIN, msg="Data origin wrong")
79    
80          # check data          # check data
81          nx=NP[0]+2*PAD_XY          nx=NP[0]+2*PAD_X
82          ny=NP[1]+2*PAD_XY          ny=NP[1]+2*PAD_Y
83          nz=NE_V+2*PAD_Z          nz=NE_V
84          z_data=int(np.round((ALT-V0)/DV)-1+PAD_Z)          z_data=int(np.round((ALT-V0)/DV)-1)
85    
86          ref=np.genfromtxt(ERS_REF, delimiter=',', dtype=float)          ref=np.genfromtxt(ERS_REF, delimiter=',', dtype=float)
87          g_ref=ref[:,0].reshape(NP)          g_ref=ref[:,0].reshape(NP)
# Line 94  class TestERSDataSource(unittest.TestCas Line 94  class TestERSDataSource(unittest.TestCas
94          s_out=out[:,1].reshape(nz,ny,nx)          s_out=out[:,1].reshape(nz,ny,nx)
95    
96          self.assertAlmostEqual(np.abs(          self.assertAlmostEqual(np.abs(
97              g_out[z_data,PAD_XY:PAD_XY+NP[1],PAD_XY:PAD_XY+NP[0]]-g_ref).max(),              g_out[z_data,PAD_Y:PAD_Y+NP[1],PAD_X:PAD_X+NP[0]]-g_ref).max(),
98              0., msg="Difference in data area")              0., msg="Difference in data area")
99    
100          # overwrite data -> should only be padding value left          # overwrite data -> should only be padding value left
101          g_out[z_data, PAD_XY:PAD_XY+NP[0], PAD_XY:PAD_XY+NP[0]]=ERS_NULL          g_out[z_data, PAD_Y:PAD_Y+NP[1], PAD_X:PAD_X+NP[0]]=ERS_NULL
102          self.assertAlmostEqual(np.abs(g_out-ERS_NULL).max(), 0.,          self.assertAlmostEqual(np.abs(g_out-ERS_NULL).max(), 0.,
103                  msg="Wrong values in padding area")                  msg="Wrong values in padding area")
104    

Legend:
Removed from v.4004  
changed lines
  Added in v.4005

  ViewVC Help
Powered by ViewVC 1.1.26