Solar longitude from pyephem?












2















I'm trying to determine when seasons start and end on Mars. This point is at 0º, 90º, 180º, and 270º Ls (solar longitude).



PyEphem offers Heliocentric longitude and latitude. How can this be correlated to solar longitude displayed here:



http://www.planetary.org/explore/space-topics/mars/mars-calendar.html










share|improve this question





























    2















    I'm trying to determine when seasons start and end on Mars. This point is at 0º, 90º, 180º, and 270º Ls (solar longitude).



    PyEphem offers Heliocentric longitude and latitude. How can this be correlated to solar longitude displayed here:



    http://www.planetary.org/explore/space-topics/mars/mars-calendar.html










    share|improve this question



























      2












      2








      2








      I'm trying to determine when seasons start and end on Mars. This point is at 0º, 90º, 180º, and 270º Ls (solar longitude).



      PyEphem offers Heliocentric longitude and latitude. How can this be correlated to solar longitude displayed here:



      http://www.planetary.org/explore/space-topics/mars/mars-calendar.html










      share|improve this question
















      I'm trying to determine when seasons start and end on Mars. This point is at 0º, 90º, 180º, and 270º Ls (solar longitude).



      PyEphem offers Heliocentric longitude and latitude. How can this be correlated to solar longitude displayed here:



      http://www.planetary.org/explore/space-topics/mars/mars-calendar.html







      python pyephem






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 28 '14 at 0:24









      Peter O.

      20.8k95969




      20.8k95969










      asked Aug 28 '14 at 0:21









      rtphokiertphokie

      102110




      102110
























          1 Answer
          1






          active

          oldest

          votes


















          1














          I think that the two quantities are the same angle, but measured from different starting points. Using that assumption, you can use PyEphem to predict Martian seasons to within two or three days — but I really would have expected better, and am not sure why the agreement is not closer!



          But this will at least get you started. Please let us know if you find out why these predictions are slightly different from those of the site you linked to! We should at some point compare them to the output of NASA Horizons, and of the Skyfield project that I am building as an improved PyEphem.



          In any case, some code to compute Ls and use it to find Mars seasons:



          # The angle that we call "the longitude of the Sun, as
          # seen from Mars" should grow at the same rate as the
          # "longitude of Mars as seen from the Sun" (since the
          # two are the same line but viewed in opposite
          # directions).
          #
          # The only problem is knowing what point to name "zero",
          # so we have to learn what .hlon was when the first
          # Martian year started:

          from ephem import Mars, Date, degrees, newton
          m = Mars()
          m.compute('1955/4/11 23:00')
          Ls0 = m.hlon

          def Ls(date):
          m.compute(date)
          return degrees(m.hlon - Ls0).norm

          # There! Ls() should give Martian solar latitude.
          # So the first round of seasons listed at the page
          # http://www.planetary.org/explore/space-topics/mars/mars-calendar.html
          # should give 90 degrees, 180 degrees, and 270 degrees:

          for date in '1955/10/27', '1956/4/27', '1956/9/21':
          print Ls(date)

          # The output is close to what we would expect:
          #
          # 90:11:58.3
          # 179:57:32.2
          # 270:13:22.6
          #
          # Great! So what if we want to know, say, the date
          # of the upcoming Spring Equinox or Summer Solstice?
          # We need functions that are smooth, well-behaved,
          # and cross zero at those two times, so that we can
          # unleash Newton's Method upon them:

          def spring_equinox(date):
          return Ls(date).znorm

          def summer_solstice(date):
          return Ls(date) - degrees('90:00:00')

          def find_spring_equinox(start_date):
          start_date = Date(start_date)
          y0 = Ls(start_date)
          y1 = Ls(start_date + 1)
          rate = y1 - y0
          angle_to_go = degrees(0.0 - y0).norm
          closer_date = start_date + angle_to_go / rate
          d = newton(spring_equinox, closer_date, closer_date + 1)
          return Date(d)

          def find_summer_solstice(start_date):
          start_date = Date(start_date)
          y0 = Ls(start_date)
          y1 = Ls(start_date + 1)
          rate = y1 - y0
          angle_to_go = degrees(degrees('90:00:00') - y0).norm
          closer_date = start_date + angle_to_go / rate
          d = newton(summer_solstice, closer_date, closer_date + 1)
          return Date(d)

          d = find_spring_equinox('2015/1/22')
          print d, Ls(d)

          d = find_summer_solstice('2015/1/22')
          print d, Ls(d)

          # Output:
          # 2015/6/16 15:03:15 0:00:00.0
          # 2015/12/31 21:12:07 90:00:00.0





          share|improve this answer






















            protected by Community Nov 17 '18 at 6:36



            Thank you for your interest in this question.
            Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



            Would you like to answer one of these unanswered questions instead?














            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            I think that the two quantities are the same angle, but measured from different starting points. Using that assumption, you can use PyEphem to predict Martian seasons to within two or three days — but I really would have expected better, and am not sure why the agreement is not closer!



            But this will at least get you started. Please let us know if you find out why these predictions are slightly different from those of the site you linked to! We should at some point compare them to the output of NASA Horizons, and of the Skyfield project that I am building as an improved PyEphem.



            In any case, some code to compute Ls and use it to find Mars seasons:



            # The angle that we call "the longitude of the Sun, as
            # seen from Mars" should grow at the same rate as the
            # "longitude of Mars as seen from the Sun" (since the
            # two are the same line but viewed in opposite
            # directions).
            #
            # The only problem is knowing what point to name "zero",
            # so we have to learn what .hlon was when the first
            # Martian year started:

            from ephem import Mars, Date, degrees, newton
            m = Mars()
            m.compute('1955/4/11 23:00')
            Ls0 = m.hlon

            def Ls(date):
            m.compute(date)
            return degrees(m.hlon - Ls0).norm

            # There! Ls() should give Martian solar latitude.
            # So the first round of seasons listed at the page
            # http://www.planetary.org/explore/space-topics/mars/mars-calendar.html
            # should give 90 degrees, 180 degrees, and 270 degrees:

            for date in '1955/10/27', '1956/4/27', '1956/9/21':
            print Ls(date)

            # The output is close to what we would expect:
            #
            # 90:11:58.3
            # 179:57:32.2
            # 270:13:22.6
            #
            # Great! So what if we want to know, say, the date
            # of the upcoming Spring Equinox or Summer Solstice?
            # We need functions that are smooth, well-behaved,
            # and cross zero at those two times, so that we can
            # unleash Newton's Method upon them:

            def spring_equinox(date):
            return Ls(date).znorm

            def summer_solstice(date):
            return Ls(date) - degrees('90:00:00')

            def find_spring_equinox(start_date):
            start_date = Date(start_date)
            y0 = Ls(start_date)
            y1 = Ls(start_date + 1)
            rate = y1 - y0
            angle_to_go = degrees(0.0 - y0).norm
            closer_date = start_date + angle_to_go / rate
            d = newton(spring_equinox, closer_date, closer_date + 1)
            return Date(d)

            def find_summer_solstice(start_date):
            start_date = Date(start_date)
            y0 = Ls(start_date)
            y1 = Ls(start_date + 1)
            rate = y1 - y0
            angle_to_go = degrees(degrees('90:00:00') - y0).norm
            closer_date = start_date + angle_to_go / rate
            d = newton(summer_solstice, closer_date, closer_date + 1)
            return Date(d)

            d = find_spring_equinox('2015/1/22')
            print d, Ls(d)

            d = find_summer_solstice('2015/1/22')
            print d, Ls(d)

            # Output:
            # 2015/6/16 15:03:15 0:00:00.0
            # 2015/12/31 21:12:07 90:00:00.0





            share|improve this answer




























              1














              I think that the two quantities are the same angle, but measured from different starting points. Using that assumption, you can use PyEphem to predict Martian seasons to within two or three days — but I really would have expected better, and am not sure why the agreement is not closer!



              But this will at least get you started. Please let us know if you find out why these predictions are slightly different from those of the site you linked to! We should at some point compare them to the output of NASA Horizons, and of the Skyfield project that I am building as an improved PyEphem.



              In any case, some code to compute Ls and use it to find Mars seasons:



              # The angle that we call "the longitude of the Sun, as
              # seen from Mars" should grow at the same rate as the
              # "longitude of Mars as seen from the Sun" (since the
              # two are the same line but viewed in opposite
              # directions).
              #
              # The only problem is knowing what point to name "zero",
              # so we have to learn what .hlon was when the first
              # Martian year started:

              from ephem import Mars, Date, degrees, newton
              m = Mars()
              m.compute('1955/4/11 23:00')
              Ls0 = m.hlon

              def Ls(date):
              m.compute(date)
              return degrees(m.hlon - Ls0).norm

              # There! Ls() should give Martian solar latitude.
              # So the first round of seasons listed at the page
              # http://www.planetary.org/explore/space-topics/mars/mars-calendar.html
              # should give 90 degrees, 180 degrees, and 270 degrees:

              for date in '1955/10/27', '1956/4/27', '1956/9/21':
              print Ls(date)

              # The output is close to what we would expect:
              #
              # 90:11:58.3
              # 179:57:32.2
              # 270:13:22.6
              #
              # Great! So what if we want to know, say, the date
              # of the upcoming Spring Equinox or Summer Solstice?
              # We need functions that are smooth, well-behaved,
              # and cross zero at those two times, so that we can
              # unleash Newton's Method upon them:

              def spring_equinox(date):
              return Ls(date).znorm

              def summer_solstice(date):
              return Ls(date) - degrees('90:00:00')

              def find_spring_equinox(start_date):
              start_date = Date(start_date)
              y0 = Ls(start_date)
              y1 = Ls(start_date + 1)
              rate = y1 - y0
              angle_to_go = degrees(0.0 - y0).norm
              closer_date = start_date + angle_to_go / rate
              d = newton(spring_equinox, closer_date, closer_date + 1)
              return Date(d)

              def find_summer_solstice(start_date):
              start_date = Date(start_date)
              y0 = Ls(start_date)
              y1 = Ls(start_date + 1)
              rate = y1 - y0
              angle_to_go = degrees(degrees('90:00:00') - y0).norm
              closer_date = start_date + angle_to_go / rate
              d = newton(summer_solstice, closer_date, closer_date + 1)
              return Date(d)

              d = find_spring_equinox('2015/1/22')
              print d, Ls(d)

              d = find_summer_solstice('2015/1/22')
              print d, Ls(d)

              # Output:
              # 2015/6/16 15:03:15 0:00:00.0
              # 2015/12/31 21:12:07 90:00:00.0





              share|improve this answer


























                1












                1








                1







                I think that the two quantities are the same angle, but measured from different starting points. Using that assumption, you can use PyEphem to predict Martian seasons to within two or three days — but I really would have expected better, and am not sure why the agreement is not closer!



                But this will at least get you started. Please let us know if you find out why these predictions are slightly different from those of the site you linked to! We should at some point compare them to the output of NASA Horizons, and of the Skyfield project that I am building as an improved PyEphem.



                In any case, some code to compute Ls and use it to find Mars seasons:



                # The angle that we call "the longitude of the Sun, as
                # seen from Mars" should grow at the same rate as the
                # "longitude of Mars as seen from the Sun" (since the
                # two are the same line but viewed in opposite
                # directions).
                #
                # The only problem is knowing what point to name "zero",
                # so we have to learn what .hlon was when the first
                # Martian year started:

                from ephem import Mars, Date, degrees, newton
                m = Mars()
                m.compute('1955/4/11 23:00')
                Ls0 = m.hlon

                def Ls(date):
                m.compute(date)
                return degrees(m.hlon - Ls0).norm

                # There! Ls() should give Martian solar latitude.
                # So the first round of seasons listed at the page
                # http://www.planetary.org/explore/space-topics/mars/mars-calendar.html
                # should give 90 degrees, 180 degrees, and 270 degrees:

                for date in '1955/10/27', '1956/4/27', '1956/9/21':
                print Ls(date)

                # The output is close to what we would expect:
                #
                # 90:11:58.3
                # 179:57:32.2
                # 270:13:22.6
                #
                # Great! So what if we want to know, say, the date
                # of the upcoming Spring Equinox or Summer Solstice?
                # We need functions that are smooth, well-behaved,
                # and cross zero at those two times, so that we can
                # unleash Newton's Method upon them:

                def spring_equinox(date):
                return Ls(date).znorm

                def summer_solstice(date):
                return Ls(date) - degrees('90:00:00')

                def find_spring_equinox(start_date):
                start_date = Date(start_date)
                y0 = Ls(start_date)
                y1 = Ls(start_date + 1)
                rate = y1 - y0
                angle_to_go = degrees(0.0 - y0).norm
                closer_date = start_date + angle_to_go / rate
                d = newton(spring_equinox, closer_date, closer_date + 1)
                return Date(d)

                def find_summer_solstice(start_date):
                start_date = Date(start_date)
                y0 = Ls(start_date)
                y1 = Ls(start_date + 1)
                rate = y1 - y0
                angle_to_go = degrees(degrees('90:00:00') - y0).norm
                closer_date = start_date + angle_to_go / rate
                d = newton(summer_solstice, closer_date, closer_date + 1)
                return Date(d)

                d = find_spring_equinox('2015/1/22')
                print d, Ls(d)

                d = find_summer_solstice('2015/1/22')
                print d, Ls(d)

                # Output:
                # 2015/6/16 15:03:15 0:00:00.0
                # 2015/12/31 21:12:07 90:00:00.0





                share|improve this answer













                I think that the two quantities are the same angle, but measured from different starting points. Using that assumption, you can use PyEphem to predict Martian seasons to within two or three days — but I really would have expected better, and am not sure why the agreement is not closer!



                But this will at least get you started. Please let us know if you find out why these predictions are slightly different from those of the site you linked to! We should at some point compare them to the output of NASA Horizons, and of the Skyfield project that I am building as an improved PyEphem.



                In any case, some code to compute Ls and use it to find Mars seasons:



                # The angle that we call "the longitude of the Sun, as
                # seen from Mars" should grow at the same rate as the
                # "longitude of Mars as seen from the Sun" (since the
                # two are the same line but viewed in opposite
                # directions).
                #
                # The only problem is knowing what point to name "zero",
                # so we have to learn what .hlon was when the first
                # Martian year started:

                from ephem import Mars, Date, degrees, newton
                m = Mars()
                m.compute('1955/4/11 23:00')
                Ls0 = m.hlon

                def Ls(date):
                m.compute(date)
                return degrees(m.hlon - Ls0).norm

                # There! Ls() should give Martian solar latitude.
                # So the first round of seasons listed at the page
                # http://www.planetary.org/explore/space-topics/mars/mars-calendar.html
                # should give 90 degrees, 180 degrees, and 270 degrees:

                for date in '1955/10/27', '1956/4/27', '1956/9/21':
                print Ls(date)

                # The output is close to what we would expect:
                #
                # 90:11:58.3
                # 179:57:32.2
                # 270:13:22.6
                #
                # Great! So what if we want to know, say, the date
                # of the upcoming Spring Equinox or Summer Solstice?
                # We need functions that are smooth, well-behaved,
                # and cross zero at those two times, so that we can
                # unleash Newton's Method upon them:

                def spring_equinox(date):
                return Ls(date).znorm

                def summer_solstice(date):
                return Ls(date) - degrees('90:00:00')

                def find_spring_equinox(start_date):
                start_date = Date(start_date)
                y0 = Ls(start_date)
                y1 = Ls(start_date + 1)
                rate = y1 - y0
                angle_to_go = degrees(0.0 - y0).norm
                closer_date = start_date + angle_to_go / rate
                d = newton(spring_equinox, closer_date, closer_date + 1)
                return Date(d)

                def find_summer_solstice(start_date):
                start_date = Date(start_date)
                y0 = Ls(start_date)
                y1 = Ls(start_date + 1)
                rate = y1 - y0
                angle_to_go = degrees(degrees('90:00:00') - y0).norm
                closer_date = start_date + angle_to_go / rate
                d = newton(summer_solstice, closer_date, closer_date + 1)
                return Date(d)

                d = find_spring_equinox('2015/1/22')
                print d, Ls(d)

                d = find_summer_solstice('2015/1/22')
                print d, Ls(d)

                # Output:
                # 2015/6/16 15:03:15 0:00:00.0
                # 2015/12/31 21:12:07 90:00:00.0






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 22 '15 at 18:27









                Brandon RhodesBrandon Rhodes

                52.1k1392128




                52.1k1392128

















                    protected by Community Nov 17 '18 at 6:36



                    Thank you for your interest in this question.
                    Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                    Would you like to answer one of these unanswered questions instead?



                    這個網誌中的熱門文章

                    Xamarin.form Move up view when keyboard appear

                    Post-Redirect-Get with Spring WebFlux and Thymeleaf

                    Anylogic : not able to use stopDelay()