Skip to content

Commit

Permalink
move SCL cloud labels to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
lillythomas committed Mar 18, 2024
1 parent b46d381 commit c82dd39
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions docs/patch_level_cloud_cover.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
" \"scl\": [\"scl\"],\n",
"}\n",
"\n",
"# Cloud labels in the SCL band: https://docs.sentinel-hub.com/api/latest/data/sentinel-2-l2a/\n",
"SCL_CLOUD_LABELS = [7, 8, 9, 10]\n",
"\n",
"STAC_API = \"https://earth-search.aws.element84.com/v1\"\n",
"COLLECTION = \"sentinel-2-l2a\""
]
Expand Down Expand Up @@ -273,11 +276,10 @@
"source": [
"# Function to count cloud pixels in a subset\n",
"def count_cloud_pixels(subset_scl):\n",
" # Cloud labels in the SCL band: https://docs.sentinel-hub.com/api/latest/data/sentinel-2-l2a/\n",
" cloud_pixels_7 = numpy.count_nonzero(subset_scl == 7)\n",
" cloud_pixels_8 = numpy.count_nonzero(subset_scl == 8)\n",
" cloud_pixels_9 = numpy.count_nonzero(subset_scl == 9)\n",
" cloud_pixels_10 = numpy.count_nonzero(subset_scl == 10)\n",
" cloud_pixels_7 = numpy.count_nonzero(subset_scl == SCL_CLOUD_LABELS[0])\n",
" cloud_pixels_8 = numpy.count_nonzero(subset_scl == SCL_CLOUD_LABELS[1])\n",
" cloud_pixels_9 = numpy.count_nonzero(subset_scl == SCL_CLOUD_LABELS[2])\n",
" cloud_pixels_10 = numpy.count_nonzero(subset_scl == SCL_CLOUD_LABELS[3])\n",
" cloud_pixels = cloud_pixels_7 + cloud_pixels_8 + cloud_pixels_9 + cloud_pixels_10\n",
" return cloud_pixels\n",
"\n",
Expand Down

0 comments on commit c82dd39

Please sign in to comment.