Code for the publication:
Unintended Consequences of Hydrologic Restoration for Mosquito-borne Disease
mamba activate copco
# # generate any custom dem files (see below), copy:
resolution=350
cp data/dem_opentopo_"$resolution"_carvedout.tif workspace/data/dem_opentopo.tif
# # generate any corresponding bedrock files (see below), copy:
cp data/bedrock_$resolution.txt workspace/data/bedrock.txt
make run_prep
# edit gage coords, minq, in config file coords as necessary
# edit dem_resolution_ts_height, in metadata file as necessary
make -B generic_config # for now, direct edits only happen to assets folder config files
# "git commit" config,metadata files before run
make cs_preflight
# TODO: zip workspace for portability and move to default CS location (<path>)
# # --- 2. Run
# # A. Run CS
# 0. Launch cs.exe GUI
# 1. `[Config File] -> Open`
# 2. `[load data]`
# # B. Record config, metadata
make cs_postflight
# # for an old run, get assets/[config.yml + metadata.yml] matching the git history at run date
# ./scripts/record_run_info.sh '2025-05-23'# TODO: it would be good to set results files to be read-only
# --- 3. Postprocess
# A. Postprocess
# # run info
python scripts/get_run_info.py
python scripts/get_run_info.py --target_folder workspace/2025-07-10T13-57-11
# # mapping
# convert all velocity,waterdepth txt grids from latest run to tif+ncdf
python scripts/cs_parse_aaigrid.py
# convert specific txt grid from latest run to png viz
python scripts/cs_parse_aaigrid.py \
--slugs waterdepth --start_date 1963-04-19 --end_date 1963-04-23 --output png
python scripts/cs_parse_aaigrid.py --slugs waterdepth --output png --latest
# convert txt grids from specific run to png viz
# run w/ bedrock "on"
workspace_folder="workspace/2025-07-10T13-57-11"
# median flow
date_target="1959-03-31"
date_plus_one="1959-04-01"
date_minus_one="1959-03-30"
python scripts/cs_parse_aaigrid.py \
--workspace_folder $workspace_folder \
--slugs waterdepth --start_date $date_minus_one --end_date "$date_plus_one" --output png --suppress_labels
mv waterdepth_"$date_target".png waterdepth_"$date_target"_bedrock-on.png
mogrify -trim waterdepth_1964-12-25_bedrock-on.png
# high flow
python scripts/cs_parse_aaigrid.py \
--workspace_folder $workspace_folder \
--slugs "waterdepth" --start_date 1964-12-24 --end_date 1964-12-26 --output png --suppress_labels
mv waterdepth_1964-12-25.png waterdepth_1964-12-25_bedrock-on.png
mogrify -trim waterdepth_1964-12-25_bedrock-on.png
# low flow
python scripts/cs_parse_aaigrid.py \
--workspace_folder $workspace_folder \
--slugs waterdepth --start_date 1959-06-06 --end_date 1959-06-08 --output png --suppress_labels
mv waterdepth_1959-06-07.png waterdepth_1959-06-07_bedrock-on.png
mogrify -trim waterdepth_1959-06-07_bedrock-on.png
# run w/ bedrock "off" and channel "dredge"
workspace_folder="workspace/2025-08-01T13-07-05"
python scripts/cs_parse_aaigrid.py \
--workspace_folder $workspace_folder \
--slugs waterdepth --start_date 1962-01-11 --end_date 1962-01-13 --output png --suppress_labels
mv waterdepth_1962-01-12.png waterdepth_1962-01-12_dredge.png
mogrify -trim waterdepth_1962-01-12_dredge.png
# # metrics targeting latest run
# from dat
python scripts/cs_parse_dat.py --slugs waterdepth
# from aaigrid
# run w/ bedrock "on"
workspace_folder="workspace/2025-07-10T13-57-11"
python figures/depth_categorize.py \
--workspace_folder $workspace_folder --start_date 1959-01-03 --end_date 1959-05-03 --slugs "waterdepth" --suppress_labels
mv __depth_categorize.pdf __depth_categorize_bedrock-on.pdf
mogrify -density 300 -format png -resize 2500x2500\> __depth_categorize_bedrock-on.pdf
mogrify -trim __depth_categorize_bedrock-on.png
# run w/ bedrock "off" and channel "dredge"
workspace_folder="workspace/2025-08-01T13-07-05"
python figures/depth_categorize.py \
--workspace_folder $workspace_folder --start_date 1959-01-03 --end_date 1959-05-03 --slugs "waterdepth" --suppress_labels
mv __depth_categorize.pdf __depth_categorize_dredge.pdf
mogrify -density 300 -format png -resize 2500x2500\> __depth_categorize_dredge.pdf
mogrify -trim __depth_categorize_dredge.png
# # mamba
mamba env create -f environment.yml
# mamba env update -f environment.yml
mamba activate copco# # C-Lisflood
# 1. Install wine (if necessary)
# brew install --cask wine-stable
# softwareupdate --install-rosetta --agree-to-license
# 2. Download from: https://sourceforge.net/projects/caesar-lisflood/
# install wget if necessary
wget https://sourceforge.net/projects/caesar-lisflood/files/CAESAR-lisflood%20quick%20start%20for%20version%202.0.zip
unzip "CAESAR-lisflood quick start for version 2.0.zip" -d caesar-lisflood/src
rm CAESAR-lisflood\ quick\ start\ for\ version\ 2.0.zip# # A. Provide lake coordinates, dam coordinates, (optional) upstream limit `id_reach` to define AOI
workspace_folder="workspace"
make init workspace_folder="$workspace_folder"
# edit $workspace_folder/metadata.yml
# # B. Pull VotE data
make pull_vote workspace_folder="$workspace_folder"
# # C. Identify target streamflow gages (from step 2), pull streamflow data
# edit $workspace_folder/metadata.yml
make pull_vote_streamflow workspace_folder="$workspace_folder"
# # D. Generate DEM tif, convert to txt
# resolution controlled by workspace/metadata.yml, default
make dem_txt dem_txt="$workspace_folder"/dem.tif workspace_folder="$workspace_folder"
# custom resolution(s), output path
resolution=350
python scripts/get_opentopo_dem.py --workspace_folder . \
--ts_height $resolution --tag $resolution --path_basin_poly workspace/data/vector.gpkg
gdal_translate -of AAIGrid data/dem_opentopo_$resolution.tif data/dem_$resolution.txt
# verify that LHS is not completely nodata, fix with:
scripts/trim_dem.sh -d 3 -f data/dem_opentopo_$resolution.tif
# # Generate Bedrock tif
# Manual process:
# 1. Open DEM in QGIS
# 2. Use raster calculator to subtract arbitrary amount (20m) = bedrock
# 3. Using the 'Serval` QGIS plugin, raise the bedrock under the dam to an amount approx 2m above DEM
make bedrock_txt # called by make run_prep
# Automated process:
mamba activate gdal311
resolution=350
gdal_calc -A data/dem_opentopo_$resolution.tif --outfile=result.tif --calc="(A.astype(numpy.float64) - 20)"
gdal vector rasterize --update --all-touched -l copco_dam -a elev data/copco_dam.gpkg result.tif
mv result.tif data/bedrock_opentopo_$resolution.tif
gdal_translate -of AAIGrid data/bedrock_opentopo_$resolution.tif data/bedrock_$resolution.txt
# # E. Preflight for run
# make clean
make -B generic_config workspace_folder="$workspace_folder"
make gage_coords # find XY coords of gages
# # further manual edits of "$workspace_folder"/config.yml:
# # See: https://sourceforge.net/p/caesar-lisflood/wiki/Tab%20Parameters%20%28description%20of%20model%20parameters%29
# # `maxrunduration`: 120, hours, should make it the number of hours of reach data
# # `inputtimestep`: 30, minutes, specifies the time step between each row of the input filehttps://sourceforge.net/projects/caesar-lisflood/
LANL O4899
© 2025. Triad National Security, LLC. All rights reserved. This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. Department of Energy/National Nuclear Security Administration. All rights in the program are reserved by Triad National Security, LLC, and the U.S. Department of Energy/National Nuclear Security Administration. The Government is granted for itself and others acting on its behalf a nonexclusive, paid-up, irrevocable worldwide license in this material to reproduce, prepare derivative works, distribute copies to the public, perform publicly and display publicly, and to permit others to do so.