Skip to content

Commit

Permalink
line length
Browse files Browse the repository at this point in the history
  • Loading branch information
lillythomas committed Mar 25, 2024
1 parent bcd8215 commit c5ffe19
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions docs/patch_level_cloud_cover.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,14 @@
" for j in range(embeddings_patch_avg_group.shape[1]):\n",
" embeddings_output_patch = embeddings_patch_avg_group[i, j]\n",
"\n",
" item_ = [element for element in list(chunk_bounds.items()) if element[0] == (i,j)]\n",
" item_ = [\n",
" element for element in list(chunk_bounds.items()) if element[0] == (i,j)\n",
" ]\n",
" box_ = [item_[0][1]['lon_start'], item_[0][1]['lat_start'],\n",
" item_[0][1]['lon_end'], item_[0][1]['lat_end']]\n",
" cloud_pct_ = [element for element in list(cloud_pcts.items()) if element[0] == (i,j)]\n",
" cloud_pct_ = [\n",
" element for element in list(cloud_pcts.items()) if element[0] == (i,j)\n",
" ]\n",
" source_url = batch[\"source_url\"]\n",
" date = batch[\"date\"]\n",
" data = {\n",
Expand Down Expand Up @@ -714,7 +718,8 @@
"metadata": {},
"outputs": [],
"source": [
"# Get indices for patches where cloud percentages exceed some interesting threshold\n",
"# Get indices for patches where cloud percentages \n",
"# exceed some interesting threshold\n",
"cloudy_indices = []\n",
"for key, value in cloud_pcts.items():\n",
" if value > 80:\n",
Expand Down Expand Up @@ -759,7 +764,8 @@
},
"outputs": [],
"source": [
"# Get indices for patches where cloud percentages do not exceed some interesting threshold\n",
"# Get indices for patches where cloud percentages \n",
"# do not exceed some interesting threshold\n",
"non_cloudy_indices = []\n",
"for key, value in cloud_pcts.items():\n",
" if value < 10:\n",
Expand Down Expand Up @@ -846,7 +852,9 @@
" window_index = idxs_windows['idx'].index(idx)\n",
" window_data = idxs_windows['window'][window_index]\n",
" #print(window_data.shape)\n",
" subset_img = numpy.clip((window_data.transpose(1,2,0)[:, :, :3]/10_000) * 3, 0,1)\n",
" subset_img = numpy.clip(\n",
" (window_data.transpose(1,2,0)[:, :, :3]/10_000) * 3, 0,1\n",
" )\n",
" ax.imshow(subset_img)\n",
" ax.set_title(f\"{tile}/{idx}/{row.cloud_cover}\")\n",
" ax.set_axis_off()\n",
Expand Down Expand Up @@ -908,13 +916,15 @@
"# Make geodataframe of the search results\n",
"# cloudy\n",
"result_cloudy_boxes = [\n",
" Polygon([(bbox[0], bbox[1]), (bbox[2], bbox[1]), (bbox[2], bbox[3]), (bbox[0], bbox[3])]) \n",
" Polygon([(bbox[0], bbox[1]), (bbox[2], bbox[1]), \n",
" (bbox[2], bbox[3]), (bbox[0], bbox[3])]) \n",
" for bbox in result_cloudy['box']]\n",
"result_cloudy_gdf = gpd.GeoDataFrame(result_cloudy, geometry=result_cloudy_boxes)\n",
"result_cloudy_gdf.crs = \"EPSG:4326\"\n",
"# non-cloudy\n",
"result_non_cloudy_boxes = [\n",
" Polygon([(bbox[0], bbox[1]), (bbox[2], bbox[1]), (bbox[2], bbox[3]), (bbox[0], bbox[3])]) \n",
" Polygon([(bbox[0], bbox[1]), (bbox[2], bbox[1]), \n",
" (bbox[2], bbox[3]), (bbox[0], bbox[3])]) \n",
" for bbox in result_non_cloudy['box']]\n",
"result_non_cloudy_gdf = gpd.GeoDataFrame(\n",
" result_non_cloudy, geometry=result_non_cloudy_boxes)\n",
Expand Down

0 comments on commit c5ffe19

Please sign in to comment.