jobovy / galpy

Galactic Dynamics in python
https://www.galpy.org
BSD 3-Clause "New" or "Revised" License
220 stars 95 forks source link

Handle unbound orbits in actionAngle-related functions in new Orbit class #383

Open jobovy opened 5 years ago

jobovy commented 5 years ago

In the new Orbit class, pure Python actionAngle-related functions fail for unbound orbits and cause the entire function to fail when Orbit contains multiple objects. Need to catch the unbound orbits without raising an error (see also #371).

RaynaRampalli commented 3 weeks ago

Hi, I'm running into this issue when calculating actions for 3+ million stars using galpy and am looping thru each star one by one. Do you have any suggested simple workarounds for suppressing the error and just returning nans or something for now? I've tried a couple things and no luck. Thank you!

jobovy commented 3 weeks ago

Hi, I'm running into this issue when calculating actions for 3+ million stars using galpy and am looping thru each star one by one. Do you have any suggested simple workarounds for suppressing the error and just returning nans or something for now? I've tried a couple things and no luck. Thank you!

Thanks for reaching out, sounds like we might actually finally have to fix this issue! Quick question: Can you determine the stars for which the action-angle calculation fails just by determining which stars are unbound, that is, have E > E(infinity)? For example, assuming the orb object is an Orbit instance with multiple objects, some of which have failing action-angles, do

import numpy
from galpy.potential import MWPotential2014, evaluatePotentials
indx= orb.E(pot=MWPotential2014,use_physical=False) < evaluatePotentials(MWPotential2014,numpy.inf,0.,use_physical=False)

Does indx than have the index for all objects that have successful action-angle coordiantes (and True^indx the index for all objects for which they fail?). If that method works, then it should be easy for you to do and I can then also use it to create a fix for this issue. Thanks!

jobovy commented 1 week ago

Hi @RaynaRampalli! Just wanted to check whether you've had a chance to try the fix that I suggested above? I'm getting ready to release a new version of galpy soon and it would be nice to include a proper fix to this issue then. Thanks!

RaynaRampalli commented 1 week ago

Hi! Sorry for the delay; thank you for responding.  I have been traveling so have not had a chance yet. I will try this out and will have an answer for you in about a week. Thanks! Best,Rayna On Jun 26, 2024, at 10:09 AM, Jo Bovy @.***> wrote: Hi @RaynaRampalli! Just wanted to check whether you've had a chance to try the fix that I suggested above? I'm getting ready to release a new version of galpy soon and it would be nice to include a proper fix to this issue then. Thanks!

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>