Skip to content

Commit 8cd77ae

Browse files
tphakalaclaude
andcommitted
feat: pass --day-of-year to birda CLI for BSG SDM support
BSG models use day-of-year (1-366) for Species Distribution Model filtering instead of month/day used by BirdNET range filtering. Compute day-of-year from the recording date and pass both flags so both model types work correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 50791d3 commit 8cd77ae

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/main/birda/runner.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface AnalysisOptions {
1111
longitude?: number | undefined;
1212
month?: number | undefined;
1313
day?: number | undefined;
14+
dayOfYear?: number | undefined;
1415
quiet?: boolean | undefined;
1516
}
1617

@@ -94,6 +95,9 @@ export function runAnalysis(sourcePath: string, options: AnalysisOptions): Analy
9495
if (options.day !== undefined) {
9596
args.push('--day', String(options.day));
9697
}
98+
if (options.dayOfYear !== undefined) {
99+
args.push('--day-of-year', String(options.dayOfYear));
100+
}
97101
if (options.quiet !== false) {
98102
args.push('-q');
99103
}

src/main/ipc/analysis.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ export function registerAnalysisHandlers(): void {
7676
}
7777
}
7878

79+
// Compute day-of-year from month/day for BSG SDM support.
80+
// BSG models use --day-of-year (1-366) instead of --month/--day.
81+
// We pass both so BirdNET gets month/day and BSG gets day-of-year.
82+
let dayOfYear: number | undefined;
83+
if (month !== undefined && day !== undefined) {
84+
const d = new Date(2024, month - 1, day); // leap year to handle Feb 29
85+
const start = new Date(2024, 0, 0);
86+
dayOfYear = Math.floor((d.getTime() - start.getTime()) / (1000 * 60 * 60 * 24));
87+
sendLog(win, 'info', 'analysis', `Computed day-of-year: ${dayOfYear} (from month=${month}, day=${day})`);
88+
}
89+
7990
// Start analysis
8091
const handle = runAnalysis(request.source_path, {
8192
model: request.model,
@@ -84,6 +95,7 @@ export function registerAnalysisHandlers(): void {
8495
longitude: request.longitude,
8596
month,
8697
day,
98+
dayOfYear,
8799
});
88100
currentAnalysis = handle;
89101

0 commit comments

Comments
 (0)