pynasapower package
Submodules
pynasapower.geometry module
- pynasapower.geometry.bbox(x_min: float | int, x_max: float | int, y_min: float | int, y_max: float | int, crs: str)
Create a bounding box polygon using minimum and maximum coordinates along with a coordinate reference system (CRS). This function takes minimum and maximum x and y coordinates, and a CRS code, and creates a GeoDataFrame containing a bounding box polygon. The function performs input validation to ensure the correctness of the input parameters.
- Parameters:
x_min (float or int) – Minimum x-coordinate of the bounding box. In case of geographical coordinates add longitude as x
x_max (float or int) – Maximum x-coordinate of the bounding box. In case of geographical coordinates add longitude as x
y_min (float or int) – Minimum y-coordinate of the bounding box. In case of geographical coordinates add latitude as y
y_max (float or int) – Maximum y-coordinate of the bounding box. In case of geographical coordinates add latitude as y
crs (str) – Coordinate Reference System (CRS) code in the format “EPSG:XXXX”, where XXXX is the EPSG code representing the CRS. For reference codes of the most commonly used projections, see spatialreference.org
- Returns:
A GeoDataFrame containing a bounding box polygon represented as a Shapely Polygon object
- Return type:
gpd.GeoDataFrame
- pynasapower.geometry.point(x: float | int, y: float | int, crs: str, z: float | int | None = None)
Generate a Point GeoDataFrame to be inserted in the API client.
- Parameters:
x (float) – X coordinate. In case of geographical coordinates add longitude as x
y (float) – Y coordinate. In case of geographical coordinates add latitude as y
crs (str) – Reference code of coordinate system. For reference codes of the most commonly used projections, see spatialreference.org
- Returns:
Geometry as geodataframe
- Return type:
gpd.GeoDataFrame
pynasapower.get_data module
- pynasapower.get_data.query_power(geometry: GeoDataFrame, start: date, end: date, to_file: bool = True, path: str = './', community: str = 'ag', parameters: list = [], temporal_api: str = 'hourly', spatial_api: str = 'point', format: str = 'csv')
Query NASA Power API for climate data based on the specified geometry, temporal range, and parameters.
- Parameters:
geometry (gpd.GeoDataFrame) – GeoDataFrame containing either a Point or a Polygon geometry.
start (datetime.date) – Start date for the data retrieval in datetime.date format. Note in case of monthly or climatology temporal_api only the year is used.
end (datetime.date) – End date for the data retrieval in datetime.date format.Note in case of monthly or climatology temporal_api only the year is used.
path (str, optional) – Path to the directory where the retrieved data files will be saved. Default is ‘./’.
to_file (bool, optional) – Whether to save the data to files or not. Default is True.
community (str, optional) – NASA Power community to query data from. Default is “ag”.
parameters (list, optional) – List of parameter names to retrieve. Default is an empty list. If it is not provided variables TOA_SW_DWN, “ALLSKY_SFC_SW_DWN, T2M, T2M_MIN, T2M_MAX, T2MDEW, WS2M, PRECTOTCORR are downloaded.
temporal_api (str, optional) – Temporal resolution for the data (e.g., “hourly”, “daily”, “monthly”, “climatology”). Default is “hourly”.
spatial_api (str, optional) – Spatial resolution for the data (e.g., “point”, “regional”). Default is “point”.
format (str, optional) – Format for the retrieved data files (e.g., “csv”, “netcdf”, “json”, “ascii”). Default is “csv”.
- Returns:
Retrieved data in dictionary format in case of format = ‘json’, pd.DataFrame in case of format = ‘csv’ or ‘ascii’ and xr.Dataset in case of format = ‘netcdf’.
- Return type:
xr.Dataset or pd.DataFrame or dict
Note
The geometry parameter must be a GeoDataFrame containing either a Point or a Polygon geometry.
The start and end parameters must be in datetime.date format.
The temporal_api parameter must be one of: “hourly”, “daily”, “monthly”, “climatology”.
The spatial_api parameter must be one of: “point”, “regional”.
The format parameter must be one of: “csv”, “netcdf”, “json”, “ascii”.