Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update indicator data #56

Merged
merged 4 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions public/basins.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file is a white list for drainage basins that will be
# selectable in the app. It includes only basins we have indicator netCDF
# coverage of.
corviday marked this conversation as resolved.
Show resolved Hide resolved

- Fraser River
- Nass River
- Skeena River
- Southwest Coast
- Stewart
- Stikine River
- Taku River
127 changes: 127 additions & 0 deletions public/conservation_units.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# This file is a white list for salmon conservation units, as defined
# by DFO, that will be selectable in the app. It includes only
# conservation units we have indicator netCDF
# coverage of.
corviday marked this conversation as resolved.
Show resolved Hide resolved

- (p)Adams and Momich Lakes-Early Summer Timing
- Akuklotz
- Aldrich
- Anderson/Seton-Early Summer Timing
- Asitika
- Atna
- Azuklotz
- Babine
- Bear
- Border
- Boundary Bay_FA_0.3
- Bowron-Early Summer Timing
- Bowser
- Bulkley
- Chiliwack-Early Summer Timing
- Chilko-Early Summer Timing
- Chilko-Summer Timing
- Christina
- Chutine
- Cultus - Late Timing
- Damdochax/Winimasik
- Damshilgwit
- Dean River
- Dennis
- East Vancouver Island-Nanaimo_SP_1.x
- Footsore/Hodder
- Francois/Fraser-Summer Timing
- Fraser Canyon
- Fraser River
- Fraser River<<bin>>
- Fraser-Harrison Fall Transplant_FA_0.3<<Bin>>
- Fred Wright
- Great Central
- Harrion-Upstream Migrating-Late Timing
- Harrison River
- Harrison-Downstream Migrating-Late Timing
- Interior Fraser
- Johanson
- Kamloops-Early Summer Timing
- King Salmon
- Kitwancool
- Kluatantan
- Kluayaz
- Kuthai
- Kwinageese
- Lillooet
- Lillooet/Harrison-Late Timing
- Little Trapper
- Lower Fraser
- Lower Fraser River_FA_0.3
- Lower Fraser River_SP_1.3
- Lower Fraser River_SU_1.3
- Lower Fraser River-Upper Pitt_SU_1.3
- Lower Nass
- Lower Skeena
- Lower Stikine
- Lower Thompson
- Maria Slough_SU_0.3
- Maxan
- McDonnell
- Meziadin
- Middle & Upper Skeena
- Middle Fraser River-Portage_FA_1.3
- Middle Skeena
- Middle Skeena-Mainstem Tributaries
- Middle-Upper Skeena
- Morice
- Motase
- Muchalat
- Nahatlatch-Early Summer Timing
- North Barriere-Early Summer Timing
- North Thompson
- North Thompson_SP_1.3
- North Thompson_SU_1.3
- Northern Transboundary Fjords
- Oweegee
- Owikeno
- Pitt-Early Summer Timing
- Quesnel-Summer Timing
- Schoen
- Seton-Later Timing
- Shuswap Complex-Early Summer Timing
- Shuswap Complex-Late Timing
- Shuswap River_SU_0.3
- Sicintine
- Skeena River
- Skeena River-High Interior
- Slamgeesh
- South Atnarko Lakes
- South Thompson
- South Thompson_SU_0.3
- South Thompson-Bessette Creek_SU_1.2
- Spawning
- Sproat
- Stephens
- Stikine-Early Timing
- Stikine-Late Timing
- Sustut
- Tahitan
- Tahlo/Morrison
- Takla/Trembleur-Early Stuart Timing
- Takla/Trembleur/Stuart-Summer Timing
- Taku
- Taku-Early Timing
- Taku-Late Timing
- Taku-Mid Timing
- Taseko-Early Summer Timing
- Tatsamenie
- Unuk
- Unuk River
- Upper Adams River_SU_x.x
- Upper Bulkley River
- Upper Fraser River_SP_1.3
- Upper Knight
- Upper Nass
- Upper Nass River
- Upper Skeena
- Vernon
- Wannock
- Wannock[Owikeno]
- Widgeon
- Zymoetz
128 changes: 128 additions & 0 deletions public/watersheds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# This file is a white list for watersheds (as named in the
# BC Freshwater Atlas) that will be selectable in the app.
# It includes only watersheds we have indicator netCDF
# coverage of.
corviday marked this conversation as resolved.
Show resolved Hide resolved

