-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
darts_export: untested export module
- Loading branch information
Showing
5 changed files
with
44 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +0,0 @@ | ||
"""Dataset export for the DARTS dataset.""" | ||
|
||
|
||
def hello() -> str: | ||
"""Say hello to the user. | ||
Returns: | ||
str: Greating message. | ||
""" | ||
return "Hello from darts-export!" | ||
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,22 @@ | ||
from pathlib import Path | ||
import xarray | ||
import rioxarray | ||
|
||
class InferenceResultWriter: | ||
Check failure on line 5 in darts-export/src/darts_export/inference.py GitHub Actions / lintRuff (I001)
Check failure on line 5 in darts-export/src/darts_export/inference.py GitHub Actions / lintRuff (E302)
|
||
|
||
def __init__(self, ds) -> None: | ||
self.ds:xarray.Dataset = ds | ||
|
||
def export_probabilities(self, path:Path, filename="pred_probabilities.tif", tags=dict()): | ||
Check failure on line 10 in darts-export/src/darts_export/inference.py GitHub Actions / lintRuff (D102)
|
||
|
||
# write the probability layer from the raster to a GeoTiff | ||
self.ds.probabilities.rio.to_raster(path / filename, driver="GTiff", tags=tags, compress="LZW") | ||
|
||
def export_binarized(self, path:Path, filename="pred_binarized.tif", tags=dict()): | ||
|
||
self.ds.binarized_segmentation.rio.to_raster(path / filename, driver="GTiff", tags=tags, compress="LZW") | ||
|
||
|
||
def export_vectors(self, path:Path, filename_prefix="pred_segments"): | ||
pass | ||
|
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,15 @@ | ||
import pytest | ||
import xarray, numpy as np | ||
import rioxarray | ||
|
||
@pytest.fixture | ||
def probabilities(): | ||
|
||
xds = xarray.DataArray(np.randint(0, 100, 16**2), | ||
dims=("y", "x"), | ||
coords={"x": range(500000, 500016), "y": range(4500000, 4500016)}, | ||
) | ||
xds.rio.write_crs("EPSG:32601", inplace=True) | ||
xds.rio.set_spatial_dims(x_dim='x', y_dim='y', inplace=True) | ||
xds.rio.write_transform(inplace=True) | ||
return xds |
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,5 @@ | ||
#import | ||
|
||
|
||
def test_writeProbabilities(probabilities): | ||
pass |