-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic time series module for unwrapping network inversion (#191)
* start timeseries module * skip B for now, make vmapped versions * start ts tests * remove unused * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * move shapely to a test req * start making test for ts * make first pass at temporal avg/blockwise processor * better test * get basic `solve` test, add velo function * more comments, add network invert func * revert back tophu to not install from conda * get test working for est velo * revamp writers/protocols * start setup for weighted least squares loading * fix shapes, add weight to velo * add spatial ref point to unw invert * rename, more tests * get file stack working * [skip ci] update CHANGELOG for past releases --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5478a89
commit 39ea994
Showing
13 changed files
with
1,020 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,5 @@ pyproj>=3.3 | |
rasterio>=1.3 | ||
ruamel_yaml>=0.15 | ||
scipy>=1.9 | ||
shapely>=1.8 | ||
threadpoolctl>=3.0 | ||
tqdm>=4.60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from dolphin._types import Index | ||
|
||
|
||
def _ensure_slices(rows: Index, cols: Index) -> tuple[slice, slice]: | ||
def _parse(key: Index): | ||
if isinstance(key, int): | ||
return slice(key, key + 1) | ||
elif key is ...: | ||
return slice(None) | ||
else: | ||
return key | ||
|
||
return _parse(rows), _parse(cols) | ||
|
||
|
||
def _unpack_3d_slices(key: tuple[Index, ...]) -> tuple[Index, slice, slice]: | ||
# Check that it's a tuple of slices | ||
if not isinstance(key, tuple): | ||
msg = "Index must be a tuple of slices." | ||
raise TypeError(msg) | ||
if len(key) not in (1, 3): | ||
msg = "Index must be a tuple of 1 or 3 slices." | ||
raise TypeError(msg) | ||
# If only the band is passed (e.g. stack[0]), convert to (0, :, :) | ||
if len(key) == 1: | ||
key = (key[0], slice(None), slice(None)) | ||
# unpack the slices | ||
bands, rows, cols = key | ||
# convert the rows/cols to slices | ||
r_slice, c_slice = _ensure_slices(rows, cols) | ||
return bands, r_slice, c_slice |
Oops, something went wrong.