{ "cells": [ { "cell_type": "markdown", "id": "17fd0b32", "metadata": {}, "source": [ "# Run and Plot a Retrieval" ] }, { "cell_type": "markdown", "id": "59fa1020", "metadata": {}, "source": [ "This notebook demonstrates how to run a trained retrieval model on real microwave radiometer measurements and plot the results." ] }, { "cell_type": "code", "execution_count": null, "id": "99db5697", "metadata": {}, "outputs": [], "source": [ "%config InlineBackend.figure_format = 'svg'\n", "\n", "from datetime import datetime\n", "\n", "from openMWR.utils import setup_logging\n", "logger = setup_logging()\n", "\n", "DATA_DIR = '../../../../data'" ] }, { "cell_type": "code", "execution_count": 32, "id": "c2d0c5ba", "metadata": {}, "outputs": [], "source": [ "site = 'munich_G5'\n", "\n", "date = datetime(2025,1,12)" ] }, { "cell_type": "markdown", "id": "6a16152c", "metadata": {}, "source": [ "## Run the Retrieval" ] }, { "cell_type": "markdown", "id": "8c33a98b", "metadata": {}, "source": [ "The first step is to load the trained model for the specified site." ] }, { "cell_type": "code", "execution_count": 33, "id": "54ceaca2", "metadata": {}, "outputs": [], "source": [ "from openMWR.models import Model\n", "model = Model.load('NN_opt', site=site, data_dir=DATA_DIR)" ] }, { "cell_type": "markdown", "id": "9a24c12f", "metadata": {}, "source": [ "Then, the measurement data for the site and date is imported. The keyword import_retrieval_data can be set to True to import the retrieval data of an RPG retrieval, if available." ] }, { "cell_type": "code", "execution_count": null, "id": "6f8b11ef", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset> Size: 178kB\n",
"Dimensions: (time: 1344, frq: 14)\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 11kB 2025-01-12 ... 2025-01-12T23...\n",
" * frq (frq) float64 112B 22.24 23.04 23.84 ... 56.66 57.3 58.0\n",
"Data variables:\n",
" TB (time, frq) float32 75kB 19.04 19.61 17.85 ... 268.2 268.6\n",
" rain_flag (time) float64 11kB 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0\n",
" azimuth_angle (time) float32 5kB 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0\n",
" elevation_angle (time) float32 5kB 90.0 90.0 90.0 90.0 ... 90.0 90.0 90.0\n",
" TB_IR (time) float32 5kB 259.5 259.1 258.8 ... 261.0 260.2 261.1\n",
" surface_p (time) float64 11kB 965.0 965.0 965.0 ... 973.9 973.9\n",
" surface_T (time) float64 11kB 271.0 270.9 270.9 ... 271.1 271.1\n",
" surface_rh (time) float64 11kB 76.2 75.87 76.0 ... 73.08 73.24 73.33\n",
" doy_cos (time) float64 11kB 0.9292 0.9292 0.9292 ... 0.9292 0.9292\n",
" doy_sin (time) float64 11kB 0.3695 0.3695 0.3695 ... 0.3695 0.3695\n",
" years_since_1970 (time) float64 11kB 55.03 55.03 55.03 ... 55.03 55.03\n",
"Attributes:\n",
" netCDF_Convention: CF-1.0\n",
" Radiometer_Location: University of Madison\n",
" Radiometer_System: RPG-HATPRO\n",
" Serial_Number: R-DPR-19/007\n",
" Station_Altitude: 200\n",
" Station_Longitude: 85�43'55'' West\n",
" Station_Latitude: 43�22'42'' North\n",
" Comment: \n",
" Radiometer_Software_Version: V10.00\n",
" Host-PC_Software_Version: V10.00<xarray.Dataset> Size: 6MB\n",
"Dimensions: (time: 1344, frq: 14, height: 208)\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 11kB 2025-01-12 ... 2025-01-12T23:59:00\n",
" * frq (frq) float64 112B 22.24 23.04 23.84 25.44 ... 56.66 57.3 58.0\n",
" * height (height) int64 2kB 0 10 25 50 75 ... 28500 29000 29500 30000\n",
"Data variables:\n",
" TB (time, frq) float32 75kB 19.04 19.61 17.85 ... 267.7 268.2 268.6\n",
" TB_IR (time) float32 5kB 259.5 259.1 258.8 259.2 ... 261.0 260.2 261.1\n",
" surface_T (time) float64 11kB 271.0 270.9 270.9 ... 271.2 271.1 271.1\n",
" surface_p (time) float64 11kB 965.0 965.0 965.0 ... 973.9 973.9 973.9\n",
" surface_rh (time) float64 11kB 76.2 75.87 76.0 75.9 ... 73.08 73.24 73.33\n",
" doy_cos (time) float64 11kB 0.9292 0.9292 0.9292 ... 0.9292 0.9292\n",
" doy_sin (time) float64 11kB 0.3695 0.3695 0.3695 ... 0.3695 0.3695\n",
" T (height, time) float64 2MB 271.5 271.6 271.4 ... 218.4 218.4\n",
" rh (height, time) float64 2MB 75.83 75.47 75.68 ... 1.296 1.303\n",
" lwc (height, time) float32 1MB 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0\n",
" lwp (time) float32 5kB 79.95 60.46 58.25 64.58 ... 29.99 27.72 30.73\n",
" iwv (time) float64 11kB 6.172 6.112 6.149 ... 3.364 3.309 3.354\n",
"Attributes:\n",
" netCDF_Convention: CF-1.0\n",
" Radiometer_Location: University of Madison\n",
" Radiometer_System: RPG-HATPRO\n",
" Serial_Number: R-DPR-19/007\n",
" Station_Altitude: 200\n",
" Station_Longitude: 85�43'55'' West\n",
" Station_Latitude: 43�22'42'' North\n",
" Comment: \n",
" Radiometer_Software_Version: V10.00\n",
" Host-PC_Software_Version: V10.00<xarray.Dataset> Size: 15MB\n",
"Dimensions: (frq: 14, time: 1344, height: 208)\n",
"Coordinates:\n",
" * frq (frq) float64 112B 22.24 23.04 23.84 25.44 ... 56.66 57.3 58.0\n",
" * time (time) datetime64[ns] 11kB 2025-01-12 ... 2025-01-12T23:59:00\n",
" * height (height) int64 2kB 0 10 25 50 75 ... 28500 29000 29500 30000\n",
"Data variables: (12/18)\n",
" TB (time, frq) float32 75kB 19.04 19.61 17.85 ... 268.2 268.6\n",
" TB_IR (time) float32 5kB 259.5 259.1 258.8 ... 261.0 260.2 261.1\n",
" surface_T (time) float64 11kB 271.0 270.9 270.9 ... 271.2 271.1 271.1\n",
" surface_p (time) float64 11kB 965.0 965.0 965.0 ... 973.9 973.9 973.9\n",
" surface_rh (time) float64 11kB 76.2 75.87 76.0 75.9 ... 73.08 73.24 73.33\n",
" doy_cos (time) float64 11kB 0.9292 0.9292 0.9292 ... 0.9292 0.9292\n",
" ... ...\n",
" ah (height, time) float64 2MB 3.274 3.275 ... 0.0004688 0.0004712\n",
" TD (height, time) float64 2MB 267.8 267.8 267.7 ... 188.2 188.2\n",
" T_grad (height, time) float64 2MB -34.94 -30.44 -31.5 ... nan nan nan\n",
" p (time, height) float64 2MB 965.0 963.8 962.0 ... 10.34 9.563\n",
" lwp_from_lwc (time) float64 11kB 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0\n",
" iwv_from_ah (time) float64 11kB 6.317 6.338 6.371 ... 3.396 3.339 3.381\n",
"Attributes:\n",
" netCDF_Convention: CF-1.0\n",
" Radiometer_Location: University of Madison\n",
" Radiometer_System: RPG-HATPRO\n",
" Serial_Number: R-DPR-19/007\n",
" Station_Altitude: 200\n",
" Station_Longitude: 85�43'55'' West\n",
" Station_Latitude: 43�22'42'' North\n",
" Comment: \n",
" Radiometer_Software_Version: V10.00\n",
" Host-PC_Software_Version: V10.00<xarray.Dataset> Size: 15MB\n",
"Dimensions: (frq: 14, time: 1344, height: 208)\n",
"Coordinates:\n",
" * frq (frq) float64 112B 22.24 23.04 23.84 25.44 ... 56.66 57.3 58.0\n",
" * time (time) datetime64[ns] 11kB 2025-01-12 ... 2025-01-12T23:59:00\n",
" * height (height) int64 2kB 0 10 25 50 75 ... 28500 29000 29500 30000\n",
" model <U6 24B 'NN_opt'\n",
"Data variables: (12/19)\n",
" TB (time, frq) float32 75kB 19.04 19.61 17.85 ... 268.2 268.6\n",
" TB_IR (time) float32 5kB 259.5 259.1 258.8 ... 261.0 260.2 261.1\n",
" surface_T (time) float64 11kB 271.0 270.9 270.9 ... 271.2 271.1 271.1\n",
" surface_p (time) float64 11kB 965.0 965.0 965.0 ... 973.9 973.9 973.9\n",
" surface_rh (time) float64 11kB 76.2 75.87 76.0 75.9 ... 73.08 73.24 73.33\n",
" doy_cos (time) float64 11kB 0.9292 0.9292 0.9292 ... 0.9292 0.9292\n",
" ... ...\n",
" TD (height, time) float64 2MB 267.8 267.8 267.7 ... 188.2 188.2\n",
" T_grad (height, time) float64 2MB -34.94 -30.44 -31.5 ... nan nan nan\n",
" p (time, height) float64 2MB 965.0 963.8 962.0 ... 10.34 9.563\n",
" lwp_from_lwc (time) float64 11kB 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0\n",
" iwv_from_ah (time) float64 11kB 6.317 6.338 6.371 ... 3.396 3.339 3.381\n",
" rain_flag (time) float64 11kB 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0\n",
"Attributes:\n",
" netCDF_Convention: CF-1.0\n",
" Radiometer_Location: University of Madison\n",
" Radiometer_System: RPG-HATPRO\n",
" Serial_Number: R-DPR-19/007\n",
" Station_Altitude: 200\n",
" Station_Longitude: 85�43'55'' West\n",
" Station_Latitude: 43�22'42'' North\n",
" Comment: \n",
" Radiometer_Software_Version: V10.00\n",
" Host-PC_Software_Version: V10.00<xarray.Dataset> Size: 45kB\n",
"Dimensions: (time: 72, frq: 14, ang: 10)\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 576B 2025-01-12T00:05:17 ... 2025...\n",
" * frq (frq) float64 112B 22.24 23.04 23.84 ... 56.66 57.3 58.0\n",
" * ang (ang) float64 80B 4.2 4.8 5.4 6.6 ... 14.4 19.2 30.0 90.0\n",
"Data variables:\n",
" TB (time, frq, ang) float32 40kB 154.3 145.6 ... 270.0 268.5\n",
" rain_flag (time) float64 576B 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0\n",
" azimuth_angle (time) float32 288B 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0\n",
" surface_p (time) float64 576B 965.0 965.2 965.4 ... 974.2 973.9\n",
" surface_T (time) float64 576B 270.9 271.0 271.0 ... 271.1 271.1\n",
" surface_rh (time) float64 576B 75.92 75.97 76.46 ... 74.88 74.2 73.77\n",
" doy_cos (time) float64 576B 0.9292 0.9292 0.9292 ... 0.9292 0.9292\n",
" doy_sin (time) float64 576B 0.3695 0.3695 0.3695 ... 0.3695 0.3695\n",
" years_since_1970 (time) float64 576B 55.03 55.03 55.03 ... 55.03 55.03\n",
"Attributes:\n",
" netCDF_Convention: CF-1.0\n",
" Radiometer_Location: University of Madison\n",
" Radiometer_System: RPG-HATPRO\n",
" Serial_Number: R-DPR-19/007\n",
" Station_Altitude: 200\n",
" Station_Longitude: 85�43'55'' West\n",
" Station_Latitude: 43�22'42'' North\n",
" Comment: \n",
" Radiometer_Software_Version: V10.00\n",
" Host-PC_Software_Version: V10.00<xarray.Dataset> Size: 346kB\n",
"Dimensions: (time: 72, frq: 14, ang: 10, height: 208)\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 576B 2025-01-12T00:05:17 ... 2025-01-12...\n",
" * frq (frq) float64 112B 22.24 23.04 23.84 25.44 ... 56.66 57.3 58.0\n",
" * ang (ang) float64 80B 4.2 4.8 5.4 6.6 8.4 11.4 14.4 19.2 30.0 90.0\n",
" * height (height) int64 2kB 0 10 25 50 75 ... 28500 29000 29500 30000\n",
"Data variables:\n",
" TB (time, frq, ang) float32 40kB 154.3 145.6 137.0 ... 270.0 268.5\n",
" surface_T (time) float64 576B 270.9 271.0 271.0 ... 271.1 271.1 271.1\n",
" surface_p (time) float64 576B 965.0 965.2 965.4 ... 974.3 974.2 973.9\n",
" surface_rh (time) float64 576B 75.92 75.97 76.46 76.33 ... 74.88 74.2 73.77\n",
" doy_cos (time) float64 576B 0.9292 0.9292 0.9292 ... 0.9292 0.9292\n",
" doy_sin (time) float64 576B 0.3695 0.3695 0.3695 ... 0.3695 0.3695\n",
" T (height, time) float64 120kB 271.4 270.9 271.3 ... 215.2 215.6\n",
" rh (height, time) float64 120kB 76.07 76.16 76.84 ... 1.09 1.094\n",
" lwc (height, time) float32 60kB 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0\n",
" lwp (time) float32 288B 91.93 107.7 137.4 ... 118.4 96.54 87.84\n",
" iwv (time) float64 576B 6.692 7.291 7.162 ... 4.296 4.356 4.202\n",
"Attributes:\n",
" netCDF_Convention: CF-1.0\n",
" Radiometer_Location: University of Madison\n",
" Radiometer_System: RPG-HATPRO\n",
" Serial_Number: R-DPR-19/007\n",
" Station_Altitude: 200\n",
" Station_Longitude: 85�43'55'' West\n",
" Station_Latitude: 43�22'42'' North\n",
" Comment: \n",
" Radiometer_Software_Version: V10.00\n",
" Host-PC_Software_Version: V10.00