Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RasterReader and RasterStackReader implementations #188

Merged
merged 22 commits into from
Jan 10, 2024

Conversation

scottstanie
Copy link
Collaborator

@scottstanie scottstanie commented Jan 10, 2024

Some timing results on a test where I had

  • 80 total rasters, shape of the input stack was (80, 2160, 3600)
  • Saved in formats
    • .bin: flat binary/ENVI
    • .h5: HDF5 with gzip
    • .lzf.h5: HDF5 with lzf compression
    • .tif: geotiff with dolphin default compression options
  • reading over all bands of (512, 512) blocks at a time, and summing up the values (just to do something with the data)

HDF5StackReader:

(mapping-311) opera-test-data$ python test_read.py --reader-class HDF5StackReader data/*[0-9].h5
              Read times              
┏━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ keep_open ┃ num_threads ┃ time (s) ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ False     │ 1           │ 4.517    │
│ False     │ 3           │ 4.901    │
│ False     │ 10          │ 7.138    │
│ True      │ 1           │ 3.453    │
│ True      │ 3           │ 3.695    │
│ True      │ 10          │ 3.893    │
└───────────┴─────────────┴──────────┘

(mapping-311) opera-test-data$ python test_read.py --reader-class HDF5StackReader data/*[0-9].lzf.h5

              Read times              
┏━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ keep_open ┃ num_threads ┃ time (s) ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ False     │ 1           │ 5.881    │
│ False     │ 3           │ 6.406    │
│ False     │ 10          │ 7.978    │
│ True      │ 1           │ 4.957    │
│ True      │ 3           │ 5.176    │
│ True      │ 10          │ 5.399    │
└───────────┴─────────────┴──────────┘

BinaryReader:


(mapping-311) opera-test-data$ python test_read.py --reader-class BinaryStackReader data/*[0-9].bin

              Read times              
┏━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ keep_open ┃ num_threads ┃ time (s) ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ False     │ 1           │ 4.196    │
│ False     │ 3           │ 2.668    │
│ False     │ 10          │ 2.584    │
└───────────┴─────────────┴──────────┘

Raster:

(mapping-311) opera-test-data$ python test_read.py --reader-class RasterStackReader data/*[0-9].bin
              Read times              
┏━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ keep_open ┃ num_threads ┃ time (s) ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ False     │ 1           │ 9.766    │
│ False     │ 3           │ 5.784    │
│ False     │ 10          │ 6.719    │
│ True      │ 1           │ 11.062   │
│ True      │ 3           │ 7.523    │
│ True      │ 10          │ 8.939    │
└───────────┴─────────────┴──────────┘
(mapping-311) opera-test-data$ python test_read.py --reader-class raster data/*[0-9].tif 
             Read times              
┏━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ keep_open ┃ num_threads ┃ time (s) ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ False     │ 1           │ 4.303    │
│ False     │ 3           │ 4.142    │
│ False     │ 10          │ 4.893    │
│ True      │ 1           │ 5.679    │
│ True      │ 3           │ 4.880    │
│ True      │ 10          │ 6.063    │
└───────────┴─────────────┴──────────┘

Comparing to the current VRT stack method for reading, there's a pretty wide range of times based on the file format.
Note that the "keep_open" and "num_threads" here dont matter, because i was reading all bands for a block so, which uses ds.ReadAsArray to let gdal read all bands.

For input HDF5 files:

# Forcing the `NETCDF:filename:/data` format
┏━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ keep_open ┃ num_threads ┃ time (s) ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ False     │ 1           │ 6.812    │
└───────────┴─────────────┴──────────┘
# Forcing the `HDF5:filename://data` format
              Read times              
┏━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ keep_open ┃ num_threads ┃ time (s) ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ False     │ 1           │ 4.285    │

geotiff inputs are much faster, and seem to beat the other readers:

              Read times              
┏━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ keep_open ┃ num_threads ┃ time (s) ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ False     │ 1           │ 2.192    │

and the binary ENVI files are slower with GDAL (likely from the block shape which doesnt match (1, ncols)

              Read times              
┏━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ keep_open ┃ num_threads ┃ time (s) ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ False     │ 1           │ 7.649    │

@scottstanie scottstanie added the work in progress WIP: Don't merge yet label Jan 10, 2024
@scottstanie scottstanie merged commit bd31392 into isce-framework:main Jan 10, 2024
1 of 2 checks passed
@scottstanie scottstanie deleted the raster-reader branch January 10, 2024 21:25
@scottstanie scottstanie removed the work in progress WIP: Don't merge yet label Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant