timjmiller / wham

State-space, age-structured fish stock assessment model
https://timjmiller.github.io/wham
Other
32 stars 16 forks source link

HTML results not showing #42

Closed JDeroba closed 3 years ago

JDeroba commented 3 years ago

I ran through all 6 example scripts that "come with WHAM", and in call cases, the html plot of results did not work. My browser would open a new tab, display the sub-tab headings (i.e., home, diagnostics, input data, ...etc.), but each sub-tab was just blank. Perhaps related, when I request png, the "NAA_res_barplot_stacked.png" plot in the diagnostics folder is blank. When I request pdf, I don't see a stacked barplot in the diagnostics file at all (everything else is fine). So it seems when png is selected that the code is attempting to make a plot that it shouldn't or can't, but that does not happen when pdf is selected. The code I ran is exactly that from the Vignettes. sessionInfo() below: R version 4.0.2 (2020-06-22) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 17763)

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] wham_1.0.3

loaded via a namespace (and not attached): [1] lattice_0.20-41 tidyr_1.1.2 png_0.1-7 assertthat_0.2.1 digest_0.6.27
[6] R6_2.5.0 backports_1.2.1 ellipse_0.4.2 ggplot2_3.3.3 pillar_1.4.7
[11] rlang_0.4.10 data.table_1.13.6 rstudioapi_0.13 blob_1.2.1 rpart_4.1-15
[16] Matrix_1.2-18 checkmate_2.0.0 labeling_0.4.2 splines_4.0.2 stringr_1.4.0
[21] foreign_0.8-80 TMB_1.7.18 htmlwidgets_1.5.3 munsell_0.5.0 tinytex_0.29
[26] compiler_4.0.2 xfun_0.20 pkgconfig_2.0.3 base64enc_0.1-3 mnormt_2.0.2
[31] tmvnsim_1.0-2 htmltools_0.5.1.1 nnet_7.3-14 tidyselect_1.1.0 tibble_3.0.6
[36] gridExtra_2.3 htmlTable_2.1.0 Hmisc_4.4-2 fansi_0.4.2 viridisLite_0.3.0
[41] crayon_1.3.4 dplyr_1.0.3 withr_2.4.1 grid_4.0.2 gtable_0.3.0
[46] lifecycle_0.2.0 DBI_1.1.0 magrittr_2.0.1 scales_1.1.1 cli_2.2.0
[51] stringi_1.5.3 farver_2.0.3 viridis_0.5.1 latticeExtra_0.6-29 ellipsis_0.3.1
[56] generics_0.1.0 vctrs_0.3.6 Formula_1.2-4 RColorBrewer_1.1-2 tools_4.0.2
[61] glue_1.4.2 purrr_0.3.4 jpeg_0.1-8.1 parallel_4.0.2 survival_3.1-12
[66] colorspace_2.0-0 cluster_2.1.0 sessioninfo_1.1.1 knitr_1.31

tcarruth commented 3 years ago

I had this issue until I removed the blank spaces from the directory in which the html report was to be built, ie: plot_wham_output(...,dir.main="C:/no_more_spaces/")

timjmiller commented 3 years ago

@JDeroba were the spaces in directory name path the issue for you?

JDeroba commented 3 years ago

@timjmiller No. Eliminating spaces did not fix the problem for me.

brianstock-NOAA commented 3 years ago

@JDeroba We just tagged a new release with a bunch of fixes and upgrades. Curious if this is still an issue. Sometime when you can let your computer spin for ~1 hour, can you run:

# install new v.1.0.4
devtools::install_github("timjmiller/wham", dependencies=TRUE)
# setwd("choose/where/to/save/output") # otherwise in working directory
library(wham)
wham.dir <- find.package("wham")
source(file.path(wham.dir, "example_scripts", "run_all_examples.R"))
JDeroba commented 3 years ago

@brianstock-NOAA I'm still having the same problem as described in the issue I initially opened. I again tried tcarruth's suggestion of no spaces in the working directory, but that does not seem to be the problem for me. sessioninfo(): R version 4.0.2 (2020-06-22) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 17763)

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] wham_1.0.4

loaded via a namespace (and not attached): [1] xfun_0.22 tidyselect_1.1.1 TMB_1.7.20 purrr_0.3.4 splines_4.0.2
[6] lattice_0.20-41 colorspace_2.0-1 vctrs_0.3.8 generics_0.1.0 htmltools_0.5.1.1
[11] viridisLite_0.4.0 base64enc_0.1-3 utf8_1.2.1 blob_1.2.1 survival_3.1-12
[16] rlang_0.4.11 pillar_1.6.0 foreign_0.8-80 glue_1.4.2 withr_2.4.2
[21] DBI_1.1.0 RColorBrewer_1.1-2 sessioninfo_1.1.1 jpeg_0.1-8.1 lifecycle_1.0.0
[26] stringr_1.4.0 munsell_0.5.0 gtable_0.3.0 htmlwidgets_1.5.3 knitr_1.33
[31] labeling_0.4.2 latticeExtra_0.6-29 parallel_4.0.2 fansi_0.4.2 htmlTable_2.1.0
[36] backports_1.2.1 checkmate_2.0.0 scales_1.1.1 Hmisc_4.5-0 tmvnsim_1.0-2
[41] farver_2.1.0 gridExtra_2.3 mnormt_2.0.2 ellipse_0.4.2 ggplot2_3.3.3
[46] png_0.1-7 digest_0.6.27 stringi_1.6.1 dplyr_1.0.6 grid_4.0.2
[51] cli_2.5.0 tools_4.0.2 magrittr_2.0.1 tibble_3.1.1 Formula_1.2-4
[56] cluster_2.1.0 crayon_1.4.1 tidyr_1.1.3 pkgconfig_2.0.3 ellipsis_0.3.2
[61] Matrix_1.2-18 data.table_1.14.0 rstudioapi_0.13 assertthat_0.2.1 viridis_0.6.1
[66] R6_2.5.0 rpart_4.1-15 nnet_7.3-14 compiler_4.0.2

