Skip to content

we3lab/wwtp-process-extraction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

159 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WWTP Unit Process Extraction from Permits Tool

These tools are designed to access unit process data from the National Pollutant Discharge Elimination System (NPDES) permits for California.

Description

Researchers have utilized the CWNS to aggregate WWTP unit processes. However, this data is infrequent, voluntary, and sparse. To address these limitations, we utilize regulatory permits. The following Python tools are used to collect its data:

  1. Build CWNS process tables

  2. Scrape permits and site metadata

  3. Extract permit text

  4. Detect treatment processes with keyword search

  5. Detect treatment processes with LLM extraction

    • wwtp_process_extraction/step5_llm_extraction.py: runs LLM extraction on permit text
      • use --method ontology-based (default) or --method list-based to select prompting strategy
      • use --model "model_name" --txt_folder "path_to_txt_folder" --facilities_information "path_to_facilities_csv"
      • results saved as JSON under output/date/llm_search_ontology or llm_search_list
  6. Post-process LLM output back to CWNS format

Figures and tables

Installation

pip install -e .

How to Run

Executing from the repository root directory:

python wwtp_process_extraction/step1_build_cwns_table.py
python wwtp_process_extraction/step2_scrape_npdes.py
python wwtp_process_extraction/step3_get_facility_descriptions.py
python wwtp_process_extraction/step4_keyword_extraction.py
# MODEL COMPARISON (all manual-read facilities, default FACILITIES_INFO_PATH)
python wwtp_process_extraction/step5_llm_extraction.py --all_models
# WEB SEARCH (claude-sonnet-4-6)
python wwtp_process_extraction/step5_llm_extraction.py  --model claude-sonnet-4-6 --web_search --all_methods
# FULL CA, ONTOLOGY-BASED, GPT-5-MINI
python wwtp_process_extraction/step5_llm_extraction.py --all_facilities
# F1 VARIANCE: 2 extra benchmark runs
python wwtp_process_extraction/step5_llm_extraction.py --repeat_runs 2
python wwtp_process_extraction/step6_postprocess_llm_output.py
python wwtp_process_extraction/table_1_evaluate_model_performance.py
python wwtp_process_extraction/figure_2_data_source_comparison.py
python wwtp_process_extraction/figure_3_extraction_comparison.py
python wwtp_process_extraction/figure_4_ca_ghg_comparison.py
python wwtp_process_extraction/figure_s2_method_comparison.py
python wwtp_process_extraction/figure_s3_category_f1_method.py

Contact

Daly Wettermark - dalyw@stanford.edu

Constance Rouffet - rouffetc@stanford.edu

Fletcher Chapin - fchapin@stanford.edu

Ashley Ramirez - ashlecr3@uci.edu

Meagan Mauter - mauter@stanford.edu

Acknowledgements

This work is funded in part by: Stanford Woods Institute for the Environment's Realizing Environmental Innovation Program (REIP) Stanford SURGE program National Alliance for Water Innovation

We acknowledge the use of Claude Code and Anthropic LLMs for drafting and refining elements of web scraping, data manipulation, and visualization code throughout the codebase.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages