Release SkillBank-EB (part 2)
Browse files
qwen3-4b-instruct-2507/water-index-trend-analysis/SKILL.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: water-index-trend-analysis
|
| 3 |
+
description: "Analyze time-series surface reflectance data to assess vegetation moisture dynamics by removing cloud contamination, computing normalized difference water index (NDWI) values, averaging results across time points, and determining the long-term trend in water content."
|
| 4 |
+
---
|
| 5 |
+
# water-index-trend-analysis
|
| 6 |
+
|
| 7 |
+
## When to use
|
| 8 |
+
Use when a user needs to evaluate changes in water content over time in a specific region using satellite-derived surface reflectance data, requiring cloud removal, NDWI computation, temporal averaging, and trend detection.
|
| 9 |
+
|
| 10 |
+
## Plan
|
| 11 |
+
1. Retrieve all available surface reflectance and quality assessment raster files from the specified directory to establish the full dataset for analysis.
|
| 12 |
+
2. For each surface reflectance band paired with its corresponding quality assessment layer, apply a cloud and shadow mask to produce a clean, cloud-free version of the band, preserving the original spatial structure and metadata.
|
| 13 |
+
3. Using the masked near-infrared and shortwave infrared bands, compute the normalized difference water index (NDWI) for each date to quantify water content in the landscape.
|
| 14 |
+
4. Aggregate the NDWI values across all time points by calculating the mean pixel value for each image, forming a time-series of average NDWI values.
|
| 15 |
+
5. Fit a linear regression model to the time-series data to determine the trend in NDWI over time, using the time index as the independent variable and the mean NDWI values as the dependent variable.
|
| 16 |
+
6. Terminate only after the linear trend slope and intercept have been computed and verified through the full sequence of observations.
|
| 17 |
+
|
| 18 |
+
## Grounded Observation Routing
|
| 19 |
+
- The list of input raster files produced by get_filelist is used to identify all available surface reflectance and quality assessment bands for processing.
|
| 20 |
+
- The cloud-masked surface reflectance band from the first apply_cloud_mask call is consumed by the calculate_ndwi tool as the input in the near-infrared channel.
|
| 21 |
+
- The cloud-masked surface reflectance band from the second apply_cloud_mask call is consumed by the calculate_ndwi tool as the input in the shortwave infrared channel.
|
| 22 |
+
- The NDWI image outputs generated by calculate_ndwi for each date are collected and passed to calc_batch_image_mean as a list of file paths to compute time-averaged values.
|
| 23 |
+
- The list of mean NDWI values produced by calc_batch_image_mean is used as the dependent variable y in compute_linear_trend, while the corresponding time indices are used as the independent variable x to determine the trend slope and intercept.
|
| 24 |
+
|
| 25 |
+
## tool-list
|
| 26 |
+
|
| 27 |
+
### get_filelist
|
| 28 |
+
|
| 29 |
+
**Parameters:** dir_path
|
| 30 |
+
|
| 31 |
+
**Description:**
|
| 32 |
+
|
| 33 |
+
Returns a list of files in the specified directory.
|
| 34 |
+
|
| 35 |
+
Parameters:
|
| 36 |
+
dir_path (str): Path to the directory.
|
| 37 |
+
|
| 38 |
+
Returns:
|
| 39 |
+
list: List of file names in the directory.
|
| 40 |
+
|
| 41 |
+
### apply_cloud_mask
|
| 42 |
+
|
| 43 |
+
**Parameters:** sr_band_path, qa_pixel_path, output_path
|
| 44 |
+
|
| 45 |
+
**Description:**
|
| 46 |
+
|
| 47 |
+
Apply cloud/shadow mask to a single Landsat 8 surface reflectance band using QA_PIXEL band.
|
| 48 |
+
|
| 49 |
+
Parameters:
|
| 50 |
+
sr_band_path (str): Path to surface reflectance band (e.g., SR_B3 or SR_B5).
|
| 51 |
+
qa_pixel_path (str): Path to QA_PIXEL band.
|
| 52 |
+
output_path (str): relative path for the output raster file, e.g. "question17/cloud_mask_2022-01-16.tif"
|
| 53 |
+
|
| 54 |
+
Returns:
|
| 55 |
+
str: Path to the saved masked raster file.
|
| 56 |
+
|
| 57 |
+
### calculate_ndwi
|
| 58 |
+
|
| 59 |
+
**Parameters:** (none)
|
| 60 |
+
|
| 61 |
+
**Description:**
|
| 62 |
+
|
| 63 |
+
Registered tool
|
| 64 |
+
|
| 65 |
+
### calc_batch_image_mean
|
| 66 |
+
|
| 67 |
+
**Parameters:** file_list, uint8 (optional)
|
| 68 |
+
|
| 69 |
+
**Description:**
|
| 70 |
+
|
| 71 |
+
Compute mean value of an batch of images.
|
| 72 |
+
|
| 73 |
+
Args:
|
| 74 |
+
file_list (list): List of image file paths.
|
| 75 |
+
uint8 (bool): Whether to convert image to uint8 format.
|
| 76 |
+
|
| 77 |
+
Returns:
|
| 78 |
+
mean (list): List of mean pixel values.
|
| 79 |
+
|
| 80 |
+
### compute_linear_trend
|
| 81 |
+
|
| 82 |
+
**Parameters:** y, x (optional)
|
| 83 |
+
|
| 84 |
+
**Description:**
|
| 85 |
+
|
| 86 |
+
Description
|
| 87 |
+
|
| 88 |
+
Computes the linear trend (slope and intercept) of a time series by fitting a line of the form:
|
| 89 |
+
|
| 90 |
+
y = a \cdot x + b
|
| 91 |
+
|
| 92 |
+
using the least squares method.
|
| 93 |
+
|
| 94 |
+
Parameters
|
| 95 |
+
• y (list):
|
| 96 |
+
The dependent variable — typically your time series data.
|
| 97 |
+
• x (list):
|
| 98 |
+
The independent variable — usually time indices. If not provided, the function will use np.arange(len(y)) as a default.
|
| 99 |
+
|
| 100 |
+
Returns
|
| 101 |
+
• slope (float):
|
| 102 |
+
The coefficient a — represents the trend.
|
| 103 |
+
• > 0: upward trend
|
| 104 |
+
• < 0: downward trend
|
| 105 |
+
• ≈ 0: no trend
|
| 106 |
+
• intercept (float):
|
| 107 |
+
The y-intercept b of the fitted line.
|