Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Notebook for OPERA RTC mosaics #18

Draft
wants to merge 5 commits into
base: agu_2023
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions image-services/opera_RTC/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: opera_rtc
channels:
- conda-forge
dependencies:
- asf_search>=6.7.0
- gdal
- geopandas
- jupyter
- matplotlib
- numpy
- pip
187 changes: 187 additions & 0 deletions image-services/opera_RTC/opera_RTC_mosaicing.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"collapsed": true,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"# Mosaicing OPERA RTC Images\n",
"\n",
"In this notebook, we will work with products from the Observational Products for End-Users from Remote Sensing Analysis (OPERA) project at the Jet Propolsion Labratory (JPL). OPERA data include Radiometric Terrain Correction (RTC) Synthetic Aperature Radar (SAR) images, which remove distortions by referencing the Copernicous global 30-m (GLO-30) Digital Elevation Model (DEM).\n",
"\n",
"OPERA Products can be accessed using the Alaska Satellite Facility (ASF) SAR Data Search tools via the graphical interface [Vertex](https://search.asf.alaska.edu/#/), the [ASF API](https://docs.asf.alaska.edu/api/basics/) or using the [`asf_search`](https://docs.asf.alaska.edu/asf_search/basics/) python module. If you do not already have one, please create a free [Earthdata Login Account](https://urs.earthdata.nasa.gov/users/new) to access products using ASF Search Tools.\n",
"\n",
"In this module, we will access OPERA RTC images using the `asf_search` python module, download the selected bursts, and merge them to create a mosaic."
]
},
{
"cell_type": "markdown",
"source": [
"## 0. Check Conda environment to manage Python modules\n",
"If running in an OSL environment, run this cell to make sure you have the right conda environment set up! If running in Binder, please skip this cell."
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"from IPython.display import Markdown\n",
"from IPython.display import display\n",
"\n",
"env = !echo $CONDA_PREFIX\n",
"if env != '/home/joyvan/.local/envs/opera_rtc':\n",
"\tdisplay(Markdown(f'<text style=color:red><strong>WARNING:</strong></text>'))\n",
" display(Markdown(f'<text style=color:red>This notebook should be run using the \"rtc_analysis\" conda environment.</text>'))\n",
" display(Markdown(f'<text style=color:red>It is currently using the \"{env[0].split(\"/\")[-1]}\" environment.</text>'))\n",
" display(Markdown(f'<text style=color:red>Select the \"rtc_analysis\" from the \"Change Kernel\" submenu of the \"Kernel\" menu.</text>'))\n",
" display(Markdown(f'<text style=color:red>If the \"rtc_analysis\" environment is not present, use <a href=\"{notebookUrl.split(\"/user\")[0]}/user/{user[0]}/notebooks/conda_environments/Create_OSL_Conda_Environments.ipynb\"> Create_OSL_Conda_Environments.ipynb </a> to create it.</text>'))\n",
" display(Markdown(f'<text style=color:red>Note that you must restart your server after creating a new environment before it is usable by notebooks.</text>'))\n"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"source": [
"## 1. Search for OPERA RTC products over San Francisco\n",
"After checking we have our environment correctly set up, we can perform the search for our desired products.The polygon in the search is centered over San Francisco."
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"import asf_search\n",
"\n",
"options = {\n",
"\t'intersectsWith': 'POLYGON((-122.5306 37.6278,-122.1372 37.6207,-122.1372 37.9566,-122.5287 37.9554,-122.5306 37.6278))',\n",
"\t'dataset': 'OPERA-S1',\n",
"\t'start': '2023-11-14T14:00:00Z',\n",
"\t'end': '2023-11-14T15:00:00Z',\n",
"\t'flightDirection': 'DESCENDING',\n",
"\t'processingLevel': [\n",
"\t\t'RTC',\n",
"\t\t'RTC-STATIC'\n",
"\t],\n",
"\t'maxResults': '1000'\n",
"}\n",
"\n",
"results = asf_search.search(**options)\n",
"print(results)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"source": [
"## 2. Download selected bursts"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"import os\n",
"\n",
"data_directory = f'{os.getcwd()}/data/'\n",
"if not os.path.isdir(data_directory):\n",
"\tos.mkdir(data_directory)\n",
"\n",
"session = asf_search.ASFSession().auth_with_creds('user', 'pass')\n",
"results.download(path=data_directory, session=session)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"source": [
"## 3. Mosaic bursts and save"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"import osgeo_utils.gdal_merge as gdal_merge\n",
"\n",
"output_file_path = f'{os.getcwd()}/OPERA_RTC_San_Francisco.tif'\n",
"input_files_paths = [f'{data_directory}{path}' for path in os.listdir(data_directory)]\n",
"parameters = ['', '-o', output_file_path] + input_files_paths + ['-co', 'COMPRESS=LZW']\n",
"gdal_merge.main(parameters)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}