This Python library provides a convenient way to download and process climate data from NASA's POWER (Prediction Of Worldwide Energy Resource) API for multiple geographic regions. The processor handles data downloading, cleaning, merging, and adding location metadata automatically.
- Python 3.6 or higher
- Required Python packages (install with
pip install -r requirements.txt
)
pandas>=1.0.0
requests>=2.25.0
tqdm>=4.50.0
You can install all requirements with:
pip install pandas requests tqdm
Create a CSV file containing the regions you want to download data for. The file must include these columns:
Region
: Name of the region/district (will be used in filenames)Latitude
: Decimal latitude coordinateLongitude
: Decimal longitude coordinate
Example district_database.csv
:
Region,Latitude,Longitude
New_York,40.7128,-74.0060
London,51.5074,-0.1278
Tokyo,35.6762,139.6503
from NASADataProcessor import Processor
# Basic initialization
processor = Processor(
output_dir="nasa_data", # Where to save downloaded files
database_file="districts.csv", # Your district database file
merged_file="all_data.csv", # Final merged output filename
log_file="logs/processor.log" # Log file path
)
You can modify the default parameters either by:
- Editing the default parameters in code
- Loading from a JSON file
processor.edit_default_params(
start="20100101", # New start date (YYYYMMDD)
end="20201231", # New end date
parameters="T2M,RH2M" # Only request temperature and humidity
)
Create a params.json
file:
{
"start": "20150101",
"end": "20201231",
"community": "ag",
"parameters": "T2M,RH2M,PRECTOTCORR",
"format": "csv",
"header": "false"
}
Then initialize with:
processor = Processor(params_file="params.json")
Download data for all regions in your database:
processor.download_data_for_all_districts()
This will:
- Create individual CSV files for each region in your output directory
- Show a progress bar
- Log all activities
NASA POWER CSVs have 25 header rows that need to be removed:
processor.clean_csv_files()
Add region names and coordinates to each CSV:
processor.add_location_data()
Combine all individual CSVs into one master file:
processor.merge_csv_files()
from NASADataProcessor import Processor
# Initialize with custom parameters
processor = Processor(
output_dir="climate_data",
database_file="my_districts.csv",
merged_file="combined_climate_data.csv"
)
# Download data for all regions
processor.download_data_for_all_districts()
# Process the files
processor.clean_csv_files()
processor.add_location_data()
processor.merge_csv_files()
print("Data processing complete!")
The processor comes with these default parameters:
- Start Date: 2004-01-01
- End Date: 2024-08-01
- Community: "ag" (agriculture)
- Parameters: Includes 17 climate variables (solar radiation, temperature, precipitation, etc.)
- Format: CSV
- Header: false
- Individual region files:
[output_dir]/[Region].csv
- Merged file:
[merged_file]
- Log file:
[log_file]
- The processor logs all activities and errors
- Failed downloads will be logged but won't stop the process
- Check the log file for troubleshooting
- Start with a small test dataset (2-3 regions) to verify your setup
- Monitor the log file (
processor.log
) for progress and errors - The API has rate limits - very large datasets may need to be downloaded in batches
- You can resume interrupted downloads - the processor won't re-download existing files
For more information about available parameters and data: https://power.larc.nasa.gov/docs/services/api/
This project is open source under the MIT License.
All public uses (publications, presentations, derivatives) must include attribution using one of these formats:
@misc{paul_nasa_power_data_processor_2025,
author = {Paul, Tonmoy},
title = {NASA Power Data Processor},
year = {2025},
publisher = {Zenodo},
howpublished = {\url{https://github.com/udvotttechnologist/NASAPowerProcessor}},
doi = {10.5281/zenodo.15651310},
version = {1.0.1},
note = {MIT License}
}