1+ /*****************************************************************************************************************/
2+
3+ // @author Michael Roberts <[email protected] > 4+ // @package @observerly /astrometry/wcs
5+ // @license Copyright © 2021-2023 observerly
6+
7+ /*****************************************************************************************************************/
8+
9+ import { describe , expect , it } from 'vitest'
10+
11+ import {
12+ type SIP2DParameters ,
13+ WCS ,
14+ convertPixelToWorldCoordinateSystem
15+ } from '../src'
16+
17+ /*****************************************************************************************************************/
18+
19+ describe ( 'convertPixelToWorldCoordinateSystem' , ( ) => {
20+ it ( 'should be defined' , ( ) => {
21+ expect ( convertPixelToWorldCoordinateSystem ) . toBeDefined ( )
22+ } )
23+
24+ it ( 'should convert pixel coordinates to equatorial coordinates correctly without SIP transformations' , ( ) => {
25+ const wcs = {
26+ crpix : { x : 200 , y : 200 } ,
27+ crval : { ra : 0 , dec : 0 } ,
28+ cd11 : 0.2 ,
29+ cd12 : 30 ,
30+ cd21 : 0.2 ,
31+ cd22 : 0.2 ,
32+ E : 0 ,
33+ F : 0
34+ } satisfies WCS
35+
36+ const pixel = { x : 100 , y : 100 }
37+
38+ const equatorial = convertPixelToWorldCoordinateSystem ( wcs , pixel )
39+
40+ expect ( equatorial ) . toEqual ( { ra : 220 , dec : - 40 } )
41+ } )
42+
43+ it ( 'should convert pixel coordinates to equatorial coordinates correctly with SIP transformations' , ( ) => {
44+ const sip = {
45+ AOrder : 2 ,
46+ BOrder : 2 ,
47+ APower : { A_1_0 : 0 , A_0_1 : 0 , A_1_1 : 2.47110429124e-07 , A_2_0 : 6.71868472834e-07 , A_0_2 : 2.8223469986e-07 } ,
48+ BPower : { B_1_0 : 0 , B_0_1 : 0 , B_1_1 : 2.47110429124e-07 , B_2_0 : 6.71868472834e-07 , B_0_2 : 2.8223469986e-07 }
49+ } satisfies SIP2DParameters
50+
51+ const wcs = {
52+ crpix : { x : 200 , y : 200 } ,
53+ crval : { ra : 0 , dec : 0 } ,
54+ cd11 : 0.2 ,
55+ cd12 : 30 ,
56+ cd21 : 0.2 ,
57+ cd22 : 0.2 ,
58+ E : 0 ,
59+ F : 0 ,
60+ SIP : sip
61+ } satisfies WCS
62+
63+ const pixel = { x : 100 , y : 100 }
64+
65+ const equatorial = convertPixelToWorldCoordinateSystem ( wcs , pixel )
66+
67+ expect ( equatorial . ra ) . toBeCloseTo ( 220.36 , 1 )
68+ expect ( equatorial . dec ) . toBeCloseTo ( - 39.99 , 1 )
69+ } )
70+ } )
71+
72+ /*****************************************************************************************************************/
0 commit comments