From c015a37a892a8066263d31de00460d404665e2db Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Mon, 29 Jul 2024 22:21:23 -0700 Subject: [PATCH 01/30] Adding support for custom seasons in validity configuration --- frontend/src/config/jordan/layers.json | 12 +++++++++- frontend/src/config/types.ts | 11 +++++++++ frontend/src/utils/date-utils.ts | 32 ++++++++++++++++++++++++-- frontend/src/utils/server-utils.ts | 24 ++++++++++++++----- 4 files changed, 70 insertions(+), 9 deletions(-) diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index 47a2619f4..76201d9f1 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -4120,7 +4120,17 @@ "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_geojson", "validity": { - "mode": "season" + "mode": "season", + "seasons": [ + { + "start": "01-March", + "end": "31-July" + }, + { + "start": "01-August", + "end": "28-February" + } + ] }, "input_layers": [ { diff --git a/frontend/src/config/types.ts b/frontend/src/config/types.ts index c6090155a..b029086c2 100644 --- a/frontend/src/config/types.ts +++ b/frontend/src/config/types.ts @@ -418,10 +418,21 @@ export type ValidityPeriod = { end_date_field: string; }; +export type SeasonBoundsConfig = { + start: string; + end: string; +}; + +export type SeasonBounds = { + start: Date; + end: Date; +}; + export type Validity = { mode: DatesPropagation; // Propagation mode for dates. backward?: number; // Number of days/dekades backward. forward?: number; // Number of days/dekades forward. + seasons?: SeasonBoundsConfig[]; }; export class WMSLayerProps extends CommonLayerProps { diff --git a/frontend/src/utils/date-utils.ts b/frontend/src/utils/date-utils.ts index ab92a3ec3..f2c434cfa 100644 --- a/frontend/src/utils/date-utils.ts +++ b/frontend/src/utils/date-utils.ts @@ -1,4 +1,4 @@ -import { DateItem } from '../config/types'; +import { DateItem, SeasonBounds, SeasonBoundsConfig } from '../config/types'; import { DateFormat } from './name-utils'; export interface StartEndDate { @@ -190,7 +190,35 @@ const SEASON_MAP: [number, number][] = [ [9, 11], ]; -export const getSeasonBounds = (date: Date) => { +/** + * Get the start and end date of the season for a given date. + * @param date The date to get the season for. + * @param seasonBounds The season bounds to use (optional) formatted as "MMMM-DD" + * @returns The start and end date of the season or null if no matching season is found. + */ +export const getSeasonBounds = ( + date: Date, + seasonBounds?: SeasonBoundsConfig[], +): SeasonBounds | null => { + if (seasonBounds) { + const foundSeason = seasonBounds.find(season => { + const start = new Date(`${date.getFullYear()}-${season.start}`); + const end = new Date(`${date.getFullYear()}-${season.end}`); + if (end < start) { + end.setFullYear(end.getFullYear() + 1); + } + return date >= start && date <= end; + }); + if (foundSeason) { + const startArr = foundSeason.start.split('-'); + const endArr = foundSeason.end.split('-'); + return { + start: new Date(`${date.getFullYear()}-${startArr[1]}-${startArr[0]}`), + end: new Date(`${date.getFullYear()}-${endArr[1]}-${endArr[0]}`), + }; + } + return null; + } const monthIndex = date.getMonth(); const foundSeason = SEASON_MAP.find( season => season[0] <= monthIndex && monthIndex <= season[1], diff --git a/frontend/src/utils/server-utils.ts b/frontend/src/utils/server-utils.ts index 53a42d2bc..0c308dbb3 100644 --- a/frontend/src/utils/server-utils.ts +++ b/frontend/src/utils/server-utils.ts @@ -10,6 +10,7 @@ import type { PathLayer, PointDataLayerProps, RequestFeatureInfo, + SeasonBounds, Validity, ValidityLayer, ValidityPeriod, @@ -405,13 +406,24 @@ export function generateIntermediateDateItemFromValidity( startDate.setMonth(startDate.getMonth() + nMonthsBackward); } } else if (mode === DatesPropagation.SEASON) { - // TODO: add support flexible seasons (i.e. s1_start, s1_end, etc.) - const { start, end } = getSeasonBounds(startDate); - - startDate.setTime(start.getTime()); - endDate.setTime(end.getTime() - oneDayInMs); + if (validity.seasons) { + const seasonBounds = getSeasonBounds(startDate); + if (seasonBounds) { + startDate.setTime(seasonBounds.start.getTime()); + endDate.setTime(seasonBounds.end.getTime() - oneDayInMs); + } else { + console.warn( + `No season found for date: ${startDate.toISOString()}`, + ); + return []; + } + } else { + const { start, end } = getSeasonBounds(startDate) as SeasonBounds; + startDate.setTime(start.getTime()); + endDate.setTime(end.getTime() - oneDayInMs); + } } else { - return []; + throw Error(`Invalid validity mode: ${mode}`); } // We create an array with the diff between the endDate and startDate and we create an array with the addition of the days in the startDate From fece4d0c83f9ff293d57898a5174fdf1488aed4b Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:34:59 -0700 Subject: [PATCH 02/30] Fixing season bounds --- frontend/src/utils/date-utils.ts | 27 +++--- frontend/src/utils/server-utils.test.ts | 124 +++++++++++++++++++++++- frontend/src/utils/server-utils.ts | 4 +- 3 files changed, 139 insertions(+), 16 deletions(-) diff --git a/frontend/src/utils/date-utils.ts b/frontend/src/utils/date-utils.ts index f2c434cfa..c3b123ad5 100644 --- a/frontend/src/utils/date-utils.ts +++ b/frontend/src/utils/date-utils.ts @@ -183,13 +183,25 @@ export const getFormattedDate = ( export const getTimeInMilliseconds = (date: string | number) => new Date(date).getTime(); -const SEASON_MAP: [number, number][] = [ +export const SEASON_MAP: [number, number][] = [ [0, 2], [3, 5], [6, 8], [9, 11], ]; +export const constructDateFromSeason = ( + date: Date, + season: SeasonBoundsConfig, +) => { + const start = new Date(`${date.getFullYear()}-${season.start}`); + const end = new Date(`${date.getFullYear()}-${season.end}`); + if (end < start) { + start.setFullYear(start.getFullYear() - 1); + } + return { start, end }; +}; + /** * Get the start and end date of the season for a given date. * @param date The date to get the season for. @@ -202,20 +214,11 @@ export const getSeasonBounds = ( ): SeasonBounds | null => { if (seasonBounds) { const foundSeason = seasonBounds.find(season => { - const start = new Date(`${date.getFullYear()}-${season.start}`); - const end = new Date(`${date.getFullYear()}-${season.end}`); - if (end < start) { - end.setFullYear(end.getFullYear() + 1); - } + const { start, end } = constructDateFromSeason(date, season); return date >= start && date <= end; }); if (foundSeason) { - const startArr = foundSeason.start.split('-'); - const endArr = foundSeason.end.split('-'); - return { - start: new Date(`${date.getFullYear()}-${startArr[1]}-${startArr[0]}`), - end: new Date(`${date.getFullYear()}-${endArr[1]}-${endArr[0]}`), - }; + return constructDateFromSeason(date, foundSeason); } return null; } diff --git a/frontend/src/utils/server-utils.test.ts b/frontend/src/utils/server-utils.test.ts index 965ed4a4a..9d0b3a7c3 100644 --- a/frontend/src/utils/server-utils.test.ts +++ b/frontend/src/utils/server-utils.test.ts @@ -1,4 +1,4 @@ -import { DatesPropagation } from 'config/types'; +import { DatesPropagation, SeasonBounds } from 'config/types'; import timezoneMock from 'timezone-mock'; import { generateIntermediateDateItemFromValidity, @@ -6,11 +6,12 @@ import { getAdminLevelDataCoverage, } from './server-utils'; import { timezones } from '../../test/helpers'; +import { getSeasonBounds, SEASON_MAP } from './date-utils'; // NOTE: all timestamps are created in the LOCAL timezone (as per js docs), so that // these tests should pass for any TZ. -describe('Test generateIntermediateDateItemFromValidity', () => { +describe.only('Test generateIntermediateDateItemFromValidity', () => { test('should return correct dates with forward propagation', () => { const layer = { name: 'myd11a2_taa_dekad', @@ -535,6 +536,125 @@ describe('Test generateIntermediateDateItemFromValidity', () => { }, ]); }); + + test('should return correct dates for seasons', () => { + const dates = ['2023-01-01']; + const layer = { + name: 'myd11a2_taa_season', + dates: dates.map(date => new Date(date).setHours(12, 0)), + validity: { + mode: DatesPropagation.SEASON, + }, + }; + const output = generateIntermediateDateItemFromValidity( + layer.dates, + layer.validity, + ); + const startOfWinter = new Date( + new Date(dates[0]).getFullYear(), + SEASON_MAP[0][0], + 1, + ); + const endOfWinter = new Date( + new Date(dates[0]).getFullYear(), + SEASON_MAP[0][1] + 1, + 0, + ); + + const daysInSeason: Date[] = []; + while ( + !daysInSeason[daysInSeason.length - 1] || + daysInSeason[daysInSeason.length - 1] < endOfWinter + ) { + if (daysInSeason.length === 0) { + // eslint-disable-next-line fp/no-mutating-methods + daysInSeason.push(startOfWinter); + } else { + // eslint-disable-next-line fp/no-mutating-methods + daysInSeason.push( + new Date( + new Date(startOfWinter).setDate( + startOfWinter.getDate() + daysInSeason.length, + ), + ), + ); + } + } + + const { start, end } = getSeasonBounds( + new Date(daysInSeason[0]), + ) as SeasonBounds; + const adjustedEnd = new Date(end).setDate(0); + expect(output).toEqual( + daysInSeason.map(date => ({ + displayDate: new Date(date).getTime(), + queryDate: new Date(dates[0]).getTime(), + endDate: new Date(adjustedEnd).getTime(), + startDate: new Date(start).getTime(), + })), + ); + }); + + test('should return correct dates for custom seasons', () => { + const dates = ['2023-01-01']; + const layer = { + name: 'myd11a2_taa_season', + dates: dates.map(date => new Date(date).setHours(12, 0)), + validity: { + mode: DatesPropagation.SEASON, + seasons: [ + { + start: '01-August', + end: '28-February', + }, + ], + }, + }; + const output = generateIntermediateDateItemFromValidity( + layer.dates, + layer.validity, + ); + const startOfWetSeason = new Date( + `${parseInt(dates[0].split('-')[0], 10) - 1}-${layer.validity.seasons[0].start}`, + ); + const endOfWetSeason = new Date( + `${dates[0].split('-')[0]}-${layer.validity.seasons[0].end}`, + ); + + const daysInSeason: Date[] = []; + while ( + !daysInSeason[daysInSeason.length - 1] || + daysInSeason[daysInSeason.length - 1] < endOfWetSeason + ) { + if (daysInSeason.length === 0) { + // eslint-disable-next-line fp/no-mutating-methods + daysInSeason.push(startOfWetSeason); + } else { + // eslint-disable-next-line fp/no-mutating-methods + daysInSeason.push( + new Date( + new Date(startOfWetSeason).setDate( + startOfWetSeason.getDate() + daysInSeason.length, + ), + ), + ); + } + } + + const { start, end } = getSeasonBounds( + new Date(dates[0]), + layer.validity.seasons, + ) as SeasonBounds; + + expect(output).toEqual( + daysInSeason.map(date => ({ + displayDate: new Date(date).getTime(), + queryDate: new Date(start).getTime(), + endDate: new Date(end).getTime(), + startDate: new Date(start).getTime(), + })), + ); + }); }); describe('getStaticRasterDataCoverage', () => { diff --git a/frontend/src/utils/server-utils.ts b/frontend/src/utils/server-utils.ts index 0c308dbb3..54d0c9d52 100644 --- a/frontend/src/utils/server-utils.ts +++ b/frontend/src/utils/server-utils.ts @@ -407,10 +407,10 @@ export function generateIntermediateDateItemFromValidity( } } else if (mode === DatesPropagation.SEASON) { if (validity.seasons) { - const seasonBounds = getSeasonBounds(startDate); + const seasonBounds = getSeasonBounds(startDate, validity.seasons); if (seasonBounds) { startDate.setTime(seasonBounds.start.getTime()); - endDate.setTime(seasonBounds.end.getTime() - oneDayInMs); + endDate.setTime(seasonBounds.end.getTime()); } else { console.warn( `No season found for date: ${startDate.toISOString()}`, From 92f5fb65c5a7138092e321531a2fe5fa827ebe19 Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:47:49 -0700 Subject: [PATCH 03/30] fixing tests --- frontend/src/context/layers/composite_data.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/src/context/layers/composite_data.ts b/frontend/src/context/layers/composite_data.ts index 97c44e3b4..8a71b95ab 100644 --- a/frontend/src/context/layers/composite_data.ts +++ b/frontend/src/context/layers/composite_data.ts @@ -16,6 +16,12 @@ export const fetchCompositeLayerData: LazyLoader = const { layer, date } = params; const referenceDate = date ? new Date(date) : new Date(); const seasonBounds = getSeasonBounds(referenceDate); + if (!seasonBounds) { + console.error( + `No season bounds found for ${layer.id} with date ${referenceDate}`, + ); + return undefined; + } const useMonthly = !layer.period || layer.period === 'monthly'; const startDate = useMonthly ? referenceDate : seasonBounds.start; // For monthly, setting an end date to one month after the start date From 78cbd13e0c4e9a02c6ded63281df296972faf7af Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Wed, 31 Jul 2024 10:52:31 -0700 Subject: [PATCH 04/30] Fixing past season bug --- frontend/src/utils/date-utils.ts | 24 +++++++++++++++++------- frontend/src/utils/server-utils.test.ts | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/frontend/src/utils/date-utils.ts b/frontend/src/utils/date-utils.ts index c3b123ad5..140b2aa73 100644 --- a/frontend/src/utils/date-utils.ts +++ b/frontend/src/utils/date-utils.ts @@ -7,6 +7,7 @@ export interface StartEndDate { } const millisecondsInADay = 24 * 60 * 60 * 1000; +const millisecondsInAYear = 365 * millisecondsInADay; export const dateWithoutTime = (date: number | Date): number => { const cleanDate = date instanceof Date ? date.getTime() : date; @@ -193,13 +194,22 @@ export const SEASON_MAP: [number, number][] = [ export const constructDateFromSeason = ( date: Date, season: SeasonBoundsConfig, -) => { - const start = new Date(`${date.getFullYear()}-${season.start}`); - const end = new Date(`${date.getFullYear()}-${season.end}`); - if (end < start) { - start.setFullYear(start.getFullYear() - 1); - } - return { start, end }; +): SeasonBounds => { + const startCurrentYear = new Date( + `${date.getFullYear()}-${season.start}`, + ).getTime(); + const endCurrentYear = new Date( + `${date.getFullYear()}-${season.end}`, + ).getTime(); + const startPreviousYear = startCurrentYear - millisecondsInAYear; + const endNextYear = endCurrentYear + millisecondsInAYear; + + // eslint-disable-next-line no-nested-ternary + return endCurrentYear >= startCurrentYear + ? { start: new Date(startCurrentYear), end: new Date(endCurrentYear) } + : date.getTime() >= startCurrentYear + ? { start: new Date(startCurrentYear), end: new Date(endNextYear) } + : { start: new Date(startPreviousYear), end: new Date(endCurrentYear) }; }; /** diff --git a/frontend/src/utils/server-utils.test.ts b/frontend/src/utils/server-utils.test.ts index 9d0b3a7c3..b138e4d7f 100644 --- a/frontend/src/utils/server-utils.test.ts +++ b/frontend/src/utils/server-utils.test.ts @@ -11,7 +11,7 @@ import { getSeasonBounds, SEASON_MAP } from './date-utils'; // NOTE: all timestamps are created in the LOCAL timezone (as per js docs), so that // these tests should pass for any TZ. -describe.only('Test generateIntermediateDateItemFromValidity', () => { +describe('Test generateIntermediateDateItemFromValidity', () => { test('should return correct dates with forward propagation', () => { const layer = { name: 'myd11a2_taa_dekad', From a1681ffbd06bc59ef9a97b236f642c8f94331584 Mon Sep 17 00:00:00 2001 From: Amit W Date: Sun, 4 Aug 2024 18:04:57 +0800 Subject: [PATCH 05/30] CDI - configure seasons as quarters --- frontend/src/config/jordan/layers.json | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index 76201d9f1..a69400c6e 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -4123,12 +4123,20 @@ "mode": "season", "seasons": [ { - "start": "01-March", - "end": "31-July" + "start": "01-January", + "end": "31-March" }, { - "start": "01-August", - "end": "28-February" + "start": "01-April", + "end": "30-June" + }, + { + "start": "01-July", + "end": "30-September" + }, + { + "start": "01-October", + "end": "31-December" } ] }, From 131e84286f63ab96f2bfdfec4f342e8fc6bacf3a Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Sun, 4 Aug 2024 22:52:13 -0700 Subject: [PATCH 06/30] Ensure query dates are availables for composite requests --- .../MapView/DateSelector/index.test.tsx | 23 ------------ .../components/MapView/DateSelector/utils.ts | 32 ----------------- .../MapView/Layers/CompositeLayer/index.tsx | 10 ++++-- frontend/src/context/layers/composite_data.ts | 29 +++++++++++---- frontend/src/context/layers/layer-data.ts | 2 ++ frontend/src/utils/date-utils.test.ts | 25 +++++++++++++ frontend/src/utils/date-utils.ts | 36 +++++++++++++++++-- frontend/src/utils/layers-utils.tsx | 2 +- 8 files changed, 93 insertions(+), 66 deletions(-) diff --git a/frontend/src/components/MapView/DateSelector/index.test.tsx b/frontend/src/components/MapView/DateSelector/index.test.tsx index 5754ef412..6e6504617 100644 --- a/frontend/src/components/MapView/DateSelector/index.test.tsx +++ b/frontend/src/components/MapView/DateSelector/index.test.tsx @@ -3,7 +3,6 @@ import { render } from '@testing-library/react'; import configureStore from 'redux-mock-store'; import { PanelSize } from 'config/types'; import DateSelector from '.'; -import { findClosestDate } from './utils'; jest.mock('react-router-dom', () => ({ useHistory: () => ({ @@ -54,25 +53,3 @@ test('renders as expected', () => { // eslint-disable-next-line fp/no-mutation global.Date.now = realDateNow; }); - -test('DateSelector utils', () => { - const findClosestDateResult = new Date( - findClosestDate( - findClosestDateData.date, - findClosestDateData.availableDates, - ), - ).toISOString(); - - expect(findClosestDateResult).toBe(findClosestDateData.result); -}); - -const findClosestDateData = { - date: 1702288800000, - availableDates: [ - 1689076800000, 1689940800000, 1690891200000, 1691755200000, 1692619200000, - 1693569600000, 1694433600000, 1695297600000, 1696161600000, 1697025600000, - 1697889600000, 1698840000000, 1699704000000, 1700568000000, 1701432000000, - 1702296000000, 1703160000000, 1704110400000, 1704974400000, - ], - result: '2023-12-11T12:00:00.000Z', -}; diff --git a/frontend/src/components/MapView/DateSelector/utils.ts b/frontend/src/components/MapView/DateSelector/utils.ts index 0092b2c8f..dea59223e 100644 --- a/frontend/src/components/MapView/DateSelector/utils.ts +++ b/frontend/src/components/MapView/DateSelector/utils.ts @@ -8,38 +8,6 @@ export type DateCompatibleLayerWithDateItems = DateCompatibleLayer & { dateItems: DateItem[]; }; -/** - * Return the closest date from a given list of available dates - * @param date - * @param availableDates - * @return date as milliseconds - */ -export function findClosestDate( - date: number, - availableDates: ReturnType[], -) { - // TODO - better handle empty arrays. - if (availableDates.length === 0) { - return date; - } - - const reducerFunc = ( - closest: ReturnType, - current: ReturnType, - ) => { - const diff = Math.abs(current - date); - const closestDiff = Math.abs(closest - date); - - if (diff < closestDiff) { - return current; - } - - return closest; - }; - - return availableDates.reduce(reducerFunc); -} - /** * Binary search to return index of available dates that matched * @param availableDates in millisecond format, should be sorted diff --git a/frontend/src/components/MapView/Layers/CompositeLayer/index.tsx b/frontend/src/components/MapView/Layers/CompositeLayer/index.tsx index cf6a44a04..6ba038e46 100644 --- a/frontend/src/components/MapView/Layers/CompositeLayer/index.tsx +++ b/frontend/src/components/MapView/Layers/CompositeLayer/index.tsx @@ -69,9 +69,15 @@ const CompositeLayer = memo(({ layer, before }: Props) => { useEffect(() => { if (requestDate) { - dispatch(loadLayerData({ layer, date: requestDate })); + dispatch( + loadLayerData({ + layer, + date: requestDate, + availableDates: layerAvailableDates, + }), + ); } - }, [dispatch, layer, requestDate]); + }, [dispatch, layer, layerAvailableDates, requestDate]); // Investigate performance impact of hexagons for large countries const finalFeatures = diff --git a/frontend/src/context/layers/composite_data.ts b/frontend/src/context/layers/composite_data.ts index 8a71b95ab..5d5a102c1 100644 --- a/frontend/src/context/layers/composite_data.ts +++ b/frontend/src/context/layers/composite_data.ts @@ -4,7 +4,11 @@ import type { CompositeLayerProps } from 'config/types'; import { fetchWithTimeout } from 'utils/fetch-with-timeout'; import { HTTPError, LocalError } from 'utils/error-utils'; import { addNotification } from 'context/notificationStateSlice'; -import { getFormattedDate, getSeasonBounds } from 'utils/date-utils'; +import { + findClosestDate, + getFormattedDate, + getSeasonBounds, +} from 'utils/date-utils'; import type { LayerDataParams, LazyLoader } from './layer-data'; @@ -13,9 +17,11 @@ export interface CompositeLayerData extends FeatureCollection {} export const fetchCompositeLayerData: LazyLoader = () => async (params: LayerDataParams, { dispatch }) => { - const { layer, date } = params; + const { layer, date, availableDates } = params; + const referenceDate = date ? new Date(date) : new Date(); - const seasonBounds = getSeasonBounds(referenceDate); + const providedSeasons = layer.validity?.seasons; + const seasonBounds = getSeasonBounds(referenceDate, providedSeasons); if (!seasonBounds) { console.error( `No season bounds found for ${layer.id} with date ${referenceDate}`, @@ -28,7 +34,18 @@ export const fetchCompositeLayerData: LazyLoader = // For seasonal, setting an end date to the end of the season const endDate = useMonthly ? new Date(startDate).setMonth(startDate.getMonth() + 1) - : seasonBounds.end; + : new Date(seasonBounds.end).getTime(); + + const availableQueryDates = availableDates + ? Array.from(new Set(availableDates.map(dateItem => dateItem.queryDate))) + : []; + + const closestDateToStart = availableDates + ? findClosestDate(startDate.getTime(), availableQueryDates) + : startDate; + const closestDateToEnd = availableDates + ? findClosestDate(endDate, availableQueryDates) + : endDate; const { baseUrl, @@ -40,8 +57,8 @@ export const fetchCompositeLayerData: LazyLoader = // docs: https://hip-service.ovio.org/docs#/default/run_q_multi_geojson_q_multi_geojson_post const body = { - begin: getFormattedDate(startDate, 'default'), - end: getFormattedDate(endDate, 'default'), + begin: getFormattedDate(closestDateToStart, 'default', true), + end: getFormattedDate(closestDateToEnd, 'default', true), area: { min_lon: boundingBox[0], min_lat: boundingBox[1], diff --git a/frontend/src/context/layers/layer-data.ts b/frontend/src/context/layers/layer-data.ts index 7709b9f3c..85ea2f4b7 100644 --- a/frontend/src/context/layers/layer-data.ts +++ b/frontend/src/context/layers/layer-data.ts @@ -1,6 +1,7 @@ import { createAsyncThunk, AsyncThunk } from '@reduxjs/toolkit'; import { AnticipatoryActionLayerProps, + DateItem, DiscriminateUnion, LayerType, PointLayerData, @@ -47,6 +48,7 @@ export interface LayerDataParams { layer: T; extent?: Extent; date?: number; + availableDates?: DateItem[]; [key: string]: any; } diff --git a/frontend/src/utils/date-utils.test.ts b/frontend/src/utils/date-utils.test.ts index d5589d212..959118e08 100644 --- a/frontend/src/utils/date-utils.test.ts +++ b/frontend/src/utils/date-utils.test.ts @@ -1,5 +1,6 @@ import { binaryFind, + findClosestDate, generateDateItemsRange, generateDatesRange, getFormattedDate, @@ -174,3 +175,27 @@ test('Test generateDatesRange', () => { 1676160000000, 1676246400000, ]); }); + +describe('can find closest date', () => { + test('findClosestDate', () => { + const findClosestDateResult = new Date( + findClosestDate( + findClosestDateData.date, + findClosestDateData.availableDates, + ), + ).toISOString(); + + expect(findClosestDateResult).toBe(findClosestDateData.result); + }); + + const findClosestDateData = { + date: 1702288800000, + availableDates: [ + 1689076800000, 1689940800000, 1690891200000, 1691755200000, 1692619200000, + 1693569600000, 1694433600000, 1695297600000, 1696161600000, 1697025600000, + 1697889600000, 1698840000000, 1699704000000, 1700568000000, 1701432000000, + 1702296000000, 1703160000000, 1704110400000, 1704974400000, + ], + result: '2023-12-11T12:00:00.000Z', + }; +}); diff --git a/frontend/src/utils/date-utils.ts b/frontend/src/utils/date-utils.ts index 140b2aa73..51a47d3e2 100644 --- a/frontend/src/utils/date-utils.ts +++ b/frontend/src/utils/date-utils.ts @@ -196,10 +196,10 @@ export const constructDateFromSeason = ( season: SeasonBoundsConfig, ): SeasonBounds => { const startCurrentYear = new Date( - `${date.getFullYear()}-${season.start}`, + `${date.getFullYear()}-${season.start}T12:00:00Z`, ).getTime(); const endCurrentYear = new Date( - `${date.getFullYear()}-${season.end}`, + `${date.getFullYear()}-${season.end}T12:00:00Z`, ).getTime(); const startPreviousYear = startCurrentYear - millisecondsInAYear; const endNextYear = endCurrentYear + millisecondsInAYear; @@ -241,3 +241,35 @@ export const getSeasonBounds = ( end: new Date(date.getFullYear(), foundSeason[1] + 1, 1), }; }; + +/** + * Return the closest date from a given list of available dates + * @param date + * @param availableDates + * @return date as milliseconds + */ +export function findClosestDate( + date: number, + availableDates: ReturnType[], +) { + // TODO - better handle empty arrays. + if (availableDates.length === 0) { + return date; + } + + const reducerFunc = ( + closest: ReturnType, + current: ReturnType, + ) => { + const diff = Math.abs(current - date); + const closestDiff = Math.abs(closest - date); + + if (diff < closestDiff) { + return current; + } + + return closest; + }; + + return availableDates.reduce(reducerFunc); +} diff --git a/frontend/src/utils/layers-utils.tsx b/frontend/src/utils/layers-utils.tsx index 1ad37ed08..ad41d923a 100644 --- a/frontend/src/utils/layers-utils.tsx +++ b/frontend/src/utils/layers-utils.tsx @@ -1,4 +1,3 @@ -import { findClosestDate } from 'components/MapView/DateSelector/utils'; import { checkLayerAvailableDatesAndContinueOrRemove } from 'components/MapView/utils'; import { appConfig } from 'config'; import { @@ -41,6 +40,7 @@ import { binaryIncludes, getFormattedDate, dateWithoutTime, + findClosestDate, } from './date-utils'; const dateSupportLayerTypes: Array = [ From 680ff15e60c321ced3a21117e3d7ee1a637755d6 Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Sun, 4 Aug 2024 23:06:10 -0700 Subject: [PATCH 07/30] Test updates --- frontend/src/context/layers/composite_data.ts | 4 ++-- frontend/src/utils/date-utils.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/context/layers/composite_data.ts b/frontend/src/context/layers/composite_data.ts index 5d5a102c1..47dddea75 100644 --- a/frontend/src/context/layers/composite_data.ts +++ b/frontend/src/context/layers/composite_data.ts @@ -57,8 +57,8 @@ export const fetchCompositeLayerData: LazyLoader = // docs: https://hip-service.ovio.org/docs#/default/run_q_multi_geojson_q_multi_geojson_post const body = { - begin: getFormattedDate(closestDateToStart, 'default', true), - end: getFormattedDate(closestDateToEnd, 'default', true), + begin: getFormattedDate(closestDateToStart, 'default'), + end: getFormattedDate(closestDateToEnd, 'default'), area: { min_lon: boundingBox[0], min_lat: boundingBox[1], diff --git a/frontend/src/utils/date-utils.ts b/frontend/src/utils/date-utils.ts index 51a47d3e2..40fed934b 100644 --- a/frontend/src/utils/date-utils.ts +++ b/frontend/src/utils/date-utils.ts @@ -196,10 +196,10 @@ export const constructDateFromSeason = ( season: SeasonBoundsConfig, ): SeasonBounds => { const startCurrentYear = new Date( - `${date.getFullYear()}-${season.start}T12:00:00Z`, + `${date.getFullYear()}-${season.start}`, ).getTime(); const endCurrentYear = new Date( - `${date.getFullYear()}-${season.end}T12:00:00Z`, + `${date.getFullYear()}-${season.end}`, ).getTime(); const startPreviousYear = startCurrentYear - millisecondsInAYear; const endNextYear = endCurrentYear + millisecondsInAYear; From 3ad780857588f40e6c57e6515b46a19c535b6c02 Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Mon, 5 Aug 2024 17:32:39 -0700 Subject: [PATCH 08/30] Better handle timezones --- frontend/src/utils/date-utils.ts | 4 ++-- frontend/src/utils/server-utils.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/utils/date-utils.ts b/frontend/src/utils/date-utils.ts index 40fed934b..ce5516d48 100644 --- a/frontend/src/utils/date-utils.ts +++ b/frontend/src/utils/date-utils.ts @@ -196,10 +196,10 @@ export const constructDateFromSeason = ( season: SeasonBoundsConfig, ): SeasonBounds => { const startCurrentYear = new Date( - `${date.getFullYear()}-${season.start}`, + `${date.getUTCFullYear()}-${season.start}T12:00:00Z`, ).getTime(); const endCurrentYear = new Date( - `${date.getFullYear()}-${season.end}`, + `${date.getUTCFullYear()}-${season.end}T12:00:00Z`, ).getTime(); const startPreviousYear = startCurrentYear - millisecondsInAYear; const endNextYear = endCurrentYear + millisecondsInAYear; diff --git a/frontend/src/utils/server-utils.test.ts b/frontend/src/utils/server-utils.test.ts index b138e4d7f..6abd0e53e 100644 --- a/frontend/src/utils/server-utils.test.ts +++ b/frontend/src/utils/server-utils.test.ts @@ -648,7 +648,7 @@ describe('Test generateIntermediateDateItemFromValidity', () => { expect(output).toEqual( daysInSeason.map(date => ({ - displayDate: new Date(date).getTime(), + displayDate: new Date(date).setUTCHours(12), queryDate: new Date(start).getTime(), endDate: new Date(end).getTime(), startDate: new Date(start).getTime(), From dbdabc42c75d64946f86876e1f50c777b53f27c9 Mon Sep 17 00:00:00 2001 From: Amit W Date: Wed, 7 Aug 2024 00:22:16 +0800 Subject: [PATCH 09/30] adjust bounding box --- frontend/src/config/jordan/prism.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/config/jordan/prism.json b/frontend/src/config/jordan/prism.json index bbd678bb8..9f51eb1b6 100644 --- a/frontend/src/config/jordan/prism.json +++ b/frontend/src/config/jordan/prism.json @@ -16,7 +16,7 @@ "wms": ["https://api.earthobservation.vam.wfp.org/ows/wms"] }, "map": { - "boundingBox": [34.42, 28.36, 39.82, 34.16] + "boundingBox": [35.42, 29.36, 38.82, 33.16] }, "defaultDisplayBoundaries": [ "admin_boundaries", From c2eaabe85c8dc760ec05d3b7c195dadc3edcccb9 Mon Sep 17 00:00:00 2001 From: Amit W Date: Wed, 7 Aug 2024 00:54:19 +0800 Subject: [PATCH 10/30] remove layers available through shared config --- frontend/src/config/jordan/layers.json | 3097 +----------------------- 1 file changed, 87 insertions(+), 3010 deletions(-) diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index a69400c6e..162d808f8 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -83,368 +83,7 @@ } } }, - "spi_1m": { - "title": "SPI - 1-month", - "type": "wms", - "server_layer_name": "r1s_dekad", - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "wcsConfig": { - "scale": 0.001, - "offset": 0, - "pixelResolution": 64 - }, - "opacity": 0.7, - "legend_text": "1-month Standardized Precipitation Index calculated from dekadal CHIRPS data", - "legend": [ - { - "value": -2.01, - "label": "< -2", - "color": "#730000" - }, - { - "value": -2, - "label": "-1.5 to -2", - "color": "#e70001" - }, - { - "value": -1.5, - "label": "-1.2 to -1.5", - "color": "#ffaa01" - }, - { - "value": -1.2, - "label": "-0.7 to -1.2", - "color": "#ffd37b" - }, - { - "value": -0.7, - "label": "-0.5 to -0.7", - "color": "#ffff02" - }, - { - "value": -0.5, - "label": "0.5 to -0.5 ", - "color": "#f0f0f0" - }, - { - "value": 0.5, - "label": "0.5 to 0.7", - "color": "#beebff" - }, - { - "value": 0.7, - "label": "0.7 to 1.2", - "color": "#73b2ff" - }, - { - "value": 1.2, - "label": "1.2 to 1.5", - "color": "#0271ff" - }, - { - "value": 1.5, - "label": "1.5 to 2.0", - "color": "#004dad" - }, - { - "value": 2, - "label": "> 2.0", - "color": "#ad03e6" - } - ] - }, - "spi_3m": { - "title": "SPI - 3-month", - "type": "wms", - "server_layer_name": "r3s_dekad", - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "wcsConfig": { - "scale": 0.001, - "offset": 0, - "pixelResolution": 64 - }, - "opacity": 0.7, - "legend_text": "3-month Standardized Precipitation Index calculated from dekadal CHIRPS data", - "legend": [ - { - "value": -2.01, - "label": "< -2", - "color": "#730000" - }, - { - "value": -2, - "label": "-1.5 to -2", - "color": "#e70001" - }, - { - "value": -1.5, - "label": "-1.2 to -1.5", - "color": "#ffaa01" - }, - { - "value": -1.2, - "label": "-0.7 to -1.2", - "color": "#ffd37b" - }, - { - "value": -0.7, - "label": "-0.5 to -0.7", - "color": "#ffff02" - }, - { - "value": -0.5, - "label": "0.5 to -0.5 ", - "color": "#f0f0f0" - }, - { - "value": 0.5, - "label": "0.5 to 0.7", - "color": "#beebff" - }, - { - "value": 0.7, - "label": "0.7 to 1.2", - "color": "#73b2ff" - }, - { - "value": 1.2, - "label": "1.2 to 1.5", - "color": "#0271ff" - }, - { - "value": 1.5, - "label": "1.5 to 2.0", - "color": "#004dad" - }, - { - "value": 2, - "label": "> 2.0", - "color": "#ad03e6" - } - ] - }, - "spi_6m": { - "title": "SPI - 6-month", - "type": "wms", - "server_layer_name": "r6s_dekad", - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "wcsConfig": { - "scale": 0.001, - "offset": 0, - "pixelResolution": 64 - }, - "opacity": 0.7, - "legend_text": "6-month Standardized Precipitation Index calculated from dekadal CHIRPS data", - "legend": [ - { - "value": -2.01, - "label": "< -2", - "color": "#730000" - }, - { - "value": -2, - "label": "-1.5 to -2", - "color": "#e70001" - }, - { - "value": -1.5, - "label": "-1.2 to -1.5", - "color": "#ffaa01" - }, - { - "value": -1.2, - "label": "-0.7 to -1.2", - "color": "#ffd37b" - }, - { - "value": -0.7, - "label": "-0.5 to -0.7", - "color": "#ffff02" - }, - { - "value": -0.5, - "label": "0.5 to -0.5 ", - "color": "#f0f0f0" - }, - { - "value": 0.5, - "label": "0.5 to 0.7", - "color": "#beebff" - }, - { - "value": 0.7, - "label": "0.7 to 1.2", - "color": "#73b2ff" - }, - { - "value": 1.2, - "label": "1.2 to 1.5", - "color": "#0271ff" - }, - { - "value": 1.5, - "label": "1.5 to 2.0", - "color": "#004dad" - }, - { - "value": 2, - "label": "> 2.0", - "color": "#ad03e6" - } - ] - }, - "spi_9m": { - "title": "SPI - 9-month", - "type": "wms", - "server_layer_name": "r9s_dekad", - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "wcsConfig": { - "scale": 0.001, - "offset": 0, - "pixelResolution": 64 - }, - "opacity": 0.7, - "legend_text": "9-month Standardized Precipitation Index calculated from dekadal CHIRPS data", - "legend": [ - { - "value": -2.01, - "label": "< -2", - "color": "#730000" - }, - { - "value": -2, - "label": "-1.5 to -2", - "color": "#e70001" - }, - { - "value": -1.5, - "label": "-1.2 to -1.5", - "color": "#ffaa01" - }, - { - "value": -1.2, - "label": "-0.7 to -1.2", - "color": "#ffd37b" - }, - { - "value": -0.7, - "label": "-0.5 to -0.7", - "color": "#ffff02" - }, - { - "value": -0.5, - "label": "0.5 to -0.5 ", - "color": "#f0f0f0" - }, - { - "value": 0.5, - "label": "0.5 to 0.7", - "color": "#beebff" - }, - { - "value": 0.7, - "label": "0.7 to 1.2", - "color": "#73b2ff" - }, - { - "value": 1.2, - "label": "1.2 to 1.5", - "color": "#0271ff" - }, - { - "value": 1.5, - "label": "1.5 to 2.0", - "color": "#004dad" - }, - { - "value": 2, - "label": "> 2.0", - "color": "#ad03e6" - } - ] - }, - "spi_1y": { - "title": "SPI - 1-year", - "type": "wms", - "server_layer_name": "rys_dekad", - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "wcsConfig": { - "scale": 0.001, - "offset": 0, - "pixelResolution": 64 - }, - "opacity": 0.7, - "legend_text": "1-year Standardized Precipitation Index calculated from dekadal CHIRPS data", - "legend": [ - { - "value": -2.01, - "label": "< -2", - "color": "#730000" - }, - { - "value": -2, - "label": "-1.5 to -2", - "color": "#e70001" - }, - { - "value": -1.5, - "label": "-1.2 to -1.5", - "color": "#ffaa01" - }, - { - "value": -1.2, - "label": "-0.7 to -1.2", - "color": "#ffd37b" - }, - { - "value": -0.7, - "label": "-0.5 to -0.7", - "color": "#ffff02" - }, - { - "value": -0.5, - "label": "0.5 to -0.5 ", - "color": "#f0f0f0" - }, - { - "value": 0.5, - "label": "0.5 to 0.7", - "color": "#beebff" - }, - { - "value": 0.7, - "label": "0.7 to 1.2", - "color": "#73b2ff" - }, - { - "value": 1.2, - "label": "1.2 to 1.5", - "color": "#0271ff" - }, - { - "value": 1.5, - "label": "1.5 to 2.0", - "color": "#004dad" - }, - { - "value": 2, - "label": "> 2.0", - "color": "#ad03e6" - } - ] - }, "rainfall_dekad": { - "title": "10-day rainfall estimate (mm)", - "type": "wms", - "server_layer_name": "rfh_dekad", - "additional_query_params": { - "styles": "rfh_16_0_300" - }, "chart_data": { "fields": [ { @@ -471,101 +110,9 @@ } ], "type": "bar" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "Estimate of precipitation over a 10-day period derived from [CHIRPS (UCSB Climate Hazards Group)](https://www.chc.ucsb.edu/data/chirps).", - "legend": [ - { - "value": 0, - "label": "0 mm", - "color": "#fafafa" - }, - { - "value": 0.01, - "label": "1-2 mm", - "color": "#fffadf" - }, - { - "value": 2, - "label": "2-5 mm", - "color": "#d3f9d0" - }, - { - "value": 5, - "label": "5-10 mm", - "color": "#a9e4a3" - }, - { - "value": 10, - "label": "10-20 mm", - "color": "#7cc594" - }, - { - "value": 20, - "label": "20-30 mm", - "color": "#5eab91" - }, - { - "value": 30, - "label": "30-40 mm", - "color": "#9fffe8" - }, - { - "value": 40, - "label": "40-50 mm", - "color": "#90e0ef" - }, - { - "value": 50, - "label": "50-60 mm", - "color": "#00b1de" - }, - { - "value": 60, - "label": "60-80 mm", - "color": "#0083f3" - }, - { - "value": 80, - "label": "80-100 mm", - "color": "#0052cd" - }, - { - "value": 100, - "label": "100-120 mm", - "color": "#0000c8" - }, - { - "value": 120, - "label": "120-150 mm", - "color": "#6003b8" - }, - { - "value": 150, - "label": "150-200 mm", - "color": "#a002fa" - }, - { - "value": 200, - "label": "200-300 mm", - "color": "#fa78fa" - }, - { - "value": 300, - "label": ">= 300 mm", - "color": "#ffc4ee" - } - ] + } }, "rain_anomaly_dekad": { - "title": "10-day rainfall anomaly", - "type": "wms", - "server_layer_name": "rfq_dekad", - "additional_query_params": { - "styles": "rfq_14_20_400" - }, "chart_data": { "fields": [ { @@ -593,92 +140,9 @@ } ], "type": "line" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "10-day precipitation anomaly compared to the long term average. Derived from [CHIRPS (UCSB Climate Hazards Group)](https://www.chc.ucsb.edu/data/chirps).", - "legend": [ - { - "value": 0, - "label": "< 20%", - "color": "#8c4800" - }, - { - "value": 20, - "label": "20-40%", - "color": "#af6b27" - }, - { - "value": 40, - "label": "40-60%", - "color": "#d58c3e" - }, - { - "value": 60, - "label": "60-70%", - "color": "#eaa83d" - }, - { - "value": 70, - "label": "70-80%", - "color": "#f5c878" - }, - { - "value": 80, - "label": "80-90%", - "color": "#fff0c4" - }, - { - "value": 90, - "label": "90-110%", - "color": "#fafafa" - }, - { - "value": 110, - "label": "110-120%", - "color": "#befafa" - }, - { - "value": 120, - "label": "120-130%", - "color": "#78e2f0" - }, - { - "value": 130, - "label": "130-150%", - "color": "#00b9de" - }, - { - "value": 150, - "label": "150-200%", - "color": "#0083f3" - }, - { - "value": 200, - "label": "200-300%", - "color": "#0052cd" - }, - { - "value": 300, - "label": "300-400%", - "color": "#0000c8" - }, - { - "value": 400, - "label": "> 400%", - "color": "#a002fa" - } - ] + } }, "rainfall_agg_1month": { - "title": "1-month rainfall aggregate (mm)", - "type": "wms", - "server_layer_name": "r1h_dekad", - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "additional_query_params": { - "styles": "rfh_16_0_400" - }, "chart_data": { "fields": [ { @@ -705,100 +169,9 @@ } ], "type": "bar" - }, - "date_interval": "days", - "opacity": 0.7, - "legend_text": "Total aggregate precipitation over a 1-month period, rolling every 10 days. Derived from [CHIRPS (UCSB Climate Hazards Group)](https://www.chc.ucsb.edu/data/chirps).", - "legend": [ - { - "value": 0, - "label": "0 mm", - "color": "#fafafa" - }, - { - "value": 0.01, - "label": "1-5 mm", - "color": "#fffadf" - }, - { - "value": 5, - "label": "5-10 mm", - "color": "#d3f9d0" - }, - { - "value": 10, - "label": "10-20 mm", - "color": "#a9e4a3" - }, - { - "value": 20, - "label": "20-30 mm", - "color": "#7cc594" - }, - { - "value": 30, - "label": "30-40 mm", - "color": "#5eab91" - }, - { - "value": 40, - "label": "40-60 mm", - "color": "#9fffe8" - }, - { - "value": 60, - "label": "60-90 mm", - "color": "#90e0ef" - }, - { - "value": 90, - "label": "90-120 mm", - "color": "#00b1de" - }, - { - "value": 120, - "label": "120-150 mm", - "color": "#0083f3" - }, - { - "value": 150, - "label": "150-200 mm", - "color": "#0052cd" - }, - { - "value": 200, - "label": "200-250 mm", - "color": "#0000c8" - }, - { - "value": 250, - "label": "250-300 mm", - "color": "#6003b8" - }, - { - "value": 300, - "label": "300-350 mm", - "color": "#a002fa" - }, - { - "value": 350, - "label": "350-400 mm", - "color": "#fa78fa" - }, - { - "value": 400, - "label": ">= 400 mm", - "color": "#ffc4ee" - } - ] + } }, "rain_anomaly_1month": { - "title": "Monthly rainfall anomaly", - "type": "wms", - "server_layer_name": "r1q_dekad", - "additional_query_params": { - "styles": "rfq_14_20_400" - }, "chart_data": { "fields": [ { @@ -826,91 +199,9 @@ } ], "type": "line" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "Monthly precipitation anomaly compared to the long term average. Derived from [CHIRPS (UCSB Climate Hazards Group)](https://www.chc.ucsb.edu/data/chirps).", - "legend": [ - { - "value": 0, - "label": "< 20%", - "color": "#8c4800" - }, - { - "value": 20, - "label": "20-40%", - "color": "#af6b27" - }, - { - "value": 40, - "label": "40-60%", - "color": "#d58c3e" - }, - { - "value": 60, - "label": "60-70%", - "color": "#eaa83d" - }, - { - "value": 70, - "label": "70-80%", - "color": "#f5c878" - }, - { - "value": 80, - "label": "80-90%", - "color": "#fff0c4" - }, - { - "value": 90, - "label": "90-110%", - "color": "#fafafa" - }, - { - "value": 110, - "label": "110-120%", - "color": "#befafa" - }, - { - "value": 120, - "label": "120-130%", - "color": "#78e2f0" - }, - { - "value": 130, - "label": "130-150%", - "color": "#00b9de" - }, - { - "value": 150, - "label": "150-200%", - "color": "#0083f3" - }, - { - "value": 200, - "label": "200-300%", - "color": "#0052cd" - }, - { - "value": 300, - "label": "300-400%", - "color": "#0000c8" - }, - { - "value": 400, - "label": "> 400%", - "color": "#a002fa" - } - ] + } }, "rainfall_agg_3month": { - "title": "3-month rainfall aggregate (mm)", - "type": "wms", - "server_layer_name": "r3h_dekad", - "additional_query_params": { - "styles": "rfh_16_0_600" - }, "chart_data": { "fields": [ { @@ -937,2035 +228,96 @@ } ], "type": "bar" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "CHIRPS 3 month dekadal rainfall aggregations", - "legend": [ - { - "value": 0, - "label": "0 mm", - "color": "#fafafa" - }, - { - "value": 0.01, - "label": "1-5 mm", - "color": "#fffadf" - }, - { - "value": 5, - "label": "5-10 mm", - "color": "#d3f9d0" - }, - { - "value": 10, - "label": "10-20 mm", - "color": "#a9e4a3" - }, - { - "value": 20, - "label": "20-30 mm", - "color": "#7cc594" - }, - { - "value": 30, - "label": "30-50 mm", - "color": "#5eab91" - }, - { - "value": 50, - "label": "50-80 mm", - "color": "#9fffe8" - }, - { - "value": 80, - "label": "80-100 mm", - "color": "#90e0ef" - }, - { - "value": 100, - "label": "100-150 mm", - "color": "#00b1de" - }, - { - "value": 150, - "label": "150-200 mm", - "color": "#0083f3" - }, - { - "value": 200, - "label": "200-250 mm", - "color": "#0052cd" - }, - { - "value": 250, - "label": "250-300 mm", - "color": "#0000c8" - }, - { - "value": 300, - "label": "300-400 mm", - "color": "#6003b8" - }, - { - "value": 400, - "label": "400-500 mm", - "color": "#a002fa" - }, - { - "value": 500, - "label": "500-700 mm", - "color": "#fa78fa" - }, - { - "value": 700, - "label": "> 700 mm", - "color": "#ffc4ee" - } - ] + } }, "rain_anomaly_3month": { - "title": "3-month rainfall anomaly", - "type": "wms", - "server_layer_name": "r3q_dekad", - "additional_query_params": { - "styles": "rfq_14_20_400" - }, "chart_data": { "fields": [ { "key": "r3q", - "label": "Rainfall anomaly", - "color": "#375692" - }, - { - "key": "rfq_avg", - "label": "Normal", - "fallback": 100, - "color": "#eb3223" - } - ], - "levels": [ - { - "level": "1", - "id": "dataviz_adm1_id", - "name": "admin1Name" - }, - { - "level": "2", - "id": "dataviz_adm2_id", - "name": "admin2Name" - } - ], - "type": "line" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "3-month precipitation anomaly compared to the long term average. Derived from [CHIRPS (UCSB Climate Hazards Group)](https://www.chc.ucsb.edu/data/chirps).", - "legend": [ - { - "value": 0, - "label": "< 20%", - "color": "#8c4800" - }, - { - "value": 20, - "label": "20-40%", - "color": "#af6b27" - }, - { - "value": 40, - "label": "40-60%", - "color": "#d58c3e" - }, - { - "value": 60, - "label": "60-70%", - "color": "#eaa83d" - }, - { - "value": 70, - "label": "70-80%", - "color": "#f5c878" - }, - { - "value": 80, - "label": "80-90%", - "color": "#fff0c4" - }, - { - "value": 90, - "label": "90-110%", - "color": "#fafafa" - }, - { - "value": 110, - "label": "110-120%", - "color": "#befafa" - }, - { - "value": 120, - "label": "120-130%", - "color": "#78e2f0" - }, - { - "value": 130, - "label": "130-150%", - "color": "#00b9de" - }, - { - "value": 150, - "label": "150-200%", - "color": "#0083f3" - }, - { - "value": 200, - "label": "200-300%", - "color": "#0052cd" - }, - { - "value": 300, - "label": "300-400%", - "color": "#0000c8" - }, - { - "value": 400, - "label": "> 400%", - "color": "#a002fa" - } - ] - }, - "rainfall_agg_6month": { - "title": "6-month rainfall aggregate (mm)", - "type": "wms", - "server_layer_name": "r6h_dekad", - "additional_query_params": { - "styles": "rfh_16_0_800" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "CHIRPS 6 month dekadal rainfall aggregations", - "legend": [ - { - "value": 0, - "label": "0 mm", - "color": "#fafafa" - }, - { - "value": 0.01, - "label": "1-10 mm", - "color": "#fffadf" - }, - { - "value": 10, - "label": "10-20 mm", - "color": "#d3f9d0" - }, - { - "value": 20, - "label": "20-30 mm", - "color": "#a9e4a3" - }, - { - "value": 30, - "label": "30-50 mm", - "color": "#7cc594" - }, - { - "value": 50, - "label": "50-80 mm", - "color": "#5eab91" - }, - { - "value": 80, - "label": "80-100 mm", - "color": "#9fffe8" - }, - { - "value": 100, - "label": "100-150 mm", - "color": "#90e0ef" - }, - { - "value": 150, - "label": "150-200 mm", - "color": "#00b1de" - }, - { - "value": 200, - "label": "200-300 mm", - "color": "#0083f3" - }, - { - "value": 300, - "label": "300-400 mm", - "color": "#0052cd" - }, - { - "value": 400, - "label": "400-500 mm", - "color": "#0000c8" - }, - { - "value": 500, - "label": "500-600 mm", - "color": "#6003b8" - }, - { - "value": 600, - "label": "600-700 mm", - "color": "#a002fa" - }, - { - "value": 700, - "label": "700-800 mm", - "color": "#fa78fa" - }, - { - "value": 800, - "label": "> 800 mm", - "color": "#ffc4ee" - } - ] - }, - "rain_anomaly_6month": { - "title": "6-month rainfall anomaly", - "type": "wms", - "server_layer_name": "r6q_dekad", - "additional_query_params": { - "styles": "ryq_14_50_200" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "6-month precipitation anomaly compared to the long term average. Derived from [CHIRPS (UCSB Climate Hazards Group)](https://www.chc.ucsb.edu/data/chirps).", - "legend": [ - { - "value": 0, - "label": "< 50%", - "color": "#8c4800" - }, - { - "value": 50, - "label": "50-60%", - "color": "#af6b27" - }, - { - "value": 60, - "label": "60-70%", - "color": "#d58c3e" - }, - { - "value": 70, - "label": "70-80%", - "color": "#eaa83d" - }, - { - "value": 80, - "label": "80-90%", - "color": "#f5c878" - }, - { - "value": 90, - "label": "90-95%", - "color": "#fff0c4" - }, - { - "value": 95, - "label": "95-105%", - "color": "#fafafa" - }, - { - "value": 105, - "label": "105-110%", - "color": "#befafa" - }, - { - "value": 110, - "label": "110-120%", - "color": "#78e2f0" - }, - { - "value": 120, - "label": "120-130%", - "color": "#00b9de" - }, - { - "value": 130, - "label": "130-150%", - "color": "#0083f3" - }, - { - "value": 150, - "label": "150-170%", - "color": "#0052cd" - }, - { - "value": 170, - "label": "170-200%", - "color": "#0000c8" - }, - { - "value": 200, - "label": "> 200%", - "color": "#a002fa" - } - ] - }, - "rainfall_agg_9month": { - "title": "9-month rainfall aggregate (mm)", - "type": "wms", - "server_layer_name": "r9h_dekad", - "additional_query_params": { - "styles": "rfh_16_0_1600" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "CHIRPS 9 month dekadal rainfall aggregations", - "legend": [ - { - "value": 0, - "label": "0 mm", - "color": "#fafafa" - }, - { - "value": 0.01, - "label": "1-10 mm", - "color": "#fffadf" - }, - { - "value": 10, - "label": "10-20 mm", - "color": "#d3f9d0" - }, - { - "value": 20, - "label": "20-50 mm", - "color": "#a9e4a3" - }, - { - "value": 50, - "label": "50-100 mm", - "color": "#7cc594" - }, - { - "value": 100, - "label": "100-200 mm", - "color": "#5eab91" - }, - { - "value": 200, - "label": "200-300 mm", - "color": "#9fffe8" - }, - { - "value": 300, - "label": "300-400 mm", - "color": "#90e0ef" - }, - { - "value": 400, - "label": "400-600 mm", - "color": "#00b1de" - }, - { - "value": 600, - "label": "600-800 mm", - "color": "#0083f3" - }, - { - "value": 800, - "label": "800-900 mm", - "color": "#0052cd" - }, - { - "value": 900, - "label": "900-1000 mm", - "color": "#0000c8" - }, - { - "value": 1000, - "label": "1000-1200 mm", - "color": "#6003b8" - }, - { - "value": 1200, - "label": "1200-1400 mm", - "color": "#a002fa" - }, - { - "value": 1400, - "label": "1400-1600 mm", - "color": "#fa78fa" - }, - { - "value": 1600, - "label": "> 1600 mm", - "color": "#ffc4ee" - } - ] - }, - "rain_anomaly_9month": { - "title": "9-month rainfall anomaly", - "type": "wms", - "server_layer_name": "r9q_dekad", - "additional_query_params": { - "styles": "ryq_14_50_200" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "9-month precipitation anomaly compared to the long term average. Derived from [CHIRPS (UCSB Climate Hazards Group)](https://www.chc.ucsb.edu/data/chirps).", - "legend": [ - { - "value": 0, - "label": "< 50%", - "color": "#8c4800" - }, - { - "value": 50, - "label": "50-60%", - "color": "#af6b27" - }, - { - "value": 60, - "label": "60-70%", - "color": "#d58c3e" - }, - { - "value": 70, - "label": "70-80%", - "color": "#eaa83d" - }, - { - "value": 80, - "label": "80-90%", - "color": "#f5c878" - }, - { - "value": 90, - "label": "90-95%", - "color": "#fff0c4" - }, - { - "value": 95, - "label": "95-105%", - "color": "#fafafa" - }, - { - "value": 105, - "label": "105-110%", - "color": "#befafa" - }, - { - "value": 110, - "label": "110-120%", - "color": "#78e2f0" - }, - { - "value": 120, - "label": "120-130%", - "color": "#00b9de" - }, - { - "value": 130, - "label": "130-150%", - "color": "#0083f3" - }, - { - "value": 150, - "label": "150-170%", - "color": "#0052cd" - }, - { - "value": 170, - "label": "170-200%", - "color": "#0000c8" - }, - { - "value": 200, - "label": "> 200%", - "color": "#a002fa" - } - ] - }, - "rainfall_agg_1year": { - "title": "1-year rainfall aggregate (mm)", - "type": "wms", - "server_layer_name": "ryh_dekad", - "additional_query_params": { - "styles": "rfh_16_0_2400" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "CHIRPS 1 year dekadal rainfall aggregations", - "legend": [ - { - "value": 0, - "label": "0 mm", - "color": "#fafafa" - }, - { - "value": 0.01, - "label": "1-10 mm", - "color": "#fffadf" - }, - { - "value": 10, - "label": "10-50 mm", - "color": "#d3f9d0" - }, - { - "value": 50, - "label": "50-100 mm", - "color": "#a9e4a3" - }, - { - "value": 100, - "label": "100-200 mm", - "color": "#7cc594" - }, - { - "value": 200, - "label": "200-400 mm", - "color": "#5eab91" - }, - { - "value": 400, - "label": "400-600 mm", - "color": "#9fffe8" - }, - { - "value": 600, - "label": "600-800 mm", - "color": "#90e0ef" - }, - { - "value": 800, - "label": "800-1000 mm", - "color": "#00b1de" - }, - { - "value": 1000, - "label": "1000-1200 mm", - "color": "#0083f3" - }, - { - "value": 1200, - "label": "1200-1400 mm", - "color": "#0052cd" - }, - { - "value": 1400, - "label": "1400-1600 mm", - "color": "#0000c8" - }, - { - "value": 1600, - "label": "1600-1800 mm", - "color": "#6003b8" - }, - { - "value": 1800, - "label": "1800-2000 mm", - "color": "#a002fa" - }, - { - "value": 2000, - "label": "2000-2400 mm", - "color": "#fa78fa" - }, - { - "value": 2400, - "label": "> 2400 mm", - "color": "#ffc4ee" - } - ] - }, - "rain_anomaly_1year": { - "title": "1-year rainfall anomaly", - "type": "wms", - "server_layer_name": "ryq_dekad", - "additional_query_params": { - "styles": "ryq_14_50_200" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "1-year precipitation anomaly compared to the long term average. Derived from [CHIRPS (UCSB Climate Hazards Group)](https://www.chc.ucsb.edu/data/chirps).", - "legend": [ - { - "value": 0, - "label": "< 50%", - "color": "#8c4800" - }, - { - "value": 50, - "label": "50-60%", - "color": "#af6b27" - }, - { - "value": 60, - "label": "60-70%", - "color": "#d58c3e" - }, - { - "value": 70, - "label": "70-80%", - "color": "#eaa83d" - }, - { - "value": 80, - "label": "80-90%", - "color": "#f5c878" - }, - { - "value": 90, - "label": "90-95%", - "color": "#fff0c4" - }, - { - "value": 95, - "label": "95-105%", - "color": "#fafafa" - }, - { - "value": 105, - "label": "105-110%", - "color": "#befafa" - }, - { - "value": 110, - "label": "110-120%", - "color": "#78e2f0" - }, - { - "value": 120, - "label": "120-130%", - "color": "#00b9de" - }, - { - "value": 130, - "label": "130-150%", - "color": "#0083f3" - }, - { - "value": 150, - "label": "150-170%", - "color": "#0052cd" - }, - { - "value": 170, - "label": "170-200%", - "color": "#0000c8" - }, - { - "value": 200, - "label": "> 200%", - "color": "#a002fa" - } - ] - }, - "days_dry": { - "title": "Days since last rain", - "type": "wms", - "server_layer_name": "dlc_dekad", - "additional_query_params": { - "styles": "dlx_13_0_26" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "Number of consecutive days with less than 2 mm precipitation in the last 30 days", - "legend": [ - { - "value": 0, - "label": "None", - "color": "#6c9fa4" - }, - { - "value": 4, - "label": "1-4 Days", - "color": "#57bec1" - }, - { - "value": 6, - "label": "5-6 Days", - "color": "#aee0c4" - }, - { - "value": 8, - "label": "7-8 Days", - "color": "#dcf1b2" - }, - { - "value": 10, - "label": "9-10 Days", - "color": "#ffffbf" - }, - { - "value": 12, - "label": "11-12 Days", - "color": "#ffeebd" - }, - { - "value": 14, - "label": "13-14 Days", - "color": "#ffec81" - }, - { - "value": 16, - "label": "15-16 Days", - "color": "#fed380" - }, - { - "value": 18, - "label": "17-18 Days", - "color": "#fec754" - }, - { - "value": 20, - "label": "19-20 Days", - "color": "#f5af28" - }, - { - "value": 22, - "label": "21-22 Days", - "color": "#d79b0b" - }, - { - "value": 26, - "label": "23-26 Days", - "color": "#c98a4b" - }, - { - "value": 27, - "label": "> 26 Days", - "color": "#aa5a00" - } - ] - }, - "streak_dry_days": { - "title": "Longest number of consecutive dry days", - "type": "wms", - "server_layer_name": "dlx_dekad", - "additional_query_params": { - "styles": "dlx_13_0_26" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "Longest number of consecutive days with less than 2 mm precipitation in the last 30 days. Derived from [CHIRPS (UCSB Climate Hazards Group)](https://www.chc.ucsb.edu/data/chirps).", - "legend": [ - { - "value": 0, - "label": "None", - "color": "#6c9fa4" - }, - { - "value": 4, - "label": "1-4 Days", - "color": "#57bec1" - }, - { - "value": 6, - "label": "5-6 Days", - "color": "#aee0c4" - }, - { - "value": 8, - "label": "7-8 Days", - "color": "#dcf1b2" - }, - { - "value": 10, - "label": "9-10 Days", - "color": "#ffffbf" - }, - { - "value": 12, - "label": "11-12 Days", - "color": "#ffeebd" - }, - { - "value": 14, - "label": "13-14 Days", - "color": "#ffec81" - }, - { - "value": 16, - "label": "15-16 Days", - "color": "#fed380" - }, - { - "value": 18, - "label": "17-18 Days", - "color": "#fec754" - }, - { - "value": 20, - "label": "19-20 Days", - "color": "#f5af28" - }, - { - "value": 22, - "label": "21-22 Days", - "color": "#d79b0b" - }, - { - "value": 26, - "label": "23-26 Days", - "color": "#c98a4b" - }, - { - "value": 27, - "label": "> 26 Days", - "color": "#aa5a00" - } - ] - }, - "days_heavy_rain": { - "title": "Number of days with heavy rainfall in the last 30 days", - "type": "wms", - "server_layer_name": "xnh_dekad", - "additional_query_params": { - "styles": "xnhie_12_0_14" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "Total number of heavy rain days (rainfall > 75th percentile) within last 30 days of dekad. Derived from [CHIRPS (UCSB Climate Hazards Group)](https://www.chc.ucsb.edu/data/chirps).", - "legend": [ - { - "value": 0, - "label": "None", - "color": "#fafafa" - }, - { - "value": 1, - "label": "1 Day", - "color": "#d3f9d0" - }, - { - "value": 2, - "label": "2 Days", - "color": "#a9e4a3" - }, - { - "value": 3, - "label": "3 Days", - "color": "#5eab91" - }, - { - "value": 4, - "label": "4 Days", - "color": "#9fffe8" - }, - { - "value": 5, - "label": "5 Days", - "color": "#90e0ef" - }, - { - "value": 6, - "label": "6 Days", - "color": "#00b1de" - }, - { - "value": 8, - "label": "7-8 Days", - "color": "#0083f3" - }, - { - "value": 10, - "label": "9-10 Days", - "color": "#0052cd" - }, - { - "value": 12, - "label": "11-12 Days", - "color": "#0031ac" - }, - { - "value": 14, - "label": "13-14 Days", - "color": "#a002fa" - }, - { - "value": 15, - "label": "> 14 Days", - "color": "#ffc4ee" - } - ] - }, - "days_intense_rain": { - "title": "Number of days with intense rainfall in the last 30 days", - "type": "wms", - "server_layer_name": "xni_dekad", - "additional_query_params": { - "styles": "xnhie_12_0_14" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "Total number of heavy rain days (rainfall > 90th percentile) within last 30 days of dekad", - "legend": [ - { - "value": 0, - "label": "None", - "color": "#fafafa" - }, - { - "value": 1, - "label": "1 Day", - "color": "#d3f9d0" - }, - { - "value": 2, - "label": "2 Days", - "color": "#a9e4a3" - }, - { - "value": 3, - "label": "3 Days", - "color": "#5eab91" - }, - { - "value": 4, - "label": "4 Days", - "color": "#9fffe8" - }, - { - "value": 5, - "label": "5 Days", - "color": "#90e0ef" - }, - { - "value": 6, - "label": "6 Days", - "color": "#00b1de" - }, - { - "value": 8, - "label": "7-8 Days", - "color": "#0083f3" - }, - { - "value": 10, - "label": "9-10 Days", - "color": "#0052cd" - }, - { - "value": 12, - "label": "11-12 Days", - "color": "#0031ac" - }, - { - "value": 14, - "label": "13-14 Days", - "color": "#a002fa" - }, - { - "value": 15, - "label": "> 14 Days", - "color": "#ffc4ee" - } - ] - }, - "days_extreme_rain": { - "title": "Number of days with extreme rainfall in the last 30 days", - "type": "wms", - "server_layer_name": "xne_dekad", - "additional_query_params": { - "styles": "xnhie_12_0_14" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "Total number of heavy rain days (rainfall > 95th percentile) within last 30 days of dekad", - "legend": [ - { - "value": 0, - "label": "None", - "color": "#fafafa" - }, - { - "value": 1, - "label": "1 Day", - "color": "#d3f9d0" - }, - { - "value": 2, - "label": "2 Days", - "color": "#a9e4a3" - }, - { - "value": 3, - "label": "3 Days", - "color": "#5eab91" - }, - { - "value": 4, - "label": "4 Days", - "color": "#9fffe8" - }, - { - "value": 5, - "label": "5 Days", - "color": "#90e0ef" - }, - { - "value": 6, - "label": "6 Days", - "color": "#00b1de" - }, - { - "value": 8, - "label": "7-8 Days", - "color": "#0083f3" - }, - { - "value": 10, - "label": "9-10 Days", - "color": "#0052cd" - }, - { - "value": 12, - "label": "11-12 Days", - "color": "#0031ac" - }, - { - "value": 14, - "label": "13-14 Days", - "color": "#a002fa" - }, - { - "value": 15, - "label": "> 14 Days", - "color": "#ffc4ee" - } - ] - }, - "streak_heavy_rain": { - "title": "Longest consecutive number of days with heavy rainfall in the last 30 days", - "type": "wms", - "server_layer_name": "xlh_dekad", - "additional_query_params": { - "styles": "xnhie_12_0_14" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "Longest consecutive number of heavy rain days (rainfall > 75th percentile) within last 30 days of dekad. Derived from [CHIRPS (UCSB Climate Hazards Group)](https://www.chc.ucsb.edu/data/chirps).", - "legend": [ - { - "value": 0, - "label": "None", - "color": "#fafafa" - }, - { - "value": 1, - "label": "1 Day", - "color": "#d3f9d0" - }, - { - "value": 2, - "label": "2 Days", - "color": "#a9e4a3" - }, - { - "value": 3, - "label": "3 Days", - "color": "#5eab91" - }, - { - "value": 4, - "label": "4 Days", - "color": "#9fffe8" - }, - { - "value": 5, - "label": "5 Days", - "color": "#90e0ef" - }, - { - "value": 6, - "label": "6 Days", - "color": "#00b1de" - }, - { - "value": 8, - "label": "7-8 Days", - "color": "#0083f3" - }, - { - "value": 10, - "label": "9-10 Days", - "color": "#0052cd" - }, - { - "value": 12, - "label": "11-12 Days", - "color": "#0031ac" - }, - { - "value": 14, - "label": "13-14 Days", - "color": "#a002fa" - }, - { - "value": 15, - "label": "> 14 Days", - "color": "#ffc4ee" - } - ] - }, - "streak_intense_rain": { - "title": "Longest consecutive intense rainfall days", - "type": "wms", - "server_layer_name": "xli_dekad", - "additional_query_params": { - "styles": "xnhie_12_0_14" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "Longest consecutive number of intense rain days (rainfall > 90th percentile) within last 30 days of dekad", - "legend": [ - { - "value": 0, - "label": "None", - "color": "#fafafa" - }, - { - "value": 1, - "label": "1 Day", - "color": "#d3f9d0" - }, - { - "value": 2, - "label": "2 Days", - "color": "#a9e4a3" - }, - { - "value": 3, - "label": "3 Days", - "color": "#5eab91" - }, - { - "value": 4, - "label": "4 Days", - "color": "#9fffe8" - }, - { - "value": 5, - "label": "5 Days", - "color": "#90e0ef" - }, - { - "value": 6, - "label": "6 Days", - "color": "#00b1de" - }, - { - "value": 8, - "label": "7-8 Days", - "color": "#0083f3" - }, - { - "value": 10, - "label": "9-10 Days", - "color": "#0052cd" - }, - { - "value": 12, - "label": "11-12 Days", - "color": "#0031ac" - }, - { - "value": 14, - "label": "13-14 Days", - "color": "#a002fa" - }, - { - "value": 15, - "label": "> 14 Days", - "color": "#ffc4ee" - } - ] - }, - "streak_extreme_rain": { - "title": "Longest consecutive extreme rainfall days", - "type": "wms", - "server_layer_name": "xle_dekad", - "additional_query_params": { - "styles": "xnhie_12_0_14" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "Longest consecutive number of extreme rain days (rainfall > 95th percentile) within last 30 days of dekad", - "legend": [ - { - "value": 0, - "label": "None", - "color": "#fafafa" - }, - { - "value": 1, - "label": "1 Day", - "color": "#d3f9d0" - }, - { - "value": 2, - "label": "2 Days", - "color": "#a9e4a3" - }, - { - "value": 3, - "label": "3 Days", - "color": "#5eab91" - }, - { - "value": 4, - "label": "4 Days", - "color": "#9fffe8" - }, - { - "value": 5, - "label": "5 Days", - "color": "#90e0ef" - }, - { - "value": 6, - "label": "6 Days", - "color": "#00b1de" - }, - { - "value": 8, - "label": "7-8 Days", - "color": "#0083f3" - }, - { - "value": 10, - "label": "9-10 Days", - "color": "#0052cd" - }, - { - "value": 12, - "label": "11-12 Days", - "color": "#0031ac" - }, - { - "value": 14, - "label": "13-14 Days", - "color": "#a002fa" - }, - { - "value": 15, - "label": "> 14 Days", - "color": "#ffc4ee" - } - ] - }, - "ndvi_dekad": { - "title": "10-day NDVI (MODIS)", - "type": "wms", - "server_layer_name": "mxd13a2_vim_dekad", - "additional_query_params": { - "styles": "vim_14_01_09" - }, - "chart_data": { - "fields": [ - { - "key": "vim", - "label": "NDVI", - "color": "#4eac5b" - }, - { - "key": "vim_avg", - "label": "Average", - "color": "#99ff99" - } - ], - "levels": [ - { - "level": "1", - "id": "dataviz_adm1_id", - "name": "admin1Name" - }, - { - "level": "2", - "id": "dataviz_adm2_id", - "name": "admin2Name" - } - ], - "type": "line" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "wcsConfig": { - "scale": 0.0001, - "offset": 0, - "pixelResolution": 64 - }, - "opacity": 0.7, - "legend_text": "Normalized Difference Vegetation Index (NDVI) derived from MODIS TERRA/AQUA", - "legend": [ - { - "value": 0, - "label": "< 0.10", - "color": "#fffae6" - }, - { - "value": 0.1, - "label": "0.10 - 0.15", - "color": "#fff0be" - }, - { - "value": 0.15, - "label": "0.15 - 0.20", - "color": "#dae3a1" - }, - { - "value": 0.2, - "label": "0.20 - 0.25", - "color": "#ccea83" - }, - { - "value": 0.25, - "label": "0.25 - 0.30", - "color": "#cbff1f" - }, - { - "value": 0.3, - "label": "0.30 - 0.35", - "color": "#86cb66" - }, - { - "value": 0.35, - "label": "0.35 - 0.40", - "color": "#2da155" - }, - { - "value": 0.4, - "label": "0.40 - 0.50", - "color": "#009600" - }, - { - "value": 0.5, - "label": "0.50 - 0.60", - "color": "#006400" - }, - { - "value": 0.6, - "label": "0.60 - 0.70", - "color": "#64a77e" - }, - { - "value": 0.7, - "label": "0.70 - 0.80", - "color": "#328968" - }, - { - "value": 0.8, - "label": "0.80 - 0.85", - "color": "#006b52" - }, - { - "value": 0.85, - "label": "0.85 - 0.90", - "color": "#004e33" - }, - { - "value": 0.9, - "label": "> 0.90", - "color": "#002a1e" - } - ] - }, - "ndvi_dekad_anomaly": { - "title": "10-day NDVI anomaly (MODIS)", - "type": "wms", - "server_layer_name": "mxd13a2_viq_dekad", - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "additional_query_params": { - "styles": "viq_13_50_150" - }, - "chart_data": { - "fields": [ - { - "key": "viq", - "label": "NDVI anomaly", - "color": "#5e803f" - }, - { - "key": "viq_avg", - "label": "Normal", - "color": "#eb3223", - "fallback": 100 - } - ], - "levels": [ - { - "level": "1", - "id": "dataviz_adm1_id", - "name": "admin1Name" - }, - { - "level": "2", - "id": "dataviz_adm2_id", - "name": "admin2Name" - } - ], - "type": "line" - }, - "opacity": 0.7, - "legend_text": "NDVI Anomaly compared to LTA", - "legend": [ - { - "value": 0, - "label": "< 50%", - "color": "#732600" - }, - { - "value": 50, - "label": "50-60%", - "color": "#d73027" - }, - { - "value": 60, - "label": "60-70%", - "color": "#f06405" - }, - { - "value": 70, - "label": "70-80%", - "color": "#fdae61" - }, - { - "value": 80, - "label": "80-90%", - "color": "#fed380" - }, - { - "value": 90, - "label": "90-95%", - "color": "#ffffbf" - }, - { - "value": 95, - "label": "95-105%", - "color": "#fafafa" - }, - { - "value": 105, - "label": "105-110%", - "color": "#cbff1f" - }, - { - "value": 110, - "label": "110-120%", - "color": "#00ff00" - }, - { - "value": 120, - "label": "120-130%", - "color": "#00c900" - }, - { - "value": 130, - "label": "130-140%", - "color": "#009600" - }, - { - "value": 140, - "label": "140-150%", - "color": "#006400" - }, - { - "value": 150, - "label": "> 150%", - "color": "#003200" - } - ] - }, - "lst_amplitude": { - "title": "Land Surface Temperature - 10-day Amplitude (MODIS)", - "type": "wms", - "server_layer_name": "myd11a2_taa_dekad", - "additional_query_params": { - "styles": "taa_21_1_48" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "wcsConfig": { - "scale": 0.02, - "offset": 0, - "pixelResolution": 64 - }, - "date_interval": "days", - "opacity": 0.7, - "legend_text": "Land Surface Temperature Amplitude refers to the difference between the maximum and minimum temperature in degrees Celsius", - "legend": [ - { - "value": 1, - "label": "< 1C", - "color": "#05284b" - }, - { - "value": 50, - "label": "1C to 2C", - "color": "#0031ac" - }, - { - "value": 100, - "label": "2C to 3C", - "color": "#0564c3" - }, - { - "value": 150, - "label": "3C to 4C", - "color": "#1d8dbe" - }, - { - "value": 200, - "label": "4C to 5C", - "color": "#57bec1" - }, - { - "value": 250, - "label": "5C to 6C", - "color": "#004231" - }, - { - "value": 300, - "label": "6C to 8C", - "color": "#006b52" - }, - { - "value": 400, - "label": "8C to 10C", - "color": "#64a77e" - }, - { - "value": 500, - "label": "10C to 12C", - "color": "#86cb66" - }, - { - "value": 600, - "label": "12C to 14C", - "color": "#ccea83" - }, - { - "value": 700, - "label": "14C to 16C", - "color": "#dcf1b2" - }, - { - "value": 800, - "label": "16C to 18C", - "color": "#ffffbf" - }, - { - "value": 900, - "label": "18C to 20C", - "color": "#ffeebd" - }, - { - "value": 1000, - "label": "20C to 24C", - "color": "#ffec81" - }, - { - "value": 1200, - "label": "24C to 28C", - "color": "#fed380" - }, - { - "value": 1400, - "label": "28C to 32C", - "color": "#fec754" - }, - { - "value": 1600, - "label": "32C to 36C", - "color": "#f5af28" - }, - { - "value": 1800, - "label": "36C to 40C", - "color": "#d79b0b" - }, - { - "value": 2000, - "label": "40C to 44C", - "color": "#d5a45f" - }, - { - "value": 2200, - "label": "44C to 48C", - "color": "#bf7f2f" - }, - { - "value": 2400, - "label": "> +48C", - "color": "#aa5a00" - } - ] - }, - "lst_daytime": { - "title": "Daytime Land Surface Temperature - 10-day (MODIS)", - "type": "wms", - "server_layer_name": "myd11a2_txa_dekad", - "additional_query_params": { - "styles": "tda_42_n24_70" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "wcsConfig": { - "scale": 0.02, - "offset": -273, - "pixelResolution": 64 - }, - "opacity": 0.7, - "legend_text": "Daytime land surface temperature", - "legend": [ - { - "value": 20, - "label": "20C - 22C", - "color": "#57bec1" - }, - { - "value": 22, - "label": "22C - 24C", - "color": "#85cfba" - }, - { - "value": 24, - "label": "24C - 26C", - "color": "#aee0c4" - }, - { - "value": 26, - "label": "26C - 28C", - "color": "#bbe4b5" - }, - { - "value": 28, - "label": "28C - 30C", - "color": "#dcf1b2" - }, - { - "value": 30, - "label": "30C - 32C", - "color": "#e8ffde" - }, - { - "value": 32, - "label": "32C - 34C", - "color": "#f2fabc" - }, - { - "value": 34, - "label": "34C - 36C", - "color": "#ffffbf" - }, - { - "value": 36, - "label": "36C - 38C", - "color": "#ffec81" - }, - { - "value": 38, - "label": "38C - 40C", - "color": "#fed380" - }, - { - "value": 40, - "label": "40C - 42C", - "color": "#f5af28" - }, - { - "value": 42, - "label": "42C - 44C", - "color": "#eac98e" - }, - { - "value": 44, - "label": "44C - 46C", - "color": "#d5a45f" - }, - { - "value": 46, - "label": "46C - 48C", - "color": "#bf7f2f" - }, - { - "value": 48, - "label": "48C - 50C", - "color": "#f88d52" - }, - { - "value": 50, - "label": "50C - 52C", - "color": "#f06405" - }, - { - "value": 52, - "label": "52C - 54C", - "color": "#de3f2e" - }, - { - "value": 54, - "label": "54C - 56C", - "color": "#cb181d" - }, - { - "value": 56, - "label": "56C - 58C", - "color": "#a50026" - }, - { - "value": 58, - "label": "58C - 60C", - "color": "#ad3a00" - } - ] - }, - "lst_nighttime": { - "title": "Nighttime Land Surface Temperature - 10-day (MODIS)", - "type": "wms", - "server_layer_name": "myd11a2_txa_dekad", - "additional_query_params": { - "styles": "tna_42_n24_70" - }, - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "wcsConfig": { - "scale": 0.02, - "offset": -273, - "pixelResolution": 64 - }, - "opacity": 0.7, - "legend_text": "Nighttime land surface temperature", - "legend": [ - { - "value": 0, - "label": "0C - 2C", - "color": "#1d2e83" - }, - { - "value": 2, - "label": "2C - 4C", - "color": "#24479d" - }, - { - "value": 4, - "label": "4C - 6C", - "color": "#2166ac" - }, - { - "value": 6, - "label": "6C - 8C", - "color": "#0564c3" - }, - { - "value": 8, - "label": "8C - 10C", - "color": "#1d8dbe" - }, - { - "value": 10, - "label": "10C - 12C", - "color": "#34a9c3" - }, - { - "value": 12, - "label": "12C - 14C", - "color": "#005867" - }, - { - "value": 14, - "label": "14C - 16C", - "color": "#378a95" - }, - { - "value": 16, - "label": "16C - 18C", - "color": "#6c9fa4" - }, - { - "value": 18, - "label": "18C - 20C", - "color": "#7ab2b9" - }, - { - "value": 20, - "label": "20C - 22C", - "color": "#57bec1" - }, - { - "value": 22, - "label": "22C - 24C", - "color": "#85cfba" - }, - { - "value": 24, - "label": "24C - 26C", - "color": "#aee0c4" - }, - { - "value": 26, - "label": "26C - 28C", - "color": "#bbe4b5" - }, - { - "value": 28, - "label": "28C - 30C", - "color": "#dcf1b2" - }, - { - "value": 30, - "label": "30C - 32C", - "color": "#e8ffde" - }, - { - "value": 32, - "label": "32C - 34C", - "color": "#f2fabc" - }, - { - "value": 34, - "label": "34C - 36C", - "color": "#ffffbf" - } - ] + "label": "Rainfall anomaly", + "color": "#375692" + }, + { + "key": "rfq_avg", + "label": "Normal", + "fallback": 100, + "color": "#eb3223" + } + ], + "levels": [ + { + "level": "1", + "id": "dataviz_adm1_id", + "name": "admin1Name" + }, + { + "level": "2", + "id": "dataviz_adm2_id", + "name": "admin2Name" + } + ], + "type": "line" + } }, - "lst_anomaly": { - "title": "Land Surface Temperature - 10-day Anomaly (MODIS)", - "type": "wms", - "server_layer_name": "myd11a2_txd_dekad", - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "additional_query_params": { - "styles": "tdd_21_m12_12" - }, - "legend_text": "Daytime land surface temperature anomaly", - "legend": [ - { - "value": -100, - "label": "< -12C", - "color": "#05284b" - }, - { - "value": -12, - "label": "-12C to -10C", - "color": "#1d2e83" - }, - { - "value": -10, - "label": "-10C to -8C", - "color": "#24479d" - }, - { - "value": -8, - "label": "-8C to -7C", - "color": "#2166ac" - }, - { - "value": -7, - "label": "-7C to -6C", - "color": "#1d8dbe" - }, - { - "value": -6, - "label": "-6C to -5C", - "color": "#34a9c3" - }, - { - "value": -5, - "label": "-5C to -4C", - "color": "#6cb4de" - }, - { - "value": -4, - "label": "-4C to -3C", - "color": "#7ecae7" - }, - { - "value": -3, - "label": "-3C to -2C", - "color": "#90e0ef" - }, - { - "value": -2, - "label": "-2C to -1C", - "color": "#c3f6ff" - }, - { - "value": -1, - "label": "-1C to +1C", - "color": "#fafafa" - }, - { - "value": 1, - "label": "+1C to +2C", - "color": "#fddbc7" - }, - { - "value": 2, - "label": "+2C to +3C", - "color": "#fcbba1" - }, - { - "value": 3, - "label": "+3C to +4C", - "color": "#fc9272" - }, - { - "value": 4, - "label": "+4C to +5C", - "color": "#fb6a4a" - }, - { - "value": 5, - "label": "+5C to +6C", - "color": "#ef3b2c" - }, - { - "value": 6, - "label": "+6C to +7C", - "color": "#d73027" - }, - { - "value": 7, - "label": "+7C to +8C", - "color": "#cb181d" - }, - { - "value": 8, - "label": "+8C to +10C", - "color": "#b2182b" - }, - { - "value": 10, - "label": "+10C to +12C", - "color": "#a50026" - }, - { - "value": 12, - "label": "> +12C", - "color": "#67000d" - } - ] + "ndvi_dekad": { + "chart_data": { + "fields": [ + { + "key": "vim", + "label": "NDVI", + "color": "#4eac5b" + }, + { + "key": "vim_avg", + "label": "Average", + "color": "#99ff99" + } + ], + "levels": [ + { + "level": "1", + "id": "dataviz_adm1_id", + "name": "admin1Name" + }, + { + "level": "2", + "id": "dataviz_adm2_id", + "name": "admin2Name" + } + ], + "type": "line" + } + }, + "ndvi_dekad_anomaly": { + "chart_data": { + "fields": [ + { + "key": "viq", + "label": "NDVI anomaly", + "color": "#5e803f" + }, + { + "key": "viq_avg", + "label": "Normal", + "color": "#eb3223", + "fallback": 100 + } + ], + "levels": [ + { + "level": "1", + "id": "dataviz_adm1_id", + "name": "admin1Name" + }, + { + "level": "2", + "id": "dataviz_adm2_id", + "name": "admin2Name" + } + ], + "type": "line" + } }, "male_unemployment": { "title": "Male unemployment", @@ -4424,280 +1776,5 @@ "start_date": "2020-12-01", "end_date": "2021-07-31", "opacity": 0.7 - }, - "daily_rainfall_forecast": { - "title": "Rolling daily rainfall forecast", - "type": "wms", - "start_date": "today", - "server_layer_name": "rfh_daily_forecast", - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "additional_query_params": { - "styles": "rfh_16_0_300" - }, - "opacity": 0.7, - "legend_text": "CHIRPS-GEFS daily forecasts (16-day rolling)", - "legend": [ - { - "value": 0, - "label": "0 mm", - "color": "#fafafa" - }, - { - "value": 0.01, - "label": "1-2 mm", - "color": "#fffadf" - }, - { - "value": 2, - "label": "2-5 mm", - "color": "#d3f9d0" - }, - { - "value": 5, - "label": "5-10 mm", - "color": "#a9e4a3" - }, - { - "value": 10, - "label": "10-20 mm", - "color": "#7cc594" - }, - { - "value": 20, - "label": "20-30 mm", - "color": "#5eab91" - }, - { - "value": 30, - "label": "30-40 mm", - "color": "#9fffe8" - }, - { - "value": 40, - "label": "40-50 mm", - "color": "#90e0ef" - }, - { - "value": 50, - "label": "50-60 mm", - "color": "#00b1de" - }, - { - "value": 60, - "label": "60-80 mm", - "color": "#0083f3" - }, - { - "value": 80, - "label": "80-100 mm", - "color": "#0052cd" - }, - { - "value": 100, - "label": "100-120 mm", - "color": "#0000c8" - }, - { - "value": 120, - "label": "120-150 mm", - "color": "#6003b8" - }, - { - "value": 150, - "label": "150-200 mm", - "color": "#a002fa" - }, - { - "value": 200, - "label": "200-300 mm", - "color": "#fa78fa" - }, - { - "value": 300, - "label": ">= 300 mm", - "color": "#ffc4ee" - } - ] - }, - "dekad_rainfall_forecast": { - "title": "10-day rainfall forecast", - "type": "wms", - "server_layer_name": "rfh_dekad_forecast", - "start_date": "today", - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "additional_query_params": { - "styles": "rfh_16_0_300" - }, - "opacity": 0.7, - "legend_text": "CHIRPS-GEFS global dekadal rainfall forecasts", - "legend": [ - { - "value": 0, - "label": "0 mm", - "color": "#fafafa" - }, - { - "value": 0.01, - "label": "1-2 mm", - "color": "#fffadf" - }, - { - "value": 2, - "label": "2-5 mm", - "color": "#d3f9d0" - }, - { - "value": 5, - "label": "5-10 mm", - "color": "#a9e4a3" - }, - { - "value": 10, - "label": "10-20 mm", - "color": "#7cc594" - }, - { - "value": 20, - "label": "20-30 mm", - "color": "#5eab91" - }, - { - "value": 30, - "label": "30-40 mm", - "color": "#9fffe8" - }, - { - "value": 40, - "label": "40-50 mm", - "color": "#90e0ef" - }, - { - "value": 50, - "label": "50-60 mm", - "color": "#00b1de" - }, - { - "value": 60, - "label": "60-80 mm", - "color": "#0083f3" - }, - { - "value": 80, - "label": "80-100 mm", - "color": "#0052cd" - }, - { - "value": 100, - "label": "100-120 mm", - "color": "#0000c8" - }, - { - "value": 120, - "label": "120-150 mm", - "color": "#6003b8" - }, - { - "value": 150, - "label": "150-200 mm", - "color": "#a002fa" - }, - { - "value": 200, - "label": "200-300 mm", - "color": "#fa78fa" - }, - { - "value": 300, - "label": ">= 300 mm", - "color": "#ffc4ee" - } - ] - }, - "dekad_rainfall_anomaly_forecast": { - "title": "10-day rainfall forecast anomaly", - "type": "wms", - "server_layer_name": "rfq_dekad", - "additional_query_params": { - "styles": "rfq_14_20_400" - }, - "start_date": "today", - "base_url": "https://api.earthobservation.vam.wfp.org/ows/", - "date_interval": "days", - "opacity": 0.7, - "legend_text": "10-day forecast anomaly compared to the long term average. Derived from CHIRPS and GEFS", - "legend": [ - { - "value": 0, - "label": "< 20%", - "color": "#8c4800" - }, - { - "value": 20, - "label": "20-40%", - "color": "#af6b27" - }, - { - "value": 40, - "label": "40-60%", - "color": "#d58c3e" - }, - { - "value": 60, - "label": "60-70%", - "color": "#eaa83d" - }, - { - "value": 70, - "label": "70-80%", - "color": "#f5c878" - }, - { - "value": 80, - "label": "80-90%", - "color": "#fff0c4" - }, - { - "value": 90, - "label": "90-110%", - "color": "#fafafa" - }, - { - "value": 110, - "label": "110-120%", - "color": "#befafa" - }, - { - "value": 120, - "label": "120-130%", - "color": "#78e2f0" - }, - { - "value": 130, - "label": "130-150%", - "color": "#00b9de" - }, - { - "value": 150, - "label": "150-200%", - "color": "#0083f3" - }, - { - "value": 200, - "label": "200-300%", - "color": "#0052cd" - }, - { - "value": 300, - "label": "300-400%", - "color": "#0000c8" - }, - { - "value": 400, - "label": "> 400%", - "color": "#a002fa" - } - ] } } \ No newline at end of file From 07afa32a99db873daafb685b950e0b1026bb0df6 Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:27:33 -0700 Subject: [PATCH 11/30] Accomodate leap years in constructDateFromSeason --- frontend/src/utils/date-utils.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/utils/date-utils.ts b/frontend/src/utils/date-utils.ts index ce5516d48..8f5055ac5 100644 --- a/frontend/src/utils/date-utils.ts +++ b/frontend/src/utils/date-utils.ts @@ -7,7 +7,6 @@ export interface StartEndDate { } const millisecondsInADay = 24 * 60 * 60 * 1000; -const millisecondsInAYear = 365 * millisecondsInADay; export const dateWithoutTime = (date: number | Date): number => { const cleanDate = date instanceof Date ? date.getTime() : date; @@ -201,8 +200,12 @@ export const constructDateFromSeason = ( const endCurrentYear = new Date( `${date.getUTCFullYear()}-${season.end}T12:00:00Z`, ).getTime(); - const startPreviousYear = startCurrentYear - millisecondsInAYear; - const endNextYear = endCurrentYear + millisecondsInAYear; + const startPreviousYear = new Date( + `${date.getUTCFullYear() - 1}-${season.start}T12:00:00Z`, + ).getTime(); + const endNextYear = new Date( + `${date.getUTCFullYear() + 1}-${season.end}T12:00:00Z`, + ).getTime(); // eslint-disable-next-line no-nested-ternary return endCurrentYear >= startCurrentYear From 67b8fe71d5f305dfb8975ba4a7cf0df8afd0083e Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:15:56 -0700 Subject: [PATCH 12/30] Adding hacky-ish expected data lag --- .../MapView/Layers/CompositeLayer/index.tsx | 5 +- frontend/src/config/jordan/layers.json | 4 + frontend/src/config/types.ts | 3 + frontend/src/utils/layers-utils.tsx | 105 ++++++++++++------ frontend/src/utils/useDefaultDate.ts | 23 +++- 5 files changed, 97 insertions(+), 43 deletions(-) diff --git a/frontend/src/components/MapView/Layers/CompositeLayer/index.tsx b/frontend/src/components/MapView/Layers/CompositeLayer/index.tsx index 6ba038e46..0e9476084 100644 --- a/frontend/src/components/MapView/Layers/CompositeLayer/index.tsx +++ b/frontend/src/components/MapView/Layers/CompositeLayer/index.tsx @@ -40,7 +40,10 @@ const paintProps: ( const CompositeLayer = memo(({ layer, before }: Props) => { // look to refacto with impactLayer and maybe other layers const [adminBoundaryLimitPolygon, setAdminBoundaryPolygon] = useState(null); - const selectedDate = useDefaultDate(layer.dateLayer); + const selectedDate = useDefaultDate( + layer.dateLayer, + layer.expectedDataLagDays, + ); const serverAvailableDates = useSelector(availableDatesSelector); const opacityState = useSelector(opacitySelector(layer.id)); const dispatch = useDispatch(); diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index 162d808f8..99085f8c5 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -1372,6 +1372,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_geojson", + "expected_data_lag_days": 55, "validity": { "forward": 1, "backward": 2, @@ -1471,6 +1472,7 @@ "type": "composite", "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_geojson", + "expected_data_lag_days": 55, "validity": { "mode": "season", "seasons": [ @@ -1586,6 +1588,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_geojson", + "expected_data_lag_days": 55, "validity": { "forward": 1, "backward": 2, @@ -1685,6 +1688,7 @@ "type": "composite", "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_geojson", + "expected_data_lag_days": 55, "validity": { "mode": "season" }, diff --git a/frontend/src/config/types.ts b/frontend/src/config/types.ts index b029086c2..1a058c676 100644 --- a/frontend/src/config/types.ts +++ b/frontend/src/config/types.ts @@ -502,6 +502,9 @@ export class CompositeLayerProps extends CommonLayerProps { @optional endDate?: string; + + @optional + expectedDataLagDays?: number; } export class StaticRasterLayerProps extends CommonLayerProps { diff --git a/frontend/src/utils/layers-utils.tsx b/frontend/src/utils/layers-utils.tsx index ad41d923a..99bb1d3b0 100644 --- a/frontend/src/utils/layers-utils.tsx +++ b/frontend/src/utils/layers-utils.tsx @@ -4,7 +4,13 @@ import { Extent, expandBoundingBox, } from 'components/MapView/Layers/raster-utils'; -import { LayerKey, LayerType, isMainLayer, DateItem } from 'config/types'; +import { + LayerKey, + LayerType, + isMainLayer, + DateItem, + CompositeLayerProps, +} from 'config/types'; import { AALayerId, LayerDefinitions, @@ -110,42 +116,56 @@ const useLayers = () => { 2, ) as Extent; - const selectedLayersWithDateSupport = useMemo( - () => - selectedLayers - .filter((layer): layer is DateCompatibleLayer => { - if ( - layer.type === 'admin_level_data' || - layer.type === 'static_raster' - ) { - return Boolean(layer.dates); - } - if (layer.type === 'point_data') { - // some WMS layer might not have date dimension (i.e. static data) - return Boolean(layer.dateUrl); - } - if (layer.type === 'wms') { - // some WMS layer might not have date dimension (i.e. static data) - return layer.id in serverAvailableDates; - } - if (layer.type === 'composite') { - // some WMS layer might not have date dimension (i.e. static data) - return ( - layer.id in serverAvailableDates || - layer.dateLayer in serverAvailableDates - ); - } - return dateSupportLayerTypes.includes(layer.type); - }) - .filter(layer => isMainLayer(layer.id, selectedLayers)) - .map(layer => ({ - ...layer, - dateItems: getPossibleDatesForLayer(layer, serverAvailableDates) - .filter(value => value) // null check - .flat(), - })), - [selectedLayers, serverAvailableDates], - ); + const selectedLayersWithDateSupport = useMemo(() => { + const initSelectedLayersWithDateSupport = selectedLayers + .filter((layer): layer is DateCompatibleLayer => { + if ( + layer.type === 'admin_level_data' || + layer.type === 'static_raster' + ) { + return Boolean(layer.dates); + } + if (layer.type === 'point_data') { + // some WMS layer might not have date dimension (i.e. static data) + return Boolean(layer.dateUrl); + } + if (layer.type === 'wms') { + // some WMS layer might not have date dimension (i.e. static data) + return layer.id in serverAvailableDates; + } + if (layer.type === 'composite') { + // some WMS layer might not have date dimension (i.e. static data) + return ( + layer.id in serverAvailableDates || + layer.dateLayer in serverAvailableDates + ); + } + return dateSupportLayerTypes.includes(layer.type); + }) + .filter(layer => isMainLayer(layer.id, selectedLayers)); + + const earliestExpectedDataLagDays = + initSelectedLayersWithDateSupport.reduce( + (acc, layer) => + Math.max( + acc, + (layer as CompositeLayerProps).expectedDataLagDays ?? 0, + ), + 0, + ); + + const soonestAvailableDate = + new Date().getTime() - + (earliestExpectedDataLagDays ?? 0) * 24 * 60 * 60 * 1000; + + return initSelectedLayersWithDateSupport.map(layer => ({ + ...layer, + dateItems: getPossibleDatesForLayer(layer, serverAvailableDates) + .filter(value => value) // null check + .filter(date => date.displayDate <= soonestAvailableDate) + .flat(), + })); + }, [selectedLayers, serverAvailableDates]); /* takes all the dates possible for every layer and counts the amount of times each one is duplicated. @@ -185,6 +205,16 @@ const useLayers = () => { if (selectedLayersWithDateSupport.length === 0) { return []; } + + const earliestExpectedDataLagDays = selectedLayersWithDateSupport.reduce( + (acc, layer) => + Math.max(acc, (layer as CompositeLayerProps).expectedDataLagDays ?? 0), + 0, + ); + const soonestAvailableDate = + new Date().getTime() - + (earliestExpectedDataLagDays ?? 0) * 24 * 60 * 60 * 1000; + const selectedNonAALayersWithDateSupport = selectedLayersWithDateSupport.filter( layer => layer.type !== 'anticipatory_action', @@ -201,6 +231,7 @@ const useLayers = () => { // convert back to number array after using YYYY-MM-DD strings in countBy ) .map(dateString => new Date(dateString).setUTCHours(12, 0, 0, 0)) + .filter(date => date <= soonestAvailableDate) .sort((a, b) => a - b); }, [selectedLayerDatesDupCount, selectedLayersWithDateSupport]); diff --git a/frontend/src/utils/useDefaultDate.ts b/frontend/src/utils/useDefaultDate.ts index 3133db400..ab30e9bd7 100644 --- a/frontend/src/utils/useDefaultDate.ts +++ b/frontend/src/utils/useDefaultDate.ts @@ -1,6 +1,6 @@ import { useDispatch, useSelector } from 'react-redux'; -import { useEffect } from 'react'; -import { isMainLayer, LayerKey } from 'config/types'; +import { useEffect, useMemo } from 'react'; +import { DateItem, isMainLayer, LayerKey } from 'config/types'; import { availableDatesSelector } from 'context/serverStateSlice'; import { dateRangeSelector, @@ -15,7 +15,10 @@ import { getFormattedDate } from './date-utils'; * Returns either the user selected date or the default date, dispatching it to the date picker beforehand. Can also return undefined if no default date is available. * @param availableDatesLookupKey key to lookup in AvailableDates */ -export function useDefaultDate(layerId: LayerKey): number | undefined { +export function useDefaultDate( + layerId: LayerKey, + expectedDataLagDays: number, +): number | undefined { const dispatch = useDispatch(); const selectedLayers = useSelector(layersSelector); // check layer without group or main layer in group @@ -26,9 +29,19 @@ export function useDefaultDate(layerId: LayerKey): number | undefined { // TODO - use getPossibleDatesForLayer const possibleDates = useSelector(availableDatesSelector)[layerId]; + const soonestAvailableDate = + new Date().getTime() - (expectedDataLagDays ?? 0) * 24 * 60 * 60 * 1000; - const defaultDate: number | undefined = - possibleDates?.[(possibleDates?.length || 0) - 1]?.displayDate; + const defaultDate = useMemo( + () => + possibleDates?.reduceRight((acc: number | undefined, date: DateItem) => { + if (!acc && date.displayDate <= soonestAvailableDate) { + return date.displayDate; + } + return acc; + }, undefined), + [possibleDates, soonestAvailableDate], + ); // React doesn't allow updating other components within another component // useEffect removes this error and updates DateSelector correctly in the lifecycle. From 200e675e32910474cd98ade94166d9b75977df24 Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:26:11 -0700 Subject: [PATCH 13/30] TS fix --- frontend/src/utils/useDefaultDate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/utils/useDefaultDate.ts b/frontend/src/utils/useDefaultDate.ts index ab30e9bd7..bc1d644f2 100644 --- a/frontend/src/utils/useDefaultDate.ts +++ b/frontend/src/utils/useDefaultDate.ts @@ -17,7 +17,7 @@ import { getFormattedDate } from './date-utils'; */ export function useDefaultDate( layerId: LayerKey, - expectedDataLagDays: number, + expectedDataLagDays?: number, ): number | undefined { const dispatch = useDispatch(); const selectedLayers = useSelector(layersSelector); From 4ac8b61585d14e8cd584dc443c9b6643f3825a46 Mon Sep 17 00:00:00 2001 From: Amit W Date: Wed, 7 Aug 2024 08:26:56 +0800 Subject: [PATCH 14/30] revert bbox --- frontend/src/config/jordan/prism.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/config/jordan/prism.json b/frontend/src/config/jordan/prism.json index 9f51eb1b6..bbd678bb8 100644 --- a/frontend/src/config/jordan/prism.json +++ b/frontend/src/config/jordan/prism.json @@ -16,7 +16,7 @@ "wms": ["https://api.earthobservation.vam.wfp.org/ows/wms"] }, "map": { - "boundingBox": [35.42, 29.36, 38.82, 33.16] + "boundingBox": [34.42, 28.36, 39.82, 34.16] }, "defaultDisplayBoundaries": [ "admin_boundaries", From 05a771994bb257f3e9666b90ec604275bc6f92c1 Mon Sep 17 00:00:00 2001 From: Amit W Date: Wed, 7 Aug 2024 14:22:49 +0800 Subject: [PATCH 15/30] update CDI date lag for demo --- frontend/src/config/jordan/layers.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index 99085f8c5..7955278bc 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -1372,7 +1372,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 55, + "expected_data_lag_days": 70, "validity": { "forward": 1, "backward": 2, @@ -1472,7 +1472,7 @@ "type": "composite", "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 55, + "expected_data_lag_days": 130, "validity": { "mode": "season", "seasons": [ @@ -1588,7 +1588,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 55, + "expected_data_lag_days": 70, "validity": { "forward": 1, "backward": 2, @@ -1688,7 +1688,7 @@ "type": "composite", "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 55, + "expected_data_lag_days": 130, "validity": { "mode": "season" }, From e141dd8891719e65702d6b0474f154e3ca64f857 Mon Sep 17 00:00:00 2001 From: Amit W Date: Wed, 7 Aug 2024 14:33:37 +0800 Subject: [PATCH 16/30] temporary arabic translations --- .../src/config/shared/translation/arabic.json | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/frontend/src/config/shared/translation/arabic.json b/frontend/src/config/shared/translation/arabic.json index 7d4ddd873..aa13c7113 100644 --- a/frontend/src/config/shared/translation/arabic.json +++ b/frontend/src/config/shared/translation/arabic.json @@ -114,5 +114,35 @@ "Land Surface Temperature Amplitude refers to the difference between the maximum and minimum temperature in degrees Celsius": "سعة درجة حرارة سطح الأرض تشير إلى الفرق بين درجة الحرارة العظمى والصغرى بالدرجات المئوية", "Nighttime Land Surface Temperature - 10-day (MODIS": "درجة حرارة سطح الأرض ليلاً - 10 أيام (MODIS", "Nighttime land surface temperature": "درجة حرارة سطح الأرض ليلا", - "Land Surface Temperature - 10-day Anomaly (MODIS)": "درجة حرارة سطح الأرض - انحراف لمدة 10 أيام (MODIS)" + "Land Surface Temperature - 10-day Anomaly (MODIS)": "درجة حرارة سطح الأرض - انحراف لمدة 10 أيام (MODIS)", + "Layers": "الطبقات", +"Charts": "المخططات", +"Analysis": "التحليل", +"About": "حول", +"Sensitivity": "الحساسية", +"Capacity": "السعة", +"Drought": "الجفاف", +"Area exposed": "المساحة المكشوفة", +"Authentication required": "المصادقة مطلوبة", +"The following layer requires authentication": "تتطلب الطبقة التالية المصادقة", +"Username": "اسم المستخدم", +"Password": "كلمة المرور", +"Send": "إرسال", +"Publication date": "تاريخ النشر", +"Map Options": "خيارات الخريطة", +"Title": "العنوان", +"Map Width": "عرض الخريطة", +"Map Labels": "تسميات الخريطة", +"Admin Areas": "مناطق الإدارة", +"Select admin area": "تحديد منطقة الإدارة", +"Position": "الموضع", +"Full Layer": "الطبقة الكاملة", +"Size": "الحجم", +"Footer": "التذييل", +"Jordan": "الأردن", +"Seasonal Combined Drought Index (v1)": "مؤشر الجفاف الموسمي المركب (الإصدار 1)", +"Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25": "مؤشر الجفاف المركب الإصدار 1. وزن مؤشر SPI = 0.5؛ وزن مؤشر LST = 0.25؛ وزن مؤشر الغطاء النباتي الطبيعي = 0.25", +"Opacity": "التعتيم", +"Remove layer": "إزالة الطبقة", +"Layer selection date": "تاريخ اختيار الطبقة" } \ No newline at end of file From c451b57631e62b00839e4b00e99a52b77eeb2e72 Mon Sep 17 00:00:00 2001 From: Amit W Date: Wed, 7 Aug 2024 14:38:04 +0800 Subject: [PATCH 17/30] additional temporary translations --- .../src/config/shared/translation/arabic.json | 82 ++++++++++++------- 1 file changed, 53 insertions(+), 29 deletions(-) diff --git a/frontend/src/config/shared/translation/arabic.json b/frontend/src/config/shared/translation/arabic.json index aa13c7113..7555b3e99 100644 --- a/frontend/src/config/shared/translation/arabic.json +++ b/frontend/src/config/shared/translation/arabic.json @@ -116,33 +116,57 @@ "Nighttime land surface temperature": "درجة حرارة سطح الأرض ليلا", "Land Surface Temperature - 10-day Anomaly (MODIS)": "درجة حرارة سطح الأرض - انحراف لمدة 10 أيام (MODIS)", "Layers": "الطبقات", -"Charts": "المخططات", -"Analysis": "التحليل", -"About": "حول", -"Sensitivity": "الحساسية", -"Capacity": "السعة", -"Drought": "الجفاف", -"Area exposed": "المساحة المكشوفة", -"Authentication required": "المصادقة مطلوبة", -"The following layer requires authentication": "تتطلب الطبقة التالية المصادقة", -"Username": "اسم المستخدم", -"Password": "كلمة المرور", -"Send": "إرسال", -"Publication date": "تاريخ النشر", -"Map Options": "خيارات الخريطة", -"Title": "العنوان", -"Map Width": "عرض الخريطة", -"Map Labels": "تسميات الخريطة", -"Admin Areas": "مناطق الإدارة", -"Select admin area": "تحديد منطقة الإدارة", -"Position": "الموضع", -"Full Layer": "الطبقة الكاملة", -"Size": "الحجم", -"Footer": "التذييل", -"Jordan": "الأردن", -"Seasonal Combined Drought Index (v1)": "مؤشر الجفاف الموسمي المركب (الإصدار 1)", -"Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25": "مؤشر الجفاف المركب الإصدار 1. وزن مؤشر SPI = 0.5؛ وزن مؤشر LST = 0.25؛ وزن مؤشر الغطاء النباتي الطبيعي = 0.25", -"Opacity": "التعتيم", -"Remove layer": "إزالة الطبقة", -"Layer selection date": "تاريخ اختيار الطبقة" + "Charts": "المخططات", + "Analysis": "التحليل", + "About": "حول", + "Sensitivity": "الحساسية", + "Capacity": "السعة", + "Drought": "الجفاف", + "Area exposed": "المساحة المكشوفة", + "Authentication required": "المصادقة مطلوبة", + "The following layer requires authentication": "تتطلب الطبقة التالية المصادقة", + "Username": "اسم المستخدم", + "Password": "كلمة المرور", + "Send": "إرسال", + "Publication date": "تاريخ النشر", + "Map Options": "خيارات الخريطة", + "Title": "العنوان", + "Map Width": "عرض الخريطة", + "Map Labels": "تسميات الخريطة", + "Admin Areas": "مناطق الإدارة", + "Select admin area": "تحديد منطقة الإدارة", + "Position": "الموضع", + "Full Layer": "الطبقة الكاملة", + "Size": "الحجم", + "Footer": "التذييل", + "Jordan": "الأردن", + "Seasonal Combined Drought Index (v1)": "مؤشر الجفاف الموسمي المركب (الإصدار 1)", + "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25": "مؤشر الجفاف المركب الإصدار 1. وزن مؤشر SPI = 0.5؛ وزن مؤشر LST = 0.25؛ وزن مؤشر الغطاء النباتي الطبيعي = 0.25", + "Opacity": "التعتيم", + "Remove layer": "إزالة الطبقة", + "Layer selection date": "تاريخ اختيار الطبقة", + "Forecasts": "التوقعات", + "Extreme Rain Events": "أحداث الأمطار الشديدة", + "Rolling daily rainfall forecast": "توقعات هطول الأمطار اليومية المستمرة", + "Download as GeoTIFF": "التنزيل بتنسيق GeoTIFF", + "Download QML Style": "التنزيل بنمط QML", + "10-day rainfall forecast": "توقعات هطول الأمطار لمدة 10 أيام", + "10-day rainfall forecast anomaly": "شذوذ توقعات هطول الأمطار لمدة 10 أيام", + "Rainfall categories": "فئات هطول الأمطار", + "Heavy (>75th percentile)": "غزيرة (>75%)", + "Intense (>90th percentile)": "كثيفة (>90%)", + "Extreme (>95th percentile)": "شديدة (>95%)", + "Consecutive days of rainfall": "أيام متتالية من هطول الأمطار", + "Demographics": "التركيبة السكانية", + "Agriculture": "الزراعة", + "Socioeconomic": "الاجتماعية والاقتصادية", + "Natural Resources": "الموارد الطبيعية", + "Water": "المياه", + "Adaptation": "التكيف", + "Combined Drought Index": "مؤشر الجفاف المشترك", + "Combined Drought Index v1": "مؤشر الجفاف المشترك الإصدار 1", + "Monthly": "شهري", + "Seasonal": "موسمي", + "Combined Drought Index v2": "مؤشر الجفاف المشترك الإصدار 2", + "Active Layer(s)": "الطبقة(الطبقات) النشطة" } \ No newline at end of file From f55e9a0c5639e27ed5078ce0e322c35ecca3fd11 Mon Sep 17 00:00:00 2001 From: Amit W Date: Wed, 7 Aug 2024 16:55:25 +0800 Subject: [PATCH 18/30] remove forecast layers There's a bug between the date fix in the CDI and the date restriction for forecasts. Removing forecasts for the purpose of this demo --- frontend/src/config/jordan/prism.json | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/config/jordan/prism.json b/frontend/src/config/jordan/prism.json index bbd678bb8..8848b7888 100644 --- a/frontend/src/config/jordan/prism.json +++ b/frontend/src/config/jordan/prism.json @@ -25,7 +25,6 @@ ], "categories": { "rainfall": { - "forecasts": ["daily_rainfall_forecast", "dekad_rainfall_forecast", "dekad_rainfall_anomaly_forecast"], "rainfall_amount": [ { "group_title": "Rainfall Aggregate", From 8a951b76a4b935ebedaa27f960c58a3bd92fd95b Mon Sep 17 00:00:00 2001 From: Amit W Date: Mon, 16 Sep 2024 19:50:39 -0700 Subject: [PATCH 19/30] extend date lag and modify CDI params based on Sara's input --- frontend/src/config/jordan/layers.json | 32 +++++++++---------- frontend/src/context/layers/composite_data.ts | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index b56a90aba..791c52f5e 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -1372,7 +1372,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 70, + "expected_data_lag_days": 110, "validity": { "forward": 1, "backward": 2, @@ -1386,7 +1386,7 @@ "CHIRPS", "R1S_DEKAD" ], - "aggregation": "last_dekad" + "aggregation": "average" }, { "id": "lst_anomaly", @@ -1395,7 +1395,7 @@ "MODIS", "MYD11C2_TDD_DEKAD" ], - "aggregation": "last_dekad" + "aggregation": "average" }, { "id": "ndvi_dekad", @@ -1405,7 +1405,7 @@ "NDVI_smoothed_5KM" ], "aggregation": "average", - "invert": "True" + "invert": "False" } ], "legend": [ @@ -1472,7 +1472,7 @@ "type": "composite", "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 130, + "expected_data_lag_days": 180, "validity": { "mode": "season", "seasons": [ @@ -1494,7 +1494,7 @@ "CHIRPS", "R1S_DEKAD" ], - "aggregation": "last_dekad" + "aggregation": "average" }, { "id": "lst_anomaly", @@ -1503,7 +1503,7 @@ "MODIS", "MYD11C2_TDD_DEKAD" ], - "aggregation": "last_dekad" + "aggregation": "average" }, { "id": "ndvi_dekad", @@ -1513,7 +1513,7 @@ "NDVI_smoothed_5KM" ], "aggregation": "average", - "invert": "True" + "invert": "False" } ], "legend": [ @@ -1580,7 +1580,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 70, + "expected_data_lag_days": 110, "validity": { "forward": 1, "backward": 2, @@ -1594,7 +1594,7 @@ "CHIRPS", "R1S_DEKAD" ], - "aggregation": "last_dekad" + "aggregation": "average" }, { "id": "lst_anomaly", @@ -1603,7 +1603,7 @@ "MODIS", "MYD11C2_TDD_DEKAD" ], - "aggregation": "last_dekad" + "aggregation": "average" }, { "id": "ndvi_dekad", @@ -1613,7 +1613,7 @@ "NDVI_smoothed_5KM" ], "aggregation": "average", - "invert": "True" + "invert": "False" } ], "legend": [ @@ -1680,7 +1680,7 @@ "type": "composite", "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 130, + "expected_data_lag_days": 180, "validity": { "mode": "season", "seasons": [ @@ -1702,7 +1702,7 @@ "CHIRPS", "R1S_DEKAD" ], - "aggregation": "last_dekad" + "aggregation": "average" }, { "id": "lst_anomaly", @@ -1711,7 +1711,7 @@ "MODIS", "MYD11C2_TDD_DEKAD" ], - "aggregation": "last_dekad" + "aggregation": "average" }, { "id": "ndvi_dekad", @@ -1721,7 +1721,7 @@ "NDVI_smoothed_5KM" ], "aggregation": "average", - "invert": "True" + "invert": "False" } ], "legend": [ diff --git a/frontend/src/context/layers/composite_data.ts b/frontend/src/context/layers/composite_data.ts index 47dddea75..0a5162c86 100644 --- a/frontend/src/context/layers/composite_data.ts +++ b/frontend/src/context/layers/composite_data.ts @@ -64,7 +64,7 @@ export const fetchCompositeLayerData: LazyLoader = min_lat: boundingBox[1], max_lon: boundingBox[2], max_lat: boundingBox[3], - start_date: areaStartDate ?? '2002-01-01', + start_date: areaStartDate ?? '2002-07-01', end_date: areaEndDate ?? '2021-07-31', }, layers: inputLayers.map(({ key, aggregation, importance, invert }) => ({ From 6a012cf2c3db554ac12fabc3d0340e5a655c0985 Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:12:14 -0700 Subject: [PATCH 20/30] Initial aggregation layer for CDI. Only monthly v1 currently --- .../MapView/Layers/CompositeLayer/index.tsx | 133 +++++++++++++----- frontend/src/config/jordan/layers.json | 108 ++++++++++++++ frontend/src/config/jordan/prism.json | 1 + frontend/src/config/types.ts | 6 + frontend/src/context/layers/composite_data.ts | 21 ++- 5 files changed, 232 insertions(+), 37 deletions(-) diff --git a/frontend/src/components/MapView/Layers/CompositeLayer/index.tsx b/frontend/src/components/MapView/Layers/CompositeLayer/index.tsx index 6ba038e46..6542baaa2 100644 --- a/frontend/src/components/MapView/Layers/CompositeLayer/index.tsx +++ b/frontend/src/components/MapView/Layers/CompositeLayer/index.tsx @@ -1,11 +1,20 @@ -import { CompositeLayerProps, LegendDefinition } from 'config/types'; +import { + CompositeLayerProps, + LegendDefinition, + MapEventWrapFunctionProps, +} from 'config/types'; import { LayerData, loadLayerData } from 'context/layers/layer-data'; import { layerDataSelector } from 'context/mapStateSlice/selectors'; import { memo, useEffect, useMemo, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { Source, Layer } from 'react-map-gl/maplibre'; -import { getLayerMapId } from 'utils/map-utils'; -import { FillLayerSpecification } from 'maplibre-gl'; +import { + findFeature, + getEvtCoords, + getLayerMapId, + useMapCallback, +} from 'utils/map-utils'; +import { FillLayerSpecification, MapLayerMouseEvent } from 'maplibre-gl'; import { Point } from 'geojson'; import booleanPointInPolygon from '@turf/boolean-point-in-polygon'; import { availableDatesSelector } from 'context/serverStateSlice'; @@ -14,6 +23,7 @@ import { getRequestDateItem } from 'utils/server-utils'; import { safeCountry } from 'config'; import { geoToH3, h3ToGeoBoundary } from 'h3-js'; // ts-ignore import { opacitySelector } from 'context/opacityStateSlice'; +import { addPopupData } from 'context/tooltipStateSlice'; import { legendToStops } from '../layer-utils'; interface Props { @@ -40,6 +50,8 @@ const paintProps: ( const CompositeLayer = memo(({ layer, before }: Props) => { // look to refacto with impactLayer and maybe other layers const [adminBoundaryLimitPolygon, setAdminBoundaryPolygon] = useState(null); + const [aggregationBoundariesPolygon, setAggregationBoundariesPolygon] = + useState(null); const selectedDate = useDefaultDate(layer.dateLayer); const serverAvailableDates = useSelector(availableDatesSelector); const opacityState = useSelector(opacitySelector(layer.id)); @@ -68,47 +80,100 @@ const CompositeLayer = memo(({ layer, before }: Props) => { }, []); useEffect(() => { - if (requestDate) { + if (layer.aggregationBoundaryPath) { + fetch(layer.aggregationBoundaryPath) + .then(response => response.json()) + .then(polygonData => setAggregationBoundariesPolygon(polygonData)) + .catch(error => console.error('Error:', error)); + } + }, [layer.aggregationBoundaryPath]); + + useEffect(() => { + if ( + (requestDate && + layer.aggregationBoundaryPath && + aggregationBoundariesPolygon) || + !layer.aggregationBoundaryPath + ) { dispatch( loadLayerData({ layer, date: requestDate, availableDates: layerAvailableDates, + aggregationBoundariesPolygon, }), ); } - }, [dispatch, layer, layerAvailableDates, requestDate]); + }, [ + dispatch, + layer, + layerAvailableDates, + requestDate, + aggregationBoundariesPolygon, + ]); // Investigate performance impact of hexagons for large countries - const finalFeatures = - data && - data.features - .map(feature => { - const point = feature.geometry as Point; - if ( - !adminBoundaryLimitPolygon || - booleanPointInPolygon( - point.coordinates, - adminBoundaryLimitPolygon as any, - ) - ) { - // Convert the point to a hexagon - const hexagon = geoToH3( - point.coordinates[1], - point.coordinates[0], - 6, // resolution, adjust as needed - ); - return { - ...feature, - geometry: { - type: 'Polygon', - coordinates: [h3ToGeoBoundary(hexagon, true)], // Convert the hexagon to a GeoJSON polygon - }, - }; - } - return null; - }) - .filter(Boolean); + const finalFeatures = layer.aggregationBoundaryPath + ? data?.features + : !layer.aggregationBoundaryPath && + data && + data?.features + .map(feature => { + const point = feature.geometry as Point; + if ( + !adminBoundaryLimitPolygon || + booleanPointInPolygon( + point.coordinates, + adminBoundaryLimitPolygon as any, + ) + ) { + // Convert the point to a hexagon + const hexagon = geoToH3( + point.coordinates[1], + point.coordinates[0], + 6, // resolution, adjust as needed + ); + return { + ...feature, + geometry: { + type: 'Polygon', + coordinates: [h3ToGeoBoundary(hexagon, true)], // Convert the hexagon to a GeoJSON polygon + }, + }; + } + return null; + }) + .filter(Boolean); + + const layerId = getLayerMapId(layer.id); + + const onClick = + ({ + dispatch: providedDispatch, + }: MapEventWrapFunctionProps) => + (evt: MapLayerMouseEvent) => { + const coordinates = getEvtCoords(evt); + + const feature = findFeature(layerId, evt); + if (!feature) { + return; + } + + const popupData = { + [layer.title]: { + data: feature.properties.value.toFixed(3), + coordinates, + }, + }; + providedDispatch(addPopupData(popupData)); + }; + + useMapCallback<'click', CompositeLayerProps>( + 'click', + layerId, + layer, + onClick, + ); if (selectedDate && data && adminBoundaryLimitPolygon) { const filteredData = { diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index b78d95a7e..232ed7501 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -1367,6 +1367,114 @@ ], "legend_text": "Groundwater developed for irrigation (MCM) " }, + "cdi_v1_aggregated": { + "title": "Monthly Combined Drought Index Aggregated (v1)", + "type": "composite", + "period": "monthly", + "base_url": "http://127.0.0.1:8000/q_multi_aggregated", + "validity": { + "forward": 1, + "backward": 2, + "mode": "dekad" + }, + "feature_info_props": { + "value": { + "type": "number", + "dataTitle": "Event name" + } + }, + "input_layers": [ + { + "id": "spi_1m", + "importance": 0.5, + "key": [ + "CHIRPS", + "R1S_DEKAD" + ], + "aggregation": "last_dekad" + }, + { + "id": "lst_anomaly", + "importance": 0.25, + "key": [ + "MODIS", + "MYD11C2_TDD_DEKAD" + ], + "aggregation": "last_dekad" + }, + { + "id": "ndvi_dekad", + "importance": 0.25, + "key": [ + "MODIS", + "NDVI_smoothed_5KM" + ], + "aggregation": "average", + "invert": "True" + } + ], + "legend": [ + { + "value": 0, + "label": "0 - 0.1", + "color": "#672200" + }, + { + "value": 0.1, + "label": "0.1 - 0.2", + "color": "#a93800" + }, + { + "value": 0.2, + "label": "0.2 - 0.3", + "color": "#e59800" + }, + { + "value": 0.3, + "label": "0.3 - 0.4", + "color": "#ffe769" + }, + { + "value": 0.4, + "label": "0.4 - 0.5", + "color": "#f0f0f0" + }, + { + "value": 0.5, + "label": "0.5 - 0.6", + "color": "#f0f0f0" + }, + { + "value": 0.6, + "label": "0.6 - 0.7", + "color": "#a9c6d6" + }, + { + "value": 0.7, + "label": "0.7 - 0.8", + "color": "#019ac4" + }, + { + "value": 0.8, + "label": "0.8 - 0.9", + "color": "#014c73" + }, + { + "value": 0.9, + "label": "0.9 - 1", + "color": "#014c73" + } + ], + "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", + "aggregation": "pixel", + "aggregate_by": "mean", + "admin_code": "admin3Pcod", + "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", + "date_layer": "spi_1m", + "start_date": "2020-12-01", + "end_date": "2021-07-31", + "opacity": 0.7 + }, "cdi_v1_monthly": { "title": "Monthly Combined Drought Index (v1)", "type": "composite", diff --git a/frontend/src/config/jordan/prism.json b/frontend/src/config/jordan/prism.json index bbd678bb8..dd2a9d030 100644 --- a/frontend/src/config/jordan/prism.json +++ b/frontend/src/config/jordan/prism.json @@ -212,6 +212,7 @@ }, "drought": { "combined_drought_index": [ + "cdi_v1_aggregated", { "group_title": "Combined Drought Index v1:", "activate_all": false, diff --git a/frontend/src/config/types.ts b/frontend/src/config/types.ts index b029086c2..8d454ef90 100644 --- a/frontend/src/config/types.ts +++ b/frontend/src/config/types.ts @@ -502,6 +502,12 @@ export class CompositeLayerProps extends CommonLayerProps { @optional endDate?: string; + @optional + aggregateBy?: 'mean' | 'median' | 'max'; + @optional + aggregationBoundaryPath?: string; + @optional + adminCode?: number; } export class StaticRasterLayerProps extends CommonLayerProps { diff --git a/frontend/src/context/layers/composite_data.ts b/frontend/src/context/layers/composite_data.ts index 47dddea75..31c98f950 100644 --- a/frontend/src/context/layers/composite_data.ts +++ b/frontend/src/context/layers/composite_data.ts @@ -16,8 +16,14 @@ export interface CompositeLayerData extends FeatureCollection {} export const fetchCompositeLayerData: LazyLoader = () => - async (params: LayerDataParams, { dispatch }) => { - const { layer, date, availableDates } = params; + async ( + params: LayerDataParams< + CompositeLayerProps & { aggregationBoundariesPolygon?: string } + >, + { dispatch }, + ) => { + const { layer, date, availableDates, aggregationBoundariesPolygon } = + params; const referenceDate = date ? new Date(date) : new Date(); const providedSeasons = layer.validity?.seasons; @@ -55,7 +61,14 @@ export const fetchCompositeLayerData: LazyLoader = } = layer; const { boundingBox } = appConfig.map; - // docs: https://hip-service.ovio.org/docs#/default/run_q_multi_geojson_q_multi_geojson_post + const aggregationMaskParam = aggregationBoundariesPolygon + ? { aggregation_mask: aggregationBoundariesPolygon } + : {}; + + const aggregateByParam = layer.aggregateBy + ? { aggregate_by: layer.aggregateBy } + : {}; + const body = { begin: getFormattedDate(closestDateToStart, 'default'), end: getFormattedDate(closestDateToEnd, 'default'), @@ -73,6 +86,8 @@ export const fetchCompositeLayerData: LazyLoader = importance, invert: Boolean(invert), })), + ...aggregationMaskParam, + ...aggregateByParam, }; try { From 65fbbcec77f2ac0e0bf9764ba2b359ad82a7f6b7 Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:18:01 -0500 Subject: [PATCH 21/30] Adding additional layers --- frontend/src/config/jordan/layers.json | 366 ++++++++++++++++++++++++- frontend/src/config/jordan/prism.json | 31 ++- 2 files changed, 383 insertions(+), 14 deletions(-) diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index 232ed7501..ca462b8fb 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -1367,7 +1367,106 @@ ], "legend_text": "Groundwater developed for irrigation (MCM) " }, - "cdi_v1_aggregated": { + "cdi_v1_monthly": { + "title": "Monthly Combined Drought Index (v1)", + "type": "composite", + "period": "monthly", + "base_url": "http://127.0.0.1:8000/q_multi_geojson", + "validity": { + "forward": 1, + "backward": 2, + "mode": "dekad" + }, + "input_layers": [ + { + "id": "spi_1m", + "importance": 0.3, + "key": [ + "CHIRPS", + "R1S_DEKAD" + ], + "aggregation": "last_dekad" + }, + { + "id": "lst_anomaly", + "importance": 0.3, + "key": [ + "MODIS", + "MYD11C2_TDD_DEKAD" + ], + "aggregation": "last_dekad" + }, + { + "id": "ndvi_dekad", + "importance": 0.4, + "key": [ + "MODIS", + "NDVI_smoothed_5KM" + ], + "aggregation": "average", + "invert": "True" + } + ], + "legend": [ + { + "value": 0, + "label": "0 - 0.1", + "color": "#672200" + }, + { + "value": 0.1, + "label": "0.1 - 0.2", + "color": "#a93800" + }, + { + "value": 0.2, + "label": "0.2 - 0.3", + "color": "#e59800" + }, + { + "value": 0.3, + "label": "0.3 - 0.4", + "color": "#ffe769" + }, + { + "value": 0.4, + "label": "0.4 - 0.5", + "color": "#f0f0f0" + }, + { + "value": 0.5, + "label": "0.5 - 0.6", + "color": "#f0f0f0" + }, + { + "value": 0.6, + "label": "0.6 - 0.7", + "color": "#a9c6d6" + }, + { + "value": 0.7, + "label": "0.7 - 0.8", + "color": "#019ac4" + }, + { + "value": 0.8, + "label": "0.8 - 0.9", + "color": "#014c73" + }, + { + "value": 0.9, + "label": "0.9 - 1", + "color": "#014c73" + } + ], + "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", + "aggregation": "pixel", + "date_layer": "spi_1m", + "start_date": "2020-12-01", + "end_date": "2021-07-31", + "opacity": 0.7 + }, + "cdi_v1_aggregated_monthly": { "title": "Monthly Combined Drought Index Aggregated (v1)", "type": "composite", "period": "monthly", @@ -1475,19 +1574,27 @@ "end_date": "2021-07-31", "opacity": 0.7 }, - "cdi_v1_monthly": { - "title": "Monthly Combined Drought Index (v1)", + "cdi_v1_seasonal": { + "title": "Seasonal Combined Drought Index (v1)", "type": "composite", - "period": "monthly", + "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_geojson", "validity": { - "forward": 1, - "backward": 2, - "mode": "dekad" + "mode": "season", + "seasons": [ + { + "start": "01-May", + "end": "31-October" + }, + { + "start": "01-November", + "end": "30-April" + } + ] }, "input_layers": [ { - "id": "spi_1m", + "id": "spi_3m", "importance": 0.5, "key": [ "CHIRPS", @@ -1569,16 +1676,16 @@ ], "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", "aggregation": "pixel", - "date_layer": "spi_1m", + "date_layer": "spi_3m", "start_date": "2020-12-01", "end_date": "2021-07-31", "opacity": 0.7 }, - "cdi_v1_seasonal": { - "title": "Seasonal Combined Drought Index (v1)", + "cdi_v1_aggregated_seasonal": { + "title": "Seasonal Combined Drought Index Aggregated (v1)", "type": "composite", "period": "seasonal", - "base_url": "https://hip-service.ovio.org/q_multi_geojson", + "base_url": "http://127.0.0.1:8000/q_multi_aggregated", "validity": { "mode": "season", "seasons": [ @@ -1592,6 +1699,12 @@ } ] }, + "feature_info_props": { + "value": { + "type": "number", + "dataTitle": "Event name" + } + }, "input_layers": [ { "id": "spi_3m", @@ -1676,6 +1789,9 @@ ], "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", "aggregation": "pixel", + "aggregate_by": "mean", + "admin_code": "admin3Pcod", + "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_3m", "start_date": "2020-12-01", "end_date": "2021-07-31", @@ -1685,7 +1801,7 @@ "title": "Monthly Combined Drought Index (v2)", "type": "composite", "period": "monthly", - "base_url": "https://hip-service.ovio.org/q_multi_geojson", + "base_url": "http://127.0.0.1:8000/q_multi_geojson", "validity": { "forward": 1, "backward": 2, @@ -1780,6 +1896,114 @@ "end_date": "2021-07-31", "opacity": 0.7 }, + "cdi_v2_aggregated_monthly": { + "title": "Monthly Combined Drought Index Aggregated (v2)", + "type": "composite", + "period": "monthly", + "base_url": "http://127.0.0.1:8000/q_multi_aggregated", + "validity": { + "forward": 1, + "backward": 2, + "mode": "dekad" + }, + "feature_info_props": { + "value": { + "type": "number", + "dataTitle": "Event name" + } + }, + "input_layers": [ + { + "id": "spi_1m", + "importance": 0.3, + "key": [ + "CHIRPS", + "R1S_DEKAD" + ], + "aggregation": "last_dekad" + }, + { + "id": "lst_anomaly", + "importance": 0.3, + "key": [ + "MODIS", + "MYD11C2_TDD_DEKAD" + ], + "aggregation": "last_dekad" + }, + { + "id": "ndvi_dekad", + "importance": 0.4, + "key": [ + "MODIS", + "NDVI_smoothed_5KM" + ], + "aggregation": "average", + "invert": "True" + } + ], + "legend": [ + { + "value": 0, + "label": "0 - 0.1", + "color": "#672200" + }, + { + "value": 0.1, + "label": "0.1 - 0.2", + "color": "#a93800" + }, + { + "value": 0.2, + "label": "0.2 - 0.3", + "color": "#e59800" + }, + { + "value": 0.3, + "label": "0.3 - 0.4", + "color": "#ffe769" + }, + { + "value": 0.4, + "label": "0.4 - 0.5", + "color": "#f0f0f0" + }, + { + "value": 0.5, + "label": "0.5 - 0.6", + "color": "#f0f0f0" + }, + { + "value": 0.6, + "label": "0.6 - 0.7", + "color": "#a9c6d6" + }, + { + "value": 0.7, + "label": "0.7 - 0.8", + "color": "#019ac4" + }, + { + "value": 0.8, + "label": "0.8 - 0.9", + "color": "#014c73" + }, + { + "value": 0.9, + "label": "0.9 - 1", + "color": "#014c73" + } + ], + "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", + "aggregation": "pixel", + "aggregate_by": "mean", + "admin_code": "admin3Pcod", + "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", + "date_layer": "spi_1m", + "start_date": "2020-12-01", + "end_date": "2021-07-31", + "opacity": 0.7 + }, "cdi_v2_seasonal": { "title": "Seasonal Combined Drought Index (v2)", "type": "composite", @@ -1886,5 +2110,121 @@ "start_date": "2020-12-01", "end_date": "2021-07-31", "opacity": 0.7 + }, + "cdi_v2_aggregated_seasonal": { + "title": "Seasonal Combined Drought Index Aggregated (v2)", + "type": "composite", + "period": "seasonal", + "base_url": "http://127.0.0.1:8000/q_multi_aggregated", + "validity": { + "mode": "season", + "seasons": [ + { + "start": "01-May", + "end": "31-October" + }, + { + "start": "01-November", + "end": "30-April" + } + ] + }, + "feature_info_props": { + "value": { + "type": "number", + "dataTitle": "Event name" + } + }, + "input_layers": [ + { + "id": "spi_3m", + "importance": 0.3, + "key": [ + "CHIRPS", + "R1S_DEKAD" + ], + "aggregation": "last_dekad" + }, + { + "id": "lst_anomaly", + "importance": 0.3, + "key": [ + "MODIS", + "MYD11C2_TDD_DEKAD" + ], + "aggregation": "last_dekad" + }, + { + "id": "ndvi_dekad", + "importance": 0.4, + "key": [ + "MODIS", + "NDVI_smoothed_5KM" + ], + "aggregation": "average", + "invert": "True" + } + ], + "legend": [ + { + "value": 0, + "label": "0 - 0.1", + "color": "#672200" + }, + { + "value": 0.1, + "label": "0.1 - 0.2", + "color": "#a93800" + }, + { + "value": 0.2, + "label": "0.2 - 0.3", + "color": "#e59800" + }, + { + "value": 0.3, + "label": "0.3 - 0.4", + "color": "#ffe769" + }, + { + "value": 0.4, + "label": "0.4 - 0.5", + "color": "#f0f0f0" + }, + { + "value": 0.5, + "label": "0.5 - 0.6", + "color": "#f0f0f0" + }, + { + "value": 0.6, + "label": "0.6 - 0.7", + "color": "#a9c6d6" + }, + { + "value": 0.7, + "label": "0.7 - 0.8", + "color": "#019ac4" + }, + { + "value": 0.8, + "label": "0.8 - 0.9", + "color": "#014c73" + }, + { + "value": 0.9, + "label": "0.9 - 1", + "color": "#014c73" + } + ], + "legend_text": "Composite Drought Index v2. SPI weight = 0.3; LST weight = 0.3; NDVI weight = 0.4", + "aggregation": "pixel", + "aggregate_by": "mean", + "admin_code": "admin3Pcod", + "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", + "date_layer": "spi_3m", + "start_date": "2020-12-01", + "end_date": "2021-07-31", + "opacity": 0.7 } } \ No newline at end of file diff --git a/frontend/src/config/jordan/prism.json b/frontend/src/config/jordan/prism.json index dd2a9d030..bf0d81c4e 100644 --- a/frontend/src/config/jordan/prism.json +++ b/frontend/src/config/jordan/prism.json @@ -212,7 +212,6 @@ }, "drought": { "combined_drought_index": [ - "cdi_v1_aggregated", { "group_title": "Combined Drought Index v1:", "activate_all": false, @@ -228,6 +227,21 @@ } ] }, + { + "group_title": "Combined Drought Index v1 Aggregated:", + "activate_all": false, + "layers": [ + { + "id": "cdi_v1_aggregated_monthly", + "label": "Monthly", + "main": true + }, + { + "id": "cdi_v1_aggregated_seasonal", + "label": "Seasonal" + } + ] + }, { "group_title": "Combined Drought Index v2:", "activate_all": false, @@ -242,6 +256,21 @@ "label": "Seasonal" } ] + }, + { + "group_title": "Combined Drought Index v2 Aggregated:", + "activate_all": false, + "layers": [ + { + "id": "cdi_v2_aggregated_monthly", + "label": "Monthly", + "main": true + }, + { + "id": "cdi_v2_aggregated_seasonal", + "label": "Seasonal" + } + ] } ] } From 97b35fa53b88b3b3f5ffb34f724c0522f8f5be2b Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:21:25 -0500 Subject: [PATCH 22/30] updating the CDI reference dates --- frontend/src/config/jordan/layers.json | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index ca462b8fb..57c64f017 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -1462,8 +1462,8 @@ "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", "aggregation": "pixel", "date_layer": "spi_1m", - "start_date": "2020-12-01", - "end_date": "2021-07-31", + "start_date": "2010-12-01", + "end_date": "2020-07-31", "opacity": 0.7 }, "cdi_v1_aggregated_monthly": { @@ -1570,8 +1570,8 @@ "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_1m", - "start_date": "2020-12-01", - "end_date": "2021-07-31", + "start_date": "2010-12-01", + "end_date": "2020-07-31", "opacity": 0.7 }, "cdi_v1_seasonal": { @@ -1677,8 +1677,8 @@ "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", "aggregation": "pixel", "date_layer": "spi_3m", - "start_date": "2020-12-01", - "end_date": "2021-07-31", + "start_date": "2010-12-01", + "end_date": "2020-07-31", "opacity": 0.7 }, "cdi_v1_aggregated_seasonal": { @@ -1793,8 +1793,8 @@ "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_3m", - "start_date": "2020-12-01", - "end_date": "2021-07-31", + "start_date": "2010-12-01", + "end_date": "2020-07-31", "opacity": 0.7 }, "cdi_v2_monthly": { @@ -1892,8 +1892,8 @@ "legend_text": "Composite Drought Index v2. SPI weight = 0.3; LST weight = 0.3; NDVI weight = 0.4", "aggregation": "pixel", "date_layer": "spi_1m", - "start_date": "2020-12-01", - "end_date": "2021-07-31", + "start_date": "2010-12-01", + "end_date": "2020-07-31", "opacity": 0.7 }, "cdi_v2_aggregated_monthly": { @@ -2000,8 +2000,8 @@ "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_1m", - "start_date": "2020-12-01", - "end_date": "2021-07-31", + "start_date": "2010-12-01", + "end_date": "2020-07-31", "opacity": 0.7 }, "cdi_v2_seasonal": { @@ -2107,8 +2107,8 @@ "legend_text": "Composite Drought Index v2. SPI weight = 0.3; LST weight = 0.3; NDVI weight = 0.4", "aggregation": "pixel", "date_layer": "spi_3m", - "start_date": "2020-12-01", - "end_date": "2021-07-31", + "start_date": "2010-12-01", + "end_date": "2020-07-31", "opacity": 0.7 }, "cdi_v2_aggregated_seasonal": { @@ -2223,8 +2223,8 @@ "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_3m", - "start_date": "2020-12-01", - "end_date": "2021-07-31", + "start_date": "2010-12-01", + "end_date": "2020-07-31", "opacity": 0.7 } } \ No newline at end of file From 6b8cd99cfe112db31ca05b2c8f097d2bbc1cfa11 Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Fri, 1 Nov 2024 16:38:59 -0500 Subject: [PATCH 23/30] Pointing to deployed server --- frontend/src/config/jordan/layers.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index 57c64f017..701babe9e 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -1371,7 +1371,7 @@ "title": "Monthly Combined Drought Index (v1)", "type": "composite", "period": "monthly", - "base_url": "http://127.0.0.1:8000/q_multi_geojson", + "base_url": "https://hip-service.ovio.org/q_multi_geojson", "validity": { "forward": 1, "backward": 2, @@ -1470,7 +1470,7 @@ "title": "Monthly Combined Drought Index Aggregated (v1)", "type": "composite", "period": "monthly", - "base_url": "http://127.0.0.1:8000/q_multi_aggregated", + "base_url": "https://hip-service.ovio.org/q_multi_aggregated", "validity": { "forward": 1, "backward": 2, @@ -1685,7 +1685,7 @@ "title": "Seasonal Combined Drought Index Aggregated (v1)", "type": "composite", "period": "seasonal", - "base_url": "http://127.0.0.1:8000/q_multi_aggregated", + "base_url": "https://hip-service.ovio.org/q_multi_aggregated", "validity": { "mode": "season", "seasons": [ @@ -1801,7 +1801,7 @@ "title": "Monthly Combined Drought Index (v2)", "type": "composite", "period": "monthly", - "base_url": "http://127.0.0.1:8000/q_multi_geojson", + "base_url": "https://hip-service.ovio.org/q_multi_geojson", "validity": { "forward": 1, "backward": 2, @@ -1900,7 +1900,7 @@ "title": "Monthly Combined Drought Index Aggregated (v2)", "type": "composite", "period": "monthly", - "base_url": "http://127.0.0.1:8000/q_multi_aggregated", + "base_url": "https://hip-service.ovio.org/q_multi_aggregated", "validity": { "forward": 1, "backward": 2, @@ -2115,7 +2115,7 @@ "title": "Seasonal Combined Drought Index Aggregated (v2)", "type": "composite", "period": "seasonal", - "base_url": "http://127.0.0.1:8000/q_multi_aggregated", + "base_url": "https://hip-service.ovio.org/q_multi_aggregated", "validity": { "mode": "season", "seasons": [ From 2a74f62a7e02abf25af3a2228f41d6054904f31e Mon Sep 17 00:00:00 2001 From: Amit W Date: Sat, 2 Nov 2024 10:04:44 -0700 Subject: [PATCH 24/30] reorganize layers in prism.json --- frontend/src/config/jordan/prism.json | 50 ++++++++++++++------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/frontend/src/config/jordan/prism.json b/frontend/src/config/jordan/prism.json index bf0d81c4e..d73edf8aa 100644 --- a/frontend/src/config/jordan/prism.json +++ b/frontend/src/config/jordan/prism.json @@ -211,64 +211,66 @@ "vulnerability": ["vulnerability_scaled"] }, "drought": { - "combined_drought_index": [ + "combined_drought_index_v1": [ { - "group_title": "Combined Drought Index v1:", + "group_title": "Monthly", "activate_all": false, "layers": [ { - "id": "cdi_v1_monthly", - "label": "Monthly", + "id": "cdi_v1_aggregated_monthly", + "label": "Aggregated", "main": true }, { - "id": "cdi_v1_seasonal", - "label": "Seasonal" + "id": "cdi_v1_monthly", + "label": "Pixel level", + "main": true } ] }, { - "group_title": "Combined Drought Index v1 Aggregated:", + "group_title": "Seasonal", "activate_all": false, "layers": [ { - "id": "cdi_v1_aggregated_monthly", - "label": "Monthly", - "main": true + "id": "cdi_v1_aggregated_seasonal", + "label": "Aggregated" }, { - "id": "cdi_v1_aggregated_seasonal", - "label": "Seasonal" + "id": "cdi_v1_seasonal", + "label": "Pixel level" } ] - }, + } + ], + "combined_drought_index_v2": [ { - "group_title": "Combined Drought Index v2:", + "group_title": "Monthly", "activate_all": false, "layers": [ { - "id": "cdi_v2_monthly", - "label": "Monthly", + "id": "cdi_v2_aggregated_monthly", + "label": "Aggregated", "main": true }, { - "id": "cdi_v2_seasonal", - "label": "Seasonal" + "id": "cdi_v2_monthly", + "label": "Pixel level", + "main": true } ] }, { - "group_title": "Combined Drought Index v2 Aggregated:", + "group_title": "Seasonal", "activate_all": false, "layers": [ { - "id": "cdi_v2_aggregated_monthly", - "label": "Monthly", - "main": true + "id": "cdi_v2_aggregated_seasonal", + "label": "Aggregated" }, { - "id": "cdi_v2_aggregated_seasonal", - "label": "Seasonal" + "id": "cdi_v2_seasonal", + "label": "Pixel level" } ] } From ef4dae386c6be582638a90a9bb06ac8f4dd4065f Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Sat, 2 Nov 2024 12:28:50 -0500 Subject: [PATCH 25/30] Updating reference period --- frontend/src/config/jordan/layers.json | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index 701babe9e..7a81548e9 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -1462,8 +1462,8 @@ "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", "aggregation": "pixel", "date_layer": "spi_1m", - "start_date": "2010-12-01", - "end_date": "2020-07-31", + "start_date": "2003-01-01", + "end_date": "2013-12-31", "opacity": 0.7 }, "cdi_v1_aggregated_monthly": { @@ -1570,8 +1570,8 @@ "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_1m", - "start_date": "2010-12-01", - "end_date": "2020-07-31", + "start_date": "2003-01-01", + "end_date": "2013-12-31", "opacity": 0.7 }, "cdi_v1_seasonal": { @@ -1677,8 +1677,8 @@ "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", "aggregation": "pixel", "date_layer": "spi_3m", - "start_date": "2010-12-01", - "end_date": "2020-07-31", + "start_date": "2003-01-01", + "end_date": "2013-12-31", "opacity": 0.7 }, "cdi_v1_aggregated_seasonal": { @@ -1793,8 +1793,8 @@ "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_3m", - "start_date": "2010-12-01", - "end_date": "2020-07-31", + "start_date": "2003-01-01", + "end_date": "2013-12-31", "opacity": 0.7 }, "cdi_v2_monthly": { @@ -1892,8 +1892,8 @@ "legend_text": "Composite Drought Index v2. SPI weight = 0.3; LST weight = 0.3; NDVI weight = 0.4", "aggregation": "pixel", "date_layer": "spi_1m", - "start_date": "2010-12-01", - "end_date": "2020-07-31", + "start_date": "2003-01-01", + "end_date": "2013-12-31", "opacity": 0.7 }, "cdi_v2_aggregated_monthly": { @@ -2000,8 +2000,8 @@ "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_1m", - "start_date": "2010-12-01", - "end_date": "2020-07-31", + "start_date": "2003-01-01", + "end_date": "2013-12-31", "opacity": 0.7 }, "cdi_v2_seasonal": { @@ -2107,8 +2107,8 @@ "legend_text": "Composite Drought Index v2. SPI weight = 0.3; LST weight = 0.3; NDVI weight = 0.4", "aggregation": "pixel", "date_layer": "spi_3m", - "start_date": "2010-12-01", - "end_date": "2020-07-31", + "start_date": "2003-01-01", + "end_date": "2013-12-31", "opacity": 0.7 }, "cdi_v2_aggregated_seasonal": { @@ -2223,8 +2223,8 @@ "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_3m", - "start_date": "2010-12-01", - "end_date": "2020-07-31", + "start_date": "2003-01-01", + "end_date": "2013-12-31", "opacity": 0.7 } } \ No newline at end of file From 8be4d67bbf842248a3955f555aa6912a9ec4aa5f Mon Sep 17 00:00:00 2001 From: Will Gislason <8203830+gislawill@users.noreply.github.com> Date: Sat, 2 Nov 2024 12:43:47 -0500 Subject: [PATCH 26/30] Adding expected lag to all layers --- frontend/src/config/jordan/layers.json | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index 6c28a17e5..3c63991b7 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -1372,7 +1372,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 110, + "expected_data_lag_days": 20, "validity": { "forward": 1, "backward": 2, @@ -1472,6 +1472,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_aggregated", + "expected_data_lag_days": 20, "validity": { "forward": 1, "backward": 2, @@ -1580,7 +1581,7 @@ "type": "composite", "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 180, + "expected_data_lag_days": 20, "validity": { "mode": "season", "seasons": [ @@ -1688,6 +1689,7 @@ "type": "composite", "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_aggregated", + "expected_data_lag_days": 20, "validity": { "mode": "season", "seasons": [ @@ -1804,7 +1806,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 110, + "expected_data_lag_days": 20, "validity": { "forward": 1, "backward": 2, @@ -1904,6 +1906,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_aggregated", + "expected_data_lag_days": 20, "validity": { "forward": 1, "backward": 2, @@ -2012,7 +2015,7 @@ "type": "composite", "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 180, + "expected_data_lag_days": 20, "validity": { "mode": "season", "seasons": [ @@ -2120,6 +2123,7 @@ "type": "composite", "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_aggregated", + "expected_data_lag_days": 20, "validity": { "mode": "season", "seasons": [ From fb7c3822fbb13abe63c72d794ce9d994afa6c641 Mon Sep 17 00:00:00 2001 From: Amit W Date: Sat, 2 Nov 2024 15:22:38 -0700 Subject: [PATCH 27/30] extend lag for CDI layers --- frontend/src/config/jordan/layers.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index 3c63991b7..11f8a2e3f 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -1372,7 +1372,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 20, + "expected_data_lag_days": 39, "validity": { "forward": 1, "backward": 2, @@ -1472,7 +1472,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_aggregated", - "expected_data_lag_days": 20, + "expected_data_lag_days": 39, "validity": { "forward": 1, "backward": 2, @@ -1581,7 +1581,7 @@ "type": "composite", "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 20, + "expected_data_lag_days": 39, "validity": { "mode": "season", "seasons": [ @@ -1689,7 +1689,7 @@ "type": "composite", "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_aggregated", - "expected_data_lag_days": 20, + "expected_data_lag_days": 39, "validity": { "mode": "season", "seasons": [ @@ -1806,7 +1806,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 20, + "expected_data_lag_days": 39, "validity": { "forward": 1, "backward": 2, @@ -1906,7 +1906,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_aggregated", - "expected_data_lag_days": 20, + "expected_data_lag_days": 39, "validity": { "forward": 1, "backward": 2, @@ -2015,7 +2015,7 @@ "type": "composite", "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 20, + "expected_data_lag_days": 39, "validity": { "mode": "season", "seasons": [ @@ -2123,7 +2123,7 @@ "type": "composite", "period": "seasonal", "base_url": "https://hip-service.ovio.org/q_multi_aggregated", - "expected_data_lag_days": 20, + "expected_data_lag_days": 39, "validity": { "mode": "season", "seasons": [ From bf5ccb858dfff513e568e8306952a8ac5ce7380a Mon Sep 17 00:00:00 2001 From: Amit W Date: Sat, 2 Nov 2024 22:49:53 -0700 Subject: [PATCH 28/30] cleanup CDI configuration (wip) --- frontend/src/config/jordan/index.ts | 2 +- frontend/src/config/jordan/layers.json | 420 +++++++++++++----- frontend/src/config/jordan/prism.json | 12 +- frontend/src/context/layers/composite_data.ts | 2 +- 4 files changed, 329 insertions(+), 107 deletions(-) diff --git a/frontend/src/config/jordan/index.ts b/frontend/src/config/jordan/index.ts index d74493a2c..57c982a48 100644 --- a/frontend/src/config/jordan/index.ts +++ b/frontend/src/config/jordan/index.ts @@ -11,5 +11,5 @@ export default { rawTables, rawReports, translation, - defaultBoundariesFile: 'jor_admbnda_adm2_jdos.json', + defaultBoundariesFile: 'jor_admbnda_adm3_jdos_merged.json', }; diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index 11f8a2e3f..e0813e2f8 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -1373,6 +1373,10 @@ "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_geojson", "expected_data_lag_days": 39, + "start_date": "2002-07-01", + "end_date": "2018-07-01", + "aggregation": "pixel", + "date_layer": "spi_1m", "validity": { "forward": 1, "backward": 2, @@ -1381,31 +1385,33 @@ "input_layers": [ { "id": "spi_1m", - "importance": 0.3, + "importance": 0.5, + "aggregation": "average", + "invert": "False", "key": [ "CHIRPS", "R1S_DEKAD" - ], - "aggregation": "last_dekad" + ] }, { "id": "lst_anomaly", - "importance": 0.3, + "importance": 0.25, + "aggregation": "average", + "invert": "True", "key": [ "MODIS", "MYD11C2_TDD_DEKAD" - ], - "aggregation": "last_dekad" + ] }, { "id": "ndvi_dekad", - "importance": 0.4, + "importance": 0.25, + "aggregation": "average", + "invert": "True", "key": [ "MODIS", "NDVI_smoothed_5KM" - ], - "aggregation": "average", - "invert": "True" + ] } ], "legend": [ @@ -1461,10 +1467,6 @@ } ], "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", - "aggregation": "pixel", - "date_layer": "spi_1m", - "start_date": "2003-01-01", - "end_date": "2013-12-31", "opacity": 0.7 }, "cdi_v1_aggregated_monthly": { @@ -1472,6 +1474,13 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_aggregated", + "start_date": "2002-07-01", + "end_date": "2018-07-01", + "aggregation": "pixel", + "aggregate_by": "mean", + "admin_code": "admin3Pcod", + "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", + "date_layer": "spi_1m", "expected_data_lag_days": 39, "validity": { "forward": 1, @@ -1488,30 +1497,32 @@ { "id": "spi_1m", "importance": 0.5, + "aggregation": "average", + "invert": "False", "key": [ "CHIRPS", "R1S_DEKAD" - ], - "aggregation": "average" + ] }, { "id": "lst_anomaly", "importance": 0.25, + "aggregation": "average", + "invert": "True", "key": [ "MODIS", "MYD11C2_TDD_DEKAD" - ], - "aggregation": "average" + ] }, { "id": "ndvi_dekad", "importance": 0.25, + "aggregation": "average", + "invert": "True", "key": [ "MODIS", "NDVI_smoothed_5KM" - ], - "aggregation": "average", - "invert": "False" + ] } ], "legend": [ @@ -1567,19 +1578,16 @@ } ], "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", - "aggregation": "pixel", - "aggregate_by": "mean", - "admin_code": "admin3Pcod", - "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", - "date_layer": "spi_1m", - "start_date": "2003-01-01", - "end_date": "2013-12-31", "opacity": 0.7 }, "cdi_v1_seasonal": { "title": "Seasonal Combined Drought Index (v1)", "type": "composite", "period": "seasonal", + "aggregation": "pixel", + "date_layer": "spi_3m", + "start_date": "2002-07-01", + "end_date": "2018-07-01", "base_url": "https://hip-service.ovio.org/q_multi_geojson", "expected_data_lag_days": 39, "validity": { @@ -1599,30 +1607,31 @@ { "id": "spi_3m", "importance": 0.5, + "aggregation": "average", "key": [ "CHIRPS", "R1S_DEKAD" - ], - "aggregation": "average" + ] }, { "id": "lst_anomaly", "importance": 0.25, + "aggregation": "average", + "invert": "True", "key": [ "MODIS", "MYD11C2_TDD_DEKAD" - ], - "aggregation": "average" + ] }, { "id": "ndvi_dekad", "importance": 0.25, + "aggregation": "average", + "invert": "False", "key": [ "MODIS", "NDVI_smoothed_5KM" - ], - "aggregation": "average", - "invert": "False" + ] } ], "legend": [ @@ -1678,16 +1687,19 @@ } ], "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", - "aggregation": "pixel", - "date_layer": "spi_3m", - "start_date": "2003-01-01", - "end_date": "2013-12-31", "opacity": 0.7 }, "cdi_v1_aggregated_seasonal": { "title": "Seasonal Combined Drought Index Aggregated (v1)", "type": "composite", "period": "seasonal", + "aggregation": "pixel", + "aggregate_by": "mean", + "admin_code": "admin3Pcod", + "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", + "date_layer": "spi_3m", + "start_date": "2002-07-01", + "end_date": "2018-07-01", "base_url": "https://hip-service.ovio.org/q_multi_aggregated", "expected_data_lag_days": 39, "validity": { @@ -1713,30 +1725,31 @@ { "id": "spi_3m", "importance": 0.5, + "aggregation": "average", "key": [ "CHIRPS", "R1S_DEKAD" - ], - "aggregation": "last_dekad" + ] }, { "id": "lst_anomaly", "importance": 0.25, + "aggregation": "average", + "invert": "True", "key": [ "MODIS", "MYD11C2_TDD_DEKAD" - ], - "aggregation": "last_dekad" + ] }, { "id": "ndvi_dekad", + "aggregation": "average", + "invert": "True", "importance": 0.25, "key": [ "MODIS", "NDVI_smoothed_5KM" - ], - "aggregation": "average", - "invert": "True" + ] } ], "legend": [ @@ -1792,19 +1805,16 @@ } ], "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", - "aggregation": "pixel", - "aggregate_by": "mean", - "admin_code": "admin3Pcod", - "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", - "date_layer": "spi_3m", - "start_date": "2003-01-01", - "end_date": "2013-12-31", "opacity": 0.7 }, "cdi_v2_monthly": { "title": "Monthly Combined Drought Index (v2)", "type": "composite", "period": "monthly", + "aggregation": "pixel", + "date_layer": "spi_1m", + "start_date": "2002-07-01", + "end_date": "2018-07-01", "base_url": "https://hip-service.ovio.org/q_multi_geojson", "expected_data_lag_days": 39, "validity": { @@ -1816,30 +1826,31 @@ { "id": "spi_1m", "importance": 0.3, + "aggregation": "average", "key": [ "CHIRPS", "R1S_DEKAD" - ], - "aggregation": "average" + ] }, { "id": "lst_anomaly", "importance": 0.3, + "aggregation": "average", + "invert": "True", "key": [ "MODIS", "MYD11C2_TDD_DEKAD" - ], - "aggregation": "average" + ] }, { "id": "ndvi_dekad", "importance": 0.4, + "aggregation": "average", + "invert": "False", "key": [ "MODIS", "NDVI_smoothed_5KM" - ], - "aggregation": "average", - "invert": "False" + ] } ], "legend": [ @@ -1895,16 +1906,19 @@ } ], "legend_text": "Composite Drought Index v2. SPI weight = 0.3; LST weight = 0.3; NDVI weight = 0.4", - "aggregation": "pixel", - "date_layer": "spi_1m", - "start_date": "2003-01-01", - "end_date": "2013-12-31", "opacity": 0.7 }, "cdi_v2_aggregated_monthly": { "title": "Monthly Combined Drought Index Aggregated (v2)", "type": "composite", "period": "monthly", + "aggregation": "pixel", + "aggregate_by": "mean", + "admin_code": "admin3Pcod", + "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", + "date_layer": "spi_1m", + "start_date": "2002-07-01", + "end_date": "2018-07-01", "base_url": "https://hip-service.ovio.org/q_multi_aggregated", "expected_data_lag_days": 39, "validity": { @@ -1922,30 +1936,31 @@ { "id": "spi_1m", "importance": 0.3, + "aggregation": "last_dekad", "key": [ "CHIRPS", "R1S_DEKAD" - ], - "aggregation": "last_dekad" + ] }, { "id": "lst_anomaly", "importance": 0.3, + "aggregation": "average", + "invert": "True", "key": [ "MODIS", "MYD11C2_TDD_DEKAD" - ], - "aggregation": "last_dekad" + ] }, { "id": "ndvi_dekad", "importance": 0.4, + "aggregation": "average", + "invert": "True", "key": [ "MODIS", "NDVI_smoothed_5KM" - ], - "aggregation": "average", - "invert": "True" + ] } ], "legend": [ @@ -2001,19 +2016,16 @@ } ], "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", - "aggregation": "pixel", - "aggregate_by": "mean", - "admin_code": "admin3Pcod", - "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", - "date_layer": "spi_1m", - "start_date": "2003-01-01", - "end_date": "2013-12-31", "opacity": 0.7 }, "cdi_v2_seasonal": { "title": "Seasonal Combined Drought Index (v2)", "type": "composite", "period": "seasonal", + "aggregation": "pixel", + "date_layer": "spi_3m", + "start_date": "2002-07-01", + "end_date": "2018-07-01", "base_url": "https://hip-service.ovio.org/q_multi_geojson", "expected_data_lag_days": 39, "validity": { @@ -2033,30 +2045,31 @@ { "id": "spi_3m", "importance": 0.3, + "aggregation": "average", "key": [ "CHIRPS", "R1S_DEKAD" - ], - "aggregation": "average" + ] }, { "id": "lst_anomaly", "importance": 0.3, + "aggregation": "average", + "invert": "True", "key": [ "MODIS", "MYD11C2_TDD_DEKAD" - ], - "aggregation": "average" + ] }, { "id": "ndvi_dekad", "importance": 0.4, + "aggregation": "average", + "invert": "False", "key": [ "MODIS", "NDVI_smoothed_5KM" - ], - "aggregation": "average", - "invert": "False" + ] } ], "legend": [ @@ -2112,16 +2125,19 @@ } ], "legend_text": "Composite Drought Index v2. SPI weight = 0.3; LST weight = 0.3; NDVI weight = 0.4", - "aggregation": "pixel", - "date_layer": "spi_3m", - "start_date": "2003-01-01", - "end_date": "2013-12-31", "opacity": 0.7 }, "cdi_v2_aggregated_seasonal": { "title": "Seasonal Combined Drought Index Aggregated (v2)", "type": "composite", "period": "seasonal", + "aggregation": "pixel", + "aggregate_by": "mean", + "admin_code": "admin3Pcod", + "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", + "date_layer": "spi_3m", + "start_date": "2002-07-01", + "end_date": "2018-07-01", "base_url": "https://hip-service.ovio.org/q_multi_aggregated", "expected_data_lag_days": 39, "validity": { @@ -2147,30 +2163,31 @@ { "id": "spi_3m", "importance": 0.3, + "aggregation": "last_dekad", "key": [ "CHIRPS", "R1S_DEKAD" - ], - "aggregation": "last_dekad" + ] }, { "id": "lst_anomaly", "importance": 0.3, + "aggregation": "average", + "invert": "True", "key": [ "MODIS", "MYD11C2_TDD_DEKAD" - ], - "aggregation": "last_dekad" + ] }, { "id": "ndvi_dekad", "importance": 0.4, + "aggregation": "average", + "invert": "True", "key": [ "MODIS", "NDVI_smoothed_5KM" - ], - "aggregation": "average", - "invert": "True" + ] } ], "legend": [ @@ -2226,13 +2243,218 @@ } ], "legend_text": "Composite Drought Index v2. SPI weight = 0.3; LST weight = 0.3; NDVI weight = 0.4", + "opacity": 0.7 + }, + "cdi_v3_monthly": { + "title": "Monthly Combined Drought Index (v3)", + "type": "composite", + "period": "monthly", + "aggregation": "pixel", + "date_layer": "spi_1m", + "start_date": "2002-07-01", + "end_date": "2018-07-01", + "base_url": "https://hip-service.ovio.org/q_multi_geojson", + "expected_data_lag_days": 39, + "validity": { + "forward": 1, + "backward": 2, + "mode": "dekad" + }, + "input_layers": [ + { + "id": "spi_1m", + "importance": 0.3, + "aggregation": "average", + "invert": "False", + "key": [ + "CHIRPS", + "R1S_DEKAD" + ] + }, + { + "id": "et0", + "importance": 0.3, + "aggregation": "average", + "invert": "True", + "key": [ + "FAO", + "WAPOR_ET0_DEKAD" + ] + }, + { + "id": "lst_anomaly", + "importance": 0.4, + "aggregation": "average", + "invert": "True", + "key": [ + "MODIS", + "MYD11C2_TDD_DEKAD" + ] + } + ], + "legend": [ + { + "value": 0, + "label": "0 - 0.1", + "color": "#672200" + }, + { + "value": 0.1, + "label": "0.1 - 0.2", + "color": "#a93800" + }, + { + "value": 0.2, + "label": "0.2 - 0.3", + "color": "#e59800" + }, + { + "value": 0.3, + "label": "0.3 - 0.4", + "color": "#ffe769" + }, + { + "value": 0.4, + "label": "0.4 - 0.5", + "color": "#f0f0f0" + }, + { + "value": 0.5, + "label": "0.5 - 0.6", + "color": "#f0f0f0" + }, + { + "value": 0.6, + "label": "0.6 - 0.7", + "color": "#a9c6d6" + }, + { + "value": 0.7, + "label": "0.7 - 0.8", + "color": "#019ac4" + }, + { + "value": 0.8, + "label": "0.8 - 0.9", + "color": "#014c73" + }, + { + "value": 0.9, + "label": "0.9 - 1", + "color": "#014c73" + } + ], + "legend_text": "Composite Drought Index v3. SPI weight = 0.3; evapotranspiration weight = 0.3; soil moisture weight = 0.4", + "opacity": 0.7 + }, + "cdi_v3_aggregated_monthly": { + "title": "Monthly Combined Drought Index Aggregated (v2)", + "type": "composite", + "period": "monthly", "aggregation": "pixel", "aggregate_by": "mean", "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", - "date_layer": "spi_3m", - "start_date": "2003-01-01", - "end_date": "2013-12-31", + "date_layer": "spi_1m", + "start_date": "2002-07-01", + "end_date": "2018-07-01", + "base_url": "https://hip-service.ovio.org/q_multi_aggregated", + "expected_data_lag_days": 39, + "validity": { + "forward": 1, + "backward": 2, + "mode": "dekad" + }, + "feature_info_props": { + "value": { + "type": "number", + "dataTitle": "Event name" + } + }, + "input_layers": [ + { + "id": "spi_1m", + "importance": 0.3, + "aggregation": "average", + "key": [ + "CHIRPS", + "R1S_DEKAD" + ] + }, + { + "id": "et0", + "importance": 0.3, + "aggregation": "average", + "invert": "True", + "key": [ + "FAO", + "WAPOR_ET0_DEKAD" + ] + }, + { + "id": "rzsm", + "importance": 0.4, + "aggregation": "average", + "invert": "False", + "key": [ + "AGERA5", + "SOIL_MOIST" + ] + } + ], + "legend": [ + { + "value": 0, + "label": "0 - 0.1", + "color": "#672200" + }, + { + "value": 0.1, + "label": "0.1 - 0.2", + "color": "#a93800" + }, + { + "value": 0.2, + "label": "0.2 - 0.3", + "color": "#e59800" + }, + { + "value": 0.3, + "label": "0.3 - 0.4", + "color": "#ffe769" + }, + { + "value": 0.4, + "label": "0.4 - 0.5", + "color": "#f0f0f0" + }, + { + "value": 0.5, + "label": "0.5 - 0.6", + "color": "#f0f0f0" + }, + { + "value": 0.6, + "label": "0.6 - 0.7", + "color": "#a9c6d6" + }, + { + "value": 0.7, + "label": "0.7 - 0.8", + "color": "#019ac4" + }, + { + "value": 0.8, + "label": "0.8 - 0.9", + "color": "#014c73" + }, + { + "value": 0.9, + "label": "0.9 - 1", + "color": "#014c73" + } + ], + "legend_text": "Composite Drought Index v3. SPI weight = 0.3; evapotranspiration weight = 0.3; soil moisture weight = 0.4", "opacity": 0.7 } } \ No newline at end of file diff --git a/frontend/src/config/jordan/prism.json b/frontend/src/config/jordan/prism.json index 7c2f53f36..9e0fb33f8 100644 --- a/frontend/src/config/jordan/prism.json +++ b/frontend/src/config/jordan/prism.json @@ -222,8 +222,7 @@ }, { "id": "cdi_v1_monthly", - "label": "Pixel level", - "main": true + "label": "Pixel level" } ] }, @@ -233,7 +232,8 @@ "layers": [ { "id": "cdi_v1_aggregated_seasonal", - "label": "Aggregated" + "label": "Aggregated", + "main": true }, { "id": "cdi_v1_seasonal", @@ -254,8 +254,7 @@ }, { "id": "cdi_v2_monthly", - "label": "Pixel level", - "main": true + "label": "Pixel level" } ] }, @@ -265,7 +264,8 @@ "layers": [ { "id": "cdi_v2_aggregated_seasonal", - "label": "Aggregated" + "label": "Aggregated", + "main": true }, { "id": "cdi_v2_seasonal", diff --git a/frontend/src/context/layers/composite_data.ts b/frontend/src/context/layers/composite_data.ts index 55adf357b..d7e821bae 100644 --- a/frontend/src/context/layers/composite_data.ts +++ b/frontend/src/context/layers/composite_data.ts @@ -78,7 +78,7 @@ export const fetchCompositeLayerData: LazyLoader = max_lon: boundingBox[2], max_lat: boundingBox[3], start_date: areaStartDate ?? '2002-07-01', - end_date: areaEndDate ?? '2021-07-31', + end_date: areaEndDate ?? '2018-07-01"', }, layers: inputLayers.map(({ key, aggregation, importance, invert }) => ({ key, From dcccddea9d962c132ab37564d496acb00c632b58 Mon Sep 17 00:00:00 2001 From: Amit W Date: Tue, 17 Dec 2024 16:28:38 -0800 Subject: [PATCH 29/30] cleanup CDI layer configs --- frontend/src/config/jordan/layers.json | 274 +++---------------------- 1 file changed, 34 insertions(+), 240 deletions(-) diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index e0813e2f8..b962292f4 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -1407,7 +1407,7 @@ "id": "ndvi_dekad", "importance": 0.25, "aggregation": "average", - "invert": "True", + "invert": "False", "key": [ "MODIS", "NDVI_smoothed_5KM" @@ -1518,7 +1518,7 @@ "id": "ndvi_dekad", "importance": 0.25, "aggregation": "average", - "invert": "True", + "invert": "False", "key": [ "MODIS", "NDVI_smoothed_5KM" @@ -1584,11 +1584,11 @@ "title": "Seasonal Combined Drought Index (v1)", "type": "composite", "period": "seasonal", - "aggregation": "pixel", - "date_layer": "spi_3m", + "base_url": "https://hip-service.ovio.org/q_multi_geojson", "start_date": "2002-07-01", "end_date": "2018-07-01", - "base_url": "https://hip-service.ovio.org/q_multi_geojson", + "aggregation": "pixel", + "date_layer": "spi_3m", "expected_data_lag_days": 39, "validity": { "mode": "season", @@ -1608,6 +1608,7 @@ "id": "spi_3m", "importance": 0.5, "aggregation": "average", + "invert": "False", "key": [ "CHIRPS", "R1S_DEKAD" @@ -1693,14 +1694,14 @@ "title": "Seasonal Combined Drought Index Aggregated (v1)", "type": "composite", "period": "seasonal", + "base_url": "https://hip-service.ovio.org/q_multi_aggregated", + "start_date": "2002-07-01", + "end_date": "2018-07-01", "aggregation": "pixel", "aggregate_by": "mean", "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_3m", - "start_date": "2002-07-01", - "end_date": "2018-07-01", - "base_url": "https://hip-service.ovio.org/q_multi_aggregated", "expected_data_lag_days": 39, "validity": { "mode": "season", @@ -1726,6 +1727,7 @@ "id": "spi_3m", "importance": 0.5, "aggregation": "average", + "invert": "False", "key": [ "CHIRPS", "R1S_DEKAD" @@ -1743,9 +1745,9 @@ }, { "id": "ndvi_dekad", - "aggregation": "average", - "invert": "True", "importance": 0.25, + "aggregation": "average", + "invert": "False", "key": [ "MODIS", "NDVI_smoothed_5KM" @@ -1811,12 +1813,12 @@ "title": "Monthly Combined Drought Index (v2)", "type": "composite", "period": "monthly", - "aggregation": "pixel", - "date_layer": "spi_1m", - "start_date": "2002-07-01", - "end_date": "2018-07-01", "base_url": "https://hip-service.ovio.org/q_multi_geojson", "expected_data_lag_days": 39, + "start_date": "2002-07-01", + "end_date": "2018-07-01", + "aggregation": "pixel", + "date_layer": "spi_1m", "validity": { "forward": 1, "backward": 2, @@ -1827,6 +1829,7 @@ "id": "spi_1m", "importance": 0.3, "aggregation": "average", + "invert": "False", "key": [ "CHIRPS", "R1S_DEKAD" @@ -1912,14 +1915,14 @@ "title": "Monthly Combined Drought Index Aggregated (v2)", "type": "composite", "period": "monthly", + "base_url": "https://hip-service.ovio.org/q_multi_aggregated", + "start_date": "2002-07-01", + "end_date": "2018-07-01", "aggregation": "pixel", "aggregate_by": "mean", "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_1m", - "start_date": "2002-07-01", - "end_date": "2018-07-01", - "base_url": "https://hip-service.ovio.org/q_multi_aggregated", "expected_data_lag_days": 39, "validity": { "forward": 1, @@ -1936,7 +1939,8 @@ { "id": "spi_1m", "importance": 0.3, - "aggregation": "last_dekad", + "aggregation": "average", + "invert": "False", "key": [ "CHIRPS", "R1S_DEKAD" @@ -1956,7 +1960,7 @@ "id": "ndvi_dekad", "importance": 0.4, "aggregation": "average", - "invert": "True", + "invert": "False", "key": [ "MODIS", "NDVI_smoothed_5KM" @@ -2015,18 +2019,18 @@ "color": "#014c73" } ], - "legend_text": "Composite Drought Index v1. SPI weight = 0.5; LST weight = 0.25; NDVI weight = 0.25", + "legend_text": "Composite Drought Index v2. SPI weight = 0.3; LST weight = 0.3; NDVI weight = 0.4", "opacity": 0.7 }, "cdi_v2_seasonal": { "title": "Seasonal Combined Drought Index (v2)", "type": "composite", "period": "seasonal", - "aggregation": "pixel", - "date_layer": "spi_3m", + "base_url": "https://hip-service.ovio.org/q_multi_geojson", "start_date": "2002-07-01", "end_date": "2018-07-01", - "base_url": "https://hip-service.ovio.org/q_multi_geojson", + "aggregation": "pixel", + "date_layer": "spi_3m", "expected_data_lag_days": 39, "validity": { "mode": "season", @@ -2046,6 +2050,7 @@ "id": "spi_3m", "importance": 0.3, "aggregation": "average", + "invert": "False", "key": [ "CHIRPS", "R1S_DEKAD" @@ -2131,14 +2136,14 @@ "title": "Seasonal Combined Drought Index Aggregated (v2)", "type": "composite", "period": "seasonal", + "base_url": "https://hip-service.ovio.org/q_multi_aggregated", + "start_date": "2002-07-01", + "end_date": "2018-07-01", "aggregation": "pixel", "aggregate_by": "mean", "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_3m", - "start_date": "2002-07-01", - "end_date": "2018-07-01", - "base_url": "https://hip-service.ovio.org/q_multi_aggregated", "expected_data_lag_days": 39, "validity": { "mode": "season", @@ -2163,7 +2168,8 @@ { "id": "spi_3m", "importance": 0.3, - "aggregation": "last_dekad", + "aggregation": "average", + "invert": "False", "key": [ "CHIRPS", "R1S_DEKAD" @@ -2183,7 +2189,7 @@ "id": "ndvi_dekad", "importance": 0.4, "aggregation": "average", - "invert": "True", + "invert": "False", "key": [ "MODIS", "NDVI_smoothed_5KM" @@ -2244,217 +2250,5 @@ ], "legend_text": "Composite Drought Index v2. SPI weight = 0.3; LST weight = 0.3; NDVI weight = 0.4", "opacity": 0.7 - }, - "cdi_v3_monthly": { - "title": "Monthly Combined Drought Index (v3)", - "type": "composite", - "period": "monthly", - "aggregation": "pixel", - "date_layer": "spi_1m", - "start_date": "2002-07-01", - "end_date": "2018-07-01", - "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 39, - "validity": { - "forward": 1, - "backward": 2, - "mode": "dekad" - }, - "input_layers": [ - { - "id": "spi_1m", - "importance": 0.3, - "aggregation": "average", - "invert": "False", - "key": [ - "CHIRPS", - "R1S_DEKAD" - ] - }, - { - "id": "et0", - "importance": 0.3, - "aggregation": "average", - "invert": "True", - "key": [ - "FAO", - "WAPOR_ET0_DEKAD" - ] - }, - { - "id": "lst_anomaly", - "importance": 0.4, - "aggregation": "average", - "invert": "True", - "key": [ - "MODIS", - "MYD11C2_TDD_DEKAD" - ] - } - ], - "legend": [ - { - "value": 0, - "label": "0 - 0.1", - "color": "#672200" - }, - { - "value": 0.1, - "label": "0.1 - 0.2", - "color": "#a93800" - }, - { - "value": 0.2, - "label": "0.2 - 0.3", - "color": "#e59800" - }, - { - "value": 0.3, - "label": "0.3 - 0.4", - "color": "#ffe769" - }, - { - "value": 0.4, - "label": "0.4 - 0.5", - "color": "#f0f0f0" - }, - { - "value": 0.5, - "label": "0.5 - 0.6", - "color": "#f0f0f0" - }, - { - "value": 0.6, - "label": "0.6 - 0.7", - "color": "#a9c6d6" - }, - { - "value": 0.7, - "label": "0.7 - 0.8", - "color": "#019ac4" - }, - { - "value": 0.8, - "label": "0.8 - 0.9", - "color": "#014c73" - }, - { - "value": 0.9, - "label": "0.9 - 1", - "color": "#014c73" - } - ], - "legend_text": "Composite Drought Index v3. SPI weight = 0.3; evapotranspiration weight = 0.3; soil moisture weight = 0.4", - "opacity": 0.7 - }, - "cdi_v3_aggregated_monthly": { - "title": "Monthly Combined Drought Index Aggregated (v2)", - "type": "composite", - "period": "monthly", - "aggregation": "pixel", - "aggregate_by": "mean", - "admin_code": "admin3Pcod", - "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", - "date_layer": "spi_1m", - "start_date": "2002-07-01", - "end_date": "2018-07-01", - "base_url": "https://hip-service.ovio.org/q_multi_aggregated", - "expected_data_lag_days": 39, - "validity": { - "forward": 1, - "backward": 2, - "mode": "dekad" - }, - "feature_info_props": { - "value": { - "type": "number", - "dataTitle": "Event name" - } - }, - "input_layers": [ - { - "id": "spi_1m", - "importance": 0.3, - "aggregation": "average", - "key": [ - "CHIRPS", - "R1S_DEKAD" - ] - }, - { - "id": "et0", - "importance": 0.3, - "aggregation": "average", - "invert": "True", - "key": [ - "FAO", - "WAPOR_ET0_DEKAD" - ] - }, - { - "id": "rzsm", - "importance": 0.4, - "aggregation": "average", - "invert": "False", - "key": [ - "AGERA5", - "SOIL_MOIST" - ] - } - ], - "legend": [ - { - "value": 0, - "label": "0 - 0.1", - "color": "#672200" - }, - { - "value": 0.1, - "label": "0.1 - 0.2", - "color": "#a93800" - }, - { - "value": 0.2, - "label": "0.2 - 0.3", - "color": "#e59800" - }, - { - "value": 0.3, - "label": "0.3 - 0.4", - "color": "#ffe769" - }, - { - "value": 0.4, - "label": "0.4 - 0.5", - "color": "#f0f0f0" - }, - { - "value": 0.5, - "label": "0.5 - 0.6", - "color": "#f0f0f0" - }, - { - "value": 0.6, - "label": "0.6 - 0.7", - "color": "#a9c6d6" - }, - { - "value": 0.7, - "label": "0.7 - 0.8", - "color": "#019ac4" - }, - { - "value": 0.8, - "label": "0.8 - 0.9", - "color": "#014c73" - }, - { - "value": 0.9, - "label": "0.9 - 1", - "color": "#014c73" - } - ], - "legend_text": "Composite Drought Index v3. SPI weight = 0.3; evapotranspiration weight = 0.3; soil moisture weight = 0.4", - "opacity": 0.7 } } \ No newline at end of file From 1eca78c0f2375519d2568c5fbc1d56e7e6aff1e7 Mon Sep 17 00:00:00 2001 From: Amit W Date: Tue, 17 Dec 2024 16:34:08 -0800 Subject: [PATCH 30/30] extend lag --- frontend/src/config/jordan/layers.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/src/config/jordan/layers.json b/frontend/src/config/jordan/layers.json index b962292f4..1c8628b3a 100644 --- a/frontend/src/config/jordan/layers.json +++ b/frontend/src/config/jordan/layers.json @@ -1372,7 +1372,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 39, + "expected_data_lag_days": 60, "start_date": "2002-07-01", "end_date": "2018-07-01", "aggregation": "pixel", @@ -1481,7 +1481,7 @@ "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_1m", - "expected_data_lag_days": 39, + "expected_data_lag_days": 60, "validity": { "forward": 1, "backward": 2, @@ -1589,7 +1589,7 @@ "end_date": "2018-07-01", "aggregation": "pixel", "date_layer": "spi_3m", - "expected_data_lag_days": 39, + "expected_data_lag_days": 60, "validity": { "mode": "season", "seasons": [ @@ -1702,7 +1702,7 @@ "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_3m", - "expected_data_lag_days": 39, + "expected_data_lag_days": 60, "validity": { "mode": "season", "seasons": [ @@ -1814,7 +1814,7 @@ "type": "composite", "period": "monthly", "base_url": "https://hip-service.ovio.org/q_multi_geojson", - "expected_data_lag_days": 39, + "expected_data_lag_days": 60, "start_date": "2002-07-01", "end_date": "2018-07-01", "aggregation": "pixel", @@ -1923,7 +1923,7 @@ "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_1m", - "expected_data_lag_days": 39, + "expected_data_lag_days": 60, "validity": { "forward": 1, "backward": 2, @@ -2031,7 +2031,7 @@ "end_date": "2018-07-01", "aggregation": "pixel", "date_layer": "spi_3m", - "expected_data_lag_days": 39, + "expected_data_lag_days": 60, "validity": { "mode": "season", "seasons": [ @@ -2144,7 +2144,7 @@ "admin_code": "admin3Pcod", "aggregation_boundary_path": "data/jordan/jor_admbnda_adm3_jdos_merged.json", "date_layer": "spi_3m", - "expected_data_lag_days": 39, + "expected_data_lag_days": 60, "validity": { "mode": "season", "seasons": [