Giter Site home page Giter Site logo

gfsynopsis's People

Contributors

andrew-edwards avatar ecophilina avatar elisekeppel avatar jdunic avatar robynforrest avatar seananderson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

obradovichs

gfsynopsis's Issues

Make a call on whether to use sdmTMB or INLA for the survey maps

Both are now implemented. It's currently set up to use sdmTMB.

An advantage for INLA is that it's already written up. A disadvantage is that it's a bit of a different paradigm than the current cpue Tweedie model and the TMB model is a spatiotemporal one that incorporates more data for the fixed effects and spatial random effects.

If going with the spatiotemporal one then the writeup will have to be different.

The end result seems to look very similar in most cases.

An advantage to the TMB one is consistency with what we are likely to do with the range shift project model.

Add management section for each species

TAC from Greg or from Gf_management?

  • see the spreadsheet that Greg sent
  • try Gf_management first

Management system (e.g. TAC, input controlled fishery, daily bag limit)
SARA/COSEWIC

Reduce the number of maturity categories

Here's an example for yelloweye now that I've included the commercial samples along with the survey samples:
image

It now becomes obvious that the size of the circles are mostly showing when the samples are being taken rather than the proportions for each month. Perhaps they should be scaled so they are proportions per month rather than proportions across the entire data set?

Also, we talked about this before and I think we should condense the maturity categories. I think Malcolm had some ideas. @elisekeppel , did you ever talk with Malcolm about this or should I get in touch with him?

Substitute data for modelled IPHC map

To convert longitude and latitude to UTMs

gfplot:::ll2utm()

Make the data match this format. The important columns are X, Y, combined, survey. You can ignore the rest. This will be inserted as iphc_fits$pred_dat. The combined is the estimate.

I can help actually integrate it.

         X        Y akima_depth depth_scaled depth_scaled2     combined pos bin    survey
1 249.8263 6027.495       380.4    1.9480471     3.7948874 1.010944e-04  NA  NA IPHC FISS
2 231.5991 6028.491       460.9    2.2949877     5.2669684 6.134827e-05  NA  NA IPHC FISS
3 227.8670 6009.485        49.4   -1.7413082     3.0321544 5.964096e+02  NA  NA IPHC FISS
4 191.8953 6030.973       246.9    1.1668254     1.3614815 3.343166e-01  NA  NA IPHC FISS
5 210.3277 6029.695       221.3    0.9689821     0.9389263 6.071074e+01  NA  NA IPHC FISS
6 209.3769 6011.210       385.9    1.9739919     3.8966440 1.721172e-03  NA  NA IPHC FISS

Add further survey details

  • Add equations for relative biomass index trends from surveys
  • Add in survey intention and stratification/design
  • Add in list of other current/on-going surveys (more than twice in past 10 years)

Maria?

Figure out saving .png files from R that match pdflatex copy mode specifications

Otherwise it's very slow to compile the png version document.

Relevant links:
https://tex.stackexchange.com/questions/327011/fast-png-embedding-using-xetex
https://tex.stackexchange.com/questions/178572/caching-includegraphics-image-files-for-speed/178611#178611

My current solution is:

library(parallel)
library(foreach)
cores <- parallel::detectCores()[1L]
cl <- parallel::makeCluster(cores)
doParallel::registerDoParallel(cl)

setwd("report/figure-pages")
fi <- list.files(".", "*.png")
out <- foreach::foreach(i = fi) %dopar% {
  system(paste0("optipng -strip all ", i))
}

but this takes time as well and although it makes things faster it still doesn't access 'copy mode' in pdflatex.

get_data(path="data-cache2/") is extracting for all species

get_data() has default type="A" but it seems to be extracting the type B species also.

I think it's something to do with get_spp_names(). Not a big problem, just worth noting that the default seems to get ignored.

I'm setting path="data-cache2/" because that's what appears to be in the make.R file that looks to be used.

Partly documenting this here so I can add it to a readme somewhere for future users (i.e. steps to produce the synopsis report), which I couldn't see anywhere obvious (sorry if I missed it). Also, my laptop is going to restart soon and so I want to document my commands.

Add to caveats section

A running list of things to add:

  • these aren't necessarily the best representations of catch and they won't necessarily match reconstructed timeseries in stock assessments
  • longline discard weights are not included (and make sure these are all removed)
  • Some recent species-specific declines in commercial catch, in particular Bocaccio and Yelloweye, are due to implementation of management measures. Might be worth noting as a caveat in the description of these plots.

Add an alphabetical index

Will require some trickery with Markdown section references in R. Too hard to find species of interest when listed by species code.

Set two species codes back again when figure out why it breaks

california grenadier is 257
deacon rockfish is 429

Have set these both to NA else I get the error

x Building figure pages for california grenadier
Fitting model for the survey SYN QCS
Interpolating depth to fill in missing data if needed...
Preloading interpolated depth for prediction grid...
Error: $ operator is invalid for atomic vectors

which we thought would be fixed by Sean's 998431.

Am pushing my commits now - have it working okay.

Notes for writing up IPHC analyses

Just came across this in my notes, probably worth referencing:

1.1.11 OTHER DFO ASSESSMENTS THAT USED IPHC SURVEY DATA

Spiny Dogfish, 2011. Doesn’t look like they looked at effective skates, and somehow joined up
the years prior to 2003 to those after, without any discussion about it.

Quillback Rockfish, 2012. Used survey, with Marie-Etienne’s method. Not sure yet how they went
back before 2003.

Ask Lynne which others may have used it.

Best way to install gfsynopsis (etc.) into library?

load_all() works fine, but I get is really for development.

I did install() but it then tried to re-install things like dplyr (that I just updated last night), couldn't do them because I had dplyr loaded in another R session, and then failed. Then dplyr wouldn't work at all so I had to re-install it manually.

I'm wondering about

install(dependencies = FALSE, upgrade_dependencies = FALSE)

but for now am just using load_all().
Thanks!

Would like to build gfsynopsis in next couple of days.

I think you said you were working some stuff out, and so not to try yet. And that you would give me the model outputs so I don't have to run them, yes?

On #31 it look like I had it building on Aug 13th, apart from a few things that will hopefully get solved when starting over.

I need to put some functions into gfplot, but it will be good to use gfsynopsis at the same time to check everything.

Implement suggested plot tweaks from working group meeting

  • change chart text from survey biomass plots to "mean +ve sets"
  • fix order of catch and cpue statistical regions
  • biomass survey plots - include equations for the biomass index and assumptions
  • biomass survey plots - note in caption that there is no scale on Y axis
  • age circles not scaled within each year
  • Precision sounds like the estimate is more precise than the Primary. Could the Y-axis be labeled as the Secondary Age?
  • shading / stacking of length hist? "Would stacking the bars, with the females on the bottom make it easier to read?" <- play with transparency
  • cpue plots: "I'm curious what the CPUE numbers are? Were they omitted for a reason?" <- add reason in caption in intro
  • catch plot: "Maybe include a statement as to why H&L discards were not included. ... not reliable?" <- @elisekeppel can you add this?
  • "changing Y-axis label to "Catch" because these figures also contain discard information."
  • add "MSA HS" to caption of biomass index plot
  • add colour legend or describe high and low for maps

Add links to res docs / SARS?

SP:

Is it possible to include hyperlinks to paper in federal science library? I compiled a list that may be of use.

  • see the spreadsheet that Greg sent for a good starting point.

Look into missing sablefish catch pre 1980

BC:

... the commercial catch plots which suggest there was no trap or hook and line catch pre-1979; there should be a small amount of domestic hook and line and trap catch back to the mid 60s and early 70s, respectively. There was also substantial foreign hook and line catch 1965-1980 (5-6000 tons).

Fix in merged catch table?

Note lack of foreign in resdoc

Figure out what’s causing the hot pixels in some maps

I’ll bet it’s a bad interpolation from the bathymetry layer onto the survey grid. Could try a different algorithm or even the new high resolution version put out by DFO recently. Needs to match the survey polygon. Also try in log vs not log space?

Finish CPUE standardization methods

  • include quantile binning strategy
  • Add example coefficient plot and example jackknife plot
  • add the simulation testing example that also illustrates coverage

Rewrite spatial methods to use TMB model

Current text explains INLA with delta model. Otherwise nearly identical.

Make sure to explain some of the extra filtering for plotting reasons. And how the depth covariates were centred and scaled.

Can't build document

May as well use this to keep track of stumbling blocks.

Running the

system.time({
  for (i in seq_along(spp$species_common_name)) {
  fig_check <- paste0(file.path("report", "figure-pages"), "/",
    gfsynopsis:::clean_name(spp$species_common_name[i]))
  fig_check1 <- paste0(fig_check, "-1.png")
  fig_check2 <- paste0(fig_check, "-2.png")
  .....

loop of make.R and get the following:

Building figure pages for north pacific spiny dogfish 
Determining qualified fleet for area 3[CD]+|5[ABCDE]+.
Fitting standardization model for area 3[CD]+|5[ABCDE]+.
Fitting CPUE model ...
Getting sdreport ...
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning messages:
1: No data available. 
2: No data available. 
3: In if (!is.na(sc[[1]])) sc <- sc %>% filter(year >= 2003) :
  the condition has length > 1 and only the first element will be used
4: In if (!is.na(sb)) { :
  the condition has length > 1 and only the first element will be used
5: In gzfile(file, mode) :
  cannot open compressed file 'report/cpue-cache/north-pacific-spiny-dogfish-3[CD]+|5[ABCDE]+-model.rds', probable reason 'Invalid argument'
Timing stopped at: 305.7 9.53 316.1
> 

My report\cpue-cache\ folder is there but is empty (related to the fifth warning).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.