From ad5d8679ded51bd197a0430e1d84fc6ff817ff8e Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Fri, 11 Oct 2024 12:48:49 +0200 Subject: [PATCH] Closes #35 --- doc/index.rst | 1 + doc/table_explorer.rst | 1 + src/pymorize/webapp.py | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 doc/table_explorer.rst diff --git a/doc/index.rst b/doc/index.rst index 561de29d..1392e7ee 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -15,6 +15,7 @@ Contents installation pymorize_building_blocks pymorize_cli + table_explorer pymorize_on_slurm schemas standard_library diff --git a/doc/table_explorer.rst b/doc/table_explorer.rst new file mode 100644 index 00000000..1d14c5a7 --- /dev/null +++ b/doc/table_explorer.rst @@ -0,0 +1 @@ +.. automodule:: pymorize.webapp diff --git a/src/pymorize/webapp.py b/src/pymorize/webapp.py index dcf62581..b3cfbe61 100644 --- a/src/pymorize/webapp.py +++ b/src/pymorize/webapp.py @@ -1,3 +1,38 @@ +""" +================================ +Web Viewer for CMIP6 Data Tables +================================ +We provide a Streamlit web application that provides an interface for interacting with CMIP6 (Coupled Model Intercomparison Project Phase 6) data tables. + +Launch it from the command line with:: + + $ pymorize table-explorer + +The application allows users to load these tables from three different sources: GitHub, a local directory, or directly from the user's laptop. The tables are JSON files containing metadata about climate model outputs. + +The main features of the application are: + +1. **Table Source Selection**: Users can select the source of the tables. The options are 'github', 'Local', and 'Laptop'. Depending on the selection, the user can provide a URL (for GitHub), a directory path (for Local), or upload files (for Laptop). + +2. **Table Processing**: The application processes each table, extracting key information such as table ID, frequency, and variable entries. Tables that do not contain variable entries or frequency are added to an ignore list. + +3. **Variable Selection and Display**: Users can select a variable from the processed tables. The application then displays all tables and frequencies where this variable is found, along with additional information such as the time method (Instantaneous, Climatology, or Mean). + +4. **Metrics Display**: The application displays metrics about the processed tables, including the number of tables, frequencies, and variables. + +5. **Ignored Tables**: The application provides an expander to view all ignored tables. + +The application uses multithreading to load and process tables from GitHub, improving performance when dealing with a large number of tables. + +This module contains several functions: + +- `process_table(tbl_name: str, data: dict)`: Processes a single table, extracting key information and updating global data structures. +- `show_selected_variable(varname)`: Displays information about the selected variable. +- `load_data_from_github(f, ctx)`: Loads a single table from GitHub. + +The application uses several global data structures to store information about the tables and variables, including `tbls`, `tbl_raw_data`, `var_to_tbl`, `frequencies`, `tids`, and `ignored_table_files`. +""" + import json import os import socket