pytroll / pyorbital

Orbital and astronomy computations in python
http://pyorbital.readthedocs.org/
GNU General Public License v3.0
224 stars 77 forks source link

Fix get_observer_look for satellite exactly at nadir #77

Closed ninahakansson closed 3 years ago

ninahakansson commented 3 years ago

When the satellite is exactly above the observer the satellite elevation angle should be 90 degrees and the azimuth angle is undefined. Set azimuth angle to 180 (initially 0) when satellite elevation is 90 degrees. Also handle the case when topz / rg is larger than 1.0 due to rounding. Previously nans were often returned for satellite elevation 90 degrees. The Orbital class also has a get_observer_look function which does not handle dask and xarray. This function has not been updated.

codecov[bot] commented 3 years ago

Codecov Report

Merging #77 (ca1d4d2) into main (6b7e685) will increase coverage by 0.35%. The diff coverage is 98.68%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #77      +/-   ##
==========================================
+ Coverage   85.31%   85.67%   +0.35%     
==========================================
  Files          13       13              
  Lines        1893     1947      +54     
==========================================
+ Hits         1615     1668      +53     
- Misses        278      279       +1     
Flag Coverage Δ
unittests 85.67% <98.68%> (+0.35%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pyorbital/tests/test_orbital.py 96.21% <98.57%> (+0.76%) :arrow_up:
pyorbital/orbital.py 86.97% <100.00%> (-0.19%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6b7e685...ca1d4d2. Read the comment docs.

ghost commented 3 years ago

Congratulations :tada:. DeepCode analyzed your code in 3.465 seconds and we found no issues. Enjoy a moment of no bugs :sunny:.

👉 View analysis in DeepCode’s Dashboard | Configure the bot

simonrp84 commented 3 years ago

While slightly out-of-scope for this PR, do you know if this problem that you've fixed here would also affect solar angles?

ninahakansson commented 3 years ago

Good question!

It should not happen for solar azimuth angles as pyorbital in astronomy get_alt_az uses np.artan2 that handles special values separately: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html So maybe I should just update to use that function also for the satellite angles?

For the sun zenith angle the formulas are different so I don't think the arcsine for values larger than 1 could happen.