{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Compare Aircraft Airspeeds\n\nCompare Aircraft Airspeeds via the DistributionDisplay\nScatter Plot\n\nWritten: Joe O'Brien\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\nfrom arm_test_data import DATASETS\nfrom scipy.stats.mstats import pearsonr\n\nimport act\nfrom act.io.icartt import read_icartt\n\n# Call the read_icartt function, which supports input\n# for ICARTT (v2.0) formatted files.\n# Example file is ARM Aerial Facility Navigation Data\nfilename_icartt = DATASETS.fetch('AAFNAV_COR_20181104_R0.ict')\nds = read_icartt(filename_icartt)\n\n# Create a DistributionDisplay object to compare fields\ndisplay = act.plotting.DistributionDisplay(ds)\n\n# Compare aircraft ground speed with indicated airspeed\ndisplay.plot_scatter(\n 'true_airspeed',\n 'ground_speed',\n m_field='ambient_temp',\n marker='x',\n cbar_label=r'Ambient Temperature ($^\\circ$C)', # noqa W605\n)\n\n# Set the range of the field on the x-axis\ndisplay.set_xrng((40, 140))\ndisplay.set_yrng((40, 140))\n\n# Determine the best fit line\nz = np.ma.polyfit(ds['true_airspeed'], ds['ground_speed'], 1)\np = np.poly1d(z)\n\n# Plot the best fit line\ndisplay.axes[0].plot(ds['true_airspeed'], p(ds['true_airspeed']), 'r', linewidth=2)\n\n# Display the line equation\ndisplay.axes[0].text(45, 135, f\"y = {z[0]:.3f}x + ({z[1]:.3f})\", color='r', fontsize=12)\n\n# Calculate Pearson Correlation Coefficient\ncc_conc = pearsonr(ds['true_airspeed'], ds['ground_speed'])\n\n# Display the Pearson CC\ndisplay.axes[0].text(45, 130, f\"Pearson CC: {cc_conc[0]:.2f}\", fontsize=12)\n\n# Display the total number of samples\ndisplay.axes[0].text(45, 125, \"N = {:.0f}\".format(ds['true_airspeed'].data.shape[0]), fontsize=12)\n\n# Display the 1:1 ratio line\ndisplay.set_ratio_line()\nplt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.14.3" } }, "nbformat": 4, "nbformat_minor": 0 }