{ "cells": [ { "cell_type": "markdown", "id": "fa641328-fd14-4d05-a2f6-99aa3b0bcdbd", "metadata": {}, "source": [ "# Example for Pairing University of Wyoming data with UFS-Chem" ] }, { "cell_type": "markdown", "id": "d7d709d8-9314-48f7-894e-9fb62fbe696c", "metadata": {}, "source": [ "This example will demonstrate how to use MELODIES MONET to pair aircraft observations from the University of Wyoming (https://weather.uwyo.edu/upperair/sounding.shtml) to model output from the UFS-Chem (dyn*.nc and phy*.nc output files) and save the paired data for each flight as a netcdf. Users can then read these files back into MELODIES MONET to create plots or calculate statistics or use this paired data output file to do their own analysis. \n", "\n", "Pairing aircraft data takes awhile so it is recommended that users first pair the data and then produce the plots and statistics, so that you are not repairing everytime you want to change something small during your analysis.\n", "\n", "This example resamples the data to '2s'. To reduce memory constraints, use a smaller window. For examples, on how to submit a job to process more flight days with a shorter resampling, see the end of this jupyter notebook." ] }, { "cell_type": "markdown", "id": "5f3155b5-f520-4eaa-8220-4c6b3ed2fc28", "metadata": {}, "source": [ "## First, we import the loop_pairing function from melodies_monet.util.tools." ] }, { "cell_type": "code", "execution_count": 1, "id": "90856e9f", "metadata": {}, "outputs": [], "source": [ "from melodies_monet.util.tools import loop_pairing" ] }, { "cell_type": "markdown", "id": "fb93d196-12e0-4374-88b7-ee236f564e3e", "metadata": {}, "source": [ "## Second, we read in a control file that explains all the pairing parameters." ] }, { "cell_type": "code", "execution_count": 2, "id": "e1ddf289-b838-4e0d-9230-41cd183dc340", "metadata": {}, "outputs": [], "source": [ "control_fn='control_looping_UWY_UFS_CHEM.yaml'" ] }, { "cell_type": "markdown", "id": "e95f38e3-a807-4fcd-8168-7bfb06ab7597", "metadata": {}, "source": [ "## Third, provide the info in a dictionary like that below and then pair the data" ] }, { "cell_type": "code", "execution_count": 3, "id": "dc80edd7", "metadata": {}, "outputs": [], "source": [ "file_pairs = {\n", " '0801_12Z_72632': {\n", " #'model': {'ufschem': '/wrk/rschwantes/aeromma_1x1/short2/2023_08_01_ufschemv1.nc'},\n", " #'obs': {'uwy': '/wrk/rschwantes/aeromma_1x1/obs/2023080112-72632.csv'}\n", " 'model': {'ufschem': 'example:ufschem:2023-08-01'},\n", " 'obs': {'uwy': 'example:uwy-sonde:2023-08-01'}\n", " }\n", "}" ] }, { "cell_type": "code", "execution_count": 4, "id": "129ee7c6-b0b3-4275-9430-1ad72e556505", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ufschem\n", "example:ufschem:2023-08-01\n", "**** Reading UFS-AQM or UFS-Chem model output...\n", "Performing extra model calculations...\n", "Calculating modeled Dewpoint...\n", "Calculating modeled relative humidity...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/home/rschwantes/MONET/met_Liam/update_to_develop/MELODIES-MONET/melodies_monet/util/metcalc.py:91: UserWarning: Saturation mixing ratio is undefined for some requested pressure/temperature combinations. Total pressure must be greater than the water vapor saturation pressure for liquid water to be in equilibrium.\n", " rlh = (metpy.calc.relative_humidity_from_specific_humidity(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Calculating modeled windpseed...\n", "Calculating modeled wind direction...\n", "Calculating modeled potential temperature...\n", "Performing extra calculations for obs...\n", "Calculating observed potential temperature...\n", "1, in pair data\n", "After pairing: longitude latitude pressure_obs time \\\n", "0 -83.47140 42.6991 98360.0 2023-08-01 11:05:36 \n", "1 -83.47140 42.6992 98235.0 2023-08-01 11:05:38 \n", "2 -83.47145 42.6992 98120.0 2023-08-01 11:05:40 \n", "3 -83.47155 42.6992 98000.0 2023-08-01 11:05:42 \n", "4 -83.47160 42.6993 97870.0 2023-08-01 11:05:44 \n", "... ... ... ... ... \n", "2707 -83.10400 41.9284 560.0 2023-08-01 13:04:50 \n", "2708 -83.10980 41.9291 550.0 2023-08-01 13:05:10 \n", "2709 -83.11510 41.9302 540.0 2023-08-01 13:05:32 \n", "2710 -83.12040 41.9314 530.0 2023-08-01 13:05:50 \n", "2711 -83.12730 41.9334 520.0 2023-08-01 13:06:12 \n", "\n", " geopotential height_m temperature_C dpt_obs ice point temperature_C \\\n", "0 332.0 286.90 286.05 12.90 \n", "1 343.0 288.80 286.70 13.55 \n", "2 352.5 290.05 286.15 13.00 \n", "3 363.5 290.55 285.85 12.70 \n", "4 374.5 290.85 285.75 12.60 \n", "... ... ... ... ... \n", "2707 35452.0 238.35 195.25 -73.60 \n", "2708 35576.0 238.95 195.65 -73.30 \n", "2709 35705.0 238.95 195.65 -73.20 \n", "2710 35838.0 239.45 195.95 -73.00 \n", "2711 35969.0 239.65 196.05 -72.80 \n", "\n", " relh_obs humidity wrt ice_% ... ptemp_obs temperature_k \\\n", "0 95.0 95.0 ... 288.258684 289.715425 \n", "1 87.5 87.5 ... 290.273127 289.951402 \n", "2 77.5 77.5 ... 291.627086 290.168457 \n", "3 74.0 74.0 ... 292.231963 290.394908 \n", "4 72.0 72.0 ... 292.644667 290.625450 \n", "... ... ... ... ... ... \n", "2707 0.0 1.0 ... 1048.552079 240.237411 \n", "2708 0.0 1.0 ... 1056.617246 240.674899 \n", "2709 0.0 1.0 ... 1062.171225 241.112322 \n", "2710 0.0 1.0 ... 1070.093524 241.548839 \n", "2711 0.0 1.0 ... 1076.831885 241.985535 \n", "\n", " dewpoint rel_hum windspeed winddir ptemp_mod spfh \\\n", "0 284.557419 71.658070 0.495779 312.910470 291.088316 0.008567 \n", "1 284.513523 70.405997 0.503581 312.826437 291.431529 0.008552 \n", "2 284.473136 69.254261 0.510756 312.749742 291.747241 0.008540 \n", "3 284.430994 68.052627 0.518245 312.668439 292.076638 0.008526 \n", "4 284.384338 66.820616 0.528139 312.503869 292.418841 0.008511 \n", "... ... ... ... ... ... ... \n", "2707 170.831865 0.006223 25.470374 92.928157 1060.169729 0.000002 \n", "2708 170.871197 0.005994 25.638503 92.916639 1067.586148 0.000002 \n", "2709 170.910563 0.005765 25.805907 92.907023 1075.002408 0.000002 \n", "2710 170.949922 0.005537 25.974081 92.896310 1082.414819 0.000002 \n", "2711 170.989330 0.005308 26.141009 92.888589 1089.828162 0.000002 \n", "\n", " ugrd vgrd \n", "0 0.363372 -0.331242 \n", "1 0.369568 -0.336126 \n", "2 0.375258 -0.340622 \n", "3 0.381203 -0.345315 \n", "4 0.389525 -0.350925 \n", "... ... ... \n", "2707 -25.436431 1.296275 \n", "2708 -25.604476 1.299525 \n", "2709 -25.771739 1.303623 \n", "2710 -25.939798 1.307319 \n", "2711 -26.106523 1.312325 \n", "\n", "[2712 rows x 23 columns]\n", "Writing: ./output/uwy_ufschem/0801_12Z_72632_uwy_ufschem.nc4\n", "WARNING: The following variables have been renamed due to illegal characters in the variable name for netcdf4 format. \n", "The original variable names can be found in the `long_name` variable attribute. \n", "['geopotential height_m', 'ice point temperature_C', 'humidity wrt ice_%', 'mixing ratio_g/kg']\n" ] } ], "source": [ "loop_pairing(control=control_fn,file_pairs=file_pairs)" ] }, { "cell_type": "code", "execution_count": null, "id": "b9550e98-f458-42a8-9d56-e65d9285630c", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "2364dede-2434-48ea-a1f9-1ede9c8ef96c", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "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.11.15" } }, "nbformat": 4, "nbformat_minor": 5 }