AWS Data Requests
This section provides code examples on how to access data from AWS S3, as provided by the Registry of Open Data on AWS.
Notes
- When new time slices are available from source data providers, they are automatically made available within Zarr Dataset. This means the data values can change, similarly to POWER's other service endpoints. For more information, please review the data availability in the POWER Dashboard.
- To support Near Real Time (NRT) data distribution, the Zarr's time dimension extends to 2029/12/31 for hourly and daily temporal levels.
Remotely Connect via Python
The code below is an overview of the process for remotely connecting 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://nasa-power.s3.amazonaws.com/syn1deg/temporal/power_syn1deg_monthly_temporal_lst.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 or 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://nasa-power.s3.us-west-2.amazonaws.com/syn1deg/temporal/power_syn1deg_monthly_temporal_lst.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 10 data that is stored in NetCDF format; however, in most cases this is not recommended. POWER makes this data available through a web interface in the POWER Data Download page.