|
1 | | -# Satellite_S5P |
2 | | -### NO2 Data Processing Script |
| 1 | +## <div align="center">Satellite_S5P</div> |
3 | 2 |
|
4 | | -This Python script is designed to process and analyze nitrogen dioxide (NO2) data from satellite observations. Here's a breakdown of its main components: |
| 3 | +<div align="center"> |
5 | 4 |
|
6 | | -### Data Extraction: |
7 | | -The script uses the extract_data function to filter and extract relevant NO2 data from a given dataset based on predefined geographical conditions (latitude and longitude ranges) and a quality threshold (qa_value). |
| 5 | + |
| 6 | + |
8 | 7 |
|
9 | | -### Data Interpolation: |
10 | | -The interp_data function utilizes a KD-tree algorithm to find the nearest neighbors in a 2D array of latitude and longitude. It then performs linear interpolation using the map_coordinates function to estimate NO2 values at specified target coordinates. |
| 8 | +</div> |
11 | 9 |
|
12 | | -### Main Loop: |
| 10 | +<div align="center"> |
| 11 | +<a href="https://github.com/Alex870521"><img src="https://cdn.simpleicons.org/github/0A66C2" width="3%" alt="GitHub"></a> |
| 12 | +<span style="margin: 0 1%"></span> |
| 13 | +<a href="https://www.linkedin.com/in/Alex870521/"><img src="https://cdn.simpleicons.org/linkedin/0A66C2" width="3%" alt="LinkedIn"></a> |
| 14 | +<span style="margin: 0 1%"></span> |
| 15 | +<a href="https://medium.com/@alex870521"><img src="https://cdn.simpleicons.org/medium/0A66C2" width="3%" alt="Medium"></a></div> |
13 | 16 |
|
14 | | -The script iterates through folders corresponding to different months of a specified year, each containing NetCDF files of satellite observations. |
15 | | -For each NetCDF file, it extracts and interpolates NO2 data and stores the results. |
| 17 | +--- |
16 | 18 |
|
17 | | -### Data Aggregation: |
18 | | -The script aggregates the processed NO2 data from multiple files within a month, calculating the average. |
| 19 | +A Python toolkit for retrieving, processing, and visualizing Sentinel-5P satellite data, with a focus on air pollutants like NO₂, CO, SO₂, O₃, and HCHO. |
19 | 20 |
|
20 | | -### Output: |
21 | | -The processed NO2 data is stored in NetCDF format, with each file representing a month of observations. |
| 21 | +## <div align="center">Features</div> |
22 | 22 |
|
23 | | -### Folder Skipping: |
24 | | -The script checks if the output NetCDF file already exists. If it does, it skips processing that particular folder to avoid unnecessary computations. |
| 23 | +- Automated data retrieval from Copernicus Open Access Hub |
| 24 | +- Advanced data processing with interpolation and quality control |
| 25 | +- High-quality visualization of pollutant concentration maps |
| 26 | +- Time series analysis capabilities |
| 27 | +- Built-in file retention management to prevent storage overflow |
25 | 28 |
|
26 | | -### Usage: |
27 | | -The script is designed to be run for a specific year, processing monthly satellite observations of NO2 data and generating NetCDF files for further analysis or visualization. |
| 29 | +## <div align="center">Prerequisites</div> |
28 | 30 |
|
29 | | -### Dependencies: |
30 | | -The script relies on various Python libraries, including NumPy, xarray, scipy, and netCDF4, for efficient data manipulation and processing. |
31 | | -This script is particularly useful for researchers or analysts working with satellite-derived NO2 data, allowing them to extract, interpolate, and aggregate information for further study. |
| 31 | +Before using this toolkit, you need to complete the following steps: |
| 32 | + |
| 33 | +1. **Copernicus Account Setup**: |
| 34 | + - Register for a free account at [Copernicus Open Access Hub](https://scihub.copernicus.eu/dhus/#/home) |
| 35 | + - Save your username and password for API access |
| 36 | + |
| 37 | +2. **Environment Configuration**: |
| 38 | + - Create a `.env` file in the project root directory with your credentials: |
| 39 | + ``` |
| 40 | + COPERNICUS_USERNAME=your_username |
| 41 | + COPERNICUS_PASSWORD=your_password |
| 42 | + ``` |
| 43 | +
|
| 44 | +## <div align="center">Installation</div> |
| 45 | +
|
| 46 | +```bash |
| 47 | +# Clone the repository |
| 48 | +git clone https://github.com/Alex870521/Satellite_S5P.git |
| 49 | +
|
| 50 | +# Navigate to the directory |
| 51 | +cd Satellite_S5P |
| 52 | +
|
| 53 | +# Install required packages |
| 54 | +pip install -r requirements.txt |
| 55 | +``` |
| 56 | + |
| 57 | +## <div align="center">Usage</div> |
| 58 | + |
| 59 | +### Fetching Satellite Data |
| 60 | +```python |
| 61 | +from src.api.sentinel_api import S5PFetcher |
| 62 | + |
| 63 | +# Initialize fetcher |
| 64 | +fetcher = S5PFetcher(max_workers=3) |
| 65 | + |
| 66 | +# Fetch products |
| 67 | +products = await fetcher.fetch_data( |
| 68 | + file_class='OFFL', # 'OFFL' for offline data, 'NRTI' for near-real-time |
| 69 | + file_type='NO2___', # Available types: 'NO2___', 'CO____', 'SO2___', 'O3__PR', 'HCHO__' |
| 70 | + start_date='2025-02-20', |
| 71 | + end_date='2025-03-06', |
| 72 | + boundary=(120, 122, 22, 25), |
| 73 | + limit=None |
| 74 | +) |
| 75 | + |
| 76 | +# Download products |
| 77 | +fetcher.parallel_download(products) |
| 78 | +``` |
| 79 | + |
| 80 | +Example output: |
| 81 | +``` |
| 82 | +╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ |
| 83 | +│ Fetching sentinel-5p products (NO₂) from 2025-02-20 to 2025-03-06 ... │ |
| 84 | +╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ |
| 85 | +╭──────────────────────────────────────── Found 7 Products ────────────────────────────────────────╮ |
| 86 | +│ │ |
| 87 | +│ Product Information │ |
| 88 | +│┏━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓ │ |
| 89 | +│┃ No. ┃ Time ┃ Name ┃ Size ┃ │ |
| 90 | +│┡━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩ │ |
| 91 | +││ 1 │ 2025-02-25T04:54:18 │ S5P_OFFL_L2__NO2____20250225T043243...50226T204825.nc │ 589.88 MB │ │ |
| 92 | +││ 2 │ 2025-02-24T05:13:14 │ S5P_OFFL_L2__NO2____20250224T045140...50225T210805.nc │ 591.67 MB │ │ |
| 93 | +││ 3 │ 2025-02-24T03:31:44 │ S5P_OFFL_L2__NO2____20250224T031009...50226T055814.nc │ 593.46 MB │ │ |
| 94 | +││ 4 │ 2025-02-23T03:50:40 │ S5P_OFFL_L2__NO2____20250223T032906...50224T235016.nc │ 593.48 MB │ │ |
| 95 | +││ 5 │ 2025-02-22T04:09:37 │ S5P_OFFL_L2__NO2____20250222T034802...50223T200228.nc │ 590.79 MB │ │ |
| 96 | +││ 6 │ 2025-02-21T04:28:32 │ S5P_OFFL_L2__NO2____20250221T040659...50222T202822.nc │ 589.21 MB │ │ |
| 97 | +││ 7 │ 2025-02-20T04:47:30 │ S5P_OFFL_L2__NO2____20250220T042555...50221T204529.nc │ 564.02 MB │ │ |
| 98 | +│└─────┴─────────────────────┴───────────────────────────────────────────────────────┴───────────┘ │ |
| 99 | +│ │ |
| 100 | +╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ |
| 101 | +``` |
| 102 | + |
| 103 | +### Processing Data |
| 104 | +```python |
| 105 | +from src.processing.data_processor import S5Processor |
| 106 | + |
| 107 | +# Initialize processor |
| 108 | +processor = S5Processor( |
| 109 | + interpolation_method='rbf', |
| 110 | + resolution=(5.5, 3.5), # Resolution in km |
| 111 | + mask_qc_value=0.5 # Quality control threshold |
| 112 | +) |
| 113 | + |
| 114 | +# Process data |
| 115 | +processor.process_each_data( |
| 116 | + file_class='OFFL', |
| 117 | + file_type='NO2___', |
| 118 | + start_date='2025-02-20', |
| 119 | + end_date='2025-03-06', |
| 120 | +) |
| 121 | +``` |
| 122 | + |
| 123 | +## <div align="center">Data Description</div> |
| 124 | + |
| 125 | +### NO2 Data Processing |
| 126 | +This toolkit processes nitrogen dioxide (NO2) and other pollutant data from satellite observations with these key features: |
| 127 | + |
| 128 | +- **Quality Control**: Filters out low-quality measurements |
| 129 | +- **Spatial Interpolation**: Converts sparse satellite readings to regular grid |
| 130 | +- **Temporal Aggregation**: Daily, weekly, and monthly averages |
| 131 | +- **Visualization**: Generates high-quality maps and time series plots |
| 132 | +- **Data Export**: Creates NetCDF files compatible with other analysis tools |
| 133 | + |
| 134 | +## <div align="center">Contact</div> |
| 135 | + |
| 136 | +For bug reports and feature requests please visit [GitHub Issues](https://github.com/Alex870521/Satellite_S5P/issues). |
0 commit comments