{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "3c51cd02-30bf-4451-acc1-df67c74b077d",
"metadata": {},
"outputs": [],
"source": [
"import geopandas as gpd\n",
"import pandas as pd"
]
},
{
"cell_type": "markdown",
"id": "450102c6-f83c-45b0-9a4c-367e74c64931",
"metadata": {},
"source": [
"# Select background tiles"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3a48992e-c1a5-4b40-980a-2e90ebc87bdb",
"metadata": {},
"outputs": [],
"source": [
"# To use satellite imagery, the `xyzserives` must be installed\n",
"try:\n",
" import xyzservices\n",
"\n",
" tiles = xyzservices.providers[\"Esri\"][\"WorldImagery\"]\n",
"except:\n",
" # Use default\n",
" tiles = None"
]
},
{
"cell_type": "markdown",
"id": "44183ae7-fb8c-4487-a24e-7e68657b9fb6",
"metadata": {},
"source": [
"# Loading data"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "b60271f1-fe0e-4b01-8642-8477e6bc4f08",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" frame_id | \n",
" total_num_bursts | \n",
" burst_id_jpl | \n",
" sensing_date | \n",
" num_candidate_bursts | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 831 | \n",
" 5022 | \n",
" t004_006641_iw1 | \n",
" 2017-02-15 | \n",
" 5298 | \n",
"
\n",
" \n",
" 1 | \n",
" 831 | \n",
" 5022 | \n",
" t004_006641_iw1 | \n",
" 2017-02-27 | \n",
" 5298 | \n",
"
\n",
" \n",
" 2 | \n",
" 831 | \n",
" 5022 | \n",
" t004_006641_iw1 | \n",
" 2017-03-11 | \n",
" 5298 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" frame_id total_num_bursts burst_id_jpl sensing_date \\\n",
"0 831 5022 t004_006641_iw1 2017-02-15 \n",
"1 831 5022 t004_006641_iw1 2017-02-27 \n",
"2 831 5022 t004_006641_iw1 2017-03-11 \n",
"\n",
" num_candidate_bursts \n",
"0 5298 \n",
"1 5298 \n",
"2 5298 "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_selected_bursts = pd.read_csv(\n",
" \"selected_bursts_option0.csv.zip\", parse_dates=[\"sensing_date\"]\n",
")\n",
"df_selected_bursts.sensing_date = df_selected_bursts.sensing_date.dt.date\n",
"\n",
"\n",
"df_selected_bursts.head(3)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "42c00025-a689-4767-ae33-d9ea0239e2dc",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" date_count | \n",
"
\n",
" \n",
" burst_id_jpl | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" t004_006641_iw1 | \n",
" 186 | \n",
"
\n",
" \n",
" t004_006641_iw2 | \n",
" 186 | \n",
"
\n",
" \n",
" t004_006641_iw3 | \n",
" 186 | \n",
"
\n",
" \n",
" t004_006642_iw1 | \n",
" 186 | \n",
"
\n",
" \n",
" t004_006642_iw2 | \n",
" 186 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" date_count\n",
"burst_id_jpl \n",
"t004_006641_iw1 186\n",
"t004_006641_iw2 186\n",
"t004_006641_iw3 186\n",
"t004_006642_iw1 186\n",
"t004_006642_iw2 186"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_selected_bursts_grouped = (\n",
" df_selected_bursts[[\"burst_id_jpl\", \"frame_id\"]]\n",
" .groupby((\"burst_id_jpl\"))\n",
" .count()\n",
" .rename({\"frame_id\": \"date_count\"}, axis=1)\n",
")\n",
"\n",
"df_selected_bursts_grouped.head()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "d91d08f5-cc68-40ee-876e-445249e2757b",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" frame_id | \n",
" burst_id_jpl | \n",
" orbit_pass | \n",
" geometry | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1653 | \n",
" t007_013218_iw1 | \n",
" ASCENDING | \n",
" MULTIPOLYGON (((-157.82827 55.48763, -157.1283... | \n",
"
\n",
" \n",
" 1 | \n",
" 1653 | \n",
" t007_013222_iw3 | \n",
" ASCENDING | \n",
" MULTIPOLYGON (((-155.37657 56.54824, -154.7210... | \n",
"
\n",
" \n",
" 2 | \n",
" 1653 | \n",
" t007_013225_iw2 | \n",
" ASCENDING | \n",
" MULTIPOLYGON (((-156.93933 56.84940, -156.1855... | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" frame_id burst_id_jpl orbit_pass \\\n",
"0 1653 t007_013218_iw1 ASCENDING \n",
"1 1653 t007_013222_iw3 ASCENDING \n",
"2 1653 t007_013225_iw2 ASCENDING \n",
"\n",
" geometry \n",
"0 MULTIPOLYGON (((-157.82827 55.48763, -157.1283... \n",
"1 MULTIPOLYGON (((-155.37657 56.54824, -154.7210... \n",
"2 MULTIPOLYGON (((-156.93933 56.84940, -156.1855... "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_burst_geoms = gpd.read_file(\"na_bursts_with_geom.geojson.zip\")\n",
"df_burst_geoms.head(3)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "a02f2b4d-8fb0-4679-9bf9-1390448533d8",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" burst_id_jpl | \n",
" date_count | \n",
" frame_id | \n",
" orbit_pass | \n",
" geometry | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" t004_006641_iw1 | \n",
" 186 | \n",
" 831 | \n",
" ASCENDING | \n",
" MULTIPOLYGON (((-77.59315 33.46137, -77.11728 ... | \n",
"
\n",
" \n",
" 1 | \n",
" t004_006641_iw2 | \n",
" 186 | \n",
" 831 | \n",
" ASCENDING | \n",
" MULTIPOLYGON (((-76.71825 33.66354, -76.22176 ... | \n",
"
\n",
" \n",
" 2 | \n",
" t004_006641_iw3 | \n",
" 186 | \n",
" 831 | \n",
" ASCENDING | \n",
" MULTIPOLYGON (((-75.79204 33.85517, -75.35592 ... | \n",
"
\n",
" \n",
" 3 | \n",
" t004_006642_iw1 | \n",
" 186 | \n",
" 831 | \n",
" ASCENDING | \n",
" MULTIPOLYGON (((-77.63169 33.62745, -77.15485 ... | \n",
"
\n",
" \n",
" 4 | \n",
" t004_006642_iw2 | \n",
" 186 | \n",
" 831 | \n",
" ASCENDING | \n",
" MULTIPOLYGON (((-76.75500 33.82960, -76.25752 ... | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" burst_id_jpl date_count frame_id orbit_pass \\\n",
"0 t004_006641_iw1 186 831 ASCENDING \n",
"1 t004_006641_iw2 186 831 ASCENDING \n",
"2 t004_006641_iw3 186 831 ASCENDING \n",
"3 t004_006642_iw1 186 831 ASCENDING \n",
"4 t004_006642_iw2 186 831 ASCENDING \n",
"\n",
" geometry \n",
"0 MULTIPOLYGON (((-77.59315 33.46137, -77.11728 ... \n",
"1 MULTIPOLYGON (((-76.71825 33.66354, -76.22176 ... \n",
"2 MULTIPOLYGON (((-75.79204 33.85517, -75.35592 ... \n",
"3 MULTIPOLYGON (((-77.63169 33.62745, -77.15485 ... \n",
"4 MULTIPOLYGON (((-76.75500 33.82960, -76.25752 ... "
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_burst_count = pd.merge(df_selected_bursts_grouped, df_burst_geoms, on=\"burst_id_jpl\")\n",
"df_burst_count = gpd.GeoDataFrame(df_burst_count, geometry=\"geometry\")\n",
"df_burst_count.head()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "de0c425f",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" frame_id | \n",
" geometry | \n",
" date_count | \n",
" orbit_pass | \n",
" path_number | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 831 | \n",
" POLYGON ((-77.63462 33.64007, -77.67350 33.807... | \n",
" 186 | \n",
" ASCENDING | \n",
" 4 | \n",
"
\n",
" \n",
" 1 | \n",
" 832 | \n",
" POLYGON ((-77.94234 34.97052, -77.98167 35.136... | \n",
" 387 | \n",
" ASCENDING | \n",
" 4 | \n",
"
\n",
" \n",
" 2 | \n",
" 833 | \n",
" POLYGON ((-78.25450 36.29876, -78.29421 36.463... | \n",
" 402 | \n",
" ASCENDING | \n",
" 4 | \n",
"
\n",
" \n",
" 3 | \n",
" 834 | \n",
" POLYGON ((-78.57216 37.62689, -78.61245 37.791... | \n",
" 399 | \n",
" ASCENDING | \n",
" 4 | \n",
"
\n",
" \n",
" 4 | \n",
" 835 | \n",
" POLYGON ((-78.89565 38.95445, -78.93684 39.119... | \n",
" 394 | \n",
" ASCENDING | \n",
" 4 | \n",
"
\n",
" \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" 1428 | \n",
" 46541 | \n",
" POLYGON ((-134.76723 56.39017, -135.42777 56.4... | \n",
" 284 | \n",
" DESCENDING | \n",
" 174 | \n",
"
\n",
" \n",
" 1429 | \n",
" 46542 | \n",
" POLYGON ((-135.18571 55.07265, -135.82487 55.1... | \n",
" 271 | \n",
" DESCENDING | \n",
" 174 | \n",
"
\n",
" \n",
" 1430 | \n",
" 46543 | \n",
" POLYGON ((-135.58757 53.75420, -136.20699 53.8... | \n",
" 264 | \n",
" DESCENDING | \n",
" 174 | \n",
"
\n",
" \n",
" 1431 | \n",
" 46799 | \n",
" MULTIPOLYGON (((-151.98765 70.03128, -153.1816... | \n",
" 2 | \n",
" DESCENDING | \n",
" 175 | \n",
"
\n",
" \n",
" 1432 | \n",
" 46800 | \n",
" POLYGON ((-149.95093 69.73885, -150.09686 69.5... | \n",
" 1 | \n",
" DESCENDING | \n",
" 175 | \n",
"
\n",
" \n",
"
\n",
"
1433 rows × 5 columns
\n",
"
"
],
"text/plain": [
" frame_id geometry date_count \\\n",
"0 831 POLYGON ((-77.63462 33.64007, -77.67350 33.807... 186 \n",
"1 832 POLYGON ((-77.94234 34.97052, -77.98167 35.136... 387 \n",
"2 833 POLYGON ((-78.25450 36.29876, -78.29421 36.463... 402 \n",
"3 834 POLYGON ((-78.57216 37.62689, -78.61245 37.791... 399 \n",
"4 835 POLYGON ((-78.89565 38.95445, -78.93684 39.119... 394 \n",
"... ... ... ... \n",
"1428 46541 POLYGON ((-134.76723 56.39017, -135.42777 56.4... 284 \n",
"1429 46542 POLYGON ((-135.18571 55.07265, -135.82487 55.1... 271 \n",
"1430 46543 POLYGON ((-135.58757 53.75420, -136.20699 53.8... 264 \n",
"1431 46799 MULTIPOLYGON (((-151.98765 70.03128, -153.1816... 2 \n",
"1432 46800 POLYGON ((-149.95093 69.73885, -150.09686 69.5... 1 \n",
"\n",
" orbit_pass path_number \n",
"0 ASCENDING 4 \n",
"1 ASCENDING 4 \n",
"2 ASCENDING 4 \n",
"3 ASCENDING 4 \n",
"4 ASCENDING 4 \n",
"... ... ... \n",
"1428 DESCENDING 174 \n",
"1429 DESCENDING 174 \n",
"1430 DESCENDING 174 \n",
"1431 DESCENDING 175 \n",
"1432 DESCENDING 175 \n",
"\n",
"[1433 rows x 5 columns]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Aggregate burst-wise polygons\n",
"frame_based = df_burst_count.dissolve(by='frame_id').reset_index()\n",
"frame_based[\"path_number\"] = frame_based.burst_id_jpl.str[1:4].astype(int)\n",
"frame_based = frame_based.drop(columns='burst_id_jpl')\n",
"frame_based"
]
},
{
"cell_type": "markdown",
"id": "45f2dd42-3164-4ed8-98bf-f82ad28a51c7",
"metadata": {},
"source": [
"# View Ascending Frames"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "9bf12ea4-f24e-4fc3-b223-877e9a2bf357",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"Make this Notebook Trusted to load map: File -> Trust Notebook
"
],
"text/plain": [
""
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"frame_based[frame_based.orbit_pass == \"ASCENDING\"].explore(tiles=tiles, color='red')"
]
},
{
"cell_type": "markdown",
"id": "bae98fee",
"metadata": {},
"source": [
"# View Descending Frames"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "f59090d5",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"Make this Notebook Trusted to load map: File -> Trust Notebook
"
],
"text/plain": [
""
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"frame_based[frame_based.orbit_pass == \"DESCENDING\"].explore(tiles=tiles)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0a96bf76",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}