dirac-institute / sorcha

An open-source community LSST Solar System Simulator
Other
18 stars 17 forks source link

Divide by zero error happening in universal_cartesian for long-period comets #688

Closed astronomerritt closed 1 year ago

astronomerritt commented 1 year ago

I'm getting the following error for one of the LPC DP0.3 input files when running on Kelvin:

Traceback (most recent call last):
  File "/users/3057027/.conda/envs/sorcha/bin/sorcha", line 8, in <module>
    sys.exit(main())
  File "/users/3057027/sorcha/src/sorcha/sorcha.py", line 498, in main
    runLSSTSimulation(args, configs, pplogger)
  File "/users/3057027/sorcha/src/sorcha/sorcha.py", line 184, in runLSSTSimulation
    observations = create_ephemeris(orbits_df, filterpointing, args, configs)
  File "/users/3057027/sorcha/src/sorcha/ephemeris/simulation_driver.py", line 40, in create_ephemeris
    sim_dict = generate_simulations(ephem, gm_sun, orbits_df)
  File "/users/3057027/sorcha/src/sorcha/ephemeris/simulation_setup.py", line 94, in generate_simulations
    x, y, z, vx, vy, vz = sp.parse_orbit_row(row, epoch, ephem, sun_dict, gm_sun)
  File "/users/3057027/sorcha/src/sorcha/ephemeris/simulation_parsing.py", line 29, in parse_orbit_row
    ecx, ecy, ecz, dx, dy, dz = universal_cartesian(
ZeroDivisionError: division by zero

The function universal_cartesian is in orbit_conversion_utilities.py.

This seems to be machine-dependent (@bernardinelli tried this on his own machine with no problems).

I'm going to try to narrow down exactly which input line is triggering this. I'm also going to try commenting out the numba decorators on Pedro's recommendation to see if I can get a more informative error message. May also see if I can get the error on my laptop.

The input files in question were emailed around the mailing list a while back. Let me know if you can't find them and want them :)

astronomerritt commented 1 year ago

Commenting out the numba decorator on universal_cartesian results in the following warning:

/users/3057027/.conda/envs/sorcha/lib/python3.10/site-packages/healpy/pixelfunc.py:654: RuntimeWarning: invalid value encountered in _vec2pix_nest
  return pixlib._vec2pix_nest(nside, x, y, z)

The code no longer errors out completely and continues to run.

matthewholman commented 1 year ago

Steph, is there anyway that you can capture the input of that call? It would be nice to know which orbit is causing the code to fail.

astronomerritt commented 1 year ago

Yep - I believe this is the problematic line from the orbits file.

ObjID,FORMAT,q,e,inc,node,argPeri,t_p,epochMJD_TDB
1495,COM,0.6504738389764808,1.013346252192974,163.82981951013986,286.2826813392955,238.2818049877852,60145.1003653,60145.10035810314
astronomerritt commented 1 year ago

From the log, GM_sun is 0.00029591220828411956. Let me know if anything else would be useful.