Skip to content

AWS Data Requests

This section provides code examples on how to access data from the AWS S3 provided by the Registry of Open Data on AWS.

Notes

  • When new time slices are available from sources data providers they are automatically made available within Zarr Dataset. This means the data values can change like POWER's other service endpoints for more information review the data availability at POWER Dashboard.
  • To support Near Real Time (NRT) data distribution the Zarr's time dimension extends to 2024/12/31 for hourly and daily temporal levels.

Remotely Connect via Python

This is an overview of the process to remotely connect to a POWER Zarr-formatted Analysis Ready Dataset (ARD) via Python.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
'''
*Version: 1.0 Published: 2022/05/31* Source: [NASA POWER](https://power.larc.nasa.gov/)
POWER Remotely Connect to a POWER Zarr via Python
This is an overview of the process to remotely connect to a POWER Zarr-formatted Analysis Ready Dataset (ARD) via Python.
'''

import fsspec

import xarray as xr

filepath = 'https://power-analysis-ready-datastore.s3.amazonaws.com/power_901_monthly_radiation_utc.zarr'
filepath_mapped = fsspec.get_mapper(filepath)
ds = xr.open_zarr(store=filepath_mapped, consolidated=True)
ds

Data Download

The Python Script below can be used to download a slice of POWER data directly from AWS as a NetCDF 4 and as a CSV.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'''
*Version: 1.0 Published: 2024/02/14* Source: [NASA POWER](https://power.larc.nasa.gov/)
POWER Remotely Connect to, Slice, and Download from a POWER Zarr via Python
This is an overview of the process to connect to and download from a POWER Zarr-formatted ARD via Python.
'''

import os
import fsspec

import pandas as pd
import xarray as xr

from datetime import datetime

filepath = 'https://power-analysis-ready-datastore.s3.us-west-2.amazonaws.com/power_901_annual_radiation_utc.zarr'
filepath_mapped = fsspec.get_mapper(filepath)
ds = xr.open_zarr(filepath_mapped, consolidated=True)

# different ways to slice the data
ds_single_point = ds.ALLSKY_SFC_LW_DWN.sel(lat=39, lon=-77, method='nearest').load()
ds_single_time = ds.ALLSKY_SFC_LW_DWN.sel(time=datetime(2022, 12, 31)).load()
ds_time_series = ds.ALLSKY_SFC_LW_DWN.sel(time=pd.date_range(datetime(2019, 12, 31), datetime(2020, 12, 31), freq='1Y')).load()
ds_region = ds.ALLSKY_SFC_LW_DWN.sel(lat=slice(35, 45), lon=slice(-85, -75)).load()

output = r'' # if none the location of the script is where the files will be outputted.

# export region as NetCDF4
ds_region.to_netcdf(path=os.path.join(output, "region.nc"))

# export as CSV
df_region = ds_region.to_dataframe()
df_region.to_csv(os.path.join(output, "region.csv"))

NetCDF Data Archive

You can also access POWER Version 9 data that is stored in NetCDF format, although in most cases this is not recommended. POWER makes these data is available in a web interface at the POWER Data Download page.