skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.41k stars 211 forks source link

angle rates #249

Closed drysdam closed 5 years ago

drysdam commented 5 years ago

I'm working with radar data, which includes range rates. That's easy to calculate as a dot product of velocity with range. But the angle rates (az and el) would be very useful for matching to the slew rates of the sensor. Similarly when I process optical data, ra/dec rates are useful.

Obviously all four of these could be found numerically by taking differences, but is there a way to get angle rates out of skyfield directly?

brandon-rhodes commented 5 years ago

I would probably go ahead and take differences because I think that method is the most robust? But there's another approach you could try, yes: if Skyfield can produce the velocity of the object you're asking about, you could use trigonometry to turn the combination of relative position x,y,z and velocity x,y,z into angle rates. I don't think either approach is built into Skyfield; maybe it should be a wishlist item?

drysdam commented 5 years ago

I thought about the analytical method, but knowing which axes are "az" at a particular moment would be hard.

The range-rate should really be instantaneous since that's exactly what a radar measures (i.e. it isn't a difference between two ranges). Fortunately the dot product will give me that.

JoshPaterson commented 5 years ago

Another way that calculating rates would be useful is for functions that find astronomical phenomena. The root and minimum finding functions in skyfield.almanac and in PR #211 use algorithms that don't need derivatives, but algorithms that do use derivatives should use less function calls and therefore should be faster.

brandon-rhodes commented 5 years ago

I'm going to close this for now, but if you'd like to offer a small Python script with a sample object for which you'd like to know the instantaneous range rate, @drysdam, then I can look through Skyfield's plumbing to see if a velocity is available for that particular kind of object. But without knowing whether you're looking at, say, the Moon, or instead something like an Earth satellite, I can't go investigate what velocity data might be available. Simply click "Reopen" if you can share a sample script!

ghost commented 5 years ago

Not sure how helpful it is, but CSPICE has several derivative computing functions, including those that compute derivatives between rectangular and spherical coordinates (which seems to be what you want to do here). If you visit:

https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/index.html

and search for "derivative", you should find several helpful functions that you could use as a basis to write Python functions.