-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d839554
commit 9914c68
Showing
13 changed files
with
179 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { DataParamGroupConfig } from 'lib/controls/data-params'; | ||
|
||
export interface RiskParams { | ||
returnPeriod: number; | ||
epoch: number; | ||
rcp: string; | ||
confidence: string | number; | ||
} | ||
|
||
export const RISK_DOMAINS: Record<string, DataParamGroupConfig<RiskParams>> = { | ||
none: { | ||
paramDomains: { | ||
returnPeriod: [0], | ||
epoch: [2010], | ||
rcp: ['baseline'], | ||
confidence: ['None'], | ||
}, | ||
paramDefaults: { | ||
returnPeriod: 0, | ||
epoch: 2010, | ||
rcp: 'baseline', | ||
confidence: 'None', | ||
}, | ||
}, | ||
fluvial: { | ||
paramDomains: { | ||
returnPeriod: [100], | ||
|
||
rcp: ['baseline'], | ||
epoch: [2010], | ||
confidence: ['None'], | ||
}, | ||
paramDefaults: { | ||
returnPeriod: 100, | ||
|
||
rcp: 'baseline', | ||
epoch: 2010, | ||
confidence: 'None', | ||
}, | ||
paramDependencies: { | ||
rcp: ({ epoch }) => { | ||
if (epoch === 2010) return ['baseline']; | ||
else if (epoch === 2050 || epoch === 2080) return ['2.6', '4.5', '8.5']; | ||
}, | ||
}, | ||
}, | ||
cyclone: { | ||
paramDomains: { | ||
returnPeriod: [100], | ||
epoch: [2010], | ||
rcp: ['baseline'], | ||
confidence: [5, 50, 95], | ||
}, | ||
paramDefaults: { | ||
returnPeriod: 100, | ||
epoch: 2010, | ||
rcp: 'baseline', | ||
confidence: 50, | ||
}, | ||
paramDependencies: { | ||
rcp: ({ epoch }) => { | ||
if (epoch === 2010) return ['baseline']; | ||
if (epoch === 2050 || epoch === 2100) return ['4.5', '8.5']; | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,78 @@ | ||
import { FormControl, FormControlLabel, FormLabel, Radio, RadioGroup } from '@mui/material'; | ||
import { | ||
FormControl, | ||
FormControlLabel, | ||
FormLabel, | ||
MenuItem, | ||
Radio, | ||
RadioGroup, | ||
Select, | ||
} from '@mui/material'; | ||
import { useRecoilState } from 'recoil'; | ||
|
||
import { StateEffectRoot } from 'lib/recoil/state-effects/StateEffectRoot'; | ||
|
||
import { InputSection } from 'sidebar/ui/InputSection'; | ||
import { InputRow } from 'sidebar/ui/InputRow'; | ||
import { EpochControl } from 'sidebar/ui/params/EpochControl'; | ||
import { RCPControl } from 'sidebar/ui/params/RCPControl'; | ||
import { riskSelectionState } from 'state/risks/risk-selection'; | ||
import { | ||
riskSourceState, | ||
riskSourceStateEffect | ||
} from 'state/risk-mapping/risk-map'; | ||
|
||
const SECTORS = { | ||
all: 'All sectors', | ||
power: 'Power', | ||
transport: 'Transport', | ||
water: 'Water', | ||
} | ||
const HAZARDS = ['none', 'cyclone', 'fluvial']; | ||
const HAZARDS_METADATA = { | ||
none: { label: 'None' }, | ||
cyclone: { label: 'Cyclone' }, | ||
fluvial: { label: 'All Flooding' }, | ||
}; | ||
|
||
export const RisksControl = () => { | ||
const [riskSource, setRiskSource] = useRecoilState(riskSourceState); | ||
const [riskSelection, setRiskSelection] = useRecoilState(riskSelectionState); | ||
console.log({ riskSource, riskSelection }) | ||
|
||
return ( | ||
<> | ||
<FormControl> | ||
<FormLabel>Sector</FormLabel> | ||
<RadioGroup value={riskSelection} onChange={(e, value) => setRiskSelection(value)}> | ||
{Object.entries(SECTORS).map(([sector, label]) => ( | ||
<FormControlLabel | ||
key={sector} | ||
label={label} | ||
control={<Radio value={sector} />} | ||
/> | ||
))} | ||
</RadioGroup> | ||
</FormControl> | ||
<StateEffectRoot state={riskSourceState} effect={riskSourceStateEffect} /> | ||
<InputSection> | ||
<FormControl fullWidth> | ||
<FormLabel>Display</FormLabel> | ||
<Select<string> | ||
variant="standard" | ||
value={riskSelection} | ||
onChange={(e) => setRiskSelection(e.target.value)} | ||
> | ||
<MenuItem value="totalValue">Total value</MenuItem> | ||
<MenuItem value="economicUse">Economic use</MenuItem> | ||
<MenuItem value="populationUse">Population use</MenuItem> | ||
<MenuItem value="totalRisk">Total risk</MenuItem> | ||
<MenuItem value="ead">Expected Annual Damages (EAD)</MenuItem> | ||
<MenuItem value="eael">Expected Annual Economic Losses (EAEL)</MenuItem> | ||
</Select> | ||
</FormControl> | ||
</InputSection> | ||
<InputSection> | ||
<FormControl> | ||
<FormLabel>Hazard</FormLabel> | ||
<RadioGroup value={riskSource} onChange={(e, value) => setRiskSource(value)}> | ||
{HAZARDS.map((hazard) => ( | ||
<FormControlLabel | ||
key={hazard} | ||
label={HAZARDS_METADATA[hazard].label} | ||
control={<Radio value={hazard} />} | ||
/> | ||
))} | ||
</RadioGroup> | ||
</FormControl> | ||
</InputSection> | ||
<InputSection> | ||
<InputRow> | ||
<EpochControl group={riskSource} /> | ||
<RCPControl group={riskSource} /> | ||
</InputRow> | ||
</InputSection> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
import { HazardParams } from 'config/hazards/domains'; | ||
import { riskViewLayer } from 'config/risks/risk-view-layer'; | ||
import { ViewLayer } from 'lib/data-map/view-layers'; | ||
import { truthyKeys } from 'lib/helpers'; | ||
import { selector } from 'recoil'; | ||
import { dataParamsByGroupState } from 'state/data-params'; | ||
import { riskVisibilityState } from 'state/risks/risk-visibility'; | ||
import { riskSourceState } from 'state/risk-mapping/risk-map'; | ||
import { riskSelectionState } from 'state/risks/risk-selection'; | ||
import { sectionVisibilityState } from 'state/sections'; | ||
|
||
export const riskLayerState = selector<ViewLayer[]>({ | ||
key: 'riskLayerState', | ||
get: ({ get }) => | ||
get(sectionVisibilityState('risks')) | ||
? truthyKeys(get(riskVisibilityState)).map((risk) => | ||
riskViewLayer(risk, get(dataParamsByGroupState(risk)) as HazardParams), | ||
) | ||
: [], | ||
get: ({ get }) => { | ||
const riskSource = get(riskSourceState); | ||
const riskSelection = get(riskSelectionState); | ||
console.log('riskLayerState', [riskViewLayer(riskSelection, get(dataParamsByGroupState(riskSource)) as HazardParams)]) | ||
return get(sectionVisibilityState('risks')) | ||
? [riskViewLayer(riskSelection, get(dataParamsByGroupState(riskSource)) as HazardParams)] | ||
: [] | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.