-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# default data paths for tests | ||
product_paths: | ||
- 'S1A_IW_GRDH_1SDV_20170907T103020_20170907T103045_018268_01EB76_Z010.SAFE' |
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,48 @@ | ||
import safe_s1 | ||
from safe_s1 import sentinel1_xml_mappings, Sentinel1Reader | ||
import os | ||
import logging | ||
from pathlib import Path | ||
import yaml | ||
|
||
logging.basicConfig() | ||
logging.captureWarnings(True) | ||
|
||
logger = logging.getLogger('s1_reader_test') | ||
logger.setLevel(logging.DEBUG) | ||
|
||
|
||
# determine the config file we will use (config.yml by default, and a local config if one is present) and retrieve | ||
# the products names | ||
local_config_pontential_path = Path(os.path.join('~', 'xarray-safe-s1', 'localconfig.yml')).expanduser() | ||
if local_config_pontential_path.exists(): | ||
config_path = local_config_pontential_path | ||
with open(config_path) as config_content: | ||
products = yaml.load(config_content, Loader=yaml.SafeLoader)['product_paths'] | ||
else: | ||
config_path = Path(os.path.join(os.path.dirname(safe_s1.__file__), 'config.yml')) | ||
with open(config_path) as config_content: | ||
raw_products = yaml.load(config_content, Loader=yaml.SafeLoader)['product_paths'] | ||
products = [sentinel1_xml_mappings.get_test_file(filename) for filename in raw_products] | ||
|
||
|
||
# Try to apply the reader on different products | ||
def test_reader(): | ||
try: | ||
for product in products: | ||
reader = Sentinel1Reader(product) | ||
# When a product is a multidataset, datatree is none, so we want to be sure that the datatree isn't empty | ||
# (selecting a dataset) | ||
sub_reader = Sentinel1Reader(reader.datasets_names[0]) | ||
dt = sub_reader.datatree | ||
for ds in dt: | ||
dt[ds].to_dataset().compute() | ||
assert True | ||
except: | ||
assert False | ||
|
||
|
||
|
||
|
||
|
||
|