From e01980980408b682d5f1d61d66e53bbb8fa4a213 Mon Sep 17 00:00:00 2001 From: grantbuster Date: Mon, 23 Dec 2024 10:17:22 -0700 Subject: [PATCH] updated documentation throughout --- README.rst | 76 +++++++++++++++---------------- docs/source/index.rst | 10 ---- docs/source/misc/installation.rst | 7 --- examples/HSDS/README.rst | 21 ++++++++- examples/NREL_Data/README.rst | 28 +++++------- examples/fsspec/README.rst | 6 +-- rex/multi_time_resource.py | 5 +- rex/resource.py | 5 +- 8 files changed, 76 insertions(+), 82 deletions(-) diff --git a/README.rst b/README.rst index 06cd5c93..52df3530 100644 --- a/README.rst +++ b/README.rst @@ -33,34 +33,25 @@ Welcome to The REsource eXtraction (rex) tool! .. inclusion-intro -rex command line tools -====================== - -- `rex `_ -- `NSRDBX `_ -- `WINDX `_ -- `US-wave `_ -- `WaveX `_ -- `MultiYearX `_ -- `rechunk `_ -- `temporal-stats `_ -- `wind-rose `_ - -Using Eagle Env -=============== - -If you would like to run `rex` on Eagle (NREL's HPC) you can use a pre-compiled -conda env: - -.. code-block:: bash - - conda activate /shared-projects/rev/modulefiles/conda/envs/rev/ - -or - -.. code-block:: bash - - source activate /shared-projects/rev/modulefiles/conda/envs/rev/ +What is rex? +============= +``rex`` stands for **REsource eXtraciton** tool. + +``rex`` enables the efficient and scalable extraction, manipulation, and +computation with NRELs flagship renewable resource datasets such as: the Wind +Integration National Dataset (WIND Toolkit), the National Solar Radiation +Database (NSRDB), the Ocean Surface Wave Hindcast (US Wave) Data, and the +High-resolution downscaled climate change data (Sup3rCC). + +To get started accessing NREL's datasets, see the primer on `NREL Renewable +Energy Resource Data +`_ or the +`installation instructions `_. + +You might also want to check out the basic `Resource Class +`_ that +can be used to efficiently query NREL data, or our various `example use cases +`_. Installing rex ============== @@ -78,12 +69,13 @@ Option 1: Install from PIP or Conda (recommended for analysts): 2. Activate directory: ``conda activate rex`` -3. Install rex: - 1) ``pip install NREL-rex`` or - 2) ``conda install nrel-rex --channel=nrel`` +3. Basic ``rex`` install: + 1) ``pip install NREL-rex`` + 2) or ``conda install nrel-rex --channel=nrel`` - - NOTE: If you install using conda and want to use `HSDS `_ - you will also need to install h5pyd manually: ``pip install h5pyd`` +4. Install for users outside of NREL that want to access data via HSDS or S3 as per the instructions `here `_: + 1) ``pip install NREL-rex[s3]`` for easy no-setup direct access of the data on S3 via ``fsspec`` as per `this example `_ + 2) or ``pip install NREL-rex[hsds]`` for more performant access of the data on HSDS with slightly more setup as per `this example `_ Option 2: Clone repo (recommended for developers) ------------------------------------------------- @@ -109,11 +101,15 @@ Option 2: Clone repo (recommended for developers) - ``WINDX`` - ``US-wave`` -Recommended Citation -==================== - -Update with current version and DOI: +rex command line tools +====================== -Michael Rossol, Grant Buster. The REsource Extraction Tool (rex). -https://github.com/NREL/rex (version v0.2.43), 2021. -https://doi.org/10.5281/zenodo.4499033. +- `rex `_ +- `NSRDBX `_ +- `WINDX `_ +- `US-wave `_ +- `WaveX `_ +- `MultiYearX `_ +- `rechunk `_ +- `temporal-stats `_ +- `wind-rose `_ diff --git a/docs/source/index.rst b/docs/source/index.rst index 5f52cf81..54db3014 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -10,14 +10,4 @@ rex documentation ******************* -What is rex? -============= -rex stands for **REsource eXtraciton** tool. - -rex enables the efficient and scalable extraction, manipulation, and -computation with NRELs flagship renewable resource datasets: -the Wind Integration National Dataset (WIND Toolkit), and the National Solar -Radiation Database (NSRDB) - .. include:: ../../README.rst - :start-after: inclusion-intro diff --git a/docs/source/misc/installation.rst b/docs/source/misc/installation.rst index 8b60dfa8..32082cc4 100644 --- a/docs/source/misc/installation.rst +++ b/docs/source/misc/installation.rst @@ -5,13 +5,6 @@ Installation :start-after: Installing rex :end-before: Recommended Citation -Usage on Eagle -============== - -.. include:: ../../../README.rst - :start-after: Using Eagle Env - :end-before: Installing rex - Command Line Tools ================== diff --git a/examples/HSDS/README.rst b/examples/HSDS/README.rst index ec9b36b7..1b3b0ee8 100644 --- a/examples/HSDS/README.rst +++ b/examples/HSDS/README.rst @@ -1,7 +1,26 @@ Highly Scalable Data Service (HSDS) =================================== -`The Highly Scalable Data Service (HSDS) `_ is a cloud-optimized solution for storing and accessing HDF5 files, e.g. the NREL wind and solar datasets. You can access NREL data via HSDS in a few ways. Read below to find out more. +`The Highly Scalable Data Service (HSDS) +`_ is a +cloud-optimized solution for storing and accessing HDF5 files, e.g. the NREL +wind and solar datasets. You can access NREL data via HSDS in a few ways. Read +below to find out more. + +Note that raw NREL .h5 data files are hosted on AWS S3. In contrast, the files +on HSDS are not real "files". They are just domains that you can access with +h5pyd or rex tools to stream small chunks of the files stored on S3. The +multi-terabyte .h5 files on S3 would be incredibly cumbersome to access +otherwise. + +Extra Requirements +------------------ + +You may need some additional software beyond the basic ``rex`` install to run this example: + +.. code-block:: bash + + pip install NREL-rex[hsds] NREL Developer API ------------------ diff --git a/examples/NREL_Data/README.rst b/examples/NREL_Data/README.rst index c454aeb3..e94a6190 100644 --- a/examples/NREL_Data/README.rst +++ b/examples/NREL_Data/README.rst @@ -70,29 +70,24 @@ However, this method is slow. The most performant method is via ``HSDS``. or server for just the time or space domain you're interested in. See `this docs page `_ -for easy (but slow) access of the source .h5 files on s3 with ``fsspec``. +for easy (but slow) access of the source .h5 files on s3 with ``fsspec`` that +requires basically zero setup. To find relevant S3 files, you can explore the +S3 directory structure on `OEDI `_ or +with the `AWS CLI `_ See `this docs page `_ for -instructions on how to set up HSDS and then continue on to the Data Access -Examples section below. +instructions on how to set up HSDS for more performant data access that +requires a bit of setup. To find relevant HSDS files, you can use HSDS and +h5pyd to explore the NREL public data directory listings. For example, if you +are running an HSDS local server, you can use the CLI utility ``hsls``, for +example, run: ``$ hsls /nrel/`` or ``$ hsls /nrel/nsrdb/v3/``. You can also use +h5pyd to do the same thing. In a python kernel, ``import h5pyd`` and then run: +``print(list(h5pyd.Folder('/nrel/')))`` to list the ``/nrel/`` directory. There is also an experiment with using `zarr `_, but the examples below may not work with these utilities and the zarr example is not regularly tested. -To find relevant HSDS files, you can use HSDS and h5pyd to explore the NREL -public data directory listings. For example, if you are running an HSDS local -server, you can use the CLI utility ``hsls``, for example, run: ``$ hsls -/nrel/`` or ``$ hsls /nrel/nsrdb/v3/``. You can also use h5pyd to do the same -thing. In a python kernel, ``import h5pyd`` and then run: -``print(list(h5pyd.Folder('/nrel/')))`` to list the ``/nrel/`` directory. - -Note that raw NREL .h5 data files are hosted on AWS S3. In contrast, the files -on HSDS are not real "files". They are just domains that you can access with -h5pyd or rex tools to stream small chunks of the files stored on S3. The -multi-terabyte .h5 files on S3 would be incredibly cumbersome to access -otherwise. - The `Open Energy Data Initiative (OEDI) `_ is also invaluable for finding the source s3 filepaths and for finding energy-relevant public datasets that are not necessarily spatiotemporal h5 @@ -105,7 +100,6 @@ Data Access Examples If you are on the NREL HPC, update the file paths with the relevant NREL HPC file paths in ``/datasets/``. - If you are not at NREL, see the "Data Location - External Users" section above for S3 instructions or for how to setup HSDS and how to find the files that you're interested in. Then update the file paths to the files you want either diff --git a/examples/fsspec/README.rst b/examples/fsspec/README.rst index 319ae160..4566f753 100644 --- a/examples/fsspec/README.rst +++ b/examples/fsspec/README.rst @@ -12,14 +12,14 @@ You may need some additional software beyond the basic ``rex`` install to run th .. code-block:: bash - pip install fsspec s3fs + pip install NREL-rex[s3] Code Example ------------ -To open an .h5 file hosted on AWS S3, simply use a path to an S3 resource.: +To open an .h5 file hosted on AWS S3, simply use a path to an S3 resource with any of the ``rex`` file handlers: -- Change ``fp`` to your desired AWS .h5 resource paths (find the s3 paths on `Open Energy Data Initiative (OEDI) `_). +- Change ``fp`` to your desired AWS .h5 resource paths (find the s3 paths on `OEDI `_ or with the `AWS CLI `_). - Running this example on a laptop, it takes ~14 seconds to read the meta data, and another ~14 seconds to read the GHI timeseries. This may be faster when running on AWS services in the same region hosting the .h5 file. It is much slower when running on the NREL VPN. .. code-block:: python diff --git a/rex/multi_time_resource.py b/rex/multi_time_resource.py index 4ac6558c..8f9b290b 100644 --- a/rex/multi_time_resource.py +++ b/rex/multi_time_resource.py @@ -232,7 +232,8 @@ def _get_hsds_file_paths(h5_path, hsds_kwargs=None): import h5pyd except Exception as e: msg = (f'Tried to open hsds file path: "{h5_path}" with ' - 'h5pyd but could not import, try `pip install h5pyd`') + 'h5pyd but could not import, try ' + '`pip install NREL-rex[hsds]`') logger.error(msg) raise ImportError(msg) from e @@ -291,7 +292,7 @@ def _get_s3_file_paths(h5_path): except Exception as e: msg = (f'Tried to open s3 file path: "{h5_path}" with ' 'fsspec but could not import, try ' - '`pip install fsspec s3fs`') + '`pip install NREL-rex[s3]`') logger.error(msg) raise ImportError(msg) from e diff --git a/rex/resource.py b/rex/resource.py index f570c931..e2b8d919 100644 --- a/rex/resource.py +++ b/rex/resource.py @@ -1150,7 +1150,8 @@ def open_file(cls, file_path, mode='r', hsds=False, hsds_kwargs=None): import h5pyd except Exception as e: msg = (f'Tried to open hsds file path: "{file_path}" with ' - 'h5pyd but could not import, try `pip install h5pyd`') + 'h5pyd but could not import, try ' + '`pip install NREL-rex[hsds]`') logger.error(msg) raise ImportError(msg) from e @@ -1171,7 +1172,7 @@ def open_file(cls, file_path, mode='r', hsds=False, hsds_kwargs=None): except Exception as e: msg = (f'Tried to open s3 file path: "{file_path}" with ' 'fsspec but could not import, try ' - '`pip install fsspec s3fs`') + '`pip install NREL-rex[s3]`') logger.error(msg) raise ImportError(msg) from e