8000 Add retrieval function for NASA MERRA2 reanalysis data by AdamRJensen · Pull Request #1274 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

Add retrieval function for NASA MERRA2 reanalysis data #1274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update pydap link in setup.py
  • Loading branch information
AdamRJensen committed Aug 20, 2021
commit 9149f3770a773a109dd9589fc6a359f18bcb1c54
15 changes: 7 additions & 8 deletions pvlib/iotools/merra2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Functions to read and retrieve MERRA2 reanalysis data from NASA.
.. codeauthor:: Adam R. Jensen<adam-r-j@hotmail.com>
"""
import os
import cftime
from pvlib.tools import (_extract_metadata_from_dataset,
_convert_C_to_K_in_dataset)
Expand Down Expand Up @@ -113,19 +112,19 @@ def get_merra2(latitude, longitude, start, end, dataset, variables, username,
start_float = cftime.date2num(start, units='days since 1-1-1 00:00:0.0')
end_float = cftime.date2num(end, units='days since 1-1-1 00:00:0.0')

#try:
# latitude = slice(latitude[0], latitude[1])
# longitude = slice(longitude[0], longitude[1])
# method = None
#except TypeError:
# method = 'nearest'
# try:
# latitude = slice(latitude[0], latitude[1])
# longitude = slice(longitude[0], longitude[1])
# method = None
# except TypeError:
# method = 'nearest'

# Setting decode_times=False results in a time saving of up to some minutes
ds = xr.open_dataset(store, decode_times=False).sel(
{'lat': latitude,
'lon': longitude,
'time': slice(start_float, end_float)},
)
)

variables = [v.lower() for v in variables] # Make all variables lower-case

Expand Down
3 changes: 2 additions & 1 deletion pvlib/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def assert_frame_equal(left, right, **kwargs):


try:
# Attempt to load NASA EarthData login credentials used for testing pvlib.iotools.get_merra2
# Attempt to load NASA EarthData login credentials used for testing
# pvlib.iotools.get_merra2
MERRA2_USERNAME = os.environ["MERRA2_USERNAME"]
MERRA2_PASSWORD = os.environ["MERRA2_PASSWORD"]
has_merra2_credentials = True
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
'optional': ['cython', 'ephem', 'netcdf4', 'nrel-pysam', 'numba',
'pvfactors', 'siphon', 'statsmodels', 'tables',
'cftime >= 1.1.1', 'xarray', 'dask',
'git+https://github.com/pydap/pydap#egg=pydap'],
'pip install -e git+https://github.com/pydap/pydap#egg=pydap'],
'doc': ['ipython', 'matplotlib', 'sphinx == 3.1.2',
'sphinx_rtd_theme==0.5.0', 'sphinx-gallery', 'docutils == 0.15.2',
'pillow', 'netcdf4', 'siphon', 'tables',
Expand Down
0