{ "cells": [ { "cell_type": "markdown", "id": "2c76a09b-ac78-4b74-8464-1c2f3eae0dcf", "metadata": {}, "source": [ "## Goal:\n", "\n", "This example shows how to calculate the Reynolds stress tensor elements from the 6-beam observations. \n", "\n", "## Steps:\n", "\n", "1) Read the WindCube's data\n", "2) Merge data from one hour of observations\n", "3) Re-structure the data for using the wind retrieval\n", "4) Calculate the Reynolds stress tensor elements" ] }, { "cell_type": "code", "execution_count": 1, "id": "074c721a-e416-4b5f-9677-d490d105b97c", "metadata": {}, "outputs": [], "source": [ "import glob as gb\n", "import matplotlib.pyplot as plt\n", "\n", "import lidarSuit as lst" ] }, { "cell_type": "markdown", "id": "ef859b9a-1dbd-4923-99fd-12227e54a2c4", "metadata": {}, "source": [ "### Step 1 and 2: reading and merging the 6-beam data" ] }, { "cell_type": "code", "execution_count": 2, "id": "90cf9f04-4bad-44bb-a03f-6c99508778f2", "metadata": {}, "outputs": [], "source": [ "# a 6-beam sample data is available at the path below\n", "data_path = '../../sampleData/wind_and_aerosols_data/12-00/*.nc'\n", "file_list = sorted(gb.glob(data_path))\n", "mergedDS = lst.dataOperations(file_list).mergedData" ] }, { "cell_type": "markdown", "id": "3094e317-3270-4db4-85bd-5386f51f9350", "metadata": {}, "source": [ "Below you can see all the variables available on the original WindCube's data. Not all of them are needed for retrieving the wind profiles. Note that the variables from the vertical observations are kept separate from the slanted observations. " ] }, { "cell_type": "code", "execution_count": 3, "id": "179532f9-5748-479e-9d47-518dd92d53f1", "metadata": {}, "outputs": [], "source": [ "# Uncomment the line below\n", "\n", "# mergedDS" ] }, { "cell_type": "markdown", "id": "3de90219-0604-4189-bc3b-2dddeb0b530f", "metadata": { "tags": [] }, "source": [ "### Step 3: re-structuring the data" ] }, { "cell_type": "code", "execution_count": 4, "id": "17e2f04b-8db4-4713-b322-d8964e955999", "metadata": {}, "outputs": [], "source": [ "restruct_data = lst.getRestructuredData(mergedDS)" ] }, { "cell_type": "markdown", "id": "ac7209fb-8ccd-4389-8236-4025f1690efa", "metadata": {}, "source": [ "The re-structured object contains all the information needed to calculate the Reynolds stress tensor elements." ] }, { "cell_type": "markdown", "id": "367c7f6d-1305-4e47-877a-dfe690034467", "metadata": {}, "source": [ "### Step 4: Calculate the Reynolds stress tensor elements" ] }, { "cell_type": "markdown", "id": "5a07b9af-fd84-4879-ab91-4982a49157cd", "metadata": {}, "source": [ "To calculate Reynolds stress tensor elements, you need to define a time window (a frequency). Since lidarSuit takes advantage of the xarray library, the frequency for calculating those elements is defined in terms of the number of profiles. However, a frequency in terms of time is more practical. In the following fuor lines, a time frequency will be related to its equivalent in terms of profile frequency." ] }, { "cell_type": "code", "execution_count": 5, "id": "d305f5eb-e51c-4789-ac8c-7167f117fd4e", "metadata": {}, "outputs": [], "source": [ "# desired time windown in minutes\n", "time_window = 5\n", "\n", "# duration of one minute in seconds\n", "minute_lenght = 60\n", "\n", "# vertical observations time resolution in seconds\n", "time_resolution = restruct_data.dataTransf90.time.diff(dim='time').values * 1e-9\n", "time_resolution = int(time_resolution[0])\n", "\n", "# frequency convertion from minutes to profile number\n", "freq = (minute_lenght/time_resolution)*time_window\n", "freq = int(freq)" ] }, { "cell_type": "markdown", "id": "824fce48-71bc-4312-8900-e5176205dc8b", "metadata": {}, "source": [ "Applying the 6-beam method to calculate Reynolds stress tensor elements" ] }, { "cell_type": "code", "execution_count": 6, "id": "66728949-d077-4d2e-a254-db3a3554e8fc", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/jdiasneto/.local/lib/python3.8/site-packages/xarray/core/nputils.py:155: RuntimeWarning: Degrees of freedom <= 0 for slice.\n", " result = getattr(npmodule, name)(values, axis=axis, **kwargs)\n", "/Users/jdiasneto/.local/lib/python3.8/site-packages/xarray/core/nputils.py:155: RuntimeWarning: Degrees of freedom <= 0 for slice.\n", " result = getattr(npmodule, name)(values, axis=axis, **kwargs)\n" ] } ], "source": [ "turb_data = lst.sixBeamMethod(restruct_data, freq=freq, freq90=freq)" ] }, { "cell_type": "markdown", "id": "90103ade-953a-449f-a6a7-3f86bc8b5597", "metadata": {}, "source": [ "Have a look at the Reynolds elements dataset" ] }, { "cell_type": "code", "execution_count": 7, "id": "e90338c7-26ff-49bd-9ea3-0db3aea2bd95", "metadata": {}, "outputs": [], "source": [ "# Uncomment the line below \n", "\n", "# turb_data.varCompDS" ] }, { "cell_type": "markdown", "id": "b2e4789f-8927-4ab6-b482-94bb68967696", "metadata": {}, "source": [ "Below we will have the first impressions of the retrieved data. Note that there are negative variances, which is mathematically impossible. Those negative is a known artefact of the 6-beam method." ] }, { "cell_type": "code", "execution_count": 8, "id": "cc0468de-2780-47b8-94a6-f0e06d3b5efa", "metadata": {}, "outputs": [], "source": [ "# Uncomment the lines below to see the plots\n", "\n", "# turb_data.varCompDS.var_u.plot(x='time', cmap='Spectral', vmin=-5, vmax=5)\n", "# plt.show()\n", "\n", "# turb_data.varCompDS.var_v.plot(x='time', cmap='Spectral', vmin=-5, vmax=5)\n", "# plt.show()\n", "\n", "# turb_data.varCompDS.var_w.plot(x='time', cmap='Spectral', vmin=0, vmax=1)\n", "# plt.show()" ] }, { "cell_type": "code", "execution_count": null, "id": "5065ddbc-352f-4d2d-83a6-3a3036328504", "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.8.13" } }, "nbformat": 4, "nbformat_minor": 5 }