From ba57aff5b6ff8ceca2f64ebce04d1382e4333d88 Mon Sep 17 00:00:00 2001 From: michealroberts Date: Tue, 12 Nov 2024 11:53:09 +0000 Subject: [PATCH] feat: add parseSIPTerm utility in wcs module in @observerly/astrometry feat: add parseSIPTerm utility in wcs module in @observerly/astrometry --- src/wcs.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wcs.ts b/src/wcs.ts index 481e816..1376ab5 100644 --- a/src/wcs.ts +++ b/src/wcs.ts @@ -21,5 +21,13 @@ export type SIP2DParameters = { BPower: { [key: string]: number } } +/*****************************************************************************************************************/ + +// Helper function to parse SIP terms like "A_0_1" and extract i, j values +export const parseSIPTerm = (term: string, prefix: 'A' | 'B'): [number, number] | null => { + const match = term.match(`^${prefix}_(\\d+)_(\\d+)$`) + return match ? [Number.parseInt(match[1], 10), Number.parseInt(match[2], 10)] : null +} + /*****************************************************************************************************************/