Skip to content

Commit

Permalink
Handle quirk in epoch lookup and damages presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tomalrussell committed Aug 7, 2024
1 parent 70da200 commit b5e4961
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/config/assets/data-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function lookupRcp(rcp: string, layer: string) {
* handle quirks/inconsistencies in feature property naming for epoch
*/
function lookupEpoch(epoch: string, hazard: HazardType, layer: string) {
if (epoch === 'present') {
if (epoch === 'present' || epoch === 'baseline') {
if (hazard === 'cyclone') {
return '2020';
}
Expand Down
6 changes: 3 additions & 3 deletions src/details/features/damages/DamageTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from '@mui/material';

import { numFormat, numRangeFormat } from '@/lib/helpers';
import { numFormat, numRangeFormat, titleCase } from '@/lib/helpers';

const padding = { px: 0.25, py: 0.25 };
export const DamageTable = ({ damages }) => (
Expand All @@ -24,8 +24,8 @@ export const DamageTable = ({ damages }) => (
{damages.map(
({ key, rcp, epoch, ead_mean, ead_amin, ead_amax, eael_mean, eael_amin, eael_amax }) => (
<TableRow key={key}>
<TableCell sx={{ pl: 0, pr: padding.px, py: padding.py }}>{rcp}</TableCell>
<TableCell sx={padding}>{epoch}</TableCell>
<TableCell sx={{ pl: 0, pr: padding.px, py: padding.py }}>{titleCase(rcp)}</TableCell>
<TableCell sx={padding}>{titleCase(epoch)}</TableCell>
<TableCell sx={padding} align="right">
{numFormat(ead_mean)}
<br />({numRangeFormat(ead_amin, ead_amax)})
Expand Down
2 changes: 1 addition & 1 deletion src/details/features/damages/DamagesSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const DamagesSection = ({ fd }) => {

export const QUIRKY_FIELDS_MAPPING = {
hazard: (h: string) => (h === 'river' ? 'fluvial' : h),
epoch: (e: string) => (e === '1980' ? 'present' : e),
epoch: (e: string) => (e === '1980' ? 'baseline' : e),
rcp: (r: string) => {
if (r === 'historical') return 'baseline';
if (r.startsWith('rcp')) return r.substring(3).replace('p', '.'); // rcp4p5 -> 4.5
Expand Down
2 changes: 1 addition & 1 deletion src/details/features/damages/ExpectedDamageChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const makeSpec = (

// need to map special value to year to maintain chronological ordering on the X axis
function prepareEpoch(epoch: string) {
return epoch === 'present' ? '2020' : epoch;
return epoch === 'present' || epoch === 'baseline' ? '2020' : epoch;
}

interface ExpectedDamageChartProps {
Expand Down
4 changes: 2 additions & 2 deletions src/details/features/damages/RPDamageTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Tooltip,
} from '@mui/material';

import { numFormat, numRangeFormat } from '@/lib/helpers';
import { numFormat, numRangeFormat, titleCase } from '@/lib/helpers';

const padding = { px: 0.25, py: 0.25 };
export const RPDamageTable = ({ damages }) => (
Expand Down Expand Up @@ -41,7 +41,7 @@ export const RPDamageTable = ({ damages }) => (
>
<TableCell sx={padding}>{d.rp}</TableCell>
</Tooltip>
<TableCell sx={{ pl: 0, pr: padding.px, py: padding.py }}>{d.rcp}</TableCell>
<TableCell sx={{ pl: 0, pr: padding.px, py: padding.py }}>{titleCase(d.rcp)}</TableCell>
<TableCell sx={padding} align="right">
{numFormat(d.damage_mean)}
<br />({numRangeFormat(d.damage_amin, d.damage_amax)})
Expand Down

0 comments on commit b5e4961

Please sign in to comment.