# - self.mask should be a raster # - grid.clip_to should be able to take a raster (use _input_handler) current_dir = os.path.dirname(os.path.realpath(__file__)) data_dir = os.path.abspath(os.path.join(current_dir, '../data')) dir_path = os.path.join(data_dir, 'dir.asc') dem_path = os.path.join(data_dir, 'dem.tif') roi_path = os.path.join(data_dir, 'roi.tif') eff_path = os.path.join(data_dir, 'eff.tif') dinf_eff_path = os.path.join(data_dir, 'dinf_eff.tif') # Initialize grid grid = Grid() crs = pyproj.Proj('epsg:4326', preserve_units=True) grid.read_ascii(dir_path, 'dir', dtype=np.uint8, crs=crs) grid.read_raster(dem_path, 'dem') grid.read_raster(roi_path, 'roi') grid.read_raster(eff_path, 'eff') grid.read_raster(dinf_eff_path, 'dinf_eff') # set nodata to 1 # why is that not working with grid.view() in test_accumulation? #grid.eff[grid.eff==grid.eff.nodata] = 1 #grid.dinf_eff[grid.dinf_eff==grid.dinf_eff.nodata] = 1 # Initialize parameters dirmap = (64, 128, 1, 2, 4, 8, 16, 32) acc_in_frame = 76499 acc_in_frame_eff = 76498 # max value with efficiency acc_in_frame_eff1 = 19125.5 # accumulation for raster cell with acc_in_frame with transport efficiency cells_in_catch = 11422 catch_shape = (159, 169)
from pysheds.grid import Grid # TODO: Major todo's # - self.mask should be a raster # - grid.clip_to should be able to take a raster (use _input_handler) current_dir = os.path.dirname(os.path.realpath(__file__)) data_dir = os.path.abspath(os.path.join(current_dir, '../data')) dir_path = os.path.join(data_dir, 'dir.asc') dem_path = os.path.join(data_dir, 'dem.tif') # Initialize grid grid = Grid() crs = pyproj.Proj('+init=epsg:4326', preserve_units=True) grid.read_ascii(dir_path, 'dir', dtype=np.uint8, crs=crs) grid.read_raster(dem_path, 'dem') # Initialize parameters dirmap = (64, 128, 1, 2, 4, 8, 16, 32) acc_in_frame = 76499 cells_in_catch = 11422 catch_shape = (159, 169) max_distance = 209 new_crs = pyproj.Proj('+init=epsg:3083') old_crs = pyproj.Proj('+init=epsg:4326', preserve_units=True) x, y = -97.29416666666677, 32.73749999999989 # TODO: Need to test dtypes of different constructor methods def test_constructors(): newgrid = grid.from_ascii(dir_path, 'dir', dtype=np.uint8, crs=crs) assert ((newgrid.dir == grid.dir).all())