Last active
August 2, 2023 14:58
-
-
Save ashiklom/8b18a5c5a9aebfba65477ea0175793d8 to your computer and use it in GitHub Desktop.
Testing H5Coro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: h5coro | |
channels: | |
- conda-forge | |
dependencies: | |
- gdal | |
- ipython | |
- proj | |
- pybind11 | |
- python |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Installation. Something like this should work | |
# # Create a conda environment | |
# conda env create h5coro | |
# conda install -c conda-forge python pybind11 gdal proj | |
# # Install script for cmake. | |
# # Run this from inside the `sliderule` source code directory: | |
# | |
# TARGETDIR="/path/to/sliderule-install" | |
# mkdir -p build | |
# cd build | |
# | |
# # Command below is *inside* the `build` directory | |
# cmake \ | |
# -DINSTALLDIR="$TARGETDIR" \ | |
# -DRUNTIMEDIR="$TARGETDIR/etc/sliderule" \ | |
# -DSHARED_LIBRARY=ON \ | |
# -DPYTHON_BINDINGS=ON \ | |
# -DUSE_AWS_PACKAGE=ON \ | |
# -DUSE_GEO_PACKAGE=ON \ | |
# -DUSE_NETSVC_PACKAGE=ON \ | |
# .. | |
# | |
# make | |
# # Or, for parallel install with verbose logging, `make -j8 VERBOSE=1` | |
# # ...and then, install files to `$TARGETDIR` | |
# make install | |
# # Run the python script below with: | |
# LD_LIBRARY_PATH="/path/to/sliderule-install/lib" python script.py | |
# | |
# # The LD_LIBRARY_PATH needs to contain the following: | |
# # - libsliderule.so.X.X.X | |
# # - srpybin.cypthon-<py_version>-<arch>-<os>-<glib_ver>.so | |
# This is needed to detect the `srpybin` library. | |
import sys | |
import os | |
# Change to: | |
# sliderule_lib = os.path.abspath("/path/to/sliderule-install/lib") | |
sliderule_lib = os.path.abspath("lib/") | |
sys.path.append(sliderule_lib) | |
# This is the sliderule Python bindings, including H5Coro | |
import srpybin | |
url = "s3://noaa-goes17/ABI-L2-FDCC/2018/239/00/OR_ABI-L2-FDCC-M3_G17_s20182390052191_e20182390054564_c20182390055159.nc" | |
asset = "awsodr" # Dummy variable | |
resource = os.path.basename(url) | |
identity = "mystore" # Dummy variable | |
driver = "s3" | |
path = os.path.dirname(url.lstrip("s3://")) | |
region = "us-east-1" | |
endpoint = "https://noaa-goes17.s3.amazonaws.com" | |
h5file = srpybin.h5coro(asset, resource, identity, driver, path, region, endpoint) | |
# Get metadata for specific variables. | |
# This works... | |
h5file.meta("Temp") | |
h5file.meta("Power") | |
# Try to read a particular variable. | |
# This fails with "invalid read location", perhaps because the data are not | |
# strictly 2-dimensional and/or there are extra rows. | |
# Arguments: (Variable name, column, start row, number of rows) | |
h5file.read("Power", 0, 0, 1) | |
# Try to read multiple variables in parallel. | |
# This doesn't | |
dat = h5file.readp([ | |
["Temp", 0, 0, 1], | |
["Temp", 0, 0, 1], | |
["Temp", 0, 0, 10] | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment