DOI-USGS / DOI-USGS/loadflex

let loadReg2 store more metadata

Open
#171 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
16
Forks
18
PR merge metrics
No merged PRs in 30d

Description

I think a user should be able to supplement the metadata that `rloadest::loadReg` collects with any slot that `loadflex::metadata` acknowledges that isn't already known to `loadReg`. This is especially important now that `metadata` has been extended to include many more slots.

The trick is to do this tidily, so that the user doesn't have to do a whole lot of retyping if they're fitting multiple models. One less-tidy option is to add explicit parameters for all of the metadata slots that aren't already collected by `loadReg`, e.g.,
```r
loadReg2 <- function(load.reg,
pred.format=c("flux","conc"),
store=c("data","fitting.function"),
site.id, lat, lon, basin.area, # etc. - add all the slots that loadReg doesn't have
...) {
```
but this could get unweildy. So another option might be to accept a partial metadata object in lieu of all those independent objects, from which only the non-loadReg slots will be used...
```r
loadReg2 <- function(load.reg,
pred.format=c("flux","conc"),
store=c("data","fitting.function"),
new.metadata,
...) {
```

but this will require careful communication to the user and/or some way of preventing them from trying to override the slots that loadReg _does_ know about. So this option requires some thinking, too.

For any solution we choose, the idea should be to get the non-loadReg slots optionally filled in.

Here are the slots that `loadReg` tracks:

https://github.com/USGS-R/loadflex/blob/master/R/loadReg.R#L31-L39
```r
constituent=load.model$constituent,
flow=load.model$flow,
load.rate="",
dates=load.model$dates,
conc.units=load.model$conc.units,
flow.units=load.model$flow.units,
load.units=load.model$load.units,
load.rate.units=paste0(load.model$load.units,"/day"),
site.name=load.model$station
```

and here are all the slots in `loadflex::metadata`:
https://github.com/USGS-R/loadflex/blob/master/R/metadata.R#L68-L94
```r
slots=c(
# Column names (except consti.name)
constituent="character",
consti.name="character",
flow="character",
load.rate="character",
dates="character",
# Units
conc.units="character",
flow.units="character",
load.units="character",
load.rate.units="character",
# Site info
station="character", # deprecated in favor of site.name, site.id
site.name="character",
site.id="character",
lat="numeric",
lon="numeric",
basin.area="numeric",
flow.site.name="character",
flow.site.id="character",
flow.lat="numeric",
flow.lon="numeric",
flow.basin.area="numeric",
basin.area.units="character",
# Other
custom="ANY"),
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.