bopen / xarray-sentinel

Xarray backend to Copernicus Sentinel-1 satellite data products
Apache License 2.0
219 stars 22 forks source link

ASF or .zip support? #86

Closed TheJeran closed 2 years ago

TheJeran commented 2 years ago

I have a bunch of S1 data from the Alaska Satellite Facility in .zip format. I tried seeing what happens if I load in the .zip but it of course didn't work. Are there plans to support ASF data? Or am I doing something wrong? Does it need to be SLC?

alexamici commented 2 years ago

I tried seeing what happens if I load in the .zip but it of course didn't work.

@TheJeran did you install the latest alpha from rasterio as described in https://github.com/bopen/xarray-sentinel#advanced-data-access-via-fsspec?

If you did install rasterio>=1.3a3, I would have expected xarray-sentinel to work and I can try to help you once you add more information on what code you tried and how it didn't work.

TheJeran commented 2 years ago

I'm using a conda environment as described in the install section. I had not done the rasterio alpha version. After installing rasterio alpha I get the same error.

It's just two lines of code atm to test if it works.

import xarray as xr
ds = xr.open_dataset('S1B_IW_SLC__1SDV_20201219T015149_20201219T015215_024765_02F221_2049.zip',engine='sentinel-1')
Traceback (most recent call last):

  File "/opt/conda/envs/XARRAY-SENTINEL/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3444, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "/tmp/ipykernel_38593/434583679.py", line 1, in <module>
    ds = xr.open_dataset('S1B_IW_SLC__1SDV_20201219T015149_20201219T015215_024765_02F221_2049.zip',engine='sentinel-1')

  File "/opt/conda/envs/XARRAY-SENTINEL/lib/python3.10/site-packages/xarray/backends/api.py", line 495, in open_dataset
    backend_ds = backend.open_dataset(

  File "/opt/conda/envs/XARRAY-SENTINEL/lib/python3.10/site-packages/xarray_sentinel/xarray_backends.py", line 18, in open_dataset
    ds = sentinel1.open_sentinel1_dataset(

  File "/opt/conda/envs/XARRAY-SENTINEL/lib/python3.10/site-packages/xarray_sentinel/sentinel1.py", line 678, in open_sentinel1_dataset
    product_attrs, product_files = esa_safe.parse_manifest_sentinel1(file)

  File "/opt/conda/envs/XARRAY-SENTINEL/lib/python3.10/site-packages/xarray_sentinel/esa_safe.py", line 110, in parse_manifest_sentinel1
    manifest = ElementTree.parse(manifest_path)

  File "/opt/conda/envs/XARRAY-SENTINEL/lib/python3.10/xml/etree/ElementTree.py", line 1229, in parse
    tree.parse(source, parser)

  File "/opt/conda/envs/XARRAY-SENTINEL/lib/python3.10/xml/etree/ElementTree.py", line 580, in parse
    self._root = parser._parse_whole(source)

  File "<string>", line unknown
ParseError: not well-formed (invalid token): line 1, column 2
rasterio.__version__
'1.3a3'
alexamici commented 2 years ago

@TheJeran you need to use an fsspec formatted URL to open a Zip file, note the zip://*/manifest.safe::... in the example: https://github.com/bopen/xarray-sentinel#advanced-data-access-via-fsspec

In your case try:

ds = xr.open_dataset('zip://*/manifest.safe::S1B_IW_SLC__1SDV_20201219T015149_20201219T015215_024765_02F221_2049.zip',engine='sentinel-1')
TheJeran commented 2 years ago

That was it! Thank you.