wcs 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,621 @@
1
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../ext'
2
+ require "wcs"
3
+
4
+ def float_close(x,y,epsilon=Float::EPSILON)
5
+ if Array===x && Array===y
6
+ if x.size != y.size
7
+ false
8
+ end
9
+ x.size.times.all? do |i|
10
+ float_close(x[i],y[i],epsilon)
11
+ end
12
+ elsif Array===x || Array===y
13
+ false
14
+ elsif Numeric===x && Numeric===y
15
+ if Float===x || Float===y
16
+ (y-x).abs <= (x.abs+y.abs)*epsilon
17
+ else
18
+ x==y
19
+ end
20
+ else
21
+ x==y
22
+ end
23
+ end
24
+
25
+ RSpec::Matchers.define :be_close_to do |y|
26
+ match do |x|
27
+ float_close(x,y,1e-14)
28
+ end
29
+ end
30
+
31
+
32
+
33
+ describe "Wcs::WorldCoor" do
34
+
35
+ cra = 0 # Center right ascension in degrees
36
+ cdec = 0 # Center declination in degrees
37
+ specpix = 1 # Number of arcseconds per pixel
38
+ xrpix = 1 # Reference pixel X coordinate
39
+ yrpix = 1 # Reference pixel X coordinate
40
+ nxpix = 100 # Number of pixels along x-axis
41
+ nypix = 100 # Number of pixels along y-axis
42
+ rotate = 0 # Rotation angle (clockwise positive) in degrees
43
+ equinox = 2000 # Equinox of coordinates, 1950 and 2000 supported
44
+ epoch = 2000
45
+ proj = "TAN" # Projection
46
+
47
+ describe Wcs::WorldCoor.new(cra,cdec,specpix,xrpix,yrpix,nxpix,nypix,rotate,equinox,epoch,proj) do
48
+ its(:class){should == Wcs::WorldCoor}
49
+ end
50
+
51
+ naxis1 = 100 # /* Number of pixels along x-axis */
52
+ naxis2 = 100 # /* Number of pixels along y-axis */
53
+ ctype1 = "RA--TAN" # /* FITS WCS projection for axis 1 */
54
+ ctype2 = "DEC-TAN" # /* FITS WCS projection for axis 2 */
55
+ crpix1 = 0 # /* Reference pixel coordinates */
56
+ crpix2 = 0 # /* Reference pixel coordinates */
57
+ crval1 = 0 # /* Coordinate at reference pixel in degrees */
58
+ crval2 = 0 # /* Coordinate at reference pixel in degrees */
59
+ cd = nil # /* Rotation matrix, used if not NULL */
60
+ cdelt1 = 0.1 # /* scale in degrees/pixel, if cd is NULL */
61
+ cdelt2 = 0.1 # /* scale in degrees/pixel, if cd is NULL */
62
+ crota = 0 # /* Rotation angle in degrees, if cd is NULL */
63
+ equinox = 2000 # /* Equinox of coordinates, 1950 and 2000 supported */
64
+ epoch = 2000 # /* Epoch of coordinates, for FK4/FK5 conversion */
65
+
66
+ describe Wcs::WorldCoor.new(naxis1, naxis2, ctype1, ctype2,
67
+ crpix1, crpix2, crval1, crval2,
68
+ cd, cdelt1, cdelt2, crota, equinox, epoch) do
69
+ its(:class){should == Wcs::WorldCoor}
70
+ end
71
+
72
+ hstr="
73
+ SIMPLE = T
74
+ BITPIX = -64
75
+ NAXIS = 2
76
+ NAXIS1 = 10000
77
+ NAXIS2 = 10000
78
+ CTYPE1 = 'RA---TAN'
79
+ CTYPE2 = 'DEC--TAN'
80
+ EQUINOX = 2000
81
+ CRVAL1 = 10.685497001
82
+ CRVAL2 = 41.270525148
83
+ CDELT1 = -0.000277780
84
+ CDELT2 = 0.000277780
85
+ CRPIX1 = 5000.0000
86
+ CRPIX2 = 5000.0000
87
+ CROTA2 = 0.0
88
+ END
89
+ "
90
+ hstr = hstr.split(/\n/).map{|x| x+" "*(80-x.size)}.join("")
91
+
92
+ describe Wcs::WorldCoor.new(hstr) do
93
+ its(:class){should == Wcs::WorldCoor}
94
+ end
95
+ end
96
+
97
+
98
+ describe "Wcs::WorldCoor" do
99
+
100
+ before{
101
+ naxis1 = 100 # /* Number of pixels along x-axis */
102
+ naxis2 = 100 # /* Number of pixels along y-axis */
103
+ ctype1 = "RA--TAN" # /* FITS WCS projection for axis 1 */
104
+ ctype2 = "DEC-TAN" # /* FITS WCS projection for axis 2 */
105
+ crpix1 = 0 # /* Reference pixel coordinates */
106
+ crpix2 = 0 # /* Reference pixel coordinates */
107
+ crval1 = 0 # /* Coordinate at reference pixel in degrees */
108
+ crval2 = 0 # /* Coordinate at reference pixel in degrees */
109
+ cd = nil # /* Rotation matrix, used if not NULL */
110
+ cdelt1 = 0.1 # /* scale in degrees/pixel, if cd is NULL */
111
+ cdelt2 = 0.1 # /* scale in degrees/pixel, if cd is NULL */
112
+ crota = 0 # /* Rotation angle in degrees, if cd is NULL */
113
+ equinox = 2000 # /* Equinox of coordinates, 1950 and 2000 supported */
114
+ epoch = 2000 # /* Epoch of coordinates, for FK4/FK5 conversion */
115
+
116
+ @wcs = Wcs::WorldCoor.new(naxis1, naxis2, ctype1, ctype2,
117
+ crpix1, crpix2, crval1, crval2,
118
+ cd, cdelt1, cdelt2, crota, equinox, epoch)
119
+ }
120
+
121
+ it {@wcs.class.should == Wcs::WorldCoor}
122
+ it {@wcs.wcs2pix(0.5,0.5).should be_close_to [5.000126927791313, 5.000317324553201, 0]}
123
+ it {@wcs.pix2wcs(50,50).should be_close_to [4.987365288755012, 4.968577292595944]}
124
+
125
+ # Set projection type from header CTYPEs
126
+ #
127
+ # @param [String] ctype1 FITS WCS projection for axis 1
128
+ # @param [String] ctype2 FITS WCS projection for axis 2
129
+ # @return [Integer]
130
+ ctype1='TAN'
131
+ ctype2='TAN'
132
+ it {@wcs.wcstype(ctype1,ctype2).should == 0}
133
+
134
+ # @return [Bool] Returns 1 if wcs structure set, else 0
135
+ it {@wcs.iswcs.should == true}
136
+
137
+ # @return [Bool] Returns 0 if wcs structure set, else 1
138
+ it {@wcs.nowcs.should == false}
139
+
140
+ # Convert pixel coordinates to World Coordinate string
141
+ #
142
+ # @param [Float] xpix Image horizontal coordinate in pixels
143
+ # @param [Float] ypix Image vertical coordinate in pixels
144
+ # @return [String] World coordinate string
145
+ xpix = 10
146
+ ypix = 10
147
+ it {@wcs.pix2wcst(xpix,ypix).should == "00:03:59.976 +00:59:59.09 FK5"}
148
+
149
+ # Convert pixel coordinates to World Coordinates
150
+ #
151
+ # @param [Float] xpix Image horizontal coordinate in pixels
152
+ # @param [Float] ypix Image vertical coordinate in pixels
153
+ # @return [[xpos,ypos]] RA and Dec in degrees
154
+ it {@wcs.pix2wcs(xpix,ypix).should == [0.9998984794143875, 0.9997462518566833]}
155
+
156
+ # Convert World Coordinates to pixel coordinates
157
+ #
158
+ # @param [Float] xpos Longitude/Right Ascension in degrees
159
+ # @param [Float] ypos Latitude/Declination in degrees
160
+ # @param [String] coorsys Coordinate system (FK4, FK5, B1950, J2000, GALACTIC, ECLIPTIC)
161
+ # @return [[xpix,ypix,offscl]]
162
+ # * xpix: Image horizontal coordinate in pixels
163
+ # * ypix: Image vertical coordinate in pixels
164
+ # * offscl: 0 if within bounds, else off scale
165
+ xpos = 1.0
166
+ ypos = 1.0
167
+ coorsys = 'J2000'
168
+ it {@wcs.wcsc2pix(xpos,ypos,coorsys).should be_close_to [10.001015515136944, 10.002538950267457, 0]}
169
+
170
+ # Convert World Coordinates to pixel coordinates
171
+ #
172
+ # @param [Float] xpos Longitude/Right Ascension in degrees
173
+ # @param [Float] ypos Latitude/Declination in degrees
174
+ # @return [[xpix,ypix,offscl]]
175
+ # * xpix: Image horizontal coordinate in pixels
176
+ # * ypix: Image vertical coordinate in pixels
177
+ # * offscl: 0 if within bounds, else off scale
178
+ it {@wcs.wcs2pix(xpos,ypos).should be_close_to [10.001015515136944, 10.002538950267457, 0]}
179
+
180
+ # Change center of WCS
181
+ #
182
+ # @param [Float] cra New center right ascension in degrees
183
+ # @param [Float] cdec New center declination in degrees
184
+ # @param [String] coorsys FK4 or FK5 coordinates (1950 or 2000)
185
+ # @return [nil]
186
+ cra = 1.0
187
+ cdec = 1.0
188
+ coorsys = 'FK5'
189
+ it {@wcs.wcsshift(cra,cdec,coorsys).should == nil}
190
+
191
+ # Return RA and Dec of image center, size in degrees
192
+ #
193
+ # @return [[ra,dec,width,height]]
194
+ # * ra: Right ascension of image center (deg) (returned)
195
+ # * dec: Declination of image center (deg) (returned)
196
+ # * width: Width in degrees (returned)
197
+ # * height: Height in degrees (returned)
198
+ it {@wcs.wcsfull.should == [5.036983632308005, 5.017631465225092, 9.861328265404987, 9.861328461681406]}
199
+
200
+ # Print the image center and size in WCS units
201
+ it {@wcs.wcscent.should == nil}
202
+
203
+ # Return image center and size in RA and Dec
204
+ #
205
+ # @return [[cra,cdec,ora,odec]]
206
+ # * cra: Right ascension of image center (deg) (returned)
207
+ # * cdec: Declination of image center (deg) (returned)
208
+ # * dra: Half-width in right ascension (deg) (returned)
209
+ # * ddec: Half-width in declination (deg) (returned)
210
+ it {@wcs.wcssize.should == [5.036983632308005, 5.017631465225092, 4.949631960155275, 4.930664230840703]}
211
+
212
+ # Return min and max RA and Dec of image in degrees
213
+ #
214
+ # @return [[ra1,ra2,dec1,dec1]]
215
+ # * ra1: Min. right ascension of image (deg) (returned)
216
+ # * ra2: Max. right ascension of image (deg) (returned)
217
+ # * dec1: Min. declination of image (deg) (returned)
218
+ # * dec2: Max. declination of image (deg) (returned)
219
+ it {@wcs.wcsrange.should == [0.09999989846104272, 9.900277248989845, 0.09851075234944665, 9.900262468395615]}
220
+
221
+ # Set scaling and rotation from CD matrix
222
+ #
223
+ # @param [Array] cd CD matrix, (2x2 array) ignored if NULL
224
+ # @return [nil]
225
+ cd = [1,0,0,1]
226
+ it {@wcs.wcscdset(cd).should == nil}
227
+
228
+ # set scaling, rotation from CDELTi, CROTA2
229
+ #
230
+ # @param [Float] cdelt1 degrees/pixel in first axis (or both axes)
231
+ # @param [Float] cdelt2 degrees/pixel in second axis if nonzero
232
+ # @param [Float] crota Rotation counterclockwise in degrees
233
+ # @return [nil]
234
+ cdelt1 = 0.001
235
+ cdelt2 = 0.001
236
+ crota = 0
237
+ it {@wcs.wcsdeltset(cdelt1,cdelt2,crota).should == nil}
238
+
239
+ # set scaling, rotation from CDELTs and PC matrix
240
+ #
241
+ # @param [Float] cdelt1 degrees/pixel in first axis (or both axes)
242
+ # @param [Float] cdelt2 degrees/pixel in second axis if nonzero
243
+ # @param [Array] pc Rotation matrix, ignored if NULL
244
+ pc = nil
245
+ it {@wcs.wcspcset(cdelt1,cdelt2,pc).should == nil}
246
+
247
+ # @return [String] name of image coordinate system
248
+ it {@wcs.getradecsys.should == 'FK5'}
249
+
250
+ # Set output coordinate system for pix2wcs
251
+ #
252
+ # @param [String] coorsys Coordinate system (B1950, J2000, etc)
253
+ # @return [nil]
254
+ coorsys = 'J2000'
255
+ it {@wcs.wcsoutinit(coorsys).should == nil}
256
+
257
+ # @return [String] Return current output coordinate system
258
+ it {@wcs.getwcsout.should == 'FK5'}
259
+
260
+ # Set input coordinate system for wcs2pix
261
+ #
262
+ # @param [String] coorsys Coordinate system (B1950, J2000, etc)
263
+ # @return [nil]
264
+ it {@wcs.wcsininit(coorsys).should == nil}
265
+
266
+ # @return [String] Return current input coordinate system
267
+ it {@wcs.getwcsin.should == 'FK5'}
268
+
269
+ # Set WCS coordinate output format
270
+ #
271
+ # @param [Integer] degout 1= degrees, 0= hh:mm:ss dd:mm:ss
272
+ # @return [Integer]
273
+ degout = 1
274
+ it {@wcs.setwcsdeg(degout).should == 0}
275
+
276
+ # Set or get number of output decimal places
277
+ #
278
+ # @param [Integer] ndec Number of decimal places in output string. if < 0, return current ndec unchanged
279
+ ndec = 2
280
+ it {@wcs.wcsndec(ndec).should == 2}
281
+
282
+ # Change WCS using arguments
283
+ #
284
+ # @param [Float] crpix1 Horizontal reference pixel
285
+ # @param [Float] crpix2 Vertical reference pixel
286
+ # @param [Float] crval1 Reference pixel horizontal coordinate in degrees
287
+ # @param [Float] crval2 Reference pixel vertical coordinate in degrees
288
+ # @param [Float] cdelt1 Horizontal scale in degrees/pixel, ignored if cd is not NULL
289
+ # @param [Float] cdelt2 Vertical scale in degrees/pixel, ignored if cd is not NULL
290
+ # @param [Float] crota Rotation angle in degrees, ignored if cd is not NULL
291
+ # @param [Array] cd Rotation matrix, used if not NULL
292
+ # @return [Integer]
293
+
294
+ crpix1 = 0 # /* Reference pixel coordinates */
295
+ crpix2 = 0 # /* Reference pixel coordinates */
296
+ crval1 = 0 # /* Coordinate at reference pixel in degrees */
297
+ crval2 = 0 # /* Coordinate at reference pixel in degrees */
298
+ cd = nil # /* Rotation matrix, used if not NULL */
299
+ cdelt1 = 0.1 # /* scale in degrees/pixel, if cd is NULL */
300
+ cdelt2 = 0.1 # /* scale in degrees/pixel, if cd is NULL */
301
+ crota = 0 # /* Rotation angle in degrees, if cd is NULL */
302
+
303
+ it {@wcs.wcsreset(crpix1,crpix2,crval1,crval2,cdelt1,cdelt2,crota,cd).should == 0}
304
+
305
+ # Change equinox of reference pixel coordinates in WCS
306
+ #
307
+ # @param [Float] equinox Desired equinox as fractional year
308
+ # @return [nil]
309
+ equinox = 2000
310
+ it {@wcs.wcseqset(equinox).should == nil}
311
+
312
+ # Set pix2wcst() mode for LINEAR coordinates
313
+ #
314
+ # @param [Integer] mode 0: x y linear, 1: x units x units, 2: x y linear units
315
+ # @return [Integer]
316
+ mode = 0
317
+ it {@wcs.setwcslin(mode).should == nil}
318
+
319
+ # Return coordinate in third dimension
320
+ #
321
+ # @return [Integer]
322
+ it {@wcs.wcszout.should == 0}
323
+ end
324
+
325
+
326
+ describe "Wcs" do
327
+ alpha = 0
328
+ delta = 0
329
+ describe Wcs.wcscon(Wcs::J2000,Wcs::GALACTIC,0,0,alpha,delta,2000) do
330
+ it{should be_close_to [96.33726964987589, -60.188551749437046]}
331
+ end
332
+
333
+
334
+ # Compute angular distance between 2 sky positions
335
+ #
336
+ # @param [Float] ra1 First longitude/right ascension in degrees
337
+ # @param [Float] dec1 First latitude/declination in degrees
338
+ # @param [Float] ra2 Second longitude/right ascension in degrees
339
+ # @param [Float] dec2 Second latitude/declination in degrees
340
+ # @return [Float]
341
+ ra1 = 0
342
+ dec1 = 0
343
+ ra2 = 1
344
+ dec2 = 1
345
+ describe Wcs.wcsdist(ra1,dec1,ra2,dec2) do
346
+ it{should be_close_to 1.414177660951948}
347
+ end
348
+
349
+ # Compute angular distance between 2 sky positions
350
+ #
351
+ # @param [Float] ra1 First longitude/right ascension in degrees
352
+ # @param [Float] dec1 First latitude/declination in degrees
353
+ # @param [Float] ra2 Second longitude/right ascension in degrees
354
+ # @param [Float] dec2 Second latitude/declination in degrees
355
+ # @return [Float]
356
+ describe Wcs.wcsdiff(ra1,dec1,ra2,dec2) do
357
+ it{should be_close_to 1.4142404881141812}
358
+ end
359
+
360
+ # Set WCS error message for later printing
361
+ #
362
+ # @param [String] errmsg Error mesage < 80 char
363
+ # @return [String]
364
+ errmsg = "test message"
365
+ describe Wcs.setwcserr(errmsg) do
366
+ it{should == ""}
367
+ end
368
+
369
+ # Print WCS error message to stderr
370
+ # @return [nil]
371
+ describe Wcs.wcserr do
372
+ it{should == ""}
373
+ end
374
+
375
+ # Set flag to use AIPS WCS instead of WCSLIB
376
+ #
377
+ # @param [Integer] oldwcs 1 for AIPS WCS subroutines, else WCSLIB
378
+ # @return [String]
379
+ oldwcs = 0
380
+ describe Wcs.setdefwcs(oldwcs) do
381
+ it{should ==""}
382
+ end
383
+
384
+ # Return flag for AIPS WCS set by setdefwcs
385
+ # @return [Integer]
386
+ describe Wcs.getdefwcs do
387
+ it{should == 0}
388
+ end
389
+
390
+ # Set third dimension for cube projections
391
+ #
392
+ # @param [Integer] izpix Set coordinate in third dimension (face)
393
+ # @return [Integer]
394
+ izpix = 4
395
+ describe Wcs.wcszin(izpix) do
396
+ it{should == 4}
397
+ end
398
+
399
+ # Set filename for WCS error message
400
+ #
401
+ # @param [String] filename FITS or IRAF file name
402
+ # @return [String]
403
+ filename = 'test.dat'
404
+ describe Wcs.setwcsfile(filename) do
405
+ it{should == ''}
406
+ end
407
+
408
+
409
+ # Save output coordinate system
410
+ #
411
+ # @param [String] wcscoor coordinate system (J2000, B1950, galactic)
412
+ # @return [String]
413
+ wcscoor = 'J2000'
414
+ describe Wcs.savewcscoor(wcscoor) do
415
+ it{should == ''}
416
+ end
417
+
418
+ # Return output coordinate system
419
+ # @return [String]
420
+ describe Wcs.getwcscoor do
421
+ it{should == 'J2000'}
422
+ end
423
+
424
+ # Convert from coordinate system sys1 to coordinate system sys2, converting
425
+ # proper motions, too, and adding them if an epoch is specified
426
+ #
427
+ # @param [Integer] sys1 Input coordinate system (J2000, B1950, ECLIPTIC, GALACTIC
428
+ # @param [Integer] sys2 Output coordinate system (J2000, B1950, ECLIPTIC, G ALACTIC
429
+ # @param [Float] eq1 Input equinox (default of sys1 if 0.0)
430
+ # @param [Float] eq2 Output equinox (default of sys2 if 0.0)
431
+ # @param [Float] ep1 Input Besselian epoch in years
432
+ # @param [Float] ep2 Output Besselian epoch in years
433
+ # @param [Float] dtheta Longitude or right ascension in degrees in sys1
434
+ # @param [Float] dphi Latitude or declination in degrees in sys1
435
+ # @param [Float] ptheta Longitude or right ascension proper motion in deg/year in sys1
436
+ # @param [Float] pphi Latitude or declination proper motion in deg/year
437
+ # @param [Float] px Parallax in arcseconds
438
+ # @param [Float] rv Radial velocity in km/sec
439
+ # @return [[dtheta,dphi,ptheta,pphi,px,rv]]
440
+ # * dtheta: Longitude or right ascension in degrees in sys1
441
+ # * dphi: Latitude or declination in degrees in sys1
442
+ # * ptheta: Longitude or right ascension proper motion in deg/year in sys1
443
+ # * pphi: Latitude or declination proper motion in deg/year
444
+ # * px: Parallax in arcseconds
445
+ # * rv: Radial velocity in km/sec
446
+ sys1 = Wcs::J2000
447
+ sys2 = Wcs::GALACTIC
448
+ eq1 = 0
449
+ eq2 = 0
450
+ ep1 = 2000
451
+ ep2 = 2000
452
+ dtheta = 0
453
+ dphi = 0
454
+ ptheta = 0
455
+ pphi = 0
456
+ px = 0
457
+ rv = 0
458
+ describe Wcs.wcsconv(sys1,sys2,eq1,eq2,ep1,ep2,dtheta,dphi,ptheta,pphi,px,rv) do
459
+ it{should be_close_to [96.33726964987589, -60.188551749437046, 0.0, 0.0, 0.0, 0.0]}
460
+ # This function is defined in C
461
+ end
462
+
463
+ # Convert from coordinate system sys1 to coordinate system sys2, converting
464
+ # proper motions, too, and adding them if an epoch is specified
465
+ #
466
+ # @param [Integer] sys1 Input coordinate system (J2000, B1950, ECLIPTIC, GALACTIC
467
+ # @param [Integer] sys2 Output coordinate system (J2000, B1950, ECLIPTIC, GALACTIC
468
+ # @param [Float] eq1 Input equinox (default of sys1 if 0.0)
469
+ # @param [Float] eq2 Output equinox (default of sys2 if 0.0)
470
+ # @param [Float] ep1 Input Besselian epoch in years (for proper motion)
471
+ # @param [Float] ep2 Output Besselian epoch in years (for proper motion)
472
+ # @param [Float] dtheta Longitude or right ascension in degrees
473
+ # @param [Float] dphi Latitude or declination in degrees
474
+ # @param [Float] ptheta Longitude or right ascension proper motion in RA degrees/yea
475
+ # @param [Float] pphi Latitude or declination proper motion in Dec degrees/year
476
+ # @return [[dtheta,dphi,ptheta,pphi]]
477
+ # * dtheta: Longitude or right ascension in degrees
478
+ # * dphi: Latitude or declination in degrees
479
+ # * ptheta: Longitude or right ascension proper motion in RA degrees/yea
480
+ # * pphi: Latitude or declination proper motion in Dec degrees/year
481
+ sys1 = Wcs::J2000
482
+ sys2 = Wcs::GALACTIC
483
+ eq1 = 0
484
+ eq2 = 0
485
+ ep1 = 0
486
+ ep2 = 0
487
+ dtheta = 0
488
+ dphi = 0
489
+ ptheta = 0
490
+ pphi = 0
491
+ describe Wcs.wcsconp(sys1,sys2,eq1,eq2,ep1,ep2,dtheta,dphi,ptheta,pphi) do
492
+ it{should be_close_to [96.33726964987589, -60.188551749437046, 0.0, 0.0]}
493
+ end
494
+
495
+ # Convert between coordinate systems and equinoxes
496
+ #
497
+ # @param [Integer] sys1 Input coordinate system (J2000, B1950, ECLIPTIC, GALACTIC
498
+ # @param [Integer] sys2 Output coordinate system (J2000, B1950, ECLIPTIC, G ALACTIC
499
+ # @param [Float] eq1 Input equinox (default of sys1 if 0.0)
500
+ # @param [Float] eq2 Output equinox (default of sys2 if 0.0)
501
+ # @param [Float] dtheta Longitude or right ascension in degrees
502
+ # @param [Float] dphi Latitude or declination in degrees
503
+ # @param [Float] epoch Besselian epoch in years
504
+ # @return [[dtheta,dphi]]
505
+ # * dtheta: Longitude or right ascension in degrees
506
+ # * dphi: Latitude or declination in degrees
507
+ sys1 = Wcs::J2000
508
+ sys2 = Wcs::GALACTIC
509
+ eq1 = 0
510
+ eq2 = 0
511
+ dtheta = 0
512
+ dphi = 0
513
+ epoch = 2000
514
+ describe Wcs.wcscon(sys1,sys2,eq1,eq2,dtheta,dphi,epoch) do
515
+ it{should be_close_to [96.33726964987589, -60.188551749437046]}
516
+ end
517
+
518
+ # Convert B1950(FK4) to J2000(FK5) coordinates
519
+ #
520
+ # @param [Float] ra Right ascension in degrees (B1950 in, J2000 out)
521
+ # @param [Float] dec Declination in degrees (B1950 in, J2000 out)
522
+ # @param [Float] epoch Besselian epoch in years
523
+ # @return [[ra,dec]]
524
+ ra = 0
525
+ dec = 0
526
+ epoch = 2000
527
+ describe Wcs.fk425e(ra,dec,epoch) do
528
+ it{should be_close_to [0.6407243227035837, 0.2783490290365543]}
529
+ end
530
+
531
+ # Convert J2000(FK5) to B1950(FK4) coordinates
532
+ #
533
+ # @param [Float] ra Right ascension in degrees (J2000 in, B1950 out)
534
+ # @param [Float] dec Declination in degrees (J2000 in, B1950 out)
535
+ # @param [Float] epoch Besselian epoch in years
536
+ # @return [[ra,dec]]
537
+ ra = 0
538
+ dec = 0
539
+ epoch = 2000
540
+ describe Wcs.fk524e(ra,dec,epoch) do
541
+ it{should be_close_to [359.3592746342251, -0.27834947215423617]}
542
+ end
543
+
544
+ # Return code for coordinate system in string
545
+ #
546
+ # @param [String] coorsys Coordinate system (B1950, J2000, etc)
547
+ # @return [Integer]
548
+ coorsys = 'J2000'
549
+ describe Wcs.wcscsys(coorsys) do
550
+ it{should == 1}
551
+ end
552
+
553
+ # Set equinox from string
554
+ #
555
+ # @param [String] wcstring_in Coordinate system (B1950, J2000, etc)
556
+ # @return [Float] return 0.0 if not obvious
557
+ wcstring_in = 'J2000'
558
+ describe Wcs.wcsceq(wcstring_in) do
559
+ it{should == 2000}
560
+ end
561
+
562
+ # Set coordinate system type string from system and equinox
563
+ #
564
+ # @param [Integer] syswcs Coordinate system code
565
+ # @param [Float] equinox Equinox of coordinate system
566
+ # @param [Float] epoch Epoch of coordinate system
567
+ # @return [String] Coordinate system string (returned)
568
+ syswcs = Wcs::J2000
569
+ equinox = 2000
570
+ epoch = 2000
571
+ describe Wcs.wcscstr(syswcs,equinox,epoch) do
572
+ it{should == "J2000"}
573
+ end
574
+
575
+ # Convert RA and Dec in degrees and distance to vector
576
+ #
577
+ # @param [Float] ra Right ascension in degrees
578
+ # @param [Float] dec Declination in degrees
579
+ # @param [Float] r Distance to object in same units as pos
580
+ # @return [[x,y,z]] x,y,z geocentric equatorial position of object
581
+ ra = 0
582
+ dec = 0
583
+ r = 1
584
+ describe Wcs.d2v3(ra,dec,r) do
585
+ it{should be_close_to [1,0,0]}
586
+ end
587
+
588
+ # Convert RA and Dec in radians and distance to vector
589
+ #
590
+ # @param [Float] ra Right ascension in radians
591
+ # @param [Float] dec Declination in radians
592
+ # @param [Float] r Distance to object in same units as pos
593
+ # @return [[x,y,z]] x,y,z geocentric equatorial position of object
594
+ describe Wcs.s2v3(ra,dec,r) do
595
+ it{should be_close_to [1,0,0]}
596
+ end
597
+
598
+ # Convert vector to RA and Dec in degrees and distance
599
+ #
600
+ # @param [Array] pos x,y,z geocentric equatorial position of object
601
+ # @return [[ra,dec,r]]
602
+ # * ra: Right ascension in degrees (returned)
603
+ # * dec: Declination in degrees (returned)
604
+ # * r: Distance to object in same units as pos (returned)
605
+ pos = [1.0,1.0,1.0]
606
+ describe Wcs.v2d3(pos) do
607
+ it{should be_close_to [45.0, 35.264389682754654, 1.7320508075688772]}
608
+ end
609
+
610
+ # Convert vector to RA and Dec in radians and distance
611
+ #
612
+ # @param [Array] pos x,y,z geocentric equatorial position of object
613
+ # @return [[ra,dec,r]]
614
+ # * ra: Right ascension in radians (returned)
615
+ # * dec: Declination in radians (returned)
616
+ # * r: Distance to object in same units as pos (returned)
617
+ describe Wcs.v2s3(pos) do
618
+ it{should be_close_to [0.7853981633974483, 0.6154797086703873, 1.7320508075688772]}
619
+ end
620
+
621
+ end