{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "9526f5a6",
   "metadata": {},
   "source": [
    "# Clutter chain"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "327a6cb6",
   "metadata": {},
   "source": [
    "The clutter map will calculate monthly. At first you have to define the parameters of the function.\n",
    "\n",
    "The **start time** and the number of **days** over which the clutter map should be created must be defined. The stop time is then calculated within the function by adding the start time and the number of days. \n",
    "Since the clutter is different depending on the elevation angle, the desired elevation angle is defined using the **elevation_angle** and **pattern** parameters. The **elevation angle** parameter is relevant for the HDF5 files and **pattern** for the scnx files. Both parameters must always be defined. The parameter **threshold** specifies that only positive values of the uncorrected reflectivity, which are in the boolean dataset of the clutter map, are considered. If the **status** parameter is set to true, then the processing progress of the clutter map is obtained as a percentage.\n",
    "\n",
    "After the stop time has been determined, a file list is generated for all raw data of the specified elevation angle for the period between start and stop time. Then the clutter map is created sequentially. I.e. all files, which are in the file list, are read in individually, the reflectivity values are extracted and in a further step the extracted reflectivity values of each file are added to an existing data array. Afterwards a boolean dataset is created where the added reflectivity values must be greater than the threshold.\n",
    "\n",
    "The output filename is created, which contains start and end time of the processed clutter map as well as the elevation angle. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "cc2c564c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import wrainfo as wrf\n",
    "import datetime as dt\n",
    "import logging"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "5471f477",
   "metadata": {},
   "outputs": [],
   "source": [
    "path_to_config_file=\"/tests/data/test_settings_wrainfo.json\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "4d746949",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "35.0% done\n",
      "65.0% done\n",
      "100.0% done\n",
      "-- output to /tests/data/clutter_map//2022/NB_WR2120_20220216_20220217_elev_0.5_cmap.nc\n"
     ]
    }
   ],
   "source": [
    "wrf.process_chains.clutter_chain(start_time=dt.datetime(2022,2,16),\n",
    "                                 path=path_to_config_file,\n",
    "                                 elevation_angle=\"dataset1\",\n",
    "                                 days=1,\n",
    "                                 threshold=0,\n",
    "                                 status=True,\n",
    "                                 pattern=\"_000.scnx.gz\",\n",
    "                                 data_type=\"cmap\",\n",
    "                                 logger=logging.getLogger())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b22813f9",
   "metadata": {},
   "source": [
    "# Functions of WRaINfo"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e2b90fa2",
   "metadata": {},
   "source": [
    "The following functions of WRaINfo are used in the ```clutter_chain```.:"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ee8b7393",
   "metadata": {},
   "source": [
    " - [wrainfo.reader.read_config_file()](https://fernlab.git-pages.gfz-potsdam.de/products/furuno/wrainfo/doc/_modules/wrainfo/reader.html#read_config_file)\n",
    " - [wrainfo.reader.create_filelist()](https://fernlab.git-pages.gfz-potsdam.de/products/furuno/wrainfo/doc/_modules/wrainfo/reader.html#create_filelist)\n",
    " - [wrainfo.clutter.create_clutter_map_sequential()](https://fernlab.git-pages.gfz-potsdam.de/products/furuno/wrainfo/doc/_modules/wrainfo/clutter.html#create_clutter_map_sequential)"
   ]
  }
 ],
 "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.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
