NOAA-OWP / hyAggregate

Develop aggregated hydrologic and hydraulic networks
Other
2 stars 1 forks source link

Add capacity for external log files rather then console based #5

Closed mikejohnson51 closed 2 years ago

mikejohnson51 commented 2 years ago

For example:

t <- "data/vpu-01-log.txt"
log_appender(appender_file(t))
for (i in 1:25) log_info(i)
readLines(t)
mikejohnson51 commented 2 years ago

New output yields the following txt file:

VPU = "01"
log_info("Processing {VPU}")

base = '/Volumes/Transcend/ngen/CONUS-hydrofabric/'
g01 = get_reference_fabric(VPU = VPU, dir = glue("{base}refactor"), overwrite = FALSE)
g02 = glue("{base}ngen11/ngen_{VPU}.gpkg")
log_file = glue("{base}ngen11/ngen_{VPU}_log.txt")
log_info(basename(g01), " --> ", basename(g02))

aggregate_network_to_distribution(
    gpkg = g01,
    outfile        = g02,
    routelink_path = get_routelink_path(),
    overwrite      = TRUE,
    nexus_locations = nexus_from_poi(g01, verbose = FALSE),
    log = log_file
  )

OUTPUT:

 [1] "INFO [2022-08-01 17:48:05] ideal_size_sqkm --> 10"                                                                                                                     
 [2] "INFO [2022-08-01 17:48:05] min_length_km --> 1"                                                                                                                        
 [3] "INFO [2022-08-01 17:48:05] min_area_sqkm --> 3"                                                                                                                        
 [4] "INFO [2022-08-01 17:48:05] outfile --> /Volumes/Transcend/ngen/CONUS-hydrofabric/ngen11/ngen_01.gpkg"                                                                  
 [5] "INFO [2022-08-01 17:48:05] --- Read in data from /Volumes/Transcend/ngen/CONUS-hydrofabric/refactor/refactor_01.gpkg ---"                                              
 [6] "WARN [2022-08-01 17:48:13] 40204 flowpaths vs. 40203 catchments"                                                                                                       
 [7] "WARN [2022-08-01 17:48:13] Removing flowpath(s): 10039898"                                                                                                             
 [8] "INFO [2022-08-01 17:48:13] "                                                                                                                                           
 [9] "---  Aggregate Along Mainstem ---"                                                                                                                                     
[10] ""                                                                                                                                                                      
[11] "SUCCESS [2022-08-01 17:48:45] Merged to idealized catchment size of 10 sqkm: 13937 features removed"                                                                   
[12] "INFO [2022-08-01 17:48:46] "                                                                                                                                           
[13] "--- Collapse Network Inward ---"                                                                                                                                       
[14] ""                                                                                                                                                                      
[15] "INFO [2022-08-01 17:50:27] Collapsing: 8021 features (round 1)"                                                                                                        
[16] "INFO [2022-08-01 17:50:41] Collapsing: 270 features (round 2)"                                                                                                         
[17] "SUCCESS [2022-08-01 17:50:46] Collapsed 8291 features."                                                                                                                
[18] "INFO [2022-08-01 17:50:46] "                                                                                                                                           
[19] "--- Applying HY_feature topology --- "                                                                                                                                 
[20] ""                                                                                                                                                                      
[21] "INFO [2022-08-01 17:50:50] "                                                                                                                                           
[22] "INFO [2022-08-01 17:50:55] --- Creating Routing Table based on: /Users/mjohnson/Library/Application Support/org.R-project.R/R/hyAggregate/RouteLink_nwm_v2_2_0.fst ---"
[23] "INFO [2022-08-01 17:51:06] --- Writing data to: /Volumes/Transcend/ngen/CONUS-hydrofabric/ngen11/ngen_01.gpkg ---"                                                     
[24] "SUCCESS [2022-08-01 17:51:06] Writing refactored_flowpaths & refactored_divides to /Volumes/Transcend/ngen/CONUS-hydrofabric/ngen11/ngen_01.gpkg"                      
[25] "SUCCESS [2022-08-01 17:51:09] Done!"