Functions¶
Download NASA POWER climate data for the points of a table.
Each point is saved as a CSV in output_folder (<identifier>.csv).
A point whose CSV already has all the period requested is not downloaded
again (unless overwrite=True), so an interrupted download can be run
again and continues where it stopped; if the period grows (e.g. an
update with a later end_date), the point is downloaded again. Busy answers of the API (429, 5xx) are
retried three times.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Points to download, e.g. the centroids of the municipalities or AGEB. |
required |
lat_col
|
str
|
Columns with the coordinates (decimal degrees, WGS84). |
'latitude'
|
lon_col
|
str
|
Columns with the coordinates (decimal degrees, WGS84). |
'latitude'
|
start_date
|
str
|
Period as |
'20150101'
|
end_date
|
str
|
Period as |
'20150101'
|
parameters
|
list of str
|
NASA POWER parameters. Temperature: |
('T2M', 'T2MDEW', 'T2MWET', 'TS', 'T2M_RANGE', 'T2M_MAX', 'T2M_MIN')
|
temporal_resolution
|
('daily', 'monthly', 'climatology')
|
|
"daily"
|
spatial_resolution
|
'point'
|
Kept for compatibility with version 0.1; only |
"point"
|
community
|
('RE', 'AG', 'SB')
|
Renewable energy, agroclimatology or sustainable buildings (units). |
"RE"
|
processes
|
int
|
Simultaneous requests (NASA asks for at most 5); 1 downloads in order.
The requests run in threads, so no |
5
|
output_folder
|
str
|
Folder for the CSV of each point. |
'./nasa_power_data'
|
start_col
|
str
|
Columns with a different period for each point. |
None
|
end_col
|
str
|
Columns with a different period for each point. |
None
|
id_col
|
str
|
Column with the identifier of each point (else |
None
|
return_consolidated
|
bool
|
If True, return the data of all the points in one table; if False, the result of each download. |
True
|
overwrite
|
bool
|
Download again every point, even if its CSV already has the period. |
False
|
verbose
|
bool
|
Show the progress. |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Columns |
Examples:
Points of the municipalities of Mexico, bundled with the package.
municipalities(cve_edo=None, point='inside')
¶
One point per municipality of Mexico (INEGI 2019), all or by state.
The table comes with the package (2,465 municipalities), so no download
is needed; it is ready for :func:climex.download_nasa_power_data with
id_col="CVEGEO".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cve_edo
|
(str, int or list)
|
State code(s) ( |
None
|
point
|
('inside', 'centroid')
|
|
"inside"
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Examples:
Points (inside each polygon) to download the climate of polygons.
Uses the representative point of each polygon, which is always inside it (the centroid of a curved municipality can fall outside).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
GeoDataFrame
|
Polygons, e.g. |
required |
id_col
|
str
|
Column with the identifier of each polygon (e.g. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
URL of one NASA POWER request for a point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latitude
|
float
|
Coordinates of the point (decimal degrees, WGS84). |
required |
longitude
|
float
|
Coordinates of the point (decimal degrees, WGS84). |
required |
parameters
|
list of str
|
NASA POWER parameters, e.g. |
required |
temporal_resolution
|
('daily', 'monthly', 'climatology')
|
|
"daily"
|
community
|
('RE', 'AG', 'SB')
|
|
"RE"
|
start
|
str
|
Dates as |
None
|
end
|
str
|
Dates as |
None
|
Read a CSV of municipal points and keep the municipalities of one state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
CSV with a |
required |
state
|
str
|
State code, e.g. |
required |
Notes
:func:climex.municipalities gives the same points for all the
municipalities of Mexico without a CSV.