Skip to content

Commit 79a3e6c

Browse files
committed
feat: adding custom area chart for evaporation
wip
1 parent fc19d5d commit 79a3e6c

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

app/public/legends/legends.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,9 @@
381381
"label": "*10^9[molec/cm2/s]"
382382
},
383383
"LIS_Global_DA_Evap": {
384-
"range": [0, 0.1],
384+
"range": [0, 100],
385385
"cm": "viridis",
386-
"label": "g/m2/s"
386+
"label": "mg/m2/s"
387387
},
388388
"HLS_NDVI": {
389389
"range": [-1, 1],
-248 Bytes
Loading

app/src/config/trilateral.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,12 +1078,21 @@ const getYearlyDates = (start, end) => {
10781078
return dateArray;
10791079
};
10801080

1081-
const getDailyDates = (start, end, interval = 1) => {
1081+
const getDailyDates = (start, end, interval = 1, s3Path = null, formatFunction = null) => {
10821082
let currentDate = DateTime.fromISO(start);
10831083
const stopDate = DateTime.fromISO(end);
10841084
const dateArray = [];
10851085
while (currentDate <= stopDate) {
1086-
dateArray.push(DateTime.fromISO(currentDate).toFormat('yyyy-MM-dd'));
1086+
if (s3Path) {
1087+
const t = DateTime.fromISO(currentDate).toFormat('yyyy-MM-dd');
1088+
let evaluated = s3Path.replace('{time}', t);
1089+
if (formatFunction) {
1090+
evaluated = s3Path.replace('{time}', formatFunction(t));
1091+
}
1092+
dateArray.push([t, evaluated]);
1093+
} else {
1094+
dateArray.push(DateTime.fromISO(currentDate).toFormat('yyyy-MM-dd'));
1095+
}
10871096
currentDate = DateTime.fromISO(currentDate).plus({ days: interval });
10881097
}
10891098
return dateArray;
@@ -5999,19 +6008,23 @@ export const globalIndicators = [
59996008
features: [],
60006009
},
60016010
aoiID: 'World',
6002-
time: getDailyDates('2002-08-02', '2021-12-01'),
6011+
time: getDailyDates('2002-08-02', '2021-12-01', 1, 's3://veda-data-store-staging/EIS/COG/LIS_GLOBAL_DA/Evap/LIS_Evap_{time}0000.d01.cog.tif', (date) => DateTime.fromISO(date).toFormat('yyyyMMdd')),
60036012
inputData: [''],
6004-
yAxis: 'g/m2/s',
6013+
yAxis: 'mg/m2/s',
60056014
eoSensor: null,
60066015
display: {
60076016
protocol: 'xyz',
60086017
minZoom: 1,
60096018
tileSize: 256,
6010-
url: 'https://staging-raster.delta-backend.com/cog/tiles/WebMercatorQuad/{z}/{x}/{y}?url=s3://veda-data-store-staging/EIS/COG/LIS_GLOBAL_DA/Evap/LIS_Evap_{time}0000.d01.cog.tif&nodata=0&rescale=0%2C0.0001&bidx=1&colormap_name=viridis', // rescale taken from VEDA defaults
6019+
url: 'https://staging-raster.delta-backend.com/cog/tiles/WebMercatorQuad/{z}/{x}/{y}?url={time}&nodata=0&rescale=0%2C0.0001&bidx=1&colormap_name=viridis', // rescale taken from VEDA defaults
60116020
name: 'Evapotranspiration - LIS 10km Global DA',
60126021
legendUrl: 'legends/trilateral/LIS_Global_DA_Evap.png',
6013-
dateFormatFunction: (date) => DateTime.fromISO(date).toFormat('yyyyMMdd'),
6014-
labelFormatFunction: (date) => DateTime.fromISO(date).toFormat('yyyy-MM-dd'),
6022+
dateFormatFunction: (date) => `${date[1]}`,
6023+
labelFormatFunction: (date) => DateTime.fromISO(date[0]).toFormat('yyyy-MM-dd'),
6024+
customAreaIndicator: true,
6025+
areaIndicator: nasaStatisticsConfig(
6026+
(value) => value * 1e6,
6027+
),
60156028
},
60166029
},
60176030
},

app/src/helpers/customAreaObjects.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,11 @@ export const fetchCustomAreaObjects = async (
386386
} else if (mergedConfig[lookup].url.includes('/cog/statistics')) {
387387
// Here we handle parallel requests to the new statistical api from nasa
388388
const requests = [];
389-
// Add limit on how many requests we can send if there are over 600 time entries
389+
// Add limit on how many requests we can send if there are over 365 time entries
390390
// TODO: Sending more requests overloads server, need to think how to handle this
391391
let requestTimes = indicator.time;
392-
if (indicator.time.length > 600) {
393-
requestTimes = indicator.time.slice(-600);
392+
if (indicator.time.length > 365) {
393+
requestTimes = indicator.time.slice(-365);
394394
}
395395
requestTimes.forEach((entry) => {
396396
const requestUrl = `${url}?url=${entry[1]}`;

0 commit comments

Comments
 (0)