tpilz / lumpR

Landscape Unit Mapping Program for R
GNU General Public License v3.0
11 stars 12 forks source link

Error in data cleaning in db_check delete obsolete #36

Closed ERottler closed 6 years ago

ERottler commented 7 years ago

db_check(dbname,

  • check=c("delete_obsolete"),
  • fix=T,
  • verbose=T)

When executing following error message returns:

% Write changes into database and update 'meta_info' (might take a while) ... Error in [.data.frame(dat_tbl, , key_t[1]) : undefined columns selected

The corresponding data base can be found at: V:\xchange\erwin\4TPilz

sessionInfo() R version 3.4.0 (2017-04-21) Platform: i386-w64-mingw32/i386 (32-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] lumpR_2.2.0 [...]

tpilz commented 7 years ago

Hi Erwin, your table "rainy_season" contains column "id" but not "pid" as it should be named correctly.

There might be other problems as well. I haven't checked everything.

Note that table "x_seasons" might cause some trouble as it is not yet really supported by lumpR (so far I was only focussing on the Hydrology part of WASA and completely excluded the sediment part).

Anyway, thanks for reporting. I will adjust db_update() to detect inconsistent column names right away (as soon as I have time).

ERottler commented 7 years ago

Hi Tobias,

thank you very much for your help! I got the database running. Unfortunately some other issue occured I am still struggling with. It is my soter.dat that gives me troubles. I updated the database, reduced it to the subbasin of interest, did all the db_checks succesfully, but when trying to run WASA the following error occurs:

ERROR (soter.dat): line 3 contains more (17) than the max expected 2+5+8 fields (maxdim.dat).

I checked and my soter.dat really contains to many columns. After the colums with the TC_IDs there again appears a column with the LU-ID, plus at the and there is a column with SDR_LU. Two too many columns get exported when producing the WASA input with db_wasa_input(). I also tried with another subbasin and the same happens. I guess it again might be due the the old structure of the database? Do you have any advice on how I can solve this problem? In V:\xchange\erwin\4TPilz you can find the database and also the soter.dat I get. It is not very urgend, but maybe you have a few minutes the next days to take a look. Should you have further questions don´t hesitate to ask. I also can come by your office any time. Maybe you also have some more general advice on how I am able to better solve such issues myself in the future? Thanks a lot! Erwin

sessionInfo() R version 3.4.1 (2017-06-30) Platform: i386-w64-mingw32/i386 (32-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 [...] other attached packages: [1] lumpR_2.2.0

tpilz commented 7 years ago

Thank your for the report. There was indeed an error when writing soter.dat and one more regarding rocky fraction of table terrain_components in db_check(). These must have slipped somehow through my error control.

I created the branch 'issue36'. Please re-install lumpR from that branch via devtools::install_github("tpilz/lumpR", ref="issue36") and tell me if everything works fine now. Then I will merge the branch to master.

Please note: Your database seems still corrupted. E.g. table "landscape_units" contains column "length" which should be called "slopelength". This will cause an error! To avoid such problems, you should install a database using lumpR::db_create() and lumpR::db_update() and fill that with your data. Or bring your old database up to date regarding the column names.

ERottler commented 7 years ago

Hi! Thanks a lot! I re-installed lumpR from the branch 'issue36' and was running apply_lumpR_template.R again. The obsolete column with LU-IDs after the TCs is gone, but I still get an error message regarding my soter.dat:

ERROR (soter.dat): line 3 contains more (16) than the max expected 2+5+8 fields (maxdim.dat).

When comparing with my working test base there still is an additional column 'SDR_LU[-]' added at the end. When removing this column manually and changing the column 'length' in 'landscape_units' to 'slopelength', the database seems to run fine. The updated database and the soter.dat I get with lumpR 'issue36' are in V:\xchange\erwin\4TPilz.

tpilz commented 7 years ago

When WASA runs fine when you remove the SDR_LU column it seems to me a problem regarding the sediment module. The column is only needed if you enable sediment transport simulations in WASA. So maybe this is a problem with the model rather than lumpR?!