Python version on the HP Prime
|
02-13-2022, 10:12 AM
Post: #1
|
|||
|
|||
Python version on the HP Prime
Hi to all,
i am a programming novice interested in astronavigation. I want to write a sight reduction program including the calculation of the most imiportant ephemeris data for sun and the brighter stars. I found some great py code that I can use. but, alas, the code does not run on the HP Python. I managed to import it to the Prime via connectivity kit (thanks to the help I got here in the forum). Anyone familiar with the python version on the HP please help me with data on the documentation of this version. the link to the code on the sun ephemeris is: https://www.celnav.de/page3.htm, sunmoon almanac by hennig Umland. thank you very much in advance, greetings kunze |
|||
02-13-2022, 04:10 PM
(This post was last modified: 02-13-2022 04:33 PM by Thomas_Sch.)
Post: #2
|
|||
|
|||
RE: Python version on the HP Prime
It's Micropython.
See e.g. https://www.hpmuseum.org/forum/thread-16862.html From the build in help (start the python app, then press Help), page 2: "HPPrime uses micropython 3.4. (You should be able to find all the documentation at https://micropython.org/). " Micropython uses only a subset of python. sunmoon (Sun and Moon Almanac 0.92 by H. Umland) maybe uses functions net contained in micropython, and/or you need to include other libraries. Edit: In the full Help go to "Tree", "Search", "Python all_modules", there all all available modules listed. (builtins, micropython, uarray, uio, ...) |
|||
02-13-2022, 08:57 PM
Post: #3
|
|||
|
|||
RE: Python version on the HP Prime
HI Thomas, thank you very much" Herzlichen Dank! lg Kuenze
|
|||
02-14-2022, 07:07 PM
Post: #4
|
|||
|
|||
RE: Python version on the HP Prime
The prime has a few issues with the sun_moon.py code:
a. fsum and isclose do not exit in the math module. b. exit is in the sys module To fix this i put the following code at the top of the file: Code: from builtins import sum as fsum Then I went thru the code and replace math.fsum with fsum and math.isclose with isclose. With these changes it runs on the prime and seems to give results similar to the original file when run in spider. You may want to change the print statements to fit better on the prime's screen. The file is attached below with the extension changed to .txt. -road sun_moon_prime.txt (Size: 47.64 KB / Downloads: 28) |
|||
02-14-2022, 08:47 PM
(This post was last modified: 02-14-2022 09:27 PM by Guenter Schink.)
Post: #5
|
|||
|
|||
RE: Python version on the HP Prime
(02-14-2022 07:07 PM)roadrunner Wrote: The file is attached below with the extension changed to .txt. Also in reply to the email of Martin. I had a cursory look at the program. Line 7 has a typo def isclose(a,b,abs_to:): needs to be changed to: def isclose(a,b,abs_tol): that is: replace the colon prior to the closing parentheses with an "l" Otherwise it seems to run almost error free. A bug in the printing command shows up however. When you print characters with ASCII code higher than 128 the printout is garbled. There is a solution however and that is graphical text output. [edit] it is the "°" character that disturbs the print out[/edit] @kuenze: Martin, I can't give you more advice than you have received already here. But I think that I can do something on input and output. But that will take its time. Günter |
|||
02-15-2022, 06:48 AM
Post: #6
|
|||
|
|||
RE: Python version on the HP Prime
Dear Günther,
thank you very much for your advice! deleting the "°" string helps and I will substitute with with "deg". in case that doesn't solve all issues I´ll come back to your kind offer. lg Kuenze |
|||
02-16-2022, 09:17 PM
Post: #7
|
|||
|
|||
RE: Python version on the HP Prime
Looks like an interesting program. As it is tailored for a wider output than the Prime provides, some beautifying actions are necessary. In my very first approach:
Astro.hpappdir.zip (Size: 13.64 KB / Downloads: 30)
BTW this code perfectly runs on my Windows PC as well as on my Android devices (Pydroid 3) BTW 2: I don't have any knowledge of the Astro subject, simply tampering with the code Günter |
|||
02-18-2022, 09:38 AM
Post: #8
|
|||
|
|||
RE: Python version on the HP Prime
Günther, thanks a lot! greetings Kunze
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)