Skip to content

Commit

Permalink
cleaned up (see description)
Browse files Browse the repository at this point in the history
- updates to ABUNDANCE_HAUL ' Y' to exclude 1980s AIGOA data removes need to filter years
- including the abundance_haul  = 'Y' filter also assumes haul_type =3 and good (>= 0) performance
- cc.YEAR >= 1982 AND cc.SURVEY_DEFINITION_ID IN (98, 143)  included NBS hauls that are not included in the standard data table production.
- hand calculating effort so that GAP_PRODUCTS.CPUE doesn't need to be joined
  • Loading branch information
zoyafuso-NOAA committed May 19, 2024
1 parent fc80982 commit ef0a66c
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions code/sql_foss/FOSS_HAUL.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
--

CREATE MATERIALIZED VIEW GAP_PRODUCTS.FOSS_HAUL AS
SELECT DISTINCT
SELECT
cc.YEAR,
CASE
WHEN cc.SURVEY_DEFINITION_ID = 143 THEN 'NBS'
Expand Down Expand Up @@ -38,7 +38,7 @@ hh.STRATUM,
hh.STATIONID AS STATION,
hh.VESSEL AS VESSEL_ID,
vv.NAME AS VESSEL_NAME,
hh.START_TIME AS DATE_TIME, -- CAST(hh.START_TIME AS TIMESTAMP(0)) AT TIME ZONE '-08:00' AS DATE_TIME,
hh.START_TIME AS DATE_TIME,
hh.START_LATITUDE AS LATITUDE_DD_START,
hh.START_LONGITUDE AS LONGITUDE_DD_START,
hh.END_LATITUDE AS LATITUDE_DD_END,
Expand All @@ -50,21 +50,15 @@ hh.DISTANCE_FISHED AS DISTANCE_FISHED_KM,
hh.DURATION AS DURATION_HR,
hh.NET_WIDTH AS NET_WIDTH_M,
hh.NET_HEIGHT AS NET_HEIGHT_M,
cp.AREA_SWEPT_KM2,
hh.DISTANCE_FISHED * hh.NET_WIDTH * 0.001 AS AREA_SWEPT_KM2,
hh.PERFORMANCE

FROM RACEBASE.HAUL hh

LEFT JOIN RACE_DATA.VESSELS vv
ON hh.VESSEL = vv.VESSEL_ID
LEFT JOIN GAP_PRODUCTS.CPUE cp
ON hh.HAULJOIN = cp.HAULJOIN
LEFT JOIN GAP_PRODUCTS.AKFIN_CRUISE cc
ON hh.CRUISEJOIN = cc.CRUISEJOIN
WHERE hh.HAUL_TYPE = 3
AND hh.ABUNDANCE_HAUL = 'Y'
AND hh.PERFORMANCE >= 0
AND cc.SURVEY_DEFINITION_ID IN (143, 98, 47, 52, 78)
AND cc.YEAR != 2020 -- no surveys happened this year because of COVID
AND (cc.YEAR >= 1982 AND cc.SURVEY_DEFINITION_ID IN (98, 143) -- EBS/NBS survey standard temporal stanza starts in 1982
OR cc.SURVEY_DEFINITION_ID = 78 -- keep all years of the BSS
OR cc.YEAR >= 1991 AND cc.SURVEY_DEFINITION_ID IN (52) -- AI survey standard temporal stanza starts in 1991
OR cc.YEAR >= 1990 AND cc.SURVEY_DEFINITION_ID IN (47)) -- GOA survey standard temporal stanza starts in 1990

WHERE hh.ABUNDANCE_HAUL = 'Y'
AND cc.SURVEY_DEFINITION_ID IN (143, 98, 47, 52, 78)

0 comments on commit ef0a66c

Please sign in to comment.