@@ -435,6 +435,7 @@ static int icrs_to_sys(const novas_frame *frame, double *pos, enum novas_referen
435
435
* 50--70 error is 50 + error from light_time2().
436
436
*
437
437
* @sa novas_make_frame()
438
+ * @sa novas_geom_to_app()
438
439
* @sa novas_sky_pos()
439
440
* @sa novas_transform_vector()
440
441
* @sa place()
@@ -453,7 +454,7 @@ int novas_geom_posvel(const object *source, const novas_frame *frame, enum novas
453
454
return novas_error (-1 , EINVAL , fn , "NULL argument: source=%p, frame=%p" , source , frame );
454
455
455
456
if (!pos && !vel )
456
- return novas_error (-1 , EINVAL , fn , "Both output vectors (pos, vel) are NULL" );
457
+ return novas_error (-1 , EINVAL , fn , "Both output vectors (pos, vel) are NULL" );
457
458
458
459
obs = (observer * ) & frame -> observer ;
459
460
@@ -533,7 +534,7 @@ int novas_geom_posvel(const object *source, const novas_frame *frame, enum novas
533
534
* @param sys The coordinate system in which to return the apparent sky location
534
535
* @param[out] out Pointer to the data structure which is populated with the calculated
535
536
* apparent location in the designated coordinate system.
536
- * @return 0 if successful, or an error from grav_def(),
537
+ * @return 0 if successful,
537
538
* 3 if Earth is the observed object, and the observer is either at the
538
539
* geocenter or on the Earth's surface,
539
540
* 50--70 error is 50 + error from light_time2(),
@@ -549,11 +550,10 @@ int novas_geom_posvel(const object *source, const novas_frame *frame, enum novas
549
550
* @author Attila Kovacs
550
551
*/
551
552
int novas_sky_pos (const object * object , const novas_frame * frame , enum novas_reference_system sys , sky_pos * out ) {
552
- static const char * fn = "novas_calc_apparent" ;
553
- enum novas_observer_place loc ;
554
- double jd_tdb , id , d_sb ;
553
+ static const char * fn = "novas_sky_pos" ;
554
+
555
555
double pos [3 ], vel [3 ];
556
- int i ;
556
+ double d_sb ;
557
557
558
558
if (!object || !frame || !out )
559
559
return novas_error (-1 , EINVAL , "NULL argument: object=%p, frame=%p, out=%p" , (void * ) object , frame , out );
@@ -566,8 +566,6 @@ int novas_sky_pos(const object *object, const novas_frame *frame, enum novas_ref
566
566
567
567
prop_error (fn , novas_geom_posvel (object , frame , NOVAS_ICRS , pos , vel ), 0 );
568
568
569
- jd_tdb = novas_get_time (& frame -> time , NOVAS_TDB );
570
-
571
569
if (object -> type == NOVAS_CATALOG_OBJECT ) {
572
570
out -> dis = 0.0 ;
573
571
d_sb = novas_vlen (pos );
@@ -592,6 +590,45 @@ int novas_sky_pos(const object *object, const novas_frame *frame, enum novas_ref
592
590
rad_vel (object , pos , vel , frame -> obs_vel , novas_vdist (frame -> obs_pos , & frame -> pos [NOVAS_EARTH ][0 ]),
593
591
novas_vdist (frame -> obs_pos , & frame -> pos [NOVAS_SUN ][0 ]), d_sb , & out -> rv );
594
592
593
+ prop_error (fn , novas_geom_to_app (frame , pos , sys , out ), 70 );
594
+
595
+ return 0 ;
596
+ }
597
+
598
+ /**
599
+ * Converts an geometric position in ICRS to an apparent position on sky, by applying appropriate
600
+ * corrections for aberration and gravitational deflection for the observer's frame.
601
+ *
602
+ * @param frame The observer frame, defining the location and time of observation
603
+ * @param pos [AU] Geometric position of source in ICRS coordinates
604
+ * @param sys The coordinate system in which to return the apparent sky location
605
+ * @param[out] out Pointer to the data structure which is populated with the calculated
606
+ * apparent location in the designated coordinate system.
607
+ * @return 0 if successful, or an error from grav_def(),
608
+ * or else -1 (errno will indicate the type of error).
609
+ *
610
+ * @sa novas_app_to_geom()
611
+ * @sa novas_geom_posvel()
612
+ * @sa novas_sky_pos()
613
+ */
614
+ int novas_geom_to_app (const novas_frame * frame , const double * pos , enum novas_reference_system sys , sky_pos * out ) {
615
+ static const char * fn = "novas_geom_to_app" ;
616
+
617
+ double jd_tdb , id , pos1 [3 ];
618
+ enum novas_observer_place loc ;
619
+ int i ;
620
+
621
+ if (!pos || !frame || !out )
622
+ return novas_error (-1 , EINVAL , "NULL argument: pos=%p, frame=%p, out=%p" , (void * ) pos , frame , out );
623
+
624
+ if (!is_frame_initialized (frame ))
625
+ return novas_error (-1 , EINVAL , fn , "frame at %p not initialized" , frame );
626
+
627
+ if (frame -> accuracy != NOVAS_FULL_ACCURACY && frame -> accuracy != NOVAS_REDUCED_ACCURACY )
628
+ return novas_error (-1 , EINVAL , fn , "invalid accuracy: %d" , frame -> accuracy );
629
+
630
+ jd_tdb = novas_get_time (& frame -> time , NOVAS_TDB );
631
+
595
632
// ---------------------------------------------------------------------
596
633
// Apply gravitational deflection of light and aberration.
597
634
// ---------------------------------------------------------------------
@@ -605,22 +642,19 @@ int novas_sky_pos(const object *object, const novas_frame *frame, enum novas_ref
605
642
}
606
643
607
644
// Compute gravitational deflection and aberration.
608
- prop_error (fn , grav_def (jd_tdb , loc , frame -> accuracy , pos , frame -> obs_pos , pos ), 70 );
645
+ prop_error (fn , grav_def (jd_tdb , loc , frame -> accuracy , pos , frame -> obs_pos , pos1 ), 0 );
609
646
610
647
// Aberration correction
611
- frame_aberration (frame , GEOM_TO_APP , pos );
648
+ frame_aberration (frame , GEOM_TO_APP , pos1 );
612
649
613
650
// Transform position to output system
614
- prop_error (fn , icrs_to_sys (frame , pos , sys ), 0 );
651
+ prop_error (fn , icrs_to_sys (frame , pos1 , sys ), 0 );
615
652
616
- // ---------------------------------------------------------------------
617
- // Finish up.
618
- // ---------------------------------------------------------------------
619
- vector2radec (pos , & out -> ra , & out -> dec );
653
+ vector2radec (pos1 , & out -> ra , & out -> dec );
620
654
621
- id = 1.0 / novas_vlen (pos );
655
+ id = 1.0 / novas_vlen (pos1 );
622
656
for (i = 3 ; -- i >= 0 ;)
623
- out -> r_hat [i ] = pos [i ] * id ;
657
+ out -> r_hat [i ] = pos1 [i ] * id ;
624
658
625
659
return 0 ;
626
660
}
@@ -761,7 +795,7 @@ int novas_hor_to_app(const novas_frame *frame, double az, double el, RefractionM
761
795
}
762
796
763
797
if (sys < 0 || sys >= NOVAS_REFERENCE_SYSTEMS )
764
- return novas_error (-1 , EINVAL , fn , "invalid reference system" , sys );
798
+ return novas_error (-1 , EINVAL , fn , "invalid reference system: %d " , sys );
765
799
766
800
time = (novas_timespec * ) & frame -> time ;
767
801
@@ -826,7 +860,7 @@ int novas_hor_to_app(const novas_frame *frame, double az, double el, RefractionM
826
860
* @return 0 if successful, or else an error from grav_undef(), or -1 (errno will
827
861
* indicate the type of error).
828
862
*
829
- * @sa novas_transform_skypos ()
863
+ * @sa novas_geom_to_app ()
830
864
*
831
865
* @since 1.1
832
866
* @author Attila Kovacs
@@ -837,13 +871,13 @@ int novas_app_to_geom(const novas_frame *frame, enum novas_reference_system sys,
837
871
double jd_tdb , app_pos [3 ];
838
872
839
873
if (!frame || !geom_icrs )
840
- return novas_error (-1 , EINVAL , fn , "NULL argument: frame=%p, nom_pos =%p" , frame , geom_icrs );
874
+ return novas_error (-1 , EINVAL , fn , "NULL argument: frame=%p, geom_icrs =%p" , frame , geom_icrs );
841
875
842
876
if (!is_frame_initialized (frame ))
843
877
return novas_error (-1 , EINVAL , fn , "frame at %p not initialized" , frame );
844
878
845
879
if (sys < 0 || sys >= NOVAS_REFERENCE_SYSTEMS )
846
- return novas_error (-1 , EINVAL , fn , "invaliud reference system" , sys );
880
+ return novas_error (-1 , EINVAL , fn , "invalid reference system: %d " , sys );
847
881
848
882
jd_tdb = novas_get_time (& frame -> time , NOVAS_TDB );
849
883
0 commit comments