Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SCM syntax highlighting & preventing 3-way merges
pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,6 @@ docs/source/_autosummary

# notebooks
examples
# pixi environments
.pixi/*
!.pixi/config.toml
38 changes: 24 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,41 @@ can be found `here <https://github.com/NREL/nsrdb/tree/main/nsrdb/gap_fill>`_.

Installation
============

NOTE: The installation instructions below assume that you have python installed
on your machine and are using either `conda <https://docs.conda.io/en/latest/index.html>`__
or `pixi <https://pixi.sh/latest/>`_ as your package/environment manager.

Option 1: Install from PIP (recommended for analysts):
------------------------------------------------------
1. Create a new environment: ``conda create --name nsrdb python=3.9``

1. Create a new environment: ``conda create --name nsrdb python=3.11``

2. Activate environment: ``conda activate nsrdb``

3. Install nsrdb: ``pip install NREL-nsrdb``

Option 2: Clone repo (recommended for developers)
-------------------------------------------------
1. from home dir, ``git clone git@github.com:NREL/nsrdb.git``
2. Create ``nsrdb`` environment and install package
1) Create a conda env: ``conda create -n nsrdb``
2) Run the command: ``conda activate nsrdb``
3) ``cd`` into the repo cloned in 1.
4) Prior to running ``pip`` below, make sure the branch is correct (install
from main!)
5) Install ``nsrdb`` and its dependencies by running:
``pip install .`` (or ``pip install -e .`` if running a dev branch
or working on the source code)
6) *Optional*: Set up the pre-commit hooks with ``pip install pre-commit`` and ``pre-commit install``

1. Run ``git clone git@github.com:NREL/nsrdb.git``
2. ``cd nsrdb``.
3. Make sure the branch is correct (install from main!)
4. If you are using conda, create and activate a new environment:
``conda create --name nsrdb python=3.11`` and ``conda activate nsrdb``

4.1 Install ``nsrdb`` and its dependencies by running: ``pip install .`` (or ``pip install -e .`` for editable install)

5. Alternatively, run ``pixi install``
6. *Optional*: Set up the pre-commit hooks with ``pip install pre-commit`` or ``pixi add pre-commit`` and ``pre-commit install``

NSRDB Versions
==============
.. list-table:: NSRDB Versions History

.. list-table::
:widths: auto
:header-rows: 1

* - Version
- Effective Date
- Data Years*
Expand All @@ -101,7 +111,7 @@ NSRDB Versions
- Complete CLI refactor.
* - 4.0.0
- 5/1/23
- GOES: 1998-2024. Meteosat: 2005-2022.
- GOES 1998-2024, Meteosat 2005-2022.
- Integrated an improved direct normal irradiance model (FARMS-DNI),
described in the paper "Integration of a physics-based direct
normal irradiance (DNI) model to enhance the National Solar
Expand Down
2 changes: 2 additions & 0 deletions nsrdb/aggregation/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,8 @@ class Manager:
'air_temperature': Aggregation.point,
'wind_direction': Aggregation.point,
'wind_speed': Aggregation.point,
'wind_direction_10m': Aggregation.point,
'wind_speed_10m': Aggregation.point,
'cloud_type': Aggregation.cloud_type,
'cld_opd_dcomp': Aggregation.cloud_property,
'cld_reff_dcomp': Aggregation.cloud_property,
Expand Down
2 changes: 2 additions & 0 deletions nsrdb/config/nsrdb_vars.csv
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ surface_pressure,hPa,uint16,1,300,1100,IDW2,TRUE,linear,tavg1_2d_slv_Nx,PS,MERRA
total_precipitable_water,cm,uint8,10,0,15,IDW2,TRUE,linear,tavg1_2d_slv_Nx,TQV,MERRA2,/projects/pxs/ancillary/merra,,2000,1000
wind_direction,degrees,uint16,1,0,360,NN,FALSE,linear,tavg1_2d_slv_Nx,,MERRA2,/projects/pxs/ancillary/merra,,2000,500
wind_speed,m/s,uint16,10,0,40,IDW4,FALSE,linear,tavg1_2d_slv_Nx,,MERRA2,/projects/pxs/ancillary/merra,,2000,500
wind_direction_10m,degrees,uint16,1,0,360,NN,FALSE,linear,tavg1_2d_slv_Nx,,MERRA2,/projects/pxs/ancillary/merra,,2000,500
wind_speed_10m,m/s,uint16,10,0,40,IDW4,FALSE,linear,tavg1_2d_slv_Nx,,MERRA2,/projects/pxs/ancillary/merra,,2000,500
cloud_fraction,unitless,float32,1,,,,,,,,UW-GOES,,,2000,250
cloud_probability,unitless,float32,1,,,,,,,,UW-GOES,,,2000,250
temp_3_75um_nom ,K,float32,1,,,,,,,,UW-GOES,,,2000,250
Expand Down
2 changes: 2 additions & 0 deletions nsrdb/config/var_descriptions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ surface_albedo,"Surface albedo is the fraction of solar energy reflected by the
surface_pressure,"Surface atmospheric pressure is the force per unit area exerted by the weight of the atmosphere above a specific location on the Earth's surface."
total_precipitable_water,"Total precipitable water is the depth of liquid water that would result from precipitating all the water vapor in a vertical column above a given location, often measured in millimeters or centimeters."
wind_direction,"Direction from which the wind is blowing, at 2 meters above the surface, measured in degrees clockwise from true north."
wind_direction_10m,"Direction from which the wind is blowing, at 10 meters above the surface, measured in degrees clockwise from true north."
wind_speed,"Wind speed at 2 meters above the surface."
wind_speed_10m,"Wind speed at 10 meters above the surface."
cloud_fraction,"Cloud fraction is the fraction of the sky covered by clouds, expressed as a percentage."
cloud_probability,"Cloud probability is the likelihood of cloud presence at a specific location or time, often based on statistical or observational data."
temp_3_75um_nom,"Brightness temperature at 3.75 micrometers wavelength, specific to the dataset."
Expand Down
8 changes: 6 additions & 2 deletions nsrdb/data_model/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class variables in Ancillary() below.
'air_temperature',
'specific_humidity',
'wind_speed',
'wind_direction',
'wind_speed_10m',
'wind_direction_10m',
'dew_point')
"""

Expand Down Expand Up @@ -104,6 +107,8 @@ class DataModel:
'total_precipitable_water',
'wind_speed',
'wind_direction',
'wind_speed_10m',
'wind_direction_10m',
'alpha',
'aod',
'ssa',
Expand Down Expand Up @@ -1772,8 +1777,7 @@ def dump(self, var, fpath_out, data, purge=False, mode='w'):
fout.time_index = self.nsrdb_ti

if 'meta' not in fout:
meta_gids = self.nsrdb_grid[['gid']]
fout.meta = meta_gids
fout.meta = self.nsrdb_grid

var_kwargs = self._factory_kwargs.get(var, {})
var_obj = VarFactory.get_base_handler(
Expand Down
31 changes: 24 additions & 7 deletions nsrdb/data_model/merra.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,28 @@ def _format_2d(data):

return flat_data

def _get_wind_data(self, file_handler):
"""Get wind speed and direction data for the given height.

Parameters
----------
file_handler : NSRDBfs
Opened MERRA source file handler.

Returns
-------
data : np.ndarray
3D numpy array (lat, lon, time) of wind speed or direction data.
"""
height = '10M' if '_10m' in self.name else '2M'
u_vector = file_handler[f'U{height}'][:]
v_vector = file_handler[f'V{height}'][:]
if self.name.startswith('wind_speed'):
data = np.hypot(u_vector, v_vector)
else:
data = np.degrees(np.arctan2(u_vector, v_vector)) + 180
return data

def _get_data(self, file):
"""Get single variable data from the given MERRA source file

Expand All @@ -193,13 +215,8 @@ def _get_data(self, file):
# open NetCDF file
with NSRDBfs(file) as f:
# depending on variable, might need extra logic
if self.name in ['wind_speed', 'wind_direction']:
u_vector = f['U2M'][:]
v_vector = f['V2M'][:]
if self.name == 'wind_speed':
data = np.sqrt(u_vector**2 + v_vector**2)
else:
data = np.degrees(np.arctan2(u_vector, v_vector)) + 180
if 'wind_speed' in self.name or 'wind_direction' in self.name:
data = self._get_wind_data(f)

elif self.dset_name == 'TOTSCATAU':
# Single scatter albedo is total scatter / aod
Expand Down
2 changes: 2 additions & 0 deletions nsrdb/data_model/variable_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class VarFactory:
'total_precipitable_water': MerraVar,
'wind_speed': MerraVar,
'wind_direction': MerraVar,
'wind_speed_10m': MerraVar,
'wind_direction_10m': MerraVar,
}

HANDLER_NAMES: ClassVar = {
Expand Down
9 changes: 5 additions & 4 deletions nsrdb/gap_fill/mlclouds_fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shutil
import time
from concurrent.futures import as_completed
from typing import ClassVar
from warnings import warn

import numpy as np
Expand All @@ -29,7 +30,7 @@ class MLCloudsFill:
Use the MLClouds algorithm with phygnn model to fill missing cloud data
"""

DEFAULT_MODEL = {
DEFAULT_MODEL: ClassVar[dict] = {
'cloud_type_model_path': None,
'cloud_prop_model_path': LEG_MODEL_FPATH,
}
Expand Down Expand Up @@ -471,9 +472,9 @@ def clean_feature_data(
)
)
logger.debug(
'Cleaned feature data dict values have these shapes: {}'.format(
[d.shape for d in feature_data.values()]
)
'Cleaned feature data dict values have these shapes: {}'.format([
d.shape for d in feature_data.values()
])
)
logger.debug(
'Feature flag column has these values: {}'.format(
Expand Down
8 changes: 7 additions & 1 deletion nsrdb/nsrdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ class NSRDB:
'surface_pressure',
),
'nsrdb_irradiance_{y}.h5': ('dhi', 'dni', 'ghi', 'fill_flag'),
'nsrdb_pv_{y}.h5': ('air_temperature', 'wind_direction', 'wind_speed'),
'nsrdb_pv_{y}.h5': (
'air_temperature',
'wind_direction',
'wind_speed',
'wind_direction_10m',
'wind_speed_10m',
),
}

def __init__(
Expand Down
12 changes: 11 additions & 1 deletion nsrdb/preprocessing/download_merra.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ def get_var_list(source):
]

elif source.lower() == 'slv':
VARIABLES = ['PS', 'QV2M', 'T2M', 'TO3', 'TQV', 'U2M', 'V2M']
VARIABLES = [
'PS',
'QV2M',
'T2M',
'TO3',
'TQV',
'U2M',
'V2M',
'U10M',
'V10M',
]

elif source.lower() == 'aer':
VARIABLES = ['TOTANGSTR', 'TOTEXTTAU', 'TOTSCATAU']
Expand Down
Loading