Skip to content

Commit

Permalink
Merge pull request #170 from mdbartos/numba
Browse files Browse the repository at this point in the history
Add iterative versions of recursive numba functions
  • Loading branch information
mdbartos authored Jan 13, 2022
2 parents 9d88960 + 7463fa2 commit 185837c
Show file tree
Hide file tree
Showing 7 changed files with 583 additions and 138 deletions.
2 changes: 1 addition & 1 deletion pysheds/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3"
__version__ = "0.3.1"
315 changes: 296 additions & 19 deletions pysheds/_sgrid.py

Large diffs are not rendered by default.

28 changes: 18 additions & 10 deletions pysheds/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ def read_raster(data, band=1, window=None, window_crs=None, mask_geometry=False,

def to_ascii(data, file_name, target_view=None, delimiter=' ', fmt=None,
interpolation='nearest', apply_input_mask=False,
apply_output_mask=True, affine=None, shape=None, crs=None,
mask=None, nodata=None, dtype=None, **kwargs):
apply_output_mask=True, inherit_nodata=True, affine=None,
shape=None, crs=None, mask=None, nodata=None, dtype=None,
**kwargs):
"""
Writes a Raster object to a formatted ascii text file.
Expand All @@ -174,6 +175,9 @@ def to_ascii(data, file_name, target_view=None, delimiter=' ', fmt=None,
If True, mask the input Raster according to data.mask.
apply_output_mask : bool
If True, mask the output Raster according to target_view.mask.
inherit_nodata : bool
If True, output ascii inherits `nodata` value from `data`.
If False, output ascii uses `nodata` value from `target_view`.
affine : affine.Affine
Affine transformation matrix (overrides target_view.affine)
shape : tuple of ints (length 2)
Expand All @@ -193,9 +197,9 @@ def to_ascii(data, file_name, target_view=None, delimiter=' ', fmt=None,
target_view = data.viewfinder
data = View.view(data, target_view, interpolation=interpolation,
apply_input_mask=apply_input_mask,
apply_output_mask=apply_output_mask, affine=affine,
shape=shape, crs=crs, mask=mask, nodata=nodata,
dtype=dtype)
apply_output_mask=apply_output_mask,
inherit_nodata=inherit_nodata, affine=affine, shape=shape,
crs=crs, mask=mask, nodata=nodata, dtype=dtype)
try:
assert (abs(data.affine.a) == abs(data.affine.e))
except:
Expand Down Expand Up @@ -225,8 +229,9 @@ def to_ascii(data, file_name, target_view=None, delimiter=' ', fmt=None,

def to_raster(data, file_name, target_view=None, profile=None, blockxsize=256,
blockysize=256, interpolation='nearest', apply_input_mask=False,
apply_output_mask=True, affine=None, shape=None, crs=None,
mask=None, nodata=None, dtype=None, **kwargs):
apply_output_mask=True, inherit_nodata=True, affine=None,
shape=None, crs=None, mask=None, nodata=None, dtype=None,
**kwargs):
"""
Writes gridded data to a raster.
Expand All @@ -251,6 +256,9 @@ def to_raster(data, file_name, target_view=None, profile=None, blockxsize=256,
If True, mask the input Raster according to data.mask.
apply_output_mask : bool
If True, mask the output Raster according to target_view.mask.
inherit_nodata : bool
If True, output Raster inherits `nodata` value from `data`.
If False, output Raster uses `nodata` value from `target_view`.
affine : affine.Affine
Affine transformation matrix (overrides target_view.affine)
shape : tuple of ints (length 2)
Expand All @@ -268,9 +276,9 @@ def to_raster(data, file_name, target_view=None, profile=None, blockxsize=256,
target_view = data.viewfinder
data = View.view(data, target_view, interpolation=interpolation,
apply_input_mask=apply_input_mask,
apply_output_mask=apply_output_mask, affine=affine,
shape=shape, crs=crs, mask=mask, nodata=nodata,
dtype=dtype)
apply_output_mask=apply_output_mask,
inherit_nodata=inherit_nodata, affine=affine, shape=shape,
crs=crs, mask=mask, nodata=nodata, dtype=dtype)
height, width = data.shape
default_blockx = width
default_profile = {
Expand Down
Loading

0 comments on commit 185837c

Please sign in to comment.