From 52ca7f27fc97a4deeed2b0e19d12c8c537878c1c Mon Sep 17 00:00:00 2001 From: Emma Marshall <55526386+e-marshall@users.noreply.github.com> Date: Sat, 3 Feb 2024 20:19:32 -0700 Subject: [PATCH] notebook edits --- asf_local_vrt.ipynb | 71 ++++++++++++++++------------------------ dataset_comparison.ipynb | 6 ++-- rtc_timeseries.ipynb | 16 +++++++-- 3 files changed, 46 insertions(+), 47 deletions(-) diff --git a/asf_local_vrt.ipynb b/asf_local_vrt.ipynb index ace5cb5..0b2a1d4 100644 --- a/asf_local_vrt.ipynb +++ b/asf_local_vrt.ipynb @@ -80,7 +80,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "id": "2eb32b85-47b7-4e1d-baeb-48af7116ce6e", "metadata": {}, "outputs": [ @@ -88,14 +88,14 @@ "name": "stdout", "output_type": "stream", "text": [ + "geopandas : 0.14.3\n", "matplotlib: 3.8.2\n", - "dask : 2024.1.1\n", - "markdown : 3.5.2\n", + "xarray : 2024.1.1\n", "pandas : 2.2.0\n", + "dask : 2024.1.1\n", "numpy : 1.26.3\n", - "geopandas : 0.14.3\n", "rioxarray : 0.15.1\n", - "xarray : 2024.1.1\n", + "markdown : 3.5.2\n", "\n" ] } @@ -259,7 +259,11 @@ "id": "e98d128b-1696-4eba-a8a6-b89b08ea2764", "metadata": {}, "source": [ - "Setup string variables to access filenames + filepaths. Currently, the file structure is organized so that each scene has its own sub-directory within `asf_rtcs`. Within each sub-directory are several files - we want to extract the tif files containing RTC imagery for the VV and VH polarizations for each scene. The function `extract_tif_fnames()` takes a path to the directory containing the sub-directories for all scenes and returns a lists of filenames for VV polarization GeoTIFF files, VH polarization GeoTIFF files and the layover-shadow mask GeoTIFF files. Separately, it returns a list of filenames for the associated README files which will be used to extract metadata later on." + "### Organizing Sentinel-1 data to create VRT objects. \n", + "\n", + "Setup string variables to access filenames + filepaths. Currently, the file structure is organized so that each scene has its own sub-directory within `asf_rtcs`. Within each sub-directory are several files - we want to extract the tif files containing RTC imagery for the VV and VH polarizations for each scene.\n", + "\n", + "The function `extract_tif_fnames()` takes a path to the directory containing the sub-directories for all scenes and returns a lists of filenames for VV polarization GeoTIFF files, VH polarization GeoTIFF files and the layover-shadow mask GeoTIFF files. Separately, it returns a list of filenames for the associated README files which will be used to extract metadata later on. " ] }, { @@ -268,13 +272,13 @@ "metadata": {}, "source": [ "```{note}\n", - "If you're following along in your own python environment, replace the string below named `dir_path_all` to be the location of the RTC data on your local machine (or wherever they are stored)\n", + "If you're following along in your own python environment, replace the string below named `dir_path_all` with the path to the directory containing the RTC data on your local machine, then execute `extract_tif_fnames()`. \n", "```" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 56, "id": "dff41701-8f7e-4f22-839f-47260a04419f", "metadata": {}, "outputs": [], @@ -310,7 +314,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 57, "id": "b409a588-e769-49d1-b62b-6f585dc9599f", "metadata": {}, "outputs": [ @@ -323,7 +327,7 @@ " ['S1A_IW_20210821T000314_DVP_RTC30_G_gpuned_748F.README.md.txt'])" ] }, - "execution_count": 7, + "execution_count": 57, "metadata": {}, "output_type": "execute_result" } @@ -342,7 +346,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 58, "id": "62b2361f-961e-463f-b9fa-66d094a24b55", "metadata": {}, "outputs": [], @@ -364,32 +368,6 @@ " fpaths_rm.append(path_readme)" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "af9d00c1-3d50-4528-8fdb-11699dd1777f", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "2164c9e4-2981-4752-bb2e-5c4d738c0993", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['/home/emmamarshall/Desktop/siparcs/asf_rtc_data/asf_rtcs/S1A_IW_20210821T000314_DVP_RTC30_G_gpuned_748F_(1)/S1A_IW_20210821T000314_DVP_RTC30_G_gpuned_748F_VH.tif', '/home/emmamarshall/Desktop/siparcs/asf_rtc_data/asf_rtcs/S1A_IW_20220116T120547_DVP_RTC30_G_gpuned_0D1E_(1)/S1A_IW_20220116T120547_DVP_RTC30_G_gpuned_0D1E_VH.tif', '/home/emmamarshall/Desktop/siparcs/asf_rtc_data/asf_rtcs/S1A_IW_20210708T120545_DVP_RTC30_G_gpuned_3E89_(1)/S1A_IW_20210708T120545_DVP_RTC30_G_gpuned_3E89_VH.tif', '/home/emmamarshall/Desktop/siparcs/asf_rtc_data/asf_rtcs/S1A_IW_20220422T120547_DVP_RTC30_G_gpuned_61B6_(1)/S1A_IW_20220422T120547_DVP_RTC30_G_gpuned_61B6_VH.tif', '/home/emmamarshall/Desktop/siparcs/asf_rtc_data/asf_rtcs/S1A_IW_20220427T121354_DVP_RTC30_G_gpuned_0535_(1)/S1A_IW_20220427T121354_DVP_RTC30_G_gpuned_0535_VH.tif', '/home/emmamarshall/Desktop/siparcs/asf_rtc_data/asf_rtcs/S1A_IW_20220410T120546_DVP_RTC30_G_gpuned_F306_(1)/S1A_IW_20220410T120546_DVP_RTC30_G_gpuned_F306_VH.tif', '/home/emmamarshall/Desktop/siparcs/asf_rtc_data/asf_rtcs/S1A_IW_20220521T121420_DVP_RTC30_G_gpuned_1380_(1)/S1A_IW_20220521T121420_DVP_RTC30_G_gpuned_1380_VH.tif', '/home/emmamarshall/Desktop/siparcs/asf_rtc_data/asf_rtcs/S1A_IW_20210809T000313_DVP_RTC30_G_gpuned_ED8C_(1)/S1A_IW_20210809T000313_DVP_RTC30_G_gpuned_ED8C_VH.tif', '/home/emmamarshall/Desktop/siparcs/asf_rtc_data/asf_rtcs/S1A_IW_20210926T000315_DVP_RTC30_G_gpuned_2CBE_(1)/S1A_IW_20210926T000315_DVP_RTC30_G_gpuned_2CBE_VH.tif', '/home/emmamarshall/Desktop/siparcs/asf_rtc_data/asf_rtcs/S1A_IW_20210502T121414_DVP_RTC30_G_gpuned_1424_(1)/S1A_IW_20210502T121414_DVP_RTC30_G_gpuned_1424_VH.tif']\n" - ] - } - ], - "source": [ - "print(fpaths_vv[0:10])" - ] - }, { "cell_type": "markdown", "id": "c9df335f-c7ca-4b0d-8051-c4882942ffbb", @@ -404,12 +382,16 @@ "metadata": {}, "source": [ "We will be using the `gdalbuildvrt` command. You can find out more about it [here](https://manpages.ubuntu.com/manpages/bionic/man1/gdalbuildvrt.1.html). This command can make a VRT that either tiles the listed files into a large mosaic, or places them each in a separate band of the VRT. Because we are dealing with a temporal stack of images we want to use the `-separate` flag to place each file into a band of the VRT.
\n", - "Because we are making a VRT from a large number of files, we'll supply a text file with the full path for each file rather than include these at the end of the command line. We'll use the same lists of filepaths that we constructed above and will write them to text files that we pass to the `gdalbuildvrt` command." + "Because we are making a VRT from a large number of files, we'll supply a text file with the full path for each file rather than include these at the end of the command line. We'll use the same lists of filepaths that we constructed above and will write them to text files that we pass to the `gdalbuildvrt` command.\n", + "\n", + "```{note}\n", + "If you are following along on your machine, be sure to replace the file paths in the below cell with the location where you would like the text files to be written.\n", + "```" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 59, "id": "a8e761e2-bae8-4f41-82bc-27822a269560", "metadata": {}, "outputs": [], @@ -433,12 +415,17 @@ "id": "78f001f9-2f4b-4f47-a69d-14c662917011", "metadata": {}, "source": [ - "Next, we will use gdal command line tools to create the VRT objects:" + "Next, we will use gdal command line tools to create the VRT objects:\n", + "\n", + "\n", + "```{note}\n", + "If you are following along on your machine, be sure to replace the file paths in the below cell with the location of the .txt files written in the step above.\n", + "```" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 60, "id": "324b2b90-ef83-4828-a083-632d547b0048", "metadata": {}, "outputs": [ @@ -473,7 +460,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 61, "id": "463e4fe1-481b-4bfa-9abe-620e9c0f0d06", "metadata": {}, "outputs": [], diff --git a/dataset_comparison.ipynb b/dataset_comparison.ipynb index 276a806..3d77e57 100644 --- a/dataset_comparison.ipynb +++ b/dataset_comparison.ipynb @@ -143,7 +143,7 @@ " fig, axs = plt.subplots(ncols=2, figsize=(15,10))\n", "\n", " power_to_db(asf_input.vv.isel(acq_date=timestep)).plot(ax=axs[0], cmap=plt.cm.Greys_r, label = 'ASF');\n", - " power_to_db(pc_input.sel(band='vv').isel(time=timestep)).plot(ax=axs[1], cmap=plt.cm.Greys_r, label = 'PC')" + " power_to_db(pc_input.sel(band='vv').isel(time=timestep)).plot(ax=axs[1], cmap=plt.cm.Greys_r, label = 'PC');" ] }, { @@ -156,7 +156,7 @@ "def single_time_mean_compare(asf_input, pc_input, time):\n", " fig, ax = plt.subplots(figsize=(8,8))\n", " power_to_db(asf_input['vv_'].isel(acq_date=time).mean(dim=['x','y'])).plot(ax=ax)\n", - " power_to_db(pc_input.sel(band='vv').isel(time=time).mean(dim=['x','y'])).plot(ax=ax, color='red')" + " power_to_db(pc_input.sel(band='vv').isel(time=time).mean(dim=['x','y'])).plot(ax=ax, color='red');" ] }, { @@ -6113,7 +6113,7 @@ "fig, ax = plt.subplots(figsize=(12,8))\n", "\n", "power_to_db(asf_subset.vv.mean(dim=['x','y'])).plot(ax=ax, color='blue', linestyle='None', marker='o', markersize=5, label = 'ASF')\n", - "power_to_db(pc_subset.sel(band='vv').mean(dim=['x','y'])).plot(ax=ax, color='red', linestyle='None', marker='o', markersize=5, label='PC')" + "power_to_db(pc_subset.sel(band='vv').mean(dim=['x','y'])).plot(ax=ax, color='red', linestyle='None', marker='o', markersize=5, label='PC');" ] }, { diff --git a/rtc_timeseries.ipynb b/rtc_timeseries.ipynb index 37ab24d..f049a4f 100644 --- a/rtc_timeseries.ipynb +++ b/rtc_timeseries.ipynb @@ -2136,7 +2136,7 @@ "\n", "lakes_prj.plot(ax=ax, facecolor='none', edgecolor='blue')\n", "\n", - "fig.suptitle('ASF RTC backscatter image, 30 Apr 2022', fontsize=14)\n" + "fig.suptitle('ASF RTC backscatter image, 30 Apr 2022', fontsize=14);\n" ] }, { @@ -3264,7 +3264,7 @@ "axs[1].set_title('VH backscatter over proglacial lakes 2021-2022')\n", "\n", "legend_elements = [Line2D([0], [0], color = 'r', lw = 3, label = 'lake 1'),\n", - " Line2D([0], [0], color = 'b', lw = 3, label = 'lake 2')] " + " Line2D([0], [0], color = 'b', lw = 3, label = 'lake 2')] ; " ] }, { @@ -3289,6 +3289,18 @@ "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.10.13" } }, "nbformat": 4,