From dcf634c044e3b70fd1f383527bbb27b045034717 Mon Sep 17 00:00:00 2001 From: annajungbluth Date: Fri, 2 Feb 2024 14:52:16 +0000 Subject: [PATCH] added notebook to investiagte modis bowtie distortions --- .../0.3-MODIS-distortion-investigation.ipynb | 983 +++++++++++++++++- 1 file changed, 980 insertions(+), 3 deletions(-) diff --git a/notebooks/dev/modis/0.3-MODIS-distortion-investigation.ipynb b/notebooks/dev/modis/0.3-MODIS-distortion-investigation.ipynb index 07259ed..648d1a7 100644 --- a/notebooks/dev/modis/0.3-MODIS-distortion-investigation.ipynb +++ b/notebooks/dev/modis/0.3-MODIS-distortion-investigation.ipynb @@ -4156,14 +4156,991 @@ "ds" ] }, + { + "cell_type": "markdown", + "id": "35faca24", + "metadata": {}, + "source": [ + "### Converting Scaled Integers to Radiances" + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "id": "bd19810f", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
<xarray.DataArray 'EV_250_Aggr1km_RefSB' (Band_250M:MODIS_SWATH_Type_L1B: 2,\n",
+       "                                          10*nscans:MODIS_SWATH_Type_L1B: 2030,\n",
+       "                                          Max_EV_frames:MODIS_SWATH_Type_L1B: 1354)>\n",
+       "[5497240 values with dtype=float32]\n",
+       "Dimensions without coordinates: Band_250M:MODIS_SWATH_Type_L1B,\n",
+       "                                10*nscans:MODIS_SWATH_Type_L1B,\n",
+       "                                Max_EV_frames:MODIS_SWATH_Type_L1B\n",
+       "Attributes: (12/13)\n",
+       "    long_name:                 Earth View 250M Aggregated 1km Reflective Sola...\n",
+       "    units:                     none\n",
+       "    valid_range:               [    0 32767]\n",
+       "    band_names:                1,2\n",
+       "    radiance_scales:           [0.02907379 0.01079062]\n",
+       "    radiance_offsets:          [-0. -0.]\n",
+       "    ...                        ...\n",
+       "    reflectance_scales:        [5.7002773e-05 3.4247674e-05]\n",
+       "    reflectance_offsets:       [-0. -0.]\n",
+       "    reflectance_units:         none\n",
+       "    corrected_counts_scales:   [0.1249733 0.1249733]\n",
+       "    corrected_counts_offsets:  [-0. -0.]\n",
+       "    corrected_counts_units:    counts
" + ], + "text/plain": [ + "\n", + "[5497240 values with dtype=float32]\n", + "Dimensions without coordinates: Band_250M:MODIS_SWATH_Type_L1B,\n", + " 10*nscans:MODIS_SWATH_Type_L1B,\n", + " Max_EV_frames:MODIS_SWATH_Type_L1B\n", + "Attributes: (12/13)\n", + " long_name: Earth View 250M Aggregated 1km Reflective Sola...\n", + " units: none\n", + " valid_range: [ 0 32767]\n", + " band_names: 1,2\n", + " radiance_scales: [0.02907379 0.01079062]\n", + " radiance_offsets: [-0. -0.]\n", + " ... ...\n", + " reflectance_scales: [5.7002773e-05 3.4247674e-05]\n", + " reflectance_offsets: [-0. -0.]\n", + " reflectance_units: none\n", + " corrected_counts_scales: [0.1249733 0.1249733]\n", + " corrected_counts_offsets: [-0. -0.]\n", + " corrected_counts_units: counts" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ds.EV_250_Aggr1km_RefSB" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "id": "18e929a4", + "metadata": {}, + "outputs": [], + "source": [ + "radiance_scale = ds.EV_250_Aggr1km_RefSB.radiance_scales\n", + "radiance_offsets = ds.EV_250_Aggr1km_RefSB.radiance_offsets" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "id": "2484c068", + "metadata": {}, + "outputs": [], + "source": [ + "data = ds.EV_250_Aggr1km_RefSB[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "id": "53f42625", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Max value: 14875.0\n", + "Min value: 205.0\n" + ] + } + ], + "source": [ + "print('Max value: ', max(data.values.flatten()))\n", + "print('Min value: ', min(data.values.flatten()))" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "id": "14e80b07", + "metadata": {}, + "outputs": [], + "source": [ + "corrected_data = (data - radiance_offsets[0])*radiance_scale[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "id": "e11254fc", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
<xarray.DataArray 'EV_250_Aggr1km_RefSB' (10*nscans:MODIS_SWATH_Type_L1B: 2030,\n",
+       "                                          Max_EV_frames:MODIS_SWATH_Type_L1B: 1354)>\n",
+       "array([[ 91.17539 ,  94.14092 ,  99.694016, ..., 152.89905 , 144.06061 ,\n",
+       "        157.40547 ],\n",
+       "       [ 94.46073 ,  95.30387 , 102.833984, ..., 134.9896  , 154.55624 ,\n",
+       "        144.52579 ],\n",
+       "       [ 95.739975,  91.69872 ,  97.97866 , ...,  93.76296 , 140.1938  ,\n",
+       "        151.6198  ],\n",
+       "       ...,\n",
+       "       [184.47318 , 183.97891 , 180.02489 , ..., 243.52203 , 240.06226 ,\n",
+       "        232.44492 ],\n",
+       "       [183.07764 , 185.25816 , 179.85043 , ..., 236.80598 , 236.16637 ,\n",
+       "        230.52605 ],\n",
+       "       [180.75172 , 181.79839 , 176.6814  , ..., 234.50916 , 230.29346 ,\n",
+       "        232.73566 ]], dtype=float32)\n",
+       "Dimensions without coordinates: 10*nscans:MODIS_SWATH_Type_L1B,\n",
+       "                                Max_EV_frames:MODIS_SWATH_Type_L1B
" + ], + "text/plain": [ + "\n", + "array([[ 91.17539 , 94.14092 , 99.694016, ..., 152.89905 , 144.06061 ,\n", + " 157.40547 ],\n", + " [ 94.46073 , 95.30387 , 102.833984, ..., 134.9896 , 154.55624 ,\n", + " 144.52579 ],\n", + " [ 95.739975, 91.69872 , 97.97866 , ..., 93.76296 , 140.1938 ,\n", + " 151.6198 ],\n", + " ...,\n", + " [184.47318 , 183.97891 , 180.02489 , ..., 243.52203 , 240.06226 ,\n", + " 232.44492 ],\n", + " [183.07764 , 185.25816 , 179.85043 , ..., 236.80598 , 236.16637 ,\n", + " 230.52605 ],\n", + " [180.75172 , 181.79839 , 176.6814 , ..., 234.50916 , 230.29346 ,\n", + " 232.73566 ]], dtype=float32)\n", + "Dimensions without coordinates: 10*nscans:MODIS_SWATH_Type_L1B,\n", + " Max_EV_frames:MODIS_SWATH_Type_L1B" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "corrected_data" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "id": "873b741f", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Max value: 432.47256\n", + "Min value: 5.960126\n" + ] + } + ], + "source": [ + "print('Max value: ', max(corrected_data.values.flatten()))\n", + "print('Min value: ', min(corrected_data.values.flatten()))" + ] + }, + { + "cell_type": "markdown", + "id": "4230405a", + "metadata": {}, + "source": [ + "NOTE: The shape of the data does not match the shape of the geolocation information!" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "id": "6a97c8b3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(406, 271)" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ds.Latitude.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "id": "ee16cb15", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(2030, 1354)" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "ds.EV_500_Aggr1km_RefSB[0]" + "ds.EV_250_Aggr1km_RefSB[0].shape" ] } ],