NEFSC / READ-SSB-CHAJI-Effort-Displacement---Scallop

Other
0 stars 0 forks source link

closure area zone plot error #202

Closed BryceMcManus-NOAA closed 1 year ago

BryceMcManus-NOAA commented 1 year ago

The closure area plots hit a snag when running wind_NY1.RDS and returns the error Error in cut.default(x, breaks, labels = FALSE, include.lowest = TRUE, : invalid number of intervals. This happens because zone_summary() uses a binned scale, which means if it attempts to plot/summarize a single area (or a collection of areas treated as single area i.e. a single multiploygon) it will break since binning requires at least two values. So this problem will happen for NY3 and any other shapefile we want to treat as a single multipolygon.

Without the binned scale, zone_summary() would return the follow plot with a continuous scale:

NY1_plot

The catch is that I can't fix this without updating FishSET. @mle2718 and @mchaji , is it worth updating FishSET to get a plot like this?

mle2718 commented 1 year ago

@BryceMcManus-NOAA , I don't think it's worth it. I think we weren't going to use any of the maps -- I think we were just looking to get things like Total revenue, operating profits etc that were inside the polygons.

If the reports run, I don't think there's a reason to update FishSET. And this is a probably a use case that other people are not going to have.

mle2718 commented 1 year ago

@BryceMcManus-NOAA and @mchaji : I've put a very cut down version of the scallop analysis report into this branch: https://github.com/NEFSC/READ-SSB-CHAJI-Effort-Displacement---Scallop/tree/scallop_tiny_report

I've created this file: https://github.com/NEFSC/READ-SSB-CHAJI-Effort-Displacement---Scallop/blob/scallop_tiny_report/analysis_code/scallop_analysis_tiny_report.Rmd and modified this one: https://github.com/NEFSC/READ-SSB-CHAJI-Effort-Displacement---Scallop/blob/scallop_tiny_report/analysis_code/knit_scallop_analysis_loop.R

This might speed development, because there is a lot of stuff in the thorough scallop analysis that we don't need for this particular subset.

mle2718 commented 1 year ago

after pulling dev,, I get this error message when I try to use wind_NY1.RDS.


Number of observations.
```{r}
zone_out <- 
zone_summary(scallop0322MainDataTable, project = project,
         spat = scallop0322WindCloseSpatTable, 
         zone.dat = "closeID",
         zone.spat = "LEASE_NUMB",
         count = TRUE,
         breaks = c(1, 10, 50, 100, 250, 500, 750, 1000, 1252),
         na.rm = TRUE, dat.center = FALSE, 
         output = "tab_plot")

zone_out$table %>% 
  pretty_lab() %>% 
  pretty_tab_sb(width = "40%")

zone_out$plot


The error message is:
Error in cut.default(x, breaks, labels = FALSE, include.lowest = TRUE, : invalid number of intervals

I'm not exactly sure what to do here. We're repurposing the scallop analysis report to answer a slightly different question that originally intended.  If we edit it, we'll lose the ability to run the original scallop analysis. 

Maybe before we go any further, we should take a short break from this and think about what output we're looking for -- there may be much easier ways to get at it than repurposing the scallop analysis code.
BryceMcManus-NOAA commented 1 year ago

@BryceMcManus-NOAA , I don't think it's worth it. I think we weren't going to use any of the maps -- I think we were just looking to get things like Total revenue, operating profits etc that were inside the polygons.

If the reports run, I don't think there's a reason to update FishSET. And this is a probably a use case that other people are not going to have.

@mchaji If we don't want the plot then we can change output to "table" instead of "tab_plot", which should avoid the issue.

BryceMcManus-NOAA commented 1 year ago

The zone output will need to be adjusted too since the output will no longer contain a plot:

out_switch <- ifelse(params$input_shapefile == "wind_NY1.RDS", "table", "tab_plot")

zone_out <- 
zone_summary(scallop0322MainDataTable, project = project,
         spat = scallop0322WindCloseSpatTable, 
         zone.dat = "closeID",
         zone.spat = "LEASE_NUMB",
         count = TRUE,
         breaks = c(1, 10, 50, 100, 250, 500, 750, 1000, 1252),
         na.rm = TRUE, dat.center = FALSE, 
         output = out_switch)

if (out_switch == "table") {

  zone_out %>% 
    pretty_lab() %>% 
    pretty_tab_sb(width = "40%")

} else {

  zone_out$table %>%
    pretty_lab() %>% 
    pretty_tab_sb(width = "40%")

  zone_out$plot
}
mchaji commented 1 year ago

I'm trying to run the scallop_analysis_tiny_report, and I am getting the following error on line 86 image Has anyone else had this issue?

mle2718 commented 1 year ago

I'm trying to run the scallop_analysis_tiny_report, and I am getting the following error on line 86 image Has anyone else had this issue?

I just pulled, restarted the R session, "knit to html" successfully. What's the rest of your workflow?

mchaji commented 1 year ago

I'm trying to run the scallop_analysis_tiny_report, and I am getting the following error on line 86 image Has anyone else had this issue?

I just pulled, restarted the R session, "knit to html" successfully. What's the rest of your workflow?

I was trying to run the report after taking out some of the CPUE chunks. It looks like I have a problem when I want to knit after my first attempt. Restarting and clearing the session fixes it, but it's super time-consuming to check my work.

mle2718 commented 1 year ago

I was trying to run the report after taking out some of the CPUE chunks. It looks like I have a problem when I want to knit after my first attempt. Restarting and clearing the session fixes it, but it's super time-consuming to check my work.

It is. I don't know of a better way, except to run chunks forward and not repeat them without restarting. Although your errors seem mostly to be related to package loading, so making sure you're not reruning the setup chunk might be enough.