Skip to content

Commit

Permalink
Merge pull request #402 from observerly/feature/wcs/parseSIPTerm
Browse files Browse the repository at this point in the history
feat: add parseSIPTerm utility in wcs module in @observerly/astrometry
  • Loading branch information
michealroberts authored Nov 12, 2024
2 parents 10c91f1 + ba57aff commit 51a4441
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/wcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


/*****************************************************************************************************************/

0 comments on commit 51a4441

Please sign in to comment.