Skip to content

Commit 4581c3e

Browse files
author
agrouaze
committed
add debug + change reltive import and pin version xarray
1 parent 4559d07 commit 4581c3e

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

highleveltests/open_GRD_IW.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import pdb
2+
from safe_s1 import Sentinel1Reader, getconfig
3+
import time
4+
import logging
5+
logging.basicConfig(level=logging.DEBUG)
6+
logging.debug('start GRD test')
7+
conf = getconfig.get_config()
8+
subswath = conf['product_paths'][0]
9+
print(subswath)
10+
t0 = time.time()
11+
if 'GRD' in subswath:
12+
sub_reader = Sentinel1Reader(subswath)
13+
else:
14+
sub_reader = Sentinel1Reader('SENTINEL1_DS:'+subswath+':IW3')
15+
elapse_t = time.time()-t0
16+
17+
dt = sub_reader.datatree
18+
print('out of the reader')
19+
print(dt)
20+
print('time to read the SAFE through nfs: %1.2f sec'%elapse_t)
21+
DN = sub_reader.load_digital_number(chunks={'pol':'VV','line':6000,'sample':8000})
22+
print('DN',DN)
23+
# pdb.set_trace()

highleveltests/open_SLC_IW.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
dt = sub_reader.datatree
1212
print('out of the reader')
1313
print(dt)
14-
print('time to read the SAFE through S3: %1.2f sec'%elapse_t)
14+
print('time to read the SAFE through nfs: %1.2f sec'%elapse_t)
1515
pdb.set_trace()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license = {text = "MIT"}
55
dependencies = [
66
"geopandas",
77
"numpy",
8-
"xarray",
8+
"xarray>=2024.10.0",
99
"lxml",
1010
"rioxarray",
1111
"jmespath",

safe_s1/reader.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import yaml
99
from affine import Affine
1010
from rioxarray import rioxarray
11-
12-
from . import sentinel1_xml_mappings
13-
from .xml_parser import XmlParser
11+
import logging
12+
from safe_s1 import sentinel1_xml_mappings
13+
from safe_s1.xml_parser import XmlParser
1414
import xarray as xr
1515
import pandas as pd
1616
import warnings
@@ -19,6 +19,7 @@
1919
class Sentinel1Reader:
2020

2121
def __init__(self, name, backend_kwargs=None):
22+
logging.debug('input name: %s',name)
2223
if not isinstance(name, (str, os.PathLike)):
2324
raise ValueError(f"cannot deal with object of type {type(name)}: {name}")
2425
# gdal dataset name
@@ -28,13 +29,19 @@ def __init__(self, name, backend_kwargs=None):
2829
"""Gdal dataset name"""
2930
name_parts = self.name.split(':')
3031
if len(name_parts) > 3:
32+
logging.debug('windows case')
3133
# windows might have semicolon in path ('c:\...')
3234
name_parts[1] = ':'.join(name_parts[1:-1])
3335
del name_parts[2:-1]
3436
name_parts[1] = os.path.basename(name_parts[1])
3537
self.short_name = ':'.join(name_parts)
38+
logging.debug('short_name : %s',self.short_name)
3639
"""Like name, but without path"""
37-
self.path = ':'.join(self.name.split(':')[1:-1])
40+
if len(name_parts) == 2:
41+
self.path = self.name.split(':')[1]
42+
else:
43+
self.path = ':'.join(self.name.split(':')[1:-1])
44+
logging.debug('path: %s',self.path)
3845
# remove trailing slash in the safe path
3946
if self.path[-1]=='/':
4047
self.path = self.path.rstrip('/')

0 commit comments

Comments
 (0)