brianstock-NOAA commented 3 years ago

Hi Jon, when the HTML results fail are the png plot files created alright? The html still works for me on Linux but I'm wondering if I should just change the default output type to be png or pdf. Can you please confirm if the png and/or pdf output works on your machine? Thanks!

Running this code is probably the fastest way to check:

devtools::install_github("timjmiller/wham", dependencies=TRUE, ref="devel")
library(wham)
wham.dir <- find.package("wham")
asap3 <- read_asap3_dat(file.path(wham.dir,"extdata","ex1_SNEMAYT.dat"))
input3 <- prepare_wham_input(asap3, recruit_model=2, model_name="Ex 1: SNEMA Yellowtail Flounder",
                              selectivity=list(model=rep("age-specific",3), 
                                  re=rep("none",3), 
                                  initial_pars=list(c(0.5,0.5,0.5,1,1,0.5),c(0.5,0.5,0.5,1,0.5,0.5),c(0.5,1,1,1,0.5,0.5)), 
                                  fix_pars=list(4:5,4,2:4)),
                              NAA_re = list(sigma="rec+1", cor="iid"))
m3 <- fit_wham(input3, do.osa = F)

plot_wham_output(mod=m3, out.type='png')
plot_wham_output(mod=m3, out.type='pdf')
plot_wham_output(mod=m3, out.type='html')
JDeroba commented 3 years ago

I ran your code. For html, an html window "WHAM Output" opens in my browser but none of the plots are visible in any window; everything is just white. All the png files work fine except for NAA_res_barplot_stacked.png, which is white. The pdf files look fine, but I did notice that there is no NAA_res_barplot_stacked in the diagnostics.pdf file. So nothing has changed in terms of this issue for me. I do think a default of png or pdf would be better. I'd suggest png because it would be easier for folks to paste them into other files (e.g., ppt) for presentations and such.

timjmiller commented 3 years ago

On my windows machine, I get this behavior when I open the "wham_ouput.html" in firefox, but it works for chrome and internet explorer. The plot Jon mentions is indeed blank in the html (diagnostics tab) for those browsers where it works. I don't know if this blank plot is what is problematic for firefox.

wham:::plot.NAA.res calls lattice::barchart which does not print the object by default. The object must be printed within the function. i.e. lattice_plot_object <- lattice::barchart() print(lattice_plot_object).

On Thu, Oct 14, 2021 at 11:36 AM JDeroba @.***> wrote:

I ran your code. For html, an html window "WHAM Output" opens in my browser but none of the plots are visible in any window; everything is just white. All the png files work fine except for NAA_res_barplot_stacked.png, which is white. The pdf files look fine, but I did notice that there is no NAA_res_barplot_stacked in the diagnostics.pdf file. So nothing has changed in terms of this issue for me. I do think a default of png or pdf would be better. I'd suggest png because it would be easier for folks to paste them into other files (e.g., ppt) for presentations and such.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/timjmiller/wham/issues/42#issuecomment-943476060, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEIGN7HKOJJ5LD46KASJY2LUG32IRANCNFSM4ZKVSDIA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Timothy J. Miller, PhD (he, him, his) Research Fishery Biologist NOAA, Northeast Fisheries Science Center Woods Hole, MA 508-495-2365

JDeroba commented 3 years ago

The html also opens for me using chrome or IE. Thanks! A simple solution! Perhaps Tim also has the right idea for the NAA.res plot.

timjmiller commented 3 years ago

I fixed plot.NAA.res on devel branch, but the html rendering still doesn't work on Firefox on windows (but it does on Linux). We could add a note/warning somewhere when running plot_wham_output and/or change the default out.type. The latter would be nice for testing because one wouldn't have 50 tabs in their browser to close.

timjmiller commented 3 years ago

I added notification to screen print when using plot_wham_output to use Google Chrome for viewing html output.

brianstock-NOAA commented 3 years ago

It seems we all agree that out.type = 'png' is the preferred default. Like Tim said, the html output is annoying in testing and I've written most of my code to make pngs for that reason. Just changed this on devel: https://github.com/timjmiller/wham/commit/1775e466d01a451ce4344763691432e8b5131410.

I've left test 1 and ex 1 to use out.type = 'html' but changed the rest of the test and vignette code to out.type = 'png'. This way we will still be alerted if the html output breaks but won't have to close 50 browser tabs during testing. Also added a note to ex1 that the html output may not work on Firefox in Windows but should with another browser.