bopen / xarray-sentinel

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

Proposal for open_dataset interface #13

Closed aurghs closed 3 years ago

aurghs commented 3 years ago

Draft for open open_dataset inferface. open_dataset takes in input both the manifest.safe and the directory.

Open without a group:

manifest_path = (
    DATA_FOLDER
    / "S1B_IW_SLC__1SDV_20210401T052622_20210401T052650_026269_032297_EFA4.SAFE"
)
xr.open_dataset(manifest_path, engine="sentinel-1")

<xarray.Dataset>
Dimensions:  ()
Data variables:
    *empty*
Attributes: (12/13)
    constellation:              sentinel-1
    platform:                   sentinel-1b
    instrument:                 ['c-sar']
    sat:orbit_state:            descending
    sat:absolute_orbit:         26269
    sat:relative_orbit:         168
    ...                         ...
    sar:frequency_band:         C
    sar:instrument_mode:        IW
    sar:polarizations:          ['VV', 'VH']
    sar:product_type:           SLC
    xs:instrument_mode_swaths:  ['IW1', 'IW2', 'IW3']
    groups:                     ['IW1/gcp', 'IW1/attitude', 'IW1/orbit', 'IW2...]

Open with group = 'IW1':

manifest_path = (
    DATA_FOLDER
    / "S1B_IW_SLC__1SDV_20210401T052622_20210401T052650_026269_032297_EFA4.SAFE"
)
xr.open_dataset(manifest_path, engine="sentinel-1", group="IW1")  
<xarray.Dataset>
Dimensions:  ()
Data variables:
    *empty*
Attributes:
    groups:   ['orbit', 'attitude', 'gcp']

Open with group = 'IW1/orbit':

manifest_path = (
    DATA_FOLDER
    / "S1B_IW_SLC__1SDV_20210401T052622_20210401T052650_026269_032297_EFA4.SAFE"
)
xr.open_dataset(manifest_path, engine="sentinel-1", group="IW1/orbit")  # type: ignore

<xarray.Dataset>
Dimensions:  (time: 17)
Coordinates:
  * time     (time) datetime64[ns] 2021-04-01T05:25:19 ... 2021-04-01T05:27:59
Data variables:
    x        (time) float64 ...
    y        (time) float64 ...
    z        (time) float64 ...
    vx       (time) float64 ...
    vy       (time) float64 ...
    vz       (time) float64 ...
Attributes:
    Conventions:       CF-1.7
    reference_system:  Earth Fixed

TBC:

alexamici commented 3 years ago

Another issue I see with tests. At the moment the individual openers are not tested independently from the logic of the main open_dataset.

Testing both the opener function and the xr.open_dataset(..., group=...) is a bit redundant and would need a refactor of the tests and possibly the use parametrize, but I think it is needed.

It can go in a different PR though.

codecov-io commented 3 years ago

Codecov Report

Merging #13 (96f268d) into main (796f762) will decrease coverage by 2.10%. The diff coverage is 89.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #13      +/-   ##
==========================================
- Coverage   93.90%   91.79%   -2.11%     
==========================================
  Files           6        6              
  Lines         279      378      +99     
==========================================
+ Hits          262      347      +85     
- Misses         17       31      +14     
Impacted Files Coverage Δ
xarray_sentinel/esa_safe.py 86.95% <85.00%> (-1.22%) :arrow_down:
xarray_sentinel/sentinel1.py 92.98% <91.17%> (-2.72%) :arrow_down:
tests/test_xarray.py 100.00% <100.00%> (ø)
tests/test_esa_safe.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 796f762...96f268d. Read the comment docs.