weecology / portalcasting

Model development, deployment, and evaluation for forecasting Portal ecosystem dynamics
https://weecology.github.io/portalcasting
Other
8 stars 10 forks source link

setup_dir() failing due to issue with moons #198

Closed ethanwhite closed 3 years ago

ethanwhite commented 3 years ago

I'm guessing something changed in the recent upstream changes but both @skmorgane (on Windows) & I (on Ubuntu) are having setup_dir() fail for us again using #179.

> setup_dir()
------------------------------------------------------------
This is portalcasting v0.20.0
------------------------------------------------------------
Establishing portalcasting directory at
 /home/ethan/testsetupdir
------------------------------------------------------------
Filling directory with standard content
 -Downloading raw files
  -PortalData
  -portalPredictions
 -Filling casts folder with files from archive
 -Writing model scripts
  -AutoArima
  -ESSS
  -NaiveArima
  -nbGARCH
  -nbsGARCH
  -pevGARCH
  -simplexEDM
  -GPEDM
  -jags_RW
 -Adding data files to data subdirectory
  -lunar data file
  -rodents data files
   -all
   -controls
   -exclosures
   -dm_controls
   -all_interp
   -controls_interp
   -exclosures_interp
  -covariate data files
Error in data.frame(moon = na_moon, possibles[which_possible, cols_keep],  : 
  arguments imply differing number of rows: 1, 0
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Pop!_OS 20.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] portalcasting_0.20.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6         lubridate_1.7.9.2  lattice_0.20-41    tidyr_1.1.2       
 [5] prettyunits_1.1.1  runjags_2.0.4-6    ps_1.5.0           zoo_1.8-8         
 [9] assertthat_0.2.1   rprojroot_2.0.2    digest_0.6.27      lmtest_0.9-38     
[13] R6_2.5.0           portalr_0.3.6      coda_0.19-4        httr_1.4.2        
[17] ggplot2_3.3.3      pillar_1.4.7       rlang_0.4.10       curl_4.3          
[21] fracdiff_1.5-1     callr_3.5.1        TTR_0.24.2         desc_1.2.0        
[25] devtools_2.3.2     tscount_1.4.3      scoringRules_1.0.1 munsell_0.5.0     
[29] xfun_0.20          compiler_4.0.3     pkgconfig_2.0.3    forecast_8.13     
[33] pkgbuild_1.2.0     urca_1.3-0         nnet_7.3-14        tidyselect_1.1.0  
[37] gridExtra_2.3      tibble_3.0.5       quadprog_1.5-8     codetools_0.2-18  
[41] viridisLite_0.3.0  fansi_0.4.2        crayon_1.3.4       dplyr_1.0.3       
[45] withr_2.4.0        MASS_7.3-53        grid_4.0.3         ltsa_1.4.6        
[49] nlme_3.1-151       jsonlite_1.7.2     gtable_0.3.0       lifecycle_0.2.0   
[53] magrittr_2.0.1     scales_1.1.1       quantmod_0.4.18    cli_2.2.0         
[57] viridis_0.5.1      fs_1.5.0           tseries_0.10-48    remotes_2.2.0     
[61] testthat_3.0.1     timeDate_3043.102  rEDM_0.7.5         lunar_0.1-04      
[65] ellipsis_0.3.1     xts_0.12.1         generics_0.1.0     vctrs_0.3.6       
[69] tools_4.0.3        glue_1.4.2         purrr_0.3.4        yaml_2.2.1        
[73] processx_3.4.5     pkgload_1.1.0      parallel_4.0.3     colorspace_2.0-0  
[77] sessioninfo_1.1.1  memoise_1.1.0      knitr_1.30         usethis_2.0.0     

Ping @juniperlsimonis

gmyenni commented 3 years ago

I'm still getting the zenodo timeout issue, so still waiting to test setup_dir. But I don't get this error when I just do fill_data. Does that work for you?

ethanwhite commented 3 years ago

Same error with fill_data for me:

> fill_data()
 -Adding data files to data subdirectory
  -lunar data file
  -rodents data files
   -all
   -controls
   -exclosures
   -dm_controls
   -all_interp
   -controls_interp
   -exclosures_interp
  -covariate data files
Error in data.frame(moon = na_moon, possibles[which_possible, cols_keep],  : 
  arguments imply differing number of rows: 1, 0
gmyenni commented 3 years ago

Okay, I can't recreate this error (on mac). But I also can't run fill_dir or setup_dir because of Zenodo errors retrieving portalPredictions. (I'm just downloading portalPredictions manually from Zenodo.) So that may be irrelevant.

ethanwhite commented 3 years ago

OK, maybe we can chat some more if we have time at the end of staff meeting.

ethanwhite commented 3 years ago

The error is coming from the recent fix:

https://github.com/weecology/portalcasting/blob/d97d0b440f9bda0dc0218c396743350564d85d11/R/prepare_covariates.R#L93-L112

Relevant values at that point:

> na_rows
    1     2     3     4     5     6     7     8     9    10    11    12    13 
 TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 
   14    15    16    17    18    19    20    21    22    23    24    25    26 
 TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 
... # All items in here are FALSE
  508   509   511   512   513   514   515 
FALSE FALSE FALSE FALSE FALSE FALSE FALSE 

> moon_in
  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
... # All FALSE
[181] FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
[193]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
... # All TRUE
[505]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE

> which_na_rows
named integer(0)

> nna_rows
[1] 0

First guess is that this is an issue with the loop when nna_rows == 0. Still exploring.

ethanwhite commented 3 years ago

Error is coming from here:

https://github.com/weecology/portalcasting/blob/d97d0b440f9bda0dc0218c396743350564d85d11/R/prepare_covariates.R#L103-L108

> str(possibles)
'data.frame':   2214 obs. of  10 variables:
 $ cast_moon    : int  NA NA NA NA NA NA NA NA NA NA ...
 $ moon         : int  NA NA NA NA NA NA NA NA NA NA ...
 $ mintemp      : num  NA NA NA NA NA NA NA NA NA NA ...
 $ maxtemp      : num  NA NA NA NA NA NA NA NA NA NA ...
 $ meantemp     : num  NA NA NA NA NA NA NA NA NA NA ...
 $ precipitation: num  NA NA NA NA NA NA NA NA NA NA ...
 $ ndvi         : num  NA NA NA NA NA NA NA NA NA NA ...
 $ source       : chr  NA NA NA NA ...
 $ date_made    : chr  NA NA NA NA ...
 $ date         : int  NA NA NA NA NA NA NA NA NA NA ...

> which_possible
integer(0)

Let me know what to look at/try next.

ethanwhite commented 3 years ago

Fixed in #197