isce-framework / s1-reader

Sentinel-1 reader
Apache License 2.0
27 stars 12 forks source link

initial version of s1_info cli tool #83

Closed scottstanie closed 2 years ago

scottstanie commented 2 years ago

The script request from in #81 is a vert nice idea since I also kept wanting to verify the burst IDs as we were testing out COMPASS.

Here's a very quick version in this PR. Plenty of room for formatting improvement in the formatting/tweaks to what information you want printed from the burst (seems like a nice case for rich).

For a bunch of zip files in data/:

(mapping) [staniewi@aurora hawaii]$ ls data/ | head
S1A_IW_SLC__1SDV_20180511T161552_20180511T161622_021859_025BF8_1292.zip
S1A_IW_SLC__1SDV_20180511T161620_20180511T161639_021859_025BF8_9FF0.zip
S1A_IW_SLC__1SDV_20180523T161553_20180523T161623_022034_026186_CD35.zip
S1A_IW_SLC__1SDV_20180523T161620_20180523T161639_022034_026186_D066.zip
S1A_IW_SLC__1SDV_20180604T161602_20180604T161637_022209_026711_A413.zip
...

(mapping) [staniewi@aurora hawaii]$ s1_info data/S1A_IW_SLC__1SDV_20180511T161552_20180511T161622_021859_025BF8_1292.zip --burst-id
Bursts in data/S1A_IW_SLC__1SDV_20180511T161552_20180511T161622_021859_025BF8_1292.zip:
--------------------------------------------------------------------------------
t087_185673_iw1
t087_185674_iw1
t087_185675_iw1
t087_185676_iw1
t087_185677_iw1
...(all 30 printed)
t087_185679_iw3
t087_185680_iw3
t087_185681_iw3
t087_185682_iw3

(mapping) [staniewi@aurora hawaii]$ s1_info data/S1A_IW_SLC__1SDV_20180511T161552_20180511T161622_021859_025BF8_1292.zip
Bursts in data/S1A_IW_SLC__1SDV_20180511T161552_20180511T161622_021859_025BF8_1292.zip:
--------------------------------------------------------------------------------
Sentinel1BurstSlc: t087_185673_iw1 at 2018-05-11 16:15:52.765047
Sentinel1BurstSlc: t087_185674_iw1 at 2018-05-11 16:15:55.521548
Sentinel1BurstSlc: t087_185675_iw1 at 2018-05-11 16:15:58.278049
Sentinel1BurstSlc: t087_185676_iw1 at 2018-05-11 16:16:01.038661
...
(mapping) [staniewi@aurora hawaii]$ s1_info --help
usage: s1_info [-h] [--pol {vv,vh,hh,hv}] [-i {1,2,3}] [-b] [-p] [-o OUTPUT_FILENAME] paths [paths ...]

Extract the burst ID information from a Sentinel-1 SLC product.

positional arguments:
  paths                 Path to the Sentinel-1 SLC product(s), or directory containing products.

options:
  -h, --help            show this help message and exit
  --pol {vv,vh,hh,hv}   Polarization to use.
  -i {1,2,3}, --iw {1,2,3}
                        Print only the burst IDs for the given IW.
  -b, --burst-id        Print only the burst IDs for all bursts.
  -p, --plot            Plot the burst map for all bursts.
  -o OUTPUT_FILENAME, --output-filename OUTPUT_FILENAME
                        Name of the output file for the burst map. Defaults to 'burst_map_<SAFE_ID>.gpkg'.
(mapping) [staniewi@aurora hawaii]$ s1_info data/S1A_IW_SLC__1SDV_20180511* -b
Bursts in data/S1A_IW_SLC__1SDV_20180511T161552_20180511T161622_021859_025BF8_1292.zip:
--------------------------------------------------------------------------------
t087_185673_iw1
t087_185674_iw1...
t087_185681_iw3
t087_185682_iw3
Bursts in data/S1A_IW_SLC__1SDV_20180511T161620_20180511T161639_021859_025BF8_9FF0.zip:
--------------------------------------------------------------------------------
t087_185683_iw1
...
t087_185688_iw3

(mapping) [staniewi@aurora hawaii]$ s1_info data/ -b | head -100
Bursts in data/S1A_IW_SLC__1SDV_20180511T161552_20180511T161622_021859_025BF8_1292.zip:
--------------------------------------------------------------------------------
t087_185673_iw1
...
t087_185682_iw3
Bursts in data/S1A_IW_SLC__1SDV_20180511T161620_20180511T161639_021859_025BF8_9FF0.zip:
--------------------------------------------------------------------------------
t087_185683_iw1.
..
t087_185688_iw3
Bursts in data/S1A_IW_SLC__1SDV_20180523T161553_20180523T161623_022034_026186_CD35.zip:
--------------------------------------------------------------------------------
t087_185673_iw1
t087_185674_iw1
...
yunjunz commented 2 years ago

Thank you @scottstanie for the quick PR! It works like a charm!

I have two minor suggestions:

  1. Add usage example in get_cli_args(), similar to what we have in mintpy (https://github.com/insarlab/MintPy/blob/main/src/mintpy/cli/dem_error.py#L24) and isce2/dem.py also. I usually find this is very helpful and more clear than the argparse syntax.
  2. For --plot output, save them into a burst_map folder and lose the burst_map prefix in the file name, instead of many files in the current dir, for a cleaner structure.
scottstanie commented 2 years ago

both good ideas, and the single directory is much nicer rather than 8x-ing the number of files haha 👍