- Adams River
- Alberni Inlet
- Atnarko River
- Babine Lake
- Babine River
- Barrington River
- Bella Coola River
- Big Bar Creek
- Big Creek
- Blackwater River
- Bonaparte River
- Bowron
- Bridge Creek
- Bulkley River
- Campbell River
- Cariboo River
- Chesletta River
- Chilako River
- Chiliwack River
- Chilko River
- Chukachida River
- Clearwater River
- Comox
- Cottonwood River
- Cowichan
- Deadman River
- Dog Creek
- Driftwood River
- Euchiniko Lake
- Euchiniko River
- Francois Lake
- Fraser Canyon
- Gold River
- Green Lake
- Guichon Creek
- Harrison River
- Herrick Creek
- Homathko River
- Horsefly River
- Inklin River
- Iskut River
- Kakiddi Creek
- Kalum River
- Kinskuch River
- Kispiox River
- Kitimat River
- Klappan River
- Klinaklini River
- Lillooet
- Lower Bell -Irving River
- Lower Chilako River
- Lower Chilcotin River
- Lower Eutsuk Lake
- Lower Fraser
- Lower Iskut River
- Lower Nass River
- Lower Nechako Reservoir
- Lower Nicola River
- Lower North Thompson River
- Lower Salmon River
- Lower Skeena River
- Lower Stikine River
- Lower Trembleur Lake
- Mahood Lake
- McGregor River
- Mess Creek
- Middle Fraser
- Middle River
- Middle Skeena River
- Middle Stikine River
- Morice River
- Morkill River
- Murtle Lake
- Musleg River
- Nahlin River
- Nakina River
- Narcosli Creek
- Nass River
- Nazko River
- Nechako River
- Nikola River
- Nimpkish River
- Owikeno Lake
- Parksville
- Piman River
- Quesnel River
- Salmon River
- San Jose River
- Seton Lake
- Sheslay River
- Shuswap Lake
- South Thompson River
- Spatsizi River
- Squamish
- Stikine River
- Stuart Lake
- Stuart River
- Sustut River
- Tabor River
- Tahltan River
- Takla Lake
- Taseko River
- Taylor River
- Thompson River
- Tsitika River
- Tuya River
- Twan Creek
- Unuk River
- Upper Bell -Irving River
- Upper Chilcotin River
- Upper Dean River
- Upper Eutsuk Lake
- Upper Fraser River
- Upper Iskut River
- Upper Nass River
- Upper Nechako Reservoir
- Upper North Thompson River
- Upper Shuswap
- Upper Skeena River
- Upper Stikine River
- Upper Trembleur Lake
- Willow River
- Zymoetz River
59 changes: 40 additions & 19 deletions src/components/AreaDisplay/AreaDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
// area they care about; displays categorical data about the selected area

import {getWatersheds, getBasins, getConservationUnits, getTaxons} from '../../data-services/scip-backend.js';
import {getWhitelist} from '../../data-services/public.js';
import AreaSelector from '../AreaSelector/AreaSelector.js';
import TaxonSelector from '../TaxonSelector/TaxonSelector.js';
import {Container, Row, Col} from 'react-bootstrap';
import React, {useState, useEffect} from 'react';
import {map, find} from 'lodash';
import {parseRegions, regionListUnion} from '../../helpers/GeographyHelpers.js';
import {parseRegions, regionListUnion, findRegionLists, findWhitelist} from '../../helpers/GeographyHelpers.js';
import _ from 'lodash';

function AreaDisplay({onChangeRegion, region}) {
Expand Down Expand Up @@ -52,9 +53,9 @@ function AreaDisplay({onChangeRegion, region}) {
// this only needs to be done once, when the component is loaded
useEffect(() => {
if(basins.length === 0) {
getBasins().then(
data => {
setBasins(parseRegions(data));
Promise.all([getBasins(), getWhitelist("basins")]).then(
api_responses => {
corviday marked this conversation as resolved.
Show resolved Hide resolved
setBasins(collateRegions(api_responses));
}
);
}
Expand Down Expand Up @@ -117,36 +118,56 @@ function AreaDisplay({onChangeRegion, region}) {
// much faster to make single unfiltered all-watersheds
// and all-basins calls than to make seven calls filtered
// by species and merge the results.
getWatersheds(boundary).then(
data => {
setWatersheds(parseRegions(data));
}
);
getConservationUnits(boundary).then(
data => {
setConservationUnits(parseRegions(data));
}
);

Promise.all([getWatersheds(boundary), getWhitelist("watersheds")]).then(
api_responses => {
setWatersheds(collateRegions(api_responses));
}
);
Promise.all([getConservationUnits(boundary), getWhitelist("conservation_units")]).then(
api_responses => {
setConservationUnits(collateRegions(api_responses));
}
);
}
else {
// some, but not all, taxons are selected.
// need to do multiple queries and merge the results.

const watershed_calls = _.map(selectedTaxons, taxon => {
return getWatersheds(boundary, taxon.common_name, taxon.subgroup)
});
Promise.all(watershed_calls).then((api_responses)=>
setWatersheds(regionListUnion(_.map(api_responses, parseRegions)))
);
const watershedWhitelist_call = getWhitelist("watersheds");

Promise.all(watershed_calls.concat([watershedWhitelist_call]))
.then((api_responses) => {
setWatersheds(collateRegions(api_responses));
});


const cu_calls = _.map(selectedTaxons, taxon => {
return getConservationUnits(boundary, taxon.common_name, taxon.subgroup)
});
Promise.all(cu_calls).then((api_responses)=>
setConservationUnits(regionListUnion(_.map(api_responses, parseRegions)))
const cuWhitelist_call = getWhitelist("conservation_units");
Promise.all(cu_calls.concat([cuWhitelist_call])).then((api_responses)=> {
setConservationUnits(collateRegions(api_responses));
}
);
}
}, [selectedBasin, selectedTaxons]);

// receives a collection of API responses, including a whitelist
// and one or more calls to the /region API. Returns a list with
// the set of unique region objects present in the whitelist and
// at least one region list
function collateRegions(api_responses) {
corviday marked this conversation as resolved.
Show resolved Hide resolved
const whitelist = findWhitelist(api_responses);
const regionLists = findRegionLists(api_responses);
function pr(rl) {
return parseRegions(rl, whitelist);
}
return regionListUnion(_.map(regionLists, pr));
}

function setBasin(event){
const basin = findRegion("basin", event.value);
Expand Down
2 changes: 1 addition & 1 deletion src/components/DataMap/DataMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function DataMap({regionBoundary, watershedStreams, downstream}) {
opacity={0.3}
transparent={true}
version={'1.1.1'}
layers={"x/storage/data/projects/comp_support/bc-srif/climatologies/fraser/annual/means/apf_flow_aClimMean_BCCAQv2_CanESM2_historical-rcp85_r1i1p1_19710101-20001231_fraser.nc/apf_flow"}
layers={"x/storage/data/projects/comp_support/bc-srif/climatologies/fraser+bccoast/annual/means/peakFlow_aClimMean_ensMean_VICGL-dynWat_rcp85_1971-2000_bccoast+fraser.nc/peakQmag_year"}
time={"1985-07-02T00:00:00Z"}
styles={"default-scalar/x-Occam"}
/>
Expand Down
Loading