Skip to content

Commit

Permalink
add download from S3
Browse files Browse the repository at this point in the history
  • Loading branch information
clausmichele committed Jan 20, 2025
1 parent 2edeb2d commit db29073
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions extract_burst_number.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -931,13 +931,45 @@
"print(f'Subswath: {SwathIdentifier}, Burst number: {tops_split_number}')"
]
},
{
"cell_type": "markdown",
"id": "c2ff6948-f42b-49b4-9b83-51094ab96a5e",
"metadata": {},
"source": [
"## 3) Get the data from the S3 bucket\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d8e8f9f6-ad6b-469d-8e50-7d5a804c49db",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"os.environ[\"AWS_ACCESS_KEY_ID\"] = \"\"\n",
"os.environ[\"AWS_SECRET_ACCESS_KEY\"] = \"\"\n",
"\n",
"if PolarisationChannels==\"VV\":\n",
" exclude_pol='vh'\n",
"elif PolarisationChannels==\"VH\":\n",
" exclude_pol='vv'\n",
"\n",
"s3_endpoint = \"eodata.dataspace.copernicus.eu\"\n",
"subswath_id = SwathIdentifier.lower()\n",
"in_path = bursts[\"value\"][0][\"S3Path\"].split(\".SAFE\")[0] + \".SAFE\"\n",
"output_path = bursts[\"value\"][0][\"S3Path\"].split(\".SAFE\")[0].split(\"/\")[-1] + \".SAFE/\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3b0156da-7baf-4e61-b4fb-4893c6eefd04",
"id": "9c726da0-237b-47fe-a2cd-9bbd193fa829",
"metadata": {},
"outputs": [],
"source": []
"source": [
"os.system(f\"s5cmd --endpoint-url \\\"https://{s3_endpoint}\\\" cp --include \\\"*{subswath_id}*\\\" --exclude \\\"*{exclude_pol}*\\\" --include \\\"manifest.safe\\\" \\\"s3:/\\\"{in_path}\\\"/*\\\" {output_path}/\")"
]
}
],
"metadata": {
Expand All @@ -956,7 +988,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.0"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down

0 comments on commit db29073

Please sign in to comment.