{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Apply the relative variability test to data\n\nThis is a short example of how the relative variability test\ncan be applied to a set of variables to determine if one has\ngreater variability than the others.\n\nThis will show the variability test being tripped if the standard\ndeviation of one variable is significantly different than that of\nthe others.\n\nAuthor: Adam Theisen\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from matplotlib import pyplot as plt\n\nimport act\nfrom act.tests import EXAMPLE_MFRSR\n\n# Read in some sample MFRSR data\nds = act.io.read_arm_netcdf(EXAMPLE_MFRSR)\nds.clean.cleanup()\nvariables = [v for v in list(ds) if v.startswith('diffuse_hemisp_narrowband_filter')]\n\n# Modify data to trip the test\ndata = ds[variables[0]].values\ndata[1000:1200] += 20\nds[variables[0]].values = data\n\n# Apply the test and have threshold of 1\nthresh = 1.0\nresult = ds.qcfilter.add_relative_variability_test(variables, thresh)\n\n# Plot up the variables and the qc test for the first filter\ndisplay = act.plotting.TimeSeriesDisplay(ds, figsize=(10, 14), subplot_shape=(2,))\nfor v in variables:\n display.plot(v, label=v, subplot_index=(0,))\n\ndisplay.qc_flag_block_plot(variables[0], subplot_index=(1,))\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 }