bertozzivill / map-itn-cube

Geospatial insecticide-treated net models for the Malaria Atlas Project
GNU General Public License v3.0
0 stars 2 forks source link

Refactor out in-/output paths and create cli part 2 #221

Closed mauricio-tki closed 3 years ago

mauricio-tki commented 3 years ago

This is pretty much the same this as #217 but for the ITN cube part.

Running the scripts should be backwards compatible except for 04_predict_rasters.r, where the year parameter is a named argument instead of a positional one.

Another addition in each script is this code:

options(keep.source = TRUE)
options(keep.source.pkgs = TRUE)
options(tryCatchLog.include.compact.call.stack = FALSE)
flog.threshold(ERROR)
tryCatchLog({
  main()
})

It uses the tryCatchLog package for a slightly improved trace when an error is thrown. Occasionally line numbers are included (not clear to me exactly when). It's a real pain when a long running script errors somewhere and R doesn't give much information as to where, this should help a bit with finding out where.

If you want to look at the diff in a more manageable fashion I would suggest skipping the commits that start with "move" (code is purely moved around/put into functions there) and just look at the ones that start with "add".

bertozzivill commented 3 years ago

Looks great, thanks @mauricio-tki!