-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding seasonet dataset + tests + doc #1466
Merged
Merged
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e0f7fcd
adding seasonet dataset + tests + doc changes
dkosm 2a2c3c0
Fixed docs
briktor fdf1a02
Added tests for missing imports
briktor 720f6a5
Use collections.abc
briktor 639c834
Changed some docstrings and comments
briktor afbb0e0
Check parameters using sets
briktor 229fdac
Changed cmap and interpolation for masks
briktor 1a3e801
Merge branch 'main' into adding_seasonet
briktor ad52891
Removed requests dependency
briktor a98fc27
Merge remote-tracking branch 'origin/adding_seasonet' into adding_sea…
briktor 6c65c1d
Shortened some lines
briktor 413c3a7
Merge branch 'main' into adding_seasonet
briktor d531696
Merge branch 'main' into adding_seasonet
dkosm 068604d
Merge branch 'main' into adding_seasonet
dkosm d9fafee
Fixed pandas warning
briktor b25133a
Merge branch 'main' into adding_seasonet
dkosm 4485abf
Improve documentation of raised error types
adamjstewart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import hashlib | ||
import os | ||
import shutil | ||
|
||
import numpy as np | ||
import rasterio | ||
from rasterio.crs import CRS | ||
from rasterio.transform import Affine | ||
|
||
np.random.seed(0) | ||
|
||
meta = { | ||
"driver": "GTiff", | ||
"nodata": None, | ||
"crs": CRS.from_epsg(32632), | ||
"transform": Affine(10.0, 0.0, 664800.0, 0.0, -10.0, 5342400.0), | ||
"compress": "zstd", | ||
} | ||
bands = ["10m_RGB", "10m_IR", "20m", "60m", "labels"] | ||
count = {"10m_RGB": 3, "10m_IR": 1, "20m": 6, "60m": 2, "labels": 1} | ||
dtype = { | ||
"10m_RGB": np.uint16, | ||
"10m_IR": np.uint16, | ||
"20m": np.uint16, | ||
"60m": np.uint16, | ||
"labels": np.uint8, | ||
} | ||
size = {"10m_RGB": 120, "10m_IR": 120, "20m": 60, "60m": 20, "labels": 120} | ||
start = {"10m_RGB": 0, "10m_IR": 0, "20m": 0, "60m": 0, "labels": 1} | ||
stop = { | ||
"10m_RGB": np.iinfo(np.uint16).max, | ||
"10m_IR": np.iinfo(np.uint16).max, | ||
"20m": np.iinfo(np.uint16).max, | ||
"60m": np.iinfo(np.uint16).max, | ||
"labels": 34, | ||
} | ||
|
||
meta_lines = [ | ||
"Index,Season,Grid,Latitude,Longitude,Satellite,Year,Month,Day," | ||
"Hour,Minute,Second,Clouds,Snow,Classes,SLRAUM,RTYP3,KTYP4,Path\n" | ||
] | ||
seasons = ["spring", "summer", "fall", "winter", "snow"] | ||
grids = [1, 2] | ||
name_comps = [ | ||
["32UME", "2018", "04", "18", "T", "10", "40", "21", "53", "928425", "7", "503876"], | ||
["32TMT", "2019", "02", "14", "T", "10", "31", "29", "47", "793488", "7", "808487"], | ||
] | ||
index = 0 | ||
for season in seasons: | ||
# Remove old data | ||
if os.path.exists(season): | ||
shutil.rmtree(season) | ||
|
||
archive = f"{season}.zip" | ||
|
||
# Remove old data | ||
if os.path.exists(archive): | ||
os.remove(archive) | ||
|
||
for grid, comp in zip(grids, name_comps): | ||
file_name = f"{comp[0]}_{''.join(comp[1:8])}_{'_'.join(comp[8:])}" | ||
dir = os.path.join(season, f"grid{grid}", file_name) | ||
os.makedirs(dir) | ||
|
||
# Random images | ||
for band in bands: | ||
meta["count"] = count[band] | ||
meta["dtype"] = dtype[band] | ||
meta["width"] = meta["height"] = size[band] | ||
with rasterio.open( | ||
os.path.join(dir, f"{file_name}_{band}.tif"), "w", **meta | ||
) as f: | ||
for j in range(1, count[band] + 1): | ||
data = np.random.randint( | ||
start[band], stop[band], size=(size[band], size[band]) | ||
).astype(dtype[band]) | ||
f.write(data, j) | ||
|
||
# Generate meta.csv lines | ||
meta_entries = [ | ||
index, | ||
season.capitalize(), | ||
grid, | ||
f"{comp[8]}.{comp[9]}", | ||
f"{comp[10]}.{comp[11]}", | ||
"A", | ||
comp[1], | ||
comp[2], | ||
comp[3], | ||
comp[5], | ||
comp[6], | ||
comp[7], | ||
0.0, | ||
0.0, | ||
"'2,3,12,15,17'", | ||
1, | ||
1, | ||
1, | ||
dir, | ||
] | ||
meta_lines.append(",".join(map(str, meta_entries)) + "\n") | ||
index += 1 | ||
|
||
# Create archives | ||
shutil.make_archive(season, "zip", ".", season) | ||
|
||
# Compute checksums | ||
with open(archive, "rb") as f: | ||
md5 = hashlib.md5(f.read()).hexdigest() | ||
print(f"{season}: {repr(md5)}") | ||
|
||
# Write meta.csv | ||
with open("meta.csv", "w") as f: | ||
f.writelines(meta_lines) | ||
|
||
# Compute checksums | ||
with open("meta.csv", "rb") as f: | ||
md5 = hashlib.md5(f.read()).hexdigest() | ||
print(f"meta.csv: {repr(md5)}") | ||
|
||
os.makedirs("splits", exist_ok=True) | ||
|
||
for split in ["train", "val", "test"]: | ||
filename = f"{split}.csv" | ||
|
||
# Create file list | ||
with open(os.path.join("splits", filename), "w") as f: | ||
for i in range(index): | ||
f.write(str(i) + "\n") | ||
|
||
shutil.make_archive("splits", "zip", ".", "splits") | ||
|
||
# Compute checksums | ||
with open("splits.zip", "rb") as f: | ||
md5 = hashlib.md5(f.read()).hexdigest() | ||
print(f"splits: {repr(md5)}") |
Binary file not shown.
Binary file added
BIN
+28.6 KB
...ME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_10m_IR.tif
Binary file not shown.
Binary file added
BIN
+84.9 KB
...E_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_10m_RGB.tif
Binary file not shown.
Binary file added
BIN
+42.7 KB
...32UME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_20m.tif
Binary file not shown.
Binary file added
BIN
+1.95 KB
...32UME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_60m.tif
Binary file not shown.
Binary file added
BIN
+9.32 KB
...ME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_labels.tif
Binary file not shown.
Binary file added
BIN
+28.6 KB
...MT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_10m_IR.tif
Binary file not shown.
Binary file added
BIN
+84.9 KB
...T_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_10m_RGB.tif
Binary file not shown.
Binary file added
BIN
+42.7 KB
...32TMT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_20m.tif
Binary file not shown.
Binary file added
BIN
+1.95 KB
...32TMT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_60m.tif
Binary file not shown.
Binary file added
BIN
+9.32 KB
...MT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_labels.tif
Binary file not shown.
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,11 @@ | ||
Index,Season,Grid,Latitude,Longitude,Satellite,Year,Month,Day,Hour,Minute,Second,Clouds,Snow,Classes,SLRAUM,RTYP3,KTYP4,Path | ||
0,Spring,1,53.928425,7.503876,A,2018,04,18,10,40,21,0.0,0.0,"2,3,12,15,17",1,1,1,spring/grid1/32UME_20180418T104021_53_928425_7_503876 | ||
1,Spring,2,47.793488,7.808487,A,2019,02,14,10,31,29,0.0,0.0,"2,3,12,15,17",1,1,1,spring/grid2/32TMT_20190214T103129_47_793488_7_808487 | ||
2,Summer,1,53.928425,7.503876,A,2018,04,18,10,40,21,0.0,0.0,"2,3,12,15,17",1,1,1,summer/grid1/32UME_20180418T104021_53_928425_7_503876 | ||
3,Summer,2,47.793488,7.808487,A,2019,02,14,10,31,29,0.0,0.0,"2,3,12,15,17",1,1,1,summer/grid2/32TMT_20190214T103129_47_793488_7_808487 | ||
4,Fall,1,53.928425,7.503876,A,2018,04,18,10,40,21,0.0,0.0,"2,3,12,15,17",1,1,1,fall/grid1/32UME_20180418T104021_53_928425_7_503876 | ||
5,Fall,2,47.793488,7.808487,A,2019,02,14,10,31,29,0.0,0.0,"2,3,12,15,17",1,1,1,fall/grid2/32TMT_20190214T103129_47_793488_7_808487 | ||
6,Winter,1,53.928425,7.503876,A,2018,04,18,10,40,21,0.0,0.0,"2,3,12,15,17",1,1,1,winter/grid1/32UME_20180418T104021_53_928425_7_503876 | ||
7,Winter,2,47.793488,7.808487,A,2019,02,14,10,31,29,0.0,0.0,"2,3,12,15,17",1,1,1,winter/grid2/32TMT_20190214T103129_47_793488_7_808487 | ||
8,Snow,1,53.928425,7.503876,A,2018,04,18,10,40,21,0.0,0.0,"2,3,12,15,17",1,1,1,snow/grid1/32UME_20180418T104021_53_928425_7_503876 | ||
9,Snow,2,47.793488,7.808487,A,2019,02,14,10,31,29,0.0,0.0,"2,3,12,15,17",1,1,1,snow/grid2/32TMT_20190214T103129_47_793488_7_808487 |
Binary file not shown.
Binary file added
BIN
+28.6 KB
...ME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_10m_IR.tif
Binary file not shown.
Binary file added
BIN
+84.9 KB
...E_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_10m_RGB.tif
Binary file not shown.
Binary file added
BIN
+42.7 KB
...32UME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_20m.tif
Binary file not shown.
Binary file added
BIN
+1.95 KB
...32UME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_60m.tif
Binary file not shown.
Binary file added
BIN
+9.32 KB
...ME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_labels.tif
Binary file not shown.
Binary file added
BIN
+28.6 KB
...MT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_10m_IR.tif
Binary file not shown.
Binary file added
BIN
+84.9 KB
...T_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_10m_RGB.tif
Binary file not shown.
Binary file added
BIN
+42.7 KB
...32TMT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_20m.tif
Binary file not shown.
Binary file added
BIN
+1.95 KB
...32TMT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_60m.tif
Binary file not shown.
Binary file added
BIN
+9.32 KB
...MT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_labels.tif
Binary file not shown.
Binary file not shown.
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,10 @@ | ||
0 | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
6 | ||
7 | ||
8 | ||
9 |
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,10 @@ | ||
0 | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
6 | ||
7 | ||
8 | ||
9 |
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,10 @@ | ||
0 | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
6 | ||
7 | ||
8 | ||
9 |
Binary file not shown.
Binary file added
BIN
+28.6 KB
...ME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_10m_IR.tif
Binary file not shown.
Binary file added
BIN
+84.9 KB
...E_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_10m_RGB.tif
Binary file not shown.
Binary file added
BIN
+42.7 KB
...32UME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_20m.tif
Binary file not shown.
Binary file added
BIN
+1.95 KB
...32UME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_60m.tif
Binary file not shown.
Binary file added
BIN
+9.32 KB
...ME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_labels.tif
Binary file not shown.
Binary file added
BIN
+28.6 KB
...MT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_10m_IR.tif
Binary file not shown.
Binary file added
BIN
+84.9 KB
...T_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_10m_RGB.tif
Binary file not shown.
Binary file added
BIN
+42.7 KB
...32TMT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_20m.tif
Binary file not shown.
Binary file added
BIN
+1.95 KB
...32TMT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_60m.tif
Binary file not shown.
Binary file added
BIN
+9.32 KB
...MT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_labels.tif
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+28.6 KB
...ME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_10m_IR.tif
Binary file not shown.
Binary file added
BIN
+84.9 KB
...E_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_10m_RGB.tif
Binary file not shown.
Binary file added
BIN
+42.7 KB
...32UME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_20m.tif
Binary file not shown.
Binary file added
BIN
+1.95 KB
...32UME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_60m.tif
Binary file not shown.
Binary file added
BIN
+9.32 KB
...ME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_labels.tif
Binary file not shown.
Binary file added
BIN
+28.6 KB
...MT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_10m_IR.tif
Binary file not shown.
Binary file added
BIN
+84.9 KB
...T_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_10m_RGB.tif
Binary file not shown.
Binary file added
BIN
+42.7 KB
...32TMT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_20m.tif
Binary file not shown.
Binary file added
BIN
+1.95 KB
...32TMT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_60m.tif
Binary file not shown.
Binary file added
BIN
+9.32 KB
...MT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_labels.tif
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+28.6 KB
...ME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_10m_IR.tif
Binary file not shown.
Binary file added
BIN
+84.9 KB
...E_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_10m_RGB.tif
Binary file not shown.
Binary file added
BIN
+42.7 KB
...32UME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_20m.tif
Binary file not shown.
Binary file added
BIN
+1.95 KB
...32UME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_60m.tif
Binary file not shown.
Binary file added
BIN
+9.32 KB
...ME_20180418T104021_53_928425_7_503876/32UME_20180418T104021_53_928425_7_503876_labels.tif
Binary file not shown.
Binary file added
BIN
+28.6 KB
...MT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_10m_IR.tif
Binary file not shown.
Binary file added
BIN
+84.9 KB
...T_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_10m_RGB.tif
Binary file not shown.
Binary file added
BIN
+42.7 KB
...32TMT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_20m.tif
Binary file not shown.
Binary file added
BIN
+1.95 KB
...32TMT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_60m.tif
Binary file not shown.
Binary file added
BIN
+9.32 KB
...MT_20190214T103129_47_793488_7_808487/32TMT_20190214T103129_47_793488_7_808487_labels.tif
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to confirm that the original SeasoNet files are also compressed with ZSTD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they are