DOI-USGS / lake-temperature-model-prep

Pipeline #1
Other
6 stars 13 forks source link

Add lake elevation to the pipeline #317

Closed jordansread closed 2 years ago

jordansread commented 2 years ago

This addresses the need in #285 to properly set the crest elevation of the lake. And more recently, the use of elevation in EA-LSTM as a static input.

I transferred the code from lake-surface-temperature-prep into here and dealt with a new funky bug captured here for the elevation data pull.

This code creates lat/lon cells for CONUS and then spins up a scipiper task table for each cell that has lake centroids in it. Each cell is then a call to get elevation from the elevatr package, and all of the values get merged into a single feather file. I used this method because we're often adding a few lakes and want to avoid trigging unnecessarily large data pulls. Presetting the grid to not shift means that only the tasks for cells that have added/lost/moved lakes will get rebuilt or new cells that now have lakes in them after an update.

After building the feather file, the value for elevation (in meters) is then applied to the nml H vector, which used to set all lakes to 320 meters above sea level.

readRDS('2_crosswalk_munge/out/centroid_lakes_sf.rds') %>% 
    inner_join(arrow::read_feather('1_crosswalk_fetch/out/ned_centroid_elevations.feather')) %>%
    dplyr::select(elevation) %>% plot(pch = 16, cex = 0.5)
image

Confirmed that high elevation lakes are in the mountain west (or east) and very low elevation lakes are on the NE coast.

A prettier picture when limiting elevations to a window above 50m and below 500m:

readRDS('2_crosswalk_munge/out/centroid_lakes_sf.rds') %>% 
    inner_join(arrow::read_feather('1_crosswalk_fetch/out/ned_centroid_elevations.feather')) %>%
    filter(elevation > 50 & elevation < 500) %>% dplyr::select(elevation) %>% plot(pch = 16, cex = 0.5)
image
jordansread commented 2 years ago

Thanks for the review @padilla410 !