Skip to content

Commit

Permalink
Update Notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanAmr3 committed Mar 18, 2024
1 parent 90228e5 commit 3a98573
Showing 1 changed file with 41 additions and 46 deletions.
87 changes: 41 additions & 46 deletions docs/examples/intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"outputs": [],
"source": [
"from earthstat.earthstat import EarthStat"
"from earthstat import EarthStat"
]
},
{
Expand Down Expand Up @@ -301,28 +301,12 @@
" country_column_name)"
]
},
{
"cell_type": "markdown",
"id": "68df9be6-46de-4884-a2f3-fc1416bf5c79",
"metadata": {},
"source": [
"### Extract Statistical Data"
]
},
{
"cell_type": "markdown",
"id": "24bc6019-d6ec-4b3c-ad8c-402924f8aabc",
"metadata": {},
"source": [
"#### Normal Processing"
]
},
{
"cell_type": "markdown",
"id": "47bdbf42-4d38-4079-97b7-d2efe17b38fb",
"metadata": {},
"source": [
"##### 1. Clipping Predictor Data\n",
"### Clipping Predictor Data\n",
"\n",
"Clip the predictor data to the boundaries defined in the main shapefile. "
]
Expand Down Expand Up @@ -375,16 +359,29 @@
"id": "8e3bdd16",
"metadata": {},
"source": [
"> **Caution:** Running clip withtout select ROI, will clip rasters using main shapefile."
"> **Note & Caution:** The Function is a multiprocessing process. Using the main shapefile without filtering may led to system crash or error due to the big amount of geometry objects in original shapefile."
]
},
{
"cell_type": "markdown",
"id": "424741da-2cf0-4be5-b103-88e812ec3984",
"metadata": {},
"source": [
"##### 2.Executing Data Aggregation\n",
"Start data aggregation process, leveraging the clipped predictor data, resampled mask, and the selectively filtered shapefile to perform detailed analysis."
"### Executing Data Aggregation\n",
"Start data aggregation process, leveraging the predictor data, mask, and the filtered shapefile.\n",
"\n",
"##### Parameters\n",
"\n",
"- `use_mask` (**bool**): Specifies whether to apply a mask to the raster data. When set to `True`, the function will use the mask path provided (if applicable) to only process areas within the mask. Default is `False`.\n",
" \n",
"- `invalid_values` (**list of int**): A list of pixel values to be treated as invalid and excluded from the aggregation. For example, `[255, 254, 251]` can be used to ignore certain values that represent no data or errors in the raster files.\n",
"\n",
"- `calculation_mode` (**str**): Determines the mode of aggregation for pixel values. Supported modes include:\n",
" - `\"overall_mean\"`: Calculates the mean of all valid pixel values across the raster dataset.\n",
" - `\"weighted_mean\"`: Calculates the weighted mean of the valid pixel values using the mask values as weights. This mode is applicable only when `use_mask` is `True` and a valid `mask_path` is provided.\n",
" - `\"filtered_mean\"`: Applies a filter using the validated mask values to mask the data before calculating the mean. This mode is intended for scenarios where only specific parts of the raster that meet certain conditions (defined by the mask) should contribute to the mean calculation.\n",
"\n",
"- `all_touched` (**bool**): If set to `True`, all pixels touched by geometries will be included in the mask. If `False`, only pixels whose center is within the geometry or touching the geometry boundary will be included. Default is `False`."
]
},
{
Expand Down Expand Up @@ -426,15 +423,12 @@
}
],
"source": [
"%time fpar_aggregator.runAggregation()"
]
},
{
"cell_type": "markdown",
"id": "ecf8481e-bc80-4ab9-ba94-062232d82db5",
"metadata": {},
"source": [
"### Parallel Processing"
"# Mask On\n",
"use_mask=True\n",
"calculation_mode=\"weighted_mean\"\n",
"all_touched=False\n",
"\n",
"%time fpar_aggregator.runAggregation(use_mask, invalid_values, calculation_mode, all_touched)"
]
},
{
Expand All @@ -444,22 +438,7 @@
"source": [
"### Parallel Processing with `runParallelAggregation`\n",
"\n",
"The `runParallelAggregation` method is designed to process and aggregate raster data across multiple files in parallel, enhancing performance for large datasets. This method leverages multiple CPU cores to simultaneously process different portions of the data, reducing overall computation time.\n",
"\n",
"#### Parameters\n",
"\n",
"- `use_mask` (**bool**): Specifies whether to apply a mask to the raster data. When set to `True`, the function will use the mask path provided (if applicable) to only process areas within the mask. Default is `False`.\n",
" \n",
"- `invalid_values` (**list of int**): A list of pixel values to be treated as invalid and excluded from the aggregation. For example, `[255, 254, 251]` can be used to ignore certain values that represent no data or errors in the raster files.\n",
"\n",
"- `calculation_mode` (**str**): Determines the mode of aggregation for pixel values. Supported modes include:\n",
" - `\"overall_mean\"`: Calculates the mean of all valid pixel values across the raster dataset.\n",
" - `\"weighted_mean\"`: Calculates the weighted mean of the valid pixel values using the mask values as weights. This mode is applicable only when `use_mask` is `True` and a valid `mask_path` is provided.\n",
" - `\"filtered_mean\"`: Applies a filter using the validated mask values to mask the data before calculating the mean. This mode is intended for scenarios where only specific parts of the raster that meet certain conditions (defined by the mask) should contribute to the mean calculation.\n",
"\n",
"- `all_touched` (**bool**): If set to `True`, all pixels touched by geometries will be included in the mask. If `False`, only pixels whose center is within the geometry or touching the geometry boundary will be included. Default is `False`.\n",
"\n",
"> **Caution:** This function combine clipping and aggregation, so it does not save clipped raster."
"The `runParallelAggregation` method is designed to process and aggregate raster data across multiple files in parallel, enhancing performance for large datasets. This method leverages multiple CPU cores to simultaneously process different portions of the data, reducing overall computation time."
]
},
{
Expand Down Expand Up @@ -550,6 +529,22 @@
"\n",
"%time fpar_aggregator.runParallelAggregation(use_mask, invalid_values, calculation_mode, all_touched)"
]
},
{
"cell_type": "markdown",
"id": "b0de7fca",
"metadata": {},
"source": [
"> **Caution:** `runAggregation` and `runParallelAggregation` function combine clipping and aggregation, so it does not save clipped raster, if you did not clip."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "474d63cf",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 3a98573

Please sign in to comment.