{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\nKimber Soiling Model\n====================\n\nExamples of soiling using the Kimber model.\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "This example shows basic usage of pvlib's Kimber Soiling model [1]_ with\n:py:func:`pvlib.soiling.kimber`.\n\nReferences\n----------\n.. [1] \"The Effect of Soiling on Large Grid-Connected Photovoltaic Systems\n   in California and the Southwest Region of the United States,\" Adrianne\n   Kimber, et al., IEEE 4th World Conference on Photovoltaic Energy\n   Conference, 2006, :doi:`10.1109/WCPEC.2006.279690`\n\nThe Kimber Soiling model assumes that soiling builds up at a constant rate\nuntil cleaned either manually or by rain. The rain must reach a threshold to\nclean the panels. When rains exceeds the threshold, it's assumed the earth is\ndamp for a grace period before it begins to soil again. There is a maximum\nsoiling build up that cannot be exceeded even if there's no rain or\nmanual cleaning.\n\nThreshold\n---------\nThe example shown here demonstrates how the threshold affects soiling.\nBecause soiling depends on rainfall, loading weather data is always the first\nstep.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from datetime import datetime\nimport pathlib\nfrom matplotlib import pyplot as plt\nfrom pvlib.iotools import read_tmy3\nfrom pvlib.soiling import kimber\nimport pvlib\n\n# get full path to the data directory\nDATA_DIR = pathlib.Path(pvlib.__file__).parent / 'data'\n\n# get TMY3 data with rain\ngreensboro, _ = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990)\n# get the rain data\ngreensboro_rain = greensboro.Lprecipdepth\n# calculate soiling with no wash dates and cleaning threshold of 25-mm of rain\nTHRESHOLD = 25.0\nsoiling_no_wash = kimber(greensboro_rain, cleaning_threshold=THRESHOLD)\nsoiling_no_wash.name = 'soiling'\n# daily rain totals\ndaily_rain = greensboro_rain.iloc[:-1].resample('D').sum()\nplt.plot(\n    daily_rain.index.to_pydatetime(), daily_rain.values/25.4,\n    soiling_no_wash.index.to_pydatetime(), soiling_no_wash.values*100.0)\nplt.hlines(\n    THRESHOLD/25.4, xmin=datetime(1990, 1, 1), xmax=datetime(1990, 12, 31),\n    linestyles='--')\nplt.grid()\nplt.title(\n    f'Kimber Soiling Model, dashed line shows threshold ({THRESHOLD}[mm])')\nplt.xlabel('timestamp')\nplt.ylabel('soiling build-up fraction [%] and daily rainfall [inches]')\nplt.legend(['daily rainfall [in]', 'soiling [%]'])\nplt.tight_layout()\n\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.7.3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}