Skip to content

Instantly share code, notes, and snippets.

@jreadey
Created November 10, 2023 19:10
Show Gist options
  • Save jreadey/7e471a0bbf1318de963e1e4f164acb87 to your computer and use it in GitHub Desktop.
Save jreadey/7e471a0bbf1318de963e1e4f164acb87 to your computer and use it in GitHub Desktop.
nsrdb_full_disc_check.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"import h5pyd\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"domainpath = \"/nrel/nsrdb/full_disc/nsrdb_full_disc_2022.h5\""
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"f = h5pyd.File(domainpath)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<HDF5 dataset \"dni\": shape (52560, 9462460), type \"<u2\">"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dset = f[\"dni\"]\n",
"dset"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['chunks',\n",
" 'data_source',\n",
" 'elevation_correction',\n",
" 'physical_max',\n",
" 'physical_min',\n",
" 'psm_scale_factor',\n",
" 'psm_units',\n",
" 'scale_factor',\n",
" 'source_dir',\n",
" 'spatial_interp_method',\n",
" 'temporal_interp_method',\n",
" 'units']"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(dset.attrs)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'class': 'H5D_CHUNKED_REF_INDIRECT',\n",
" 'file_uri': 's3://nrel-pds-nsrdb/full_disc/nsrdb_full_disc_irradiance_2022.h5',\n",
" 'dims': [2000, 500],\n",
" 'chunk_table': 'd-988bc5aa-b7a591d0-c746-5cc34b-579ca6'}"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dset.id.layout"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"chunk_table_id = dset.id.layout[\"chunk_table\"]"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<HDF5 dataset (\"anonymous\"): shape (27, 18925), type \"|V12\">"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"chunk_table = f[f\"datasets/{chunk_table_id}\"]\n",
"chunk_table"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"510975"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"chunk_count = np.prod(chunk_table.shape)\n",
"chunk_count"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"allocated_count = 0\n",
"arr = chunk_table[...]\n",
"for row in arr:\n",
" for x in row:\n",
" if x:\n",
" allocated_count += 1\n",
"allocated_count"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "py39",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment