Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

camelCase variables in background_CONUS.sqlite causing dropped variables in metadata in 3_createModel.R #187

Closed
matthewpaulking opened this issue May 2, 2019 · 2 comments

Comments

@matthewpaulking
Copy link
Contributor

Currently, the pre-attributed background points database background_CONUS.sqlite contains camelCase variable names in the "geo*" series of predictors, e.g., geoClay, geoSDune.

Downstream, this causes the specific model-run attribute database (<cutecode>_yyyymmdd_hhmmss_att.sqlite) to have those camelCase conventions.

When 3_createModel.R runs it loads:

  1. envvar_list <- The environmental variable names from the tracking database (db = SDM_lookupAndTracking.sqlite; column = lkpEnvVars.gridName) which are lowercase.
  2. df.abs <- The actual background points from the model run (<cutecode>_yyyymmdd_hhmmss_att.sqlite) which are in camelcase

Line 82 is using the names from df.abs, so the camelCase version in df.abs won't pick up the lowercase versions in envvar_list, thus unintentionally dropping those from writing out the metadata in tblModelResultsVarsUsed in SDM_lookupAndTracking.sqlite

envvar_list <- names(df.abs)[names(df.abs) %in% envvar_list] # gets a list of environmental variables

Two possible solutions:

  1. force tolower()
names(df.abs) <- tolower(names(df.abs))
  1. Fix the column names in background_CONUS.sqlite.

Option 1 is easy and only one line extra, but curious if you think Option 2 is also a good idea.

@tghoward
Copy link
Contributor

tghoward commented May 3, 2019

Good sleuthing! Yes, we are in a bit of flux as the names in earlier versions of SDM_lookupAndTracking.sqlite were also in camelcase. You are right that in the long-term we should take option 2 and set it up as best practice to always use only lower case for gridnames.

Sounds like it is also safest to always account for that best practice to be broken; which means we should take your option 1 no matter what.

@tghoward
Copy link
Contributor

tghoward commented May 3, 2019

hopefully taken care of in #189

@tghoward tghoward closed this as completed May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants