def test_1d_levee_bathy(self):
        """test load"""
        mdu = self._mdu_path('testcase_1d_levee')
        with SubgridWrapper(mdu=mdu) as subgrid:
            logger.info("loaded 1d levee testcase")
            for i in xrange(100):
                subgrid.update(-1)
            mode = 1
            value = 30
            size = 45.0
            xc = 147790
            yc = 527080
            node = 231
            dps_pre = subgrid.get_nd('dps').copy()
            subgrid.changebathy(xc, yc, size, value, mode)
            dps_post = subgrid.get_nd('dps').copy()

            quad_grid = make_quad_grid(subgrid)
            nods = set(quad_grid[100:110, 100:110].ravel())
            dps_pre = subgrid.get_nd('dps')
            dps_pre[100:110, 100:110] = dps_pre[100:110, 100:110] + 5.0

            subgrid.update_tables('dps', list(nods))
            for i in xrange(100):
                subgrid.update(-1)
            dps_post = subgrid.get_nd('dps').copy()
            npt.assert_allclose(dps_post, dps_pre, rtol=0.01)
Esempio n. 2
0
    def test_1d_levee_bathy(self):
        """test load"""
        mdu = self._mdu_path('testcase_1d_levee')
        with SubgridWrapper(mdu=mdu) as subgrid:
            logger.info("loaded 1d levee testcase")
            for i in xrange(100):
                subgrid.update(-1)
            mode = 1
            value = 30
            size = 45.0
            xc = 147790
            yc = 527080
            node = 231
            dps_pre = subgrid.get_nd('dps').copy()
            subgrid.changebathy(xc, yc, size, value, mode)
            dps_post = subgrid.get_nd('dps').copy()

            quad_grid = make_quad_grid(subgrid)
            nods = set(quad_grid[100:110, 100:110].ravel())
            dps_pre = subgrid.get_nd('dps')
            dps_pre[100:110, 100:110] = dps_pre[100:110, 100:110] + 5.0

            subgrid.update_tables('dps', list(nods))
            for i in xrange(100):
                subgrid.update(-1)
            dps_post = subgrid.get_nd('dps').copy()
            npt.assert_allclose(dps_post, dps_pre, rtol=0.01)
Esempio n. 3
0
 def test_draw_and_update_tables(self):
     geom_json = """
     { "type": "Polygon", "coordinates": [ [
         [ 81015.066359097298118, 440929.453467557614204 ],
         [ 81117.980358958055149, 440700.214556140999775 ],
         [ 81166.972951597010251, 440713.396766208577901 ],
         [ 81133.564320785750169, 440811.235749009530991 ],
         [ 81090.294539064285345, 440949.198693339480087 ],
         [ 81015.066359097298118, 440929.453467557614204 ]
     ] ] }
     """
     with SubgridWrapper(mdu=self._mdu_path('duifp')) as subgrid:
         subgrid.update(-1)
         x0 = subgrid.get_nd('x0p')
         x1 = subgrid.get_nd('x1p')
         y0 = subgrid.get_nd('y0p')
         y1 = subgrid.get_nd('y1p')
         raster = subgrid.get_nd('soiltype')
         if raster is None:
             raise ValueError("Make sure you are testing with a model " +
                              "with soiltype + numlayers > 0")
         rr, cc = draw_shape_on_raster(geom_json,
                                       raster,
                                       21,
                                       extent=(x0, y0, x1, y1))
         quad_grid = make_quad_grid(subgrid)
         quad_cells = set(quad_grid[row, col] for row, col in zip(rr, cc))
         subgrid.update_tables('soiltype', quad_cells)
         # TODO: create proper assert, what should we check here.
         self.assertGreater(len(quad_cells), 5)
Esempio n. 4
0
 def test_draw_and_update_tables(self):
     geom_json = """
     { "type": "Polygon", "coordinates": [ [
         [ 81015.066359097298118, 440929.453467557614204 ],
         [ 81117.980358958055149, 440700.214556140999775 ],
         [ 81166.972951597010251, 440713.396766208577901 ],
         [ 81133.564320785750169, 440811.235749009530991 ],
         [ 81090.294539064285345, 440949.198693339480087 ],
         [ 81015.066359097298118, 440929.453467557614204 ]
     ] ] }
     """
     with SubgridWrapper(mdu=self._mdu_path('duifp')) as subgrid:
         subgrid.update(-1)
         x0 = subgrid.get_nd('x0p')
         x1 = subgrid.get_nd('x1p')
         y0 = subgrid.get_nd('y0p')
         y1 = subgrid.get_nd('y1p')
         raster = subgrid.get_nd('soiltype')
         if raster is None:
             raise ValueError("Make sure you are testing with a model " +
                              "with soiltype + numlayers > 0")
         rr, cc = draw_shape_on_raster(geom_json,
                                       raster,
                                       21,
                                       extent=(x0, y0, x1, y1))
         quad_grid = make_quad_grid(subgrid)
         quad_cells = set(quad_grid[row, col] for row, col in zip(rr, cc))
         subgrid.update_tables('soiltype', quad_cells)
         # TODO: create proper assert, what should we check here.
         self.assertGreater(len(quad_cells), 5)