Skip to content

Instantly share code, notes, and snippets.

@jreadey
Created April 18, 2022 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jreadey/5df328f589433f2dd95a48dd1cfe0e51 to your computer and use it in GitHub Desktop.
Save jreadey/5df328f589433f2dd95a48dd1cfe0e51 to your computer and use it in GitHub Desktop.
import sys
import h5pyd
import random
import logging
loglevel = logging.ERROR
logging.basicConfig(format='%(asctime)s %(message)s', level=loglevel)
if len(sys.argv) > 1 and sys.argv[1] in ("-h", "--help"):
print("usage: python bigandfancy.py <numcol>")
sys.exit()
if len(sys.argv) > 1:
num_cols = int(sys.argv[1])
else:
num_cols = 4
if num_cols < 1:
sys.exit("no numcols")
filepath = "/nrel/nsrdb/v3/nsrdb_2000.h5"
f = h5pyd.File(filepath, bucket="nrel-pds-hsds", retries=1)
dset = f['wind_speed']
cols = []
while len(cols) < num_cols:
n = random.randint(0, dset.shape[1])
if n not in cols:
cols.append(n)
cols.sort()
arr = dset[0:50, cols]
print(arr.shape)
print(f"{arr.min()} {arr.max()} {arr.mean():6.2f}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment