[Git][debian-gis-team/xarray-safe-s1][upstream] New upstream version 2024.11.12
Antonio Valentino (@antonio.valentino)
gitlab at salsa.debian.org
Mon Nov 25 18:02:54 GMT 2024
Antonio Valentino pushed to branch upstream at Debian GIS Project / xarray-safe-s1
Commits:
9b8992c3 by Antonio Valentino at 2024-11-25T17:39:50+00:00
New upstream version 2024.11.12
- - - - -
7 changed files:
- .github/workflows/publish.yml
- docs/index.rst
- + highleveltests/open_GRD_IW.py
- highleveltests/open_SLC_IW.py
- pyproject.toml
- safe_s1/reader.py
- safe_s1/sentinel1_xml_mappings.py
Changes:
=====================================
.github/workflows/publish.yml
=====================================
@@ -28,7 +28,7 @@ jobs:
twine check dist/*
pip install dist/*.whl
- name: Publish to PyPI
- uses: pypa/gh-action-pypi-publish at 81e9d935c883d0b210363ab89cf05f3894778450
+ uses: pypa/gh-action-pypi-publish at 15c56dba361d8335944d31a2ecd17d700fc7bcbc
with:
password: ${{ secrets.pypi_token }}
repository_url: https://upload.pypi.org/legacy/
=====================================
docs/index.rst
=====================================
@@ -13,12 +13,12 @@ Overview
........
**safe_s1** rely on `xarray.open_rasterio` and `rasterio` to read *digital_number* from SAFE
- product to return an xarray-datatree.
+ product to return an xarray.datatree.
Luts are decoded from xml files following `ESA Sentinel-1 Product Specification`_.
- `safe_s1.metadata.Sentinel1reader` is the main class and contains a xarray-datatree with the useful data. In the following example, you will find some additional functions and properties that can be useful.
+ `safe_s1.metadata.Sentinel1reader` is the main class and contains a xarray.datatree with the useful data. In the following example, you will find some additional functions and properties that can be useful.
Examples
........
=====================================
highleveltests/open_GRD_IW.py
=====================================
@@ -0,0 +1,23 @@
+import pdb
+from safe_s1 import Sentinel1Reader, getconfig
+import time
+import logging
+logging.basicConfig(level=logging.DEBUG)
+logging.debug('start GRD test')
+conf = getconfig.get_config()
+subswath = conf['product_paths'][0]
+print(subswath)
+t0 = time.time()
+if 'GRD' in subswath:
+ sub_reader = Sentinel1Reader(subswath)
+else:
+ sub_reader = Sentinel1Reader('SENTINEL1_DS:'+subswath+':IW3')
+elapse_t = time.time()-t0
+
+dt = sub_reader.datatree
+print('out of the reader')
+print(dt)
+print('time to read the SAFE through nfs: %1.2f sec'%elapse_t)
+DN = sub_reader.load_digital_number(chunks={'pol':'VV','line':6000,'sample':8000})
+print('DN',DN)
+# pdb.set_trace()
=====================================
highleveltests/open_SLC_IW.py
=====================================
@@ -11,5 +11,5 @@ elapse_t = time.time()-t0
dt = sub_reader.datatree
print('out of the reader')
print(dt)
-print('time to read the SAFE through S3: %1.2f sec'%elapse_t)
+print('time to read the SAFE through nfs: %1.2f sec'%elapse_t)
pdb.set_trace()
=====================================
pyproject.toml
=====================================
@@ -5,8 +5,7 @@ license = {text = "MIT"}
dependencies = [
"geopandas",
"numpy",
- "xarray",
- "xarray-datatree",
+ "xarray>=2024.10.0",
"lxml",
"rioxarray",
"jmespath",
=====================================
safe_s1/reader.py
=====================================
@@ -8,11 +8,10 @@ import rasterio
import yaml
from affine import Affine
from rioxarray import rioxarray
-
-from . import sentinel1_xml_mappings
-from .xml_parser import XmlParser
+import logging
+from safe_s1 import sentinel1_xml_mappings
+from safe_s1.xml_parser import XmlParser
import xarray as xr
-import datatree
import pandas as pd
import warnings
@@ -20,6 +19,7 @@ import warnings
class Sentinel1Reader:
def __init__(self, name, backend_kwargs=None):
+ logging.debug('input name: %s',name)
if not isinstance(name, (str, os.PathLike)):
raise ValueError(f"cannot deal with object of type {type(name)}: {name}")
# gdal dataset name
@@ -29,13 +29,19 @@ class Sentinel1Reader:
"""Gdal dataset name"""
name_parts = self.name.split(':')
if len(name_parts) > 3:
+ logging.debug('windows case')
# windows might have semicolon in path ('c:\...')
name_parts[1] = ':'.join(name_parts[1:-1])
del name_parts[2:-1]
name_parts[1] = os.path.basename(name_parts[1])
self.short_name = ':'.join(name_parts)
+ logging.debug('short_name : %s',self.short_name)
"""Like name, but without path"""
- self.path = ':'.join(self.name.split(':')[1:-1])
+ if len(name_parts) == 2:
+ self.path = self.name.split(':')[1]
+ else:
+ self.path = ':'.join(self.name.split(':')[1:-1])
+ logging.debug('path: %s',self.path)
# remove trailing slash in the safe path
if self.path[-1]=='/':
self.path = self.path.rstrip('/')
@@ -108,7 +114,7 @@ class Sentinel1Reader:
'antenna_pattern':self.antenna_pattern,
'swath_merging': self.swath_merging
}
- self.dt = datatree.DataTree.from_dict(self._dict)
+ self.dt = xr.DataTree.from_dict(self._dict)
assert self.dt==self.datatree
else:
print('multidataset')
@@ -341,7 +347,7 @@ class Sentinel1Reader:
Returns
-------
- datatree.DataTree
+ xr.DataTree
Contains data from the reader
"""
return self.dt
=====================================
safe_s1/sentinel1_xml_mappings.py
=====================================
@@ -151,6 +151,7 @@ xpath_mappings = {
'aux_cal': (scalar, '//metadataSection/metadataObject/metadataWrap/xmlData/safe:processing/safe:resource/safe:processing/safe:resource[@role="AUX_CAL"]/@name'),
'aux_pp1': (scalar, '//metadataSection/metadataObject/metadataWrap/xmlData/safe:processing/safe:resource/safe:processing/safe:resource[@role="AUX_PP1"]/@name'),
+ 'aux_ins': (scalar, '//metadataSection/metadataObject/metadataWrap/xmlData/safe:processing/safe:resource/safe:processing/safe:resource[@role="AUX_INS"]/@name'),
'aux_cal_sl2': (scalar,'//metadataSection/metadataObject/metadataWrap/xmlData/safe:processing/safe:resource[@role="AUX_CAL"]/@name'),
'annotation_files': (
@@ -182,6 +183,9 @@ xpath_mappings = {
'xsd_overlay_file': (
normpath,
'/xfdu:XFDU/metadataSection/metadataObject[@ID="s1Level1MapOverlaySchema"]/metadataReference/@href'),
+ 'instrument_configuration_id': (scalar,
+ '//s1sarl1:standAloneProductInformation/s1sarl1:instrumentConfigurationID/text()',
+ )
},
'calibration': {
'polarization': (scalar, '/calibration/adsHeader/polarisation'),
@@ -901,7 +905,9 @@ compounds_vars = {
'stop_date': 'manifest.stop_date',
'footprints': 'manifest.footprints',
'aux_cal': 'manifest.aux_cal',
- 'aux_pp1': 'manifest.aux_pp1'
+ 'aux_pp1': 'manifest.aux_pp1',
+ 'aux_ins': 'manifest.aux_ins',
+ 'icid' : 'manifest.instrument_configuration_id'
},
'safe_attributes_sl2': {
'ipf_version': 'manifest.ipf_version',
View it on GitLab: https://salsa.debian.org/debian-gis-team/xarray-safe-s1/-/commit/9b8992c35c2a4b3c278069313d544330c9e05664
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/xarray-safe-s1/-/commit/9b8992c35c2a4b3c278069313d544330c9e05664
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20241125/520bac8f/attachment-0001.htm>
More information about the Pkg-grass-devel
mailing list