From 81f148851cb17a82e2924d9b11898d18a7218cbd Mon Sep 17 00:00:00 2001 From: Jordan A Caraballo-Vega Date: Mon, 10 Jul 2023 17:24:01 -0400 Subject: [PATCH] Adding more comments to the app --- README.rst | 87 ++++++++++++++++++- docs/eo_validation.rst | 33 -------- docs/examples/ValidationDashboard.ipynb | 106 ------------------------ docs/modules.rst | 4 +- eo_validation/validation_dashboard.py | 8 -- 5 files changed, 88 insertions(+), 150 deletions(-) delete mode 100644 docs/eo_validation.rst delete mode 100644 docs/examples/ValidationDashboard.ipynb diff --git a/README.rst b/README.rst index a951585..8296428 100644 --- a/README.rst +++ b/README.rst @@ -101,14 +101,99 @@ dashboard in order to successfully point to the necessary directories and paths. .. code:: python + from ipyleaflet import basemaps from IPython.display import display from eo_validation.validation_dashboard import ValidationDashboard dashboard = ValidationDashboard( - center=[14, -14] + center=[14, -14], + zoom=3, + max_zoom=20, + default_max_zoom=20, + default_zoom=18, + scroll_wheel_zoom=True, + keyboard=True, + basemap=basemaps.Esri.WorldImagery, + height="600px", + data_dir="/efs/projects/3sl/data/Tappan", + mask_dir="/efs/projects/3sl/labelsv2", + output_dir="/home/jovyan/eo-validation-output-test", + default_bands=[ + ('Coastal Blue', 1), + ('Blue', 2), + ('Green', 3), + ('Yellow', 4), + ('Red', 5), + ('Red Edge', 6), + ('NIR1', 7), + ('NIR2', 8) + ], + rgb_bands = [7, 3, 2], + rgb_disabled=False, + validation_classes=[ + 'other', + 'trees/shrub', + 'cropland', + 'other vegetation', + 'water', + 'build' + ], + mask_classes=[ + 'other', + 'tree', + 'crop', + 'burn' + ], + points_dir='/home/jovyan/efs/projects/3sl/validation/original_points', + gen_points=True, + n_points=200, + expected_accuracies=[0.90, 0.90, 0.90, 0.90], + expected_standard_error=0.01, + product_name='otcb', + chunks={"band": 1, "x": 2048, "y": 2048} ) display(dashboard) +The arguments from the ValidationDashboard class are as follow: + +- **center** (List[int, int]): center location to start map at, default: [14, -14] +- **zoom** (int): zoom value to start map at, default: 3 +- **max_zoom** (int): maximum zoom value to perform close up on validation points, default: 20 +- **default_max_zoom** (int): default maximum zoom value, default: 20 +- **default_zoom** (int): default zoom value, default: 18 +- **scroll_wheel_zoom** (bool): enable mouse scroll to perform zoom, default: True +- **keyboard** (bool): enable keyboard options to move across points, default: True +- **basemap** (ipyleaflet.basemap): basemap object from ipyleaflet to use as background, default: basemaps.Esri.WorldImagery +- **height** (str): height of the output map in the Jupyter cell, default: 600px +- **data_dir** (str): directory to point at input data files in GeoTIFF, default: ~/ +- **mask_dir** (str): directory to point at mask data files in GeoTIFF; if not available, random points without stratification will be generated, default: ~/ +- **output_dir** (str): directory to store output database at, default: ~/eo-validation-output +- **default_bands** (List[tuple]): list of tuples representing band values, default: [('Coastal Blue', 1), ('Blue', 2), ('Green', 3), ('Yellow', 4), ('Red', 5), ('Red Edge', 6), ('NIR1', 7), ('NIR2', 8)] +- **rgb_bands** (List[int]): list of integer bands to use as RGB, default: [1, 2, 3] +- **rgb_disabled** (bool): disable toggling RGB band dropdown, default: False +- **validation_classes** (List[str]): list of validation classes to use, default: ['other', 'trees/shrub', 'cropland', 'other vegetation', 'water', 'build'] +- **mask_classes** (List[str]): list of classes to use in the random stratification process, default: ['other', 'tree', 'crop', 'burn'] +- **points_dir**: (str): directory where original points are located if they were already generated), default: ~/eo-validation/original_points +- **gen_points** (bool): generate random points on the fly, default: True +- **n_points** (int): number of points to generate if **gen_points** is True, default: 200 +- **expected_accuracies** (List[float]): list of expected accuracies for each class following Oloffson method, default: [0.90, 0.90, 0.90, 0.90] +- **expected_standard_error** (float): expected standard error per class, default: 0.01 +- **chunks** (dict): data sharding options from xarray, default: {"band": 1, "x": 2048, "y": 2048} + +Teams' Validation Quickstart +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Place data sowhere +Create general points +Open notebook + +Teams' Validation Example +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Place data sowhere +Create general points +Open notebook + Contributing ------------ diff --git a/docs/eo_validation.rst b/docs/eo_validation.rst deleted file mode 100644 index a5f8fdd..0000000 --- a/docs/eo_validation.rst +++ /dev/null @@ -1,33 +0,0 @@ -eo-validation ------------------- - -Package to ease the coordinated validation of remote sensing imagery. - -Installation ------------------ - -Install with pip -:: - - pip install eo-validation - -Creating a new environment in your local system -:: - conda create -n validation-notebook jupyter ipysheet leafmap geopandas localtileserver rioxarray --channel anaconda --channel conda-forge - -API ----- - -.. automodule:: eo_validation - :members: - -Authors ----------- - -Jordan A. Caraballo-Vega, jordan.a.caraballo-vega@nasa.gov - -License ---------------- - -The package is released under the `MIT -License `__. diff --git a/docs/examples/ValidationDashboard.ipynb b/docs/examples/ValidationDashboard.ipynb deleted file mode 100644 index 27dbe5c..0000000 --- a/docs/examples/ValidationDashboard.ipynb +++ /dev/null @@ -1,106 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "9f315b6b-73ad-467e-88af-70d09251eacd", - "metadata": {}, - "source": [ - "# 3SL Validation Notebook\n", - "\n", - "The following notebook is meant to ease the validation process of raster based semantic segmentation products.\n", - "\n", - "Instructions\n", - "1. Login to SMCE daskhub via URL: https://daskhub.dsg.smce.nasa.gov\n", - "2. Choose “Small Server”\n", - "3. Open terminal window by clicking on the “terminal” icon in the lower left of the launcher window\n", - " a. Alternatively you can click file -> new -> terminal\n", - "4. cd /efs/Konrad_GMU\n", - "5. mkdir \\ (only needs to be done once)\n", - "6. cd \\\n", - "7. Type `wget https://raw.githubusercontent.com/nasa-nccs-hpda/senegal-lcluc-tensorflow/main/notebooks/ValidationDashboard.ipynb`\n", - "8. In table of contents (left side of window) click on efs -> Konrad_GMU -> \\ \n", - " a. Here you should see the notebook you downloaded earlier\n", - " b. Double click on the notebook to open it\n", - " c. Use the >> button to run the notebook from the beginning or use the > button to go one cell at a time\n", - " \n", - "Validation output files will be saved under:\n", - " /home/jovyan/efs/3sl/validation/${username}/${date}-${filename}-${username}.gpkg" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "3020b230-dcf3-486a-af7e-4568a7160c10", - "metadata": {}, - "outputs": [], - "source": [ - "import sys\n", - "import socket\n", - "from IPython.display import display\n", - "\n", - "# If you did not install eo-validation via pip, you will need to \n", - "# set the path to the directory that houses your git repository\n", - "sys.path.append('/home/jovyan/eo-validation')\n", - "\n", - "# TODO: git clone repository, and add as an export to sys.path\n", - "\n", - "from eo_validation.validation_dashboard import ValidationDashboard" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "10f1da5e-8255-4bfe-918f-52fe1881ee87", - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "8099e398b6c24ad3854161c6d7c16188", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "ValidationDashboard(center=[14, -14], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_titl…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "dashboard = ValidationDashboard()\n", - "display(dashboard)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "39db291f-9630-47d1-a136-784112f91023", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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 -} diff --git a/docs/modules.rst b/docs/modules.rst index 0829426..1d24822 100644 --- a/docs/modules.rst +++ b/docs/modules.rst @@ -2,9 +2,9 @@ eo-validation package ======================== eo_validation.validation_dashboard.ValidationDashboard ----------------------- +------------------------------------------------------- -.. automodule:: eo_validation.validation_dashboard.ValidationDashboard +.. automodule:: eo_validation :members: :undoc-members: :show-inheritance: diff --git a/eo_validation/validation_dashboard.py b/eo_validation/validation_dashboard.py index 9ad9044..46ecc15 100644 --- a/eo_validation/validation_dashboard.py +++ b/eo_validation/validation_dashboard.py @@ -206,12 +206,6 @@ def __init__(self, **kwargs): else: self.expected_standard_error = kwargs['expected_standard_error'] - # Set product name - if "product_name" not in kwargs: - self.product_name = 'otcb' - else: - self.product_name = kwargs['product_name'] - # Set xarray chunk attributes if "chunks" not in kwargs: self.chunks = {"band": 1, "x": 2048, "y": 2048} @@ -400,8 +394,6 @@ def add_markers( ): # Extract label filename from data filename - # mask_filename = os.path.join( - # self.mask_dir, f'{Path(in_raster).stem}.{self.product_name}.tif') mask_filename = glob( os.path.join(self.mask_dir, f'{Path(in_raster).stem}*.tif'))