afsc-gap-products / gap_products

This repository supports code used to create tables in the GAP_PRODUCTS Oracle schema. These tables include the master production tables, tables shared with AKFIN, and tables publicly shared on FOSS.
https://afsc-gap-products.github.io/gap_products/
Creative Commons Zero v1.0 Universal
5 stars 5 forks source link

Update AKFIN vignettes on website #36

Closed zoyafuso-NOAA closed 3 months ago

zoyafuso-NOAA commented 3 months ago

There are some issues with the vignette on the website for AI rock sole size composition example:

Solution:

Update the SQL portion of the vignette with the code below. I don't know how to do the ggplot2 part of the example so I will pass that over to @EmilyMarkowitz-NOAA when she gets around to it.

-- 7.0.7 AI rock sole size composition
SELECT 
YEAR,
LENGTH_MM / 10 AS LENGTH_CM, 
SUM(POPULATION_COUNT) AS POPULATION_COUNT

FROM GAP_PRODUCTS.AKFIN_SIZECOMP 

-- 99904 is the AREA_ID that codes for the whole AI survey region
WHERE AREA_ID = 99904
-- including northern rock sole, southern rock sole, and rock sole unid.
AND SPECIES_CODE IN (10260, 10261, 10262)
-- remove the -9 LENGTH_MM code
AND LENGTH_MM > 0
-- sum over species_codes and sexes
GROUP BY (YEAR, LENGTH_MM)

I embedded the CI calculations into the SQL call for the POP 7.0.10 example:

-- Select columns for output data
SELECT 
SURVEY_DEFINITION_ID, 
BIOMASS_MT / 1000 AS BIOMASS_KMT, 
(BIOMASS_MT - 2 * SQRT(BIOMASS_VAR)) / 1000 AS BIOMASS_KCI_DW,
(BIOMASS_MT + 2 * SQRT(BIOMASS_VAR)) / 1000 AS BIOMASS_KCI_UP,
YEAR

-- Identify what tables to pull data from
FROM GAP_PRODUCTS.AKFIN_BIOMASS

-- Filter data results
WHERE SPECIES_CODE = 30060 
AND SURVEY_DEFINITION_ID = 47 
AND AREA_ID = 99903 
AND YEAR BETWEEN 1990 AND 2023