Reads user-set parameters for package saltmarsh.
Details
User parameters are set in two distinct locations:
The initialization file, in the user's home directory,
~/saltmarsh.yml
. This file should contain five lines:basedir: c:/Work/etc/saltmarsh
parsdir: pars
parsfile: pars.yml
scratchdir: c:/Work/etc/saltmarsh/data/scratch
a.
basedir
points to the base directoryb.
parsdir
is the parameters subdirectory. It should bepars
unless you have a good reason to change it.c.
parsfile
points to the main parameter file. It should bepars.yml
.d.
scratchdir
points to the scratch drive, where thecache
directory will be located. See notes on caching, below.Everything else, in
<basedir>/<parsdir>
. The primary parameter file ispars.yml
, which points to other parameters (such assites.txt
).
These parameters include:
sites
the name of the sites file,sites.txt
by defaultclasses
the name of the classes file,classes.txt
by defaultdirs
alternative names for various subdirectories. The directories will keep the standard structure–you can change names here but not paths.gather
a block of parameters forgather()
This approach splits the user- and platform-dependent parameters (saltmarsh.yml
)
from parameters that are likely to be shared among users and across platforms (those in
parsdir
). It allows multiple users on a shared machine (such as Unity cluster)
to set user-specific parameters if need be, while sharing other parameters.
This function reads the user parameters and adds them to the environment the
with
all parameters. It is automatically run upon loading the package, and may be
rerun by the user if parameter files are changed.
You can change standard directory names (data
, models
, gis
, flights
, field
,
shapefiles
, samples
, predicted
, and cache
) by setting each within a dirs:
block in pars.yml
.
Directories default to standard names, which is usually what you want.
To change parameters on the fly, you can set the components of the
. If you change any elements of
dirs
, you'll have to run set_dirs()
afterwards. Note
that parameters changed on the fly will only persist until the next call to init()
,
which can be called on demand but also happens automatically when the package is loaded.
For example:
the$sites <- 'newsites'
the$dirs$cache <- 'newcache'
the$dirs$samples <- 'samples99'
set_dirs()
Notes on caching. A cache directory is required when sourcedrive = google
or sftp
. The cache
directory should be larger than the total amount of data processed–this code isn't doing any quota
management. This is not an issue when using a
scratch drive on Unity,
as the limit is 50 TB. There's no great need to carry over cached data over long periods, as downloading
from Google or SFTP to Unity is very fast. Be polite and release the scratch workspace when you're done.
See comments in get_file()
for more notes on caching.