林棟樑 | Don Lin

中文 | English

手機的天象圖App及AI的角色

      手機,每天都在用;天象每天都有變化. 發展手機上用的天象圖App能與世人分享就是我個人2025年春天產生的興趣. 其實早在五六年前我自己就已經用Excel寫出一個紐約的天象圖, 天天看日,月,金,木,水,火,土星的星象. 這7個天體(也稱七曜)是離我們地球最近的天體, 所以自古以來, 對天象愛好的東西方人士來講, 都有一份特殊的感情, 因為它們就像是我們地球的大家族裡面的成員. 在一般家庭中, 我們對家庭的成員都隨時隨地清楚地知道他們是在什麼地方. 天象愛好者, 都想要知道這七曜的位置. 再者,對日本人來講, 七曜太重要, 所以把一個禮拜的7天依次從禮拜日開始, 稱為日曜日, 月曜日, 火曜日, 水曜日, 木曜日, 金曜日,及土曜日. 中國的古書裡更是把這水,金,火,木,土五個行星分別稱作辰星, 太白金星, 熒惑, 歲星, 鎮星. 天王星, 海王星, 冥王星, 古人沒看過. 它們分別在1781, 1846及1930才被發現, 由於離地球太遠, 太過暗淡, 在夜空上肉眼難見. 而且現在冥王星已經不算是太陽系的行星等級了.

    天象圖簡介 — 天象圖簡單的說就是太陽系行星或恆星在天空上的位置. 由於白天時太陽太明亮, 眾星失色, 所以天象圖一般都是用在夜間的夜空觀看. 除太陽外, 宇宙恆星通常在天球上都不會動, 它們雖不動, 但是我們地球卻在做週期的轉動, 所以在地球上的人看起來, 這些恆星都是在動. 以前的人是用如圖一的「星盤圖」來看這些恆星.  比起恆星在天球上的不動, 我們身邊的七曜(日,月,金,木,水,火,土星)在天球上都在動. 所以星盤圖是沒有這七曜的. 因為這七曜是地球本身的週期轉動再加上這七曜在天球上的動的總結. 天象圖就是地球上一個觀察者仰望天空時宇宙恆星及太陽系天體在天空的位置. 講到七曜在天空上運轉軌道的位置, 就不得不提到英國的偉大物理學家牛頓(Newton). 他在1687年年發表他的萬有引力定律, 完美地解釋了所有天體運行的道理. 這包含精準的預測月亮繞地球以及地球和其他行星繞太陽的軌道位置以及週期. 當然,前人也由觀測知道這些週期, 只是現在從物理學萬有引力原理可以把這些軌道位置以及週期精準的算出來. 對天文軌道計算有興趣的朋友可以參考”Astronomical Algorithms”, 2nd Ed., by J. Meeus, 或是Paul Schlyter的文章”Computing planaetary positions – a tutorial with worked examples” ; 其網站 為(https://stjarnhimlen.se/comp/tutorial.html).

   製作天象圖 — 在不同的經緯度的觀察者其天象圖各自不同. 這是因為不僅他們仰首所看到的天球部位不同, 他們各自的地平線也不同. 地平線的上方天空中的星象是觀察者可以看到的; 地平線以下是看不到的. 所以製作天象圖的第一步是要根據觀察者所在的經緯度畫出一個水平線的圈圈. 然後用該觀察者的水平面把天球切成兩半. 觀察者的天頂指向的那一個半天球是可觀察到的天象; 這一半天球上的星曜就要畫到地平線所代表的這個圈圈裡面. 我們都知道地球在自轉, 而其轉軸就直指北極星. 所以在地球上的人看北極星是不動的. 現在假設一個人站在地球的北極上 (北緯90度的那一點), 他的可觀測的半個天球就是天球的北半部. 當地球在自轉的時候, 他的這個可觀測半天球並沒有改變. 所以他永遠就是看到天球的北半部; 遍佈在南半球的恆星他一個也看不到. 在北緯不那麼高的觀測者, 有些南半球的恆星他也是永遠看不到. 這些在製作天象圖時就會自然顯現出來. 本文的重點不是在詳細解說計算的細節 (細節請參考上面那篇文章以及Jean Meeus的書), 而是在講解現代的人工智慧(AI)如何幫忙寫網站軟體電腦程式.

AI的功能 — AI功能強大, 眾所皆知. 不僅可以畫圖, 可以做video, 可以做歌曲, 歌詞加上歌唱口音. 既然這麼厲害, 筆者就向免費的AI — Grok — 請教寫網站軟體程式HTML. 給的問句是這樣的: write an HTML code to show two points moving along a circle. 小老鼠一旦按那個輸入的箭頭, AI想都沒想, 就立刻把軟體程式一行一行地寫出來, 速度之快令人咋舌. Grok的設計還蠻貼心的, 除了程式外, 還可以按Preview去看結果: 果然是兩個球在圓週上跑. 電腦程式的嚴格要求是無話可說, 除了邏輯要通以外,一個字母的打錯都會讓它無法執行. AI能夠有寫電腦程式的能力, 可能就會讓許多現代的軟體工程師對自己職務的安全性感到不安. 話說回來, AI的這種寫軟體程式的能力, 到底高到哪個程度, 是不是高深莫測, 倒是令人感覺很有興趣. 因此, 筆者就問一個比較深一點天象圖的繪圖問題write an HTML code which displays the sky map, like that of a typical planisphere, of New York City for the 7 celestial objects of Sun, Moon, Mercury, Venus, Mars, Jupiter and Saturn, plus Polaris, when a user enters a date and a time. Grok AI雖然洋洋灑灑地寫了100多條軟體程式,但是卻不能動, ChatGPT AI及其他的AI也是一樣. 結論是, 這些AI, 寫軟體程式初級中級的程度是有, 但是高深一點的話, 還尚待努力. 筆者的目標是要一個可以放到手機上的天象圖App, 畫出七曜的位置, 加上北極星以及12個星座的大略位置, 就像星盤圖一樣. User先選一個城市, 然後可以自己填入日期時間不管是現在, 或是過去的, 將來的時間, 這個App就畫出一個該城市,該時間的天象圖. 既然目前的AI還沒有能力製作這樣的一個天象圖App, 筆者因此就把這個整體的複雜性結構拆散成許多不太複雜的分段, 然後叫AI來幫忙. 每個段落的問句也不是非常簡單, 必須想盡辦法引導AI能過寫出對自己有用的程式. 最後就是要把這些片片斷斷的軟體程式整合出一個總體性的軟體程式, 然後來debug, 測試它畫出來的天象圖是否正確: 比方說, 日出的時間太陽就在東方的水平線上, 中午的時間太陽就在該城市觀察者的頭頂正中央上,日落的時間太陽就在西方的水平線上. 除此之外也需要check NASA的data以及其他天文網站的各色各樣的information.

最後成果: 這個App, 經過不斷的修正, 最後的結果在手機上的screen就像圖二所示. 點一下How To Use, 就會顯出如何操作這個App. 要開始用的時候,  第一步先選城市. (像New Jersey, Pennsylvania, 及Connecticut等美國東部的人, 就選紐約市), 然後就是看你要看當下的天象圖, 或是以前的, 或以後的日子及時間; 如果是當下的天象圖, 就點NOW, 天象圖就立刻顯出來. 這時你如果想看12星座, 就點Show Zodiac. 要讓12星座消失, 就再點NOW. 如果要看別的時間的天象圖, 就點Input your date-time, 選或填日期時間. 時間的最後空格是AM代表早上, PM代表下午. 然後就是要點Submit. 天象圖就立刻顯出來. 如果想看12星座, 就點Show Zodia.

圖三是代表2025年6月5日 下午10點2分22秒的紐約天象圖. 這是選紐約市,然後點NOW得到的圖. 圖上有七曜(日,月,水,金,火,木,土星),還有北極星,天狼星(Sirius,天上最亮恆星)及冥王星 (Pluto).

如果再點Show Zodiac, 就得到圖四, 有12個星座.

2026812號的日全蝕:這一天, 全球許多地方可以看到日偏蝕. 要看日全蝕就要到西班牙. 月亮陰影在黃昏8:26pm 從西班牙西北的 Eboya 登陸, 東南走向, 到 8:33pm 在西班牙東南Cala en Baster 結束, 如圖五的地圖所示

圖六是明年2026年8月12號傍晚8:28pm在日全蝕那時刻的西班牙的馬德里天象圖. 由於是傍晚時分,所以太陽已經靠近西邊的地平線.這個時候月亮跟太陽在天象圖上,幾幾乎是重疊的, 這就是日蝕的條件.

7/26/196的三國時代天象:

羅貫中寫的三國演義在第十四回, “時侍中太史令王立私謂宗正劉艾曰:「吾仰觀天文, 自去春太白犯鎮星於鬥牛, 過天津, 熒惑又逆行, 與太白會於天關, 金火交會, 必有新天子出. 吾觀大漢氣數將終, 晉魏之地, 必有興者」” 太史令王立講吾仰觀天文的時間是在建安元年(公元196). 熒惑是火星, 太白是金星. 筆者考證, 熒惑與太白會於天關 應是公元196年的7/26. 把這個日子填入筆者的這個App內, 時間拉到太陽還沒上升的時刻(夜空還看得到熒惑與太白), 城市選上海, 那麼曹操的太史令王立所看到的天象圖就如圖七, 12星座也加進去. 果然, 火星與金星都在天關星的金牛座附近.

結論: 人工智慧功能非常強大,它甚至可以幫助編寫涉及大量邏輯的電腦程式。本文提供了一個使用人工智慧來幫助編寫軟體程式,幫忙開發建立一個天象圖的App的範例。(姓名: 林棟樑, 2025-06-27 於New Jersey)

附註: 對天文有興趣的朋友, 這個可以看到過去, 現在,及將來的”天象圖”App的Link是SkyMapPlus.andrewl.in. 把這個Link upload到你的手機Home Screen,就可以隨時隨地用手機觀看天象, 非常方便.


中文 | English

Build a Sky Map App on iPhone and AI’s Assistance

Mobile phones are used every day; the sky changes every day. Developing a Sky Map App for mobile phones that can be shared with the world is my personal interest in the spring of 2025. In fact, as early as five or six years ago, I used Excel to write a New York sky map, and looked at the celestial bodies such as the sun, moon, Venus, Jupiter, Mercury, Mars, and Saturn every day. These 7 celestial bodies (also known as the Seven Luminaries) are the celestial bodies closest to our Earth. So, since ancient times, people in the East and the West who love celestial phenomena have had a special feeling for them, because they are like members of our big family on Earth. In ordinary families, we know clearly where our family members are at any time and anywhere. Sky lovers all want to know the location of these seven Luminaries. Moreover, for the Japanese, the Seven Luminaries are too important, so the 7 days of a week are called 日曜日 (Sun), 月曜日(Moon), 火曜日(Mars), 水曜日(Mercury), 木曜日(Jupiter), 金曜日(Venus),及土曜日(Saturn),  in order, starting from Sunday. In ancient Chinese books, the five planets Mercury, Venus, Mars, Jupiter, and Saturn were called Chenxing (辰星), Taibai Jinxing (太白金星), Yinghuo(熒惑), Suixing (歲星), and Zhenxing (鎮星), respectively. The ancients had never seen Uranus, Neptune, and Pluto. They were discovered in 1781, 1846, and 1930 respectively. They are too far from the Earth and too dim to be seen with the naked eye in the night sky. Moreover, Pluto is no longer considered a planet in the solar system.

Introduction to Sky Maps — Simply put, sky maps are the positions of the planets or stars in the sky. Since the sun is too bright during the day and the stars are outshined, sky maps are generally used to view the night sky at night. Except for the sun, the stars in the universe usually do not move on the celestial sphere. Although they do not move, our Earth is rotating periodically, so to people on Earth, these stars are moving. In the past, people used the “Planisphere” as shown in Figure 1 to view these stars. Compared with the stars that are stationary on the celestial sphere, the seven celestial bodies around us (the sun, the moon, Venus, Jupiter, Mercury, Mars, and Saturn) are all moving on the celestial sphere. Therefore, you cannot see these seven celestial bodies in the Planisphere. Because the motion of each of these seven bodies is the combination of the periodic rotation of the Earth itself and the movement of these seven bodies on the celestial sphere. The sky map shows the positions of the stars in the universe and the celestial bodies of the solar system in the sky when an observer on Earth lies on lawn (head toward north) and looks up to the sky. When talking about the orbits of the solar planets in the sky, we have to mention the great British physicist Newton. He published his law of gravitation in 1687. It perfectly explains the movement of all celestial bodies. This includes the accurate prediction of the orbital positions and periods of the moon around the Earth and the Earth and other planets around the sun. Of course, our ancestors also knew these periods from observation, but now we can accurately calculate these orbital positions and periods from the principle of gravitational force in physics. Friends who are interested in astronomical orbit calculations can refer to ”Astronomical Algorithms”, 2nd Ed., by J. Meeus, or the article by Paul Schlyter”Computing planaetary positions – a tutorial with worked examples” ; the link is (https://stjarnhimlen.se/comp/tutorial.html).

Making a sky map — Observers at different longitudes and latitudes will have different sky maps. This is because not only do they look up at different parts of the celestial sphere, but their horizons are also different. The stars in the sky above the horizon are visible to the observer; those below the horizon are invisible. So the first step in making a sky map is to draw a circle of horizontal lines according to the longitude and latitude of the observer. Then use the observer’s horizontal plane to cut the celestial sphere in half. The half of the celestial sphere that the observer’s zenith points to is the “observable” half; the stars on this half of the celestial sphere should be drawn inside the circle represented by the horizon. We all know that the Earth rotates, and its axis of rotation points directly to the North Star (Polaris). So the North Star does not move as seen by the people on the north hemisphere on Earth. Now suppose a person stands at the North Pole of the Earth (the point at 90 degrees north in latitude), his observable half of the celestial sphere is the northern half of the celestial sphere. When the Earth rotates, his observable half of the celestial sphere does not change. So he always sees the northern half of the celestial sphere; he cannot see any of the stars in the southern hemisphere. Observers at lower latitudes in the north will never see some stars in the southern hemisphere. These should naturally appear when making a sky map. The focus of this article is not to explain the details of the calculation (please refer to the above article and Jean Meeus’ book for details), but to explain how modern artificial intelligence (AI) can help writing website software computer codes.

AI’s functions – That AI is powerful is well known. It can not only draw pictures, but also make videos, and make songs with lyrics and singing accents. Since it is so powerful, I asked the free version of an AI — Grok — to teach me how to write HTML code for website software. One of the specific questions I asked AI was: Write an HTML code to show two points moving along a circle. Once the mouse pressed the input arrow, AI immediately wrote out the software code, line by line without thinking, and the speed was amazing. The design of Grok for software developers is quite friendly and considerate, i.e., in addition to the code, you can also press Preview to see the result: it is indeed two balls running on the circumference of a circle. It is well known that requirements of any working computer codes are very strict:  in addition to the strict logic from line to line, any typo will render the code impossible to execute. Indeed, AI’s ability to write computer codes may make many modern software engineers feel uneasy about the security of their jobs. Having said that, it is very interesting to see how much advanced the AI’s ability can be in writing software codes. Is it unfathomable? To probe that, I asked a more advanced question which is about drawing a sky map. The request I gave to Grok was: “Write an HTML code which displays the sky map, like that of a typical planisphere, of New York City for the 7 celestial objects of Sun, Moon, Mercury, Venus, Mars, Jupiter and Saturn, plus Polaris, when a user enters a date and a time”. Although Grok wrote more than 100 lines of software codes, it cannot execute; nothing came out. The same is true for ChatGPT and other AIs. The conclusion is that these AIs have the basic and intermediate level of software programming, but for more advanced/complex tasks, the AI developers still need to work harder. My goal is to have a sky map App that can be put on a mobile phone, drawing the positions of the seven celestial bodies, plus showing the approximate positions of the North Star and the 12 constellations, just like a star map. The user first selects a city, and then can fill in the date and time by himself/herself, whether it is now, in the past, or in the future, and the App will draw a sky map of the city at that time. Since the current AI is not capable of taking up the entire task of making such a sky map App, I broke down this complex task into many less-complex segments, and then asked AI to help. The questions in each segment were not very simple either, and I had to do everything I could to guide AI to write codes that are useful for the project. Finally, I had to integrate these fragmented software codes into an overall software program, and then debugged it to test whether the sky map it draws is correct: for example, the sun is on the eastern horizon at sunrise time, the sun is directly above the head of the observer in the city at solar noon, and the sun is on the western horizon at sunset. In addition, I also need to check NASA data and various information from other astronomical websites to ensure that the App is doing its job.

Final result: After continuous revisions, the final result of this App is shown in Figure 2 on the screen of the mobile phone. Click on How To Use, and it will show how to operate this App. Read it to have a general idea about the App. When you want to start using it, the first step is to select a city. (People in the eastern United States such as New Jersey, Pennsylvania, and Connecticut, choose New York City), then you need to see whether you want to see the current sky map, or the past or future days and times; if it is the current sky map, click NOW, and the sky map will appear immediately. At this time, if you want to see the 12 constellations, click Show Zodiac. To make the 12 constellations disappear, click NOW again. If you want to see the sky map of another time, click “Input your date-time”, select or fill in the date and time. The last space of the time is AM for morning and PM for afternoon. Then you need to click Submit. The sky map will appear immediately. If you want to see the 12 constellations, click Show Zodiac.

Figure 3 is a New York sky map at 10:02:22 pm on June 5, 2025. This is the map obtained by selecting New York City and then clicking NOW. The map shows the seven celestial bodies (Sun, Moon, Mercury, Venus, Mars, Jupiter, Saturn), as well as the North Star, Sirius (the brightest star in the sky) and Pluto.

If you click Show Zodiac, you will get Figure 4, which has 12 constellations.

Total solar eclipse on August 12, 2026: On this day, partial solar eclipse can be seen in many places around the world. To see the total solar eclipse, you have to go to Spain (or Iceland/Greenland). The shadow of the moon lands in Eboya in northwest Spain at 8:26pm, moves southeast, and ends at Cala en Baster in southeast Spain at 8:33pm, as shown in the map in Figure 5.

Figure 6 is a sky map of Madrid, Spain, at 8:28pm on the evening of August 12, 2026, when there will be a total solar eclipse. Because it is evening, the sun is already close to the western horizon. At this time, the moon and the sun are almost overlapping on the sky map, which is the condition for a solar eclipse.

The astronomical phenomena of the Three Kingdoms (三國演義) era on July 26, 196:

In the fourteenth chapter of the Romance of the Three Kingdoms written by Luo Guanzhong(羅貫中), “At that time, the Imperial Secretary Wang Li (王立) privately told the Imperial Clan Minister Liu Ai(劉艾): “I looked up at the sky and found that since last spring, Taibai (太白; Venus) has violated Zhenxing (鎮星; Saturn) in the region of Sagittarius and Capricorn and passed Deneb (天津星). Yinghuo (熒惑; Mars) has also gone retrograde and will meet Taibai in the direction of Zeta Tau star (天關星). When gold (referring to Venus) and fire (referring to Mars) meet, a new emperor will surely appear. I see that the fate of the Han Dynasty will end, and the land of Jin (晉) and Wei (魏) will surely rise.” The Imperial Secretary Wang Li said that he looked up at the sky in the first year of Jian’an (196 AD). The author has verified that Yinghuo (熒惑; Mars) and Taibai (太白; Venus) met at Zeta Tau (Tianguan; 天關) on July 26, 196. Fill this date into the author’s App, drag the time to the time when the sun has not risen (Mars and Venus can still be seen in the night sky), and choose Shanghai as the city. Then the sky map seen by Cao Cao’s (曹操) Imperial Secretary Wang Li (王立) is as shown in Figure 7, and the 12 constellations are also added. As expected, Mars and Venus are both near the Taurus constellation which has the star of Zeta Tau (Tianguan; 天關星).

Conclusion: Artificial intelligence is very powerful, it can even help write computer codes involving a lot of logic. This article provides an example of using artificial intelligence to help write software codes in developing a sky map app.  
(Don Lin, 6/27/2025, New Jersey)

Note: For friends who are interested in astronomy, the link of this “sky map” app which can be used to see the past, present, and future sky maps is SkyMapPlus.andrewl.in. Upload this link to your mobile phone’s Home Screen, and you will be rewarded with watching the locations of celestial bodies with your mobile phone anytime, anywhere.