mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
fix(firms): drop LIVE from the row's source and the voice answer for a snapshot that ends at a set time
The catalog source 'NASA FIRMS · LIVE' still led the row; getStats() now names the source 'NASA FIRMS' for such a snapshot. get_active_fires says "in the 24 hours to" its end and reports window_end. The end is checked to be a printable time, cleared under KEY REQUIRED, the test moves next to the layer, and the changelog and CURRENT-STATE describe it.
This commit is contained in:
1 parent
43706b8dd0
commit
4ef0869a87
10 files changed
+163
-61
No files matched your search
@@ -94,7 +94,8 @@ export const getActiveFires = defineTool({
|
||||
name: 'get_active_fires',
|
||||
title: 'Active fires',
|
||||
description:
|
||||
'Satellite fire detections from NASA FIRMS in the last 24 hours within an ' +
|
||||
'Satellite fire detections from NASA FIRMS in the last 24 hours (or the 24 ' +
|
||||
'hours to window_end, when the source names one) within an ' +
|
||||
'area, most intense (fire radiative power) first. Optionally limited to a ' +
|
||||
'minimum fire radiative power in megawatts and a confidence level — the ' +
|
||||
"same filter as the Active Fires layer's intensity controls.",
|
||||
@@ -171,7 +172,10 @@ export const getActiveFires = defineTool({
|
||||
summary:
|
||||
`${countNoun(fires.length, 'fire detection')}` +
|
||||
(filterNotes.length ? ` (${filterNotes.join(', ')})` : '') +
|
||||
` in ${area.label} in the last 24 hours` +
|
||||
` in ${area.label} ` +
|
||||
(Number.isFinite(snapshot.at)
|
||||
? `in the 24 hours to ${isoTime(snapshot.at)}`
|
||||
: 'in the last 24 hours') +
|
||||
(notes.length ? ` (${notes.join('; ')}).` : '.'),
|
||||
data: {
|
||||
view: suggestView(services, { area, layers: ['local-firms'] }),
|
||||
@@ -182,6 +186,7 @@ export const getActiveFires = defineTool({
|
||||
stale,
|
||||
missing_sources: missing,
|
||||
fetched_at: isoTime(snapshot.fetchedAt),
|
||||
window_end: Number.isFinite(snapshot.at) ? isoTime(snapshot.at) : null,
|
||||
...result,
|
||||
rows: result.rows.map((fire) => ({
|
||||
lat: fire.lat,
|
||||
|
||||
@@ -46,29 +46,80 @@ test('fire acquisition timestamps preserve valid leap days and UTC times', async
|
||||
});
|
||||
|
||||
const WEEK = [
|
||||
{ lat: 24.1, lon: 121.1, frp: 864, confidence: 'l', acqDate: '2026-10-01', acqTime: '0100' },
|
||||
{ lat: 24.2, lon: 121.2, frp: 120, confidence: 'h', acqDate: '2026-10-01', acqTime: '0100' },
|
||||
{ lat: 24.3, lon: 121.3, frp: 20, confidence: 'n', acqDate: '2026-10-01', acqTime: '0100' },
|
||||
{ lat: 24.4, lon: 121.4, frp: 2, confidence: 'h', acqDate: '2026-10-01', acqTime: '0100' },
|
||||
{ lat: 30, lon: 100, frp: 500, confidence: 'h', acqDate: '2026-10-01', acqTime: '0100' },
|
||||
{
|
||||
lat: 24.1,
|
||||
lon: 121.1,
|
||||
frp: 864,
|
||||
confidence: 'l',
|
||||
acqDate: '2026-10-01',
|
||||
acqTime: '0100',
|
||||
},
|
||||
{
|
||||
lat: 24.2,
|
||||
lon: 121.2,
|
||||
frp: 120,
|
||||
confidence: 'h',
|
||||
acqDate: '2026-10-01',
|
||||
acqTime: '0100',
|
||||
},
|
||||
{
|
||||
lat: 24.3,
|
||||
lon: 121.3,
|
||||
frp: 20,
|
||||
confidence: 'n',
|
||||
acqDate: '2026-10-01',
|
||||
acqTime: '0100',
|
||||
},
|
||||
{
|
||||
lat: 24.4,
|
||||
lon: 121.4,
|
||||
frp: 2,
|
||||
confidence: 'h',
|
||||
acqDate: '2026-10-01',
|
||||
acqTime: '0100',
|
||||
},
|
||||
{
|
||||
lat: 30,
|
||||
lon: 100,
|
||||
frp: 500,
|
||||
confidence: 'h',
|
||||
acqDate: '2026-10-01',
|
||||
acqTime: '0100',
|
||||
},
|
||||
];
|
||||
const TAIWAN = { area: { bbox: [120, 23, 122, 25] } };
|
||||
|
||||
test('get_active_fires shows every detection by default and reports the filter it used', async () => {
|
||||
const result = await catalogWith(WEEK).call('get_active_fires', TAIWAN);
|
||||
assert.deepEqual(result.data.rows.map((row) => row.frp_mw), [864, 120, 20, 2]);
|
||||
assert.deepEqual(
|
||||
result.data.rows.map((row) => row.frp_mw),
|
||||
[864, 120, 20, 2],
|
||||
);
|
||||
assert.deepEqual(result.data.filter, { min_frp_mw: 0, confidence: 'all' });
|
||||
assert.match(result.summary, /^4 fire detections in /);
|
||||
});
|
||||
|
||||
test('get_active_fires applies the same minimum-FRP and confidence filter as the layer', async () => {
|
||||
const catalog = catalogWith(WEEK);
|
||||
const strong = await catalog.call('get_active_fires', { ...TAIWAN, min_frp_mw: 20 });
|
||||
assert.deepEqual(strong.data.rows.map((row) => row.frp_mw), [864, 120, 20]);
|
||||
const strong = await catalog.call('get_active_fires', {
|
||||
...TAIWAN,
|
||||
min_frp_mw: 20,
|
||||
});
|
||||
assert.deepEqual(
|
||||
strong.data.rows.map((row) => row.frp_mw),
|
||||
[864, 120, 20],
|
||||
);
|
||||
assert.match(strong.summary, /^3 fire detections \(≥ 20 MW\) in /);
|
||||
|
||||
const nominal = await catalog.call('get_active_fires', { ...TAIWAN, confidence: 'nominal' });
|
||||
assert.deepEqual(nominal.data.rows.map((row) => row.frp_mw), [120, 20, 2], 'the 864 MW low-confidence fire drops');
|
||||
const nominal = await catalog.call('get_active_fires', {
|
||||
...TAIWAN,
|
||||
confidence: 'nominal',
|
||||
});
|
||||
assert.deepEqual(
|
||||
nominal.data.rows.map((row) => row.frp_mw),
|
||||
[120, 20, 2],
|
||||
'the 864 MW low-confidence fire drops',
|
||||
);
|
||||
assert.match(nominal.summary, /\(nominal or high confidence\)/);
|
||||
|
||||
const both = await catalog.call('get_active_fires', {
|
||||
@@ -76,7 +127,27 @@ test('get_active_fires applies the same minimum-FRP and confidence filter as the
|
||||
min_frp_mw: 19.6,
|
||||
confidence: 'high',
|
||||
});
|
||||
assert.deepEqual(both.data.rows.map((row) => row.frp_mw), [120]);
|
||||
assert.deepEqual(
|
||||
both.data.rows.map((row) => row.frp_mw),
|
||||
[120],
|
||||
);
|
||||
assert.deepEqual(both.data.filter, { min_frp_mw: 20, confidence: 'high' });
|
||||
assert.match(both.summary, /\(≥ 20 MW, high confidence\)/);
|
||||
});
|
||||
|
||||
test('get_active_fires names the end of a snapshot that ends at a set time', async () => {
|
||||
const at = Date.UTC(2026, 9, 1, 3);
|
||||
const catalog = composeCatalog({
|
||||
tools: [getActiveFires],
|
||||
services: { fires: { getSnapshot: async () => ({ fires: WEEK, at }) } },
|
||||
});
|
||||
const result = await catalog.call('get_active_fires', TAIWAN);
|
||||
assert.match(
|
||||
result.summary,
|
||||
/in the 24 hours to 2026-10-01T03:00:00\.000Z\.$/,
|
||||
);
|
||||
assert.equal(result.data.window_end, '2026-10-01T03:00:00.000Z');
|
||||
const now = await catalogWith(WEEK).call('get_active_fires', TAIWAN);
|
||||
assert.match(now.summary, /in the last 24 hours\.$/);
|
||||
assert.equal(now.data.window_end, null);
|
||||
});
|
||||
Reference in new issue
Block a user