def importWells(path, grid, lst_domain, fac=1 / 365 / 86400, V_col="V Bancaris", layer=0): """ extract the infos about the uptake of water in wells path : path to the shp (multi points required) grid : the modelgrid fac : the factor to apply on the Volume to get m3/s V_col : the column name containing info about Volume layer : the layer on which the wells are active """ GDB = gp.read_file(path) stress_data_well = [] ix = GridIntersect(grid) for o in GDB.index: Vw = GDB[V_col][o] if not (np.isnan(Vw)) | (Vw == 0): try: cellidx = ix.intersect_point(GDB.geometry[o]).cellids[0][0] cellidy = ix.intersect_point(GDB.geometry[o]).cellids[0][1] cellid = (layer, cellidx, cellidy) if cellid in lst_domain: stress_data_well.append((cellid, -fac * Vw)) except: pass return stress_data_well
def test_rect_grid_point_outside(): # avoid test fail when shapely not available try: import shapely except: return gr = get_rect_grid() ix = GridIntersect(gr, method="structured") result = ix.intersect_point(Point(25., 25.)) assert len(result) == 0 return result
def test_rect_grid_point_outside_shapely(rtree=True): # avoid test fail when shapely not available try: import shapely except: return gr = get_rect_grid() ix = GridIntersect(gr, method='vertex', rtree=rtree) result = ix.intersect_point(Point(25., 25.)) assert len(result) == 0 return result
def test_point_offset_rot_structured_grid(): # avoid test fail when shapely not available try: import shapely except: return sgr = get_rect_grid(angrot=45., xyoffset=10.) p = Point(10., 10 + np.sqrt(200.)) ix = GridIntersect(sgr, method="structured") result = ix.intersect_point(p) # assert len(result) == 1. return result
def test_rect_grid_multipoint_in_one_cell_shapely(): # avoid test fail when shapely not available try: import shapely except: return gr = get_rect_grid() ix = GridIntersect(gr) result = ix.intersect_point(MultiPoint([Point(1., 1.), Point(2., 2.)])) assert len(result) == 1 assert result.cellids[0] == (1, 0) return result
def test_rect_grid_point_on_inner_boundary_shapely(): # avoid test fail when shapely not available try: import shapely except: return gr = get_rect_grid() ix = GridIntersect(gr) result = ix.intersect_point(Point(10., 10.)) assert len(result) == 1 assert np.all(result.cellids[0] == (0, 0)) return result
def test_rect_grid_point_on_outer_boundary(): # avoid test fail when shapely not available try: import shapely except: return gr = get_rect_grid() ix = GridIntersect(gr, method="structured") result = ix.intersect_point(Point(20., 10.)) assert len(result) == 1 assert np.all(result.cellids[0] == (0, 1)) return result
def test_tri_grid_point_outside(): # avoid test fail when shapely not available try: import shapely except: return gr = get_tri_grid(triangle_exe=triangle_exe) if gr == -1: return ix = GridIntersect(gr) result = ix.intersect_point(Point(25., 25.)) assert len(result) == 0 return result
def test_rect_grid_multipoint_in_multiple_cells(): # avoid test fail when shapely not available try: import shapely except: return gr = get_rect_grid() ix = GridIntersect(gr, method="structured") result = ix.intersect_point(MultiPoint([Point(1., 1.), Point(12., 12.)])) assert len(result) == 2 assert result.cellids[0] == (1, 0) assert result.cellids[1] == (0, 1) return result
def test_tri_grid_multipoint_in_one_cell(): # avoid test fail when shapely not available try: import shapely except: return gr = get_tri_grid(triangle_exe=triangle_exe) if gr == -1: return ix = GridIntersect(gr) result = ix.intersect_point(MultiPoint([Point(1., 1.), Point(2., 2.)])) assert len(result) == 1 assert result.cellids[0] == 1 return result
def test_tri_grid_point_on_inner_boundary(): # avoid test fail when shapely not available try: import shapely except: return gr = get_tri_grid(triangle_exe=triangle_exe) if gr == -1: return ix = GridIntersect(gr) result = ix.intersect_point(Point(10., 10.)) assert len(result) == 1 assert np.all(result.cellids[0] == 0) return result
def test_tri_grid_point_on_outer_boundary(rtree=True): # avoid test fail when shapely not available try: import shapely except: return gr = get_tri_grid() if gr == -1: return ix = GridIntersect(gr, rtree=rtree) result = ix.intersect_point(Point(20., 10.)) assert len(result) == 1 assert np.all(result.cellids[0] == 0) return result
def test_tri_grid_multipoint_in_multiple_cells(rtree=True): # avoid test fail when shapely not available try: import shapely except: return gr = get_tri_grid() if gr == -1: return ix = GridIntersect(gr, rtree=rtree) result = ix.intersect_point(MultiPoint([Point(1., 1.), Point(12., 12.)])) assert len(result) == 2 assert result.cellids[0] == 0 assert result.cellids[1] == 1 return result
def importWells3D(path, grid, lst_domain, fac=1 / 365 / 86400, V_col="V Bancaris", geol_col="NAPPE_CAPT", geol_layer=["PLIOCENE", "QUATERNAIRE"], layer_num=[1, 0]): """ extract the infos about the amount of water uptake by wells path : path to the shp (multi points required) grid : the modelgrid fac : the factor to transform volume units to get m3/s (depends of original units) V_col : the column name containing info about Volume geol_col = the column name containing geol infos geol_layer : the name of the differents lithology encountered layer_num : the num layer corresponding to the lithology in geol_layer """ ix = GridIntersect(grid) BD_prlvm = gp.read_file(path) stress_data_well = [] for ilayer in range(len(geol_layer)): # iterate through layers BD = BD_prlvm[BD_prlvm[geol_col] == geol_layer[ ilayer]] # only keep layers with the right geol for o in BD.index: #iterate through each well Vw = BD.loc[o, V_col] if not (np.isnan(Vw)) | (Vw == 0): #keep productive well cellidx = ix.intersect_point(BD.geometry[o]).cellids[0][0] cellidy = ix.intersect_point(BD.geometry[o]).cellids[0][1] cellid = (layer_num[ilayer], cellidx, cellidy ) #cell on which the well is active if cellid in lst_domain: # check if the well is in the domain stress_data_well.append((cellid, -fac * Vw)) return stress_data_well