{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Plotting Baseline Surface Radiation Network (BSRN) QC Flags\n\nSimple example for applying BSRN QC and\nplotting the data and the corresponding QC flags\nusing colorblind friendly colors.\nhttps://bsrn.awi.de/data/quality-checks/\n\nAuthor: Ken Kehoe\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from arm_test_data import DATASETS\nfrom matplotlib import pyplot as plt\n\nimport act\n\n# Read in data and convert from ARM QC standard to CF QC standard\nfilename_brs = DATASETS.fetch('sgpbrsC1.b1.20190705.000000.cdf')\nds = act.io.arm.read_arm_netcdf(filename_brs, cleanup_qc=True)\n\n# Creat Plot Display and plot data including embedded QC from data file\nvariable = 'down_short_hemisp'\ndisplay = act.plotting.TimeSeriesDisplay(ds, figsize=(15, 10), subplot_shape=(2,))\n\n# Plot radiation data in top plot\ndisplay.plot(variable, subplot_index=(0,), day_night_background=True, cvd_friendly=True)\n\n# Plot ancillary QC data in bottom plot\ndisplay.qc_flag_block_plot(variable, subplot_index=(1,), cvd_friendly=True)\nplt.show()\n\n# Add initial BSRN QC tests to ancillary QC varialbles. Use defualts for\n# test set to Physicall Possible and use_dask.\nds.qcfilter.bsrn_limits_test(\n gbl_SW_dn_name='down_short_hemisp',\n glb_diffuse_SW_dn_name='down_short_diffuse_hemisp',\n direct_normal_SW_dn_name='short_direct_normal',\n glb_SW_up_name='up_short_hemisp',\n glb_LW_dn_name='down_long_hemisp_shaded',\n glb_LW_up_name='up_long_hemisp',\n)\n\n# Add initial BSRN QC tests to ancillary QC varialbles. Use defualts for\n# test set to Extremely Rare\" and to use Dask processing.\nds.qcfilter.bsrn_limits_test(\n test='Extremely Rare',\n gbl_SW_dn_name='down_short_hemisp',\n glb_diffuse_SW_dn_name='down_short_diffuse_hemisp',\n direct_normal_SW_dn_name='short_direct_normal',\n glb_SW_up_name='up_short_hemisp',\n glb_LW_dn_name='down_long_hemisp_shaded',\n glb_LW_up_name='up_long_hemisp',\n use_dask=True,\n)\n\n# Add comparison BSRN QC tests to ancillary QC varialbles. Request two of the possible\n# comparison tests.\nds.qcfilter.bsrn_comparison_tests(\n ['Global over Sum SW Ratio', 'Diffuse Ratio'],\n gbl_SW_dn_name='down_short_hemisp',\n glb_diffuse_SW_dn_name='down_short_diffuse_hemisp',\n direct_normal_SW_dn_name='short_direct_normal',\n)\n\n# Add K-tests QC to ancillary QC variables.\nds.qcfilter.normalized_rradiance_test(\n [\n 'Clearness index',\n 'Upper total transmittance',\n 'Upper direct transmittance',\n 'Upper diffuse transmittance',\n ],\n dni='short_direct_normal',\n dhi='down_short_hemisp',\n ghi='down_short_diffuse_hemisp',\n)\n\n# Creat Plot Display and plot data including embedded QC from data file\nvariable = 'down_short_hemisp'\ndisplay = act.plotting.TimeSeriesDisplay(ds, figsize=(15, 10), subplot_shape=(2,))\n\n# Plot radiation data in top plot. Add QC information to top plot.\ndisplay.plot(\n variable,\n subplot_index=(0,),\n day_night_background=True,\n assessment_overplot=True,\n cvd_friendly=True,\n)\n\n# Plot ancillary QC data in bottom plot\ndisplay.qc_flag_block_plot(variable, subplot_index=(1,), cvd_friendly=True)\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 }