From be4d267824eef042373c8c3c37e5d250abeb85d5 Mon Sep 17 00:00:00 2001 From: Borlaff Date: Tue, 1 Oct 2024 11:34:39 -0700 Subject: [PATCH] Adding is_moonlit method --- .DS_Store | Bin 0 -> 8196 bytes skyfield/positionlib.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..556f2e06adc6555d6d168ef7da888b955dc87dcc GIT binary patch literal 8196 zcmeHMTWl0n7(U;$$P5g0S_WxLl?@BZrNG)2%2l`9fpJgXzpDS z`9=Kc3~?^QKFmOvfyo*0=p!`c_EBcYG#ob;`wl`$>5KQU8E)obm2?-w`o0*JG;6jzNA2nD>z5Ctl!{^6f7_62*p{)9rm zdioqY=QjI`r4%La=p8z(Wen>rw4&2v&?7xZbwZGk-k-Z*(UN7W>KZpUZQHr0W4uf$ zuaMRG4|We5j*&6--n5g|EzPiwbQKKE9q6M(Tdr}~&~uWgeAQ{C2lera%Bt#xHLA*| z+;%B0(v!~^$MS}ILWzpvc!g447Eu?=`!(9zZd>yf(?sQhPorOp%6qR%_pvwV{+$F0)nJCTvIQvRlCe|MmHrz>*aiTG%djh~?M_JHuXPXW4mnkzHa}*fsVu`<>kYAfN;@Fbnfgg(y~{ z0qf9+^=QH#v|%qg(2pY+fPoweIF6GT!LvAp(|8_d@Dg6b>v$7y;az-yb2yI+_#9v0 zGQP$)xPl+?6Mn&U{DGVJ6MqRag({(1SSTzJRtsx{n6N?EC~OwC2<^gNp-;#Prf^Ki z@d$(>?G6@04D=%;C!HolyCF_H;oQ`;tJ%I|XREw>+R*OmT#sn;h-eEUOINIESidE4 z3y~bcMbzHO1)l(S(Z(l$kB$k*9rr0IKfI{O!P~6lEbSuZ=*LA5{>sc?c65nI%u!|p z!)429*s46hhc&BKi^Nhz@P~3uT|FHDX{96>u4<$q_(0yYSt3>{rQ-{$sw*F_iOUM3 z!$Jxc+PaMvx~z!*6ymS4AJ}z5{7pjqT*7)K9z~2$p1^h==j}+M3kQ+HA!MLo5Eg74 zgM+6qil;G#XYibl_!saZUcsw``#115-XYwd#e4V=ALA2ziqCKnmk9q~2Kc{5=>HYJ zO+fUXyAh2WQz3ddnX^pWIzqN06Yh4K9-|Vz%}THS-+J%A|4)x#!d-?L2s3bB89-@E zvL!*T_d3kHT0275A-cTg%^Ty=ccIQN$4UC-ILTZ8Fr@nkP4#@@fgIzKG}Qj}KLp(R TMSlN3yTk8)`2C;m-~Yb>@pgUk literal 0 HcmV?d00001 diff --git a/skyfield/positionlib.py b/skyfield/positionlib.py index cb71b9b0e..884c441d3 100644 --- a/skyfield/positionlib.py +++ b/skyfield/positionlib.py @@ -593,6 +593,34 @@ def is_sunlit(self, ephemeris): near, far = intersect_line_and_sphere(sun_m + earth_m, earth_m, ERAD) return nan_to_num(far) <= 0 + + + def is_moonlit(self, ephemeris): + """Return whether a position in Earth orbit is in moonlight. + + Returns ``True`` or ``False``, or an array of such values, to + indicate whether this position is in moonlight or is blocked by + the Earth’s shadow. It should work with positions produced + either by calling ``at()`` on a satellite object, or by calling + ``at()`` on the relative position ``sat - topos`` of a satellite + with respect to an Earth observer’s position. See + :ref:`satellite-is-sunlit`. + + """ + if self.center == 399: + earth_m = - self.position.m + else: + gcrs_position = self._observer_gcrs_au + if gcrs_position is None: + raise ValueError('cannot tell whether this position is moonlit') + earth_m = - self.position.m - gcrs_position * AU_M + + moon_m = (ephemeris['moon'] - ephemeris['earth']).at(self.t).position.m + near, far = intersect_line_and_sphere(moon_m + earth_m, earth_m, ERAD) + return nan_to_num(far) <= 0 + + + def is_behind_earth(self): """Return whether the Earth blocks the view of this object.