Smithsonian / SuperNOVAS

The Naval Observatory NOVAS C astrometry library, made better
https://smithsonian.github.io/SuperNOVAS/
The Unlicense
13 stars 3 forks source link

Worked example bugs #70

Closed kiranshila closed 1 month ago

kiranshila commented 1 month ago

So, I'm trying to follow the readme on getting az/el for a sidereal source with the new methods and am running into some issues.

I'm trying

#include "novas.h"
#include "solarsystem.h"
#include <stdio.h>

int main(void) {
  cat_entry star;
  object source;
  observer obs;
  novas_timespec t_obs;
  sky_pos apparent;
  novas_frame obs_frame;
  double az, el;

  novas_debug(NOVAS_DEBUG_EXTRA);

  make_cat_entry("Antares", "FK4", 1, 16.43894213, -26.323094, -12.11, -23.30, 5.89, -3.4, &star);
  transform_cat(CHANGE_EPOCH, NOVAS_JD_B1950, &star, NOVAS_JD_J2000, "FK5", &star);
  transform_cat(CHANGE_J2000_TO_ICRS, 0.0, &star, 0.0, "ICRS", &star);
  make_cat_object(&star, &source);

  make_observer_on_surface(-50.7374, -60.0982, 60.0, 0.0, 0.0, &obs);
  novas_set_time(NOVAS_TAI, 2460570.659259, 37, 0.114, &t_obs);

  novas_make_frame(NOVAS_FULL_ACCURACY, &obs, &t_obs, 0.0, 0.0, &obs_frame);

  novas_sky_pos(&source, &obs_frame, NOVAS_CIRS, &apparent);
  novas_app_to_hor(&obs_frame, NOVAS_CIRS, apparent.ra, apparent.dec, novas_standard_refraction, &az, &el);

  printf("AZ: %f, EL: %f", az, el);
}

But novas_make_frame fails due to a call in planetary ephemeris.

  ERROR! earth_sun_calc_hp: low-precision calculation is not currently allowed as a substitute [=> 3]
       @ ephemeris:planet [=> 13]
       @ novas_create_frame [=> 23]

If I'm understanding this correctly - with all the default Makefile options, linking against solsys3 - there is no "high performance" planet model, so that's why we get this error. Switching the accuracy to NOVAS_REDUCED_ACCURACY results in numbers that look about right (although I was going to cross check with SLALIB or something). But this means all the other calculations are in reduced accuracy, not just the planet ephemeris stuff. I will only ever point at sidereal objects, so I wish I could elid all the planet stuff, to be honest.

Trying one other thing, letting the "lower performance" solsys stuff take the place of the _hp routine with

  enable_earth_sun_hp(1);

results in some other error

  ERROR! earth_sun_calc: invalid or unsupported planet number: 5 [=> 2]
       @ earth_sun_calc_hp [=> 2]
       @ ephemeris:planet [=> 12]
       @ light_time2 [=> 22]

  ERROR! earth_sun_calc: invalid or unsupported planet number: 6 [=> 2]
       @ earth_sun_calc_hp [=> 2]
       @ ephemeris:planet [=> 12]
       @ light_time2 [=> 22]
       @ obs_planets [=> 12]
       @ novas_change_observer [=> 12]
       @ novas_create_frame [=> 52]

Which I suppose all points to the fact that solsys3 doesn't seem by default compatible with the novas_make_frame infrastructure, but I'm not sure how those errors didn't pop up in the reduced accuracy version.

attipaci commented 1 month ago

Right, you cannot construct a high-precision frame without having positions for the massive planets, around which gravitational bending cannot be ignored in general, if you want μas precision. But, you can still construct reduced precision frames with mas precision without those planets. And that should work.

attipaci commented 1 month ago

Basically, there are limited number of high-precision calculations that you can do without having a proper ephemeris plugin... For v1.2 (expected Feb 2025), I'm thinking of implementing a CALCEPH plugin to make it easier to deal with ephemeris files, and point to a suitable JPL ephemeris data that one can use it with to get major planet positions for high-precision calculations. For the Linux packages, I can even package the ephemeris data separately, unless someone already provides packages for those...

attipaci commented 1 month ago

I'll transfer this to discussion, since it's not really an issue. It's just an inconvenient feature.

kiranshila commented 1 month ago

Ok sounds good! This is for radio, and we only need arcmin pointing anyway haha. I see in the docs for novas_make_frame this is mentioned, but it didn't connect for me that the default solsys3 epehem won't work for full accuracy,

attipaci commented 1 month ago

You'll probably want to observe planets, moons, asteroids, and comets with DSA-2000, and you'll inevitable have to have an ephemeris provider. And once you have that, you can integrate it with SuperNOVAS, and you'll have all the high-precision features unlocked....