aendie / SFalmanac-Py3

Creates the daily pages of a Nautical Almanac using Skyfield (Python 3)
GNU General Public License v3.0
18 stars 5 forks source link

Startup always gives an error #5

Closed yangyang-studio closed 2 years ago

yangyang-studio commented 2 years ago

mmexport1638096206442 mmexport1638096222142 mmexport1638096227900 mmexport1638096231735 Please have time to see, if there is a video tutorial or step instructions are better, look forward to your reply, thank you!

aendie commented 2 years ago

Thanks for your report. I have a CPU with 8 logical processors, where it works. I will later on test restricting the count to 4 logical processors. I'm sure I did this before, but I'll see if this still works. Give some time for testing.

My first suggestion is to turn off parallel processing by editing config.py. Simply set MULTIpr = False on line 33.

aendie commented 2 years ago

I attempted to reproduce your problem on a spare laptop. I uninstalled the current Python and installed "Anaconda3-2019.10-Windows-v86_64.exe". I've never used Anaconda before but now I have Anaconda with Python 3.7.4, which is very close to your version as far as I can tell:

(base) D:\_DEVpackaging\TEST anaconda>python
Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

(base) D:\_DEVpackaging\TEST anaconda>

I use MiKTeK, to convert to PDF but your failure doesn't even get that far. I then ran pip install sfalmanac to get the program installed. Then I ran it, and below you see that it worked:

(base) D:\_DEVpackaging\TEST anaconda>python -m sfalmanac
[#################################] 100% finals2000A.all
[#################################] 100% de421.bsp
[#################################] 100% hip_main.dat
 Path to config.py:  C:\ProgramData\Anaconda3\Lib\site-packages\sfalmanac\lib\
 Downloaded data in: C:\ProgramData\Anaconda3\Lib\site-packages\sfalmanac\astro-data\

  What do you want to create?:

    1   Nautical Almanac   (for a day/month/year)
    2   Sun tables only    (for a day/month/year)
    3   Event Time tables  (for a day/month/year)
    4   Nautical almanac   -  6 days from today
    5   Sun tables only    - 30 days from today
    6   Event Time tables  -  6 days from today
    7   "Increments and Corrections" tables (static data)
1
  Enter as numeric digits:

    - starting date as 'DDMMYYYY'
    - or just 'YYYY' (for a whole year)
    - or 'YYYY-YYYY' (for first and last year)
    - or just 'MM' (01 - 12) for the current or a future month
    - or '-MM' for a previous month (e.g. '-02' is last February)
    - nothing for the current day

  What table style is required?:

    t   Traditional
    m   Modern
m

NOTE: only 8 logical processors are available for parallel processessing

Creating the nautical almanac for 28 November 2021
execution time = 3.55 seconds
stopwatch      = 11.00 seconds
(stopwatch = time spent getting moonrise and/or moonset times)
Moonrise/moonset time seeks  = 93
Above/below horizon searches = 30

This is pdfTeX, Version 3.141592653-2.6-1.40.23 (MiKTeX 21.8)
entering extended mode

======================================================================
mpmsvc: starting package maintenance...
mpmsvc: installation directory: "C:\Program Files\MiKTeX"
mpmsvc: package repository: https://mirror.clientvps.com/CTAN/systems/win32/miktex/tm/packages/
mpmsvc: visiting repository https://mirror.clientvps.com/CTAN/systems/win32/miktex/tm/packages/...
mpmsvc: repository type: remote package repository
mpmsvc: loading package repository manifest...
mpmsvc: downloading https://mirror.clientvps.com/CTAN/systems/win32/miktex/tm/packages/miktex-zzdb1-2.9.tar.lzma...
mpmsvc: 0.25 MB, 6.23 Mbit/s
mpmsvc: package repository digest: f102b1e773ec3721c73826dbbac1fe7d
mpmsvc: going to download 177685 bytes
mpmsvc: going to install 5 file(s) (1 package(s))
mpmsvc: downloading https://mirror.clientvps.com/CTAN/systems/win32/miktex/tm/packages/enumitem.tar.lzma...
mpmsvc: 0.18 MB, 11.19 Mbit/s
mpmsvc: extracting files from enumitem.tar.lzma...
======================================================================
finished creating 'NAmod_20211128.pdf'

(base) D:\_DEVpackaging\TEST anaconda>

So your error may be because you have a different operating system. Your fault did not fail in a line of code in SFalmanac, but in the Skyfield astronomical library (or even lower), which is rather unusual. I can, however, ask the author of Skyfield if he has ever seen this problem and if he can suggest a solution.

Please understand that unless I can actually reproduce your problem, it is hard for me to guess what might be wrong on your computer.

yangyang-studio commented 2 years ago

Thank you for your reply, I try the first method you said, the result is wrong or that kind of prompt, it is estimated that you said the second. Then I'll wait and see, wait for a better solution. mmexport1638150817975

aendie commented 2 years ago

I have no response yet regarding if the fault lies in the astronomical library. However, I agree - this error should not happen.

What hardware and operating system are you using? A MacBook? Unfortunately I don't have one. Does a MacBook come with standard Python already pre-installed? Is there a second computer you could test this on (other than a MacBook)?

Another suggestion would be to uninstall Anaconda and install the original Python 3.9.9 for macOS instead (if you can't find a Windows PC).

yangyang-studio commented 2 years ago

Thank you for reply. I took the time to install a python in windows 10 and test it.

brandon-rhodes commented 2 years ago

The error message makes it sound like the file is too short — like maybe it got truncated by an interrupted download (except that Skyfield shouldn't move it over from its temporary download filename unless the download completes?), or like maybe it wrote to a full filesystem. @aendie, what would the filename be of the file it downloads? @yangyang-studio could show us the file size using the file system browser, and we could compare the size to the same file on our system, to see if it is smaller.

My next step would be to edit the daf.py file and, right before line 111, put a print() statement to learn exactly what offset and length Skyfield is asking for.

yangyang-studio commented 2 years ago

Try Windows 10 installation ,anaconda3.9.7 is used and an error is currently being reported.

iokit.py Using the latest file. mmexport1638251385773

brandon-rhodes commented 2 years ago
  1. Can you visit that URL in the Windows 10 browser?
  2. Can you translate the error message? A quick search for that error code suggests your Windows 10 machine might not be connected to the Internet.
yangyang-studio commented 2 years ago

What he means is: After a period of time, the connection attachment fails without a correct reply or the connection h ost does not respond

yangyang-studio commented 2 years ago

On our side of the network, we need to run vpn for the link to open properly. I'm already using a vpn on my computer, but it's still in the picture.

yangyang-studio commented 2 years ago

https://github.com/aendie/SFalmanac-Py3/issues/5#issuecomment-982159459 @brandon-rhodes This is installed in the Apple notebook, the files are downloaded successfully, that is, the problem in the operation, you can see the first screenshot I sent

aendie commented 2 years ago

I ran a test in WIndows 10 and activated VPN (so that only communication via VPN is possible, by "activating a Network Lock"). I then deleted the three files that are downloaded when SFalmanac starts, and ran SFalmanac. All three files were successfully downloaded, i.e. SFalmanac works when a VPN link is established.

I suspect that the download doesn't work properly on your Windows system, so I packed the three files into "astro-data.zip" on this web site. I would ask you to download (i.e. copy them) to your folder where SFalmanac is. ("D:\SFalmanac-Py3-master" as on your last screenshot. Unzip them and check the file sizes:

de421.bsp          16.788.480 bytes
finals2000A.all     3.437.204 bytes
hip_main.dat       53.316.318 bytes

Run SFalmanac again with python sfalmanac.py - does it work now?

yangyang-studio commented 2 years ago

我在 WINdows 10 中运行了一个测试并激活了 VPN(因此_只能_通过 VPN 进行通信,通过“激活网络锁”)。然后我删除了SFalmanac启动时下载的三个文件,然后运行SFalmanac。所有三个文件都已成功下载,即 SFalmanac 在建立 VPN 链接时工作。

我怀疑下载在您的 Windows 系统上无法正常运行,因此我将这三个文件打包到此网站上的“astro-data.zip”中。我会要求您将它们下载(即复制)到 SFalmanac 所在的文件夹中。(“D:\SFalmanac-Py3-master”如上一张截图所示。解压缩它们并检查文件大小:

de421.bsp          16.788.480 bytes
finals2000A.all     3.437.204 bytes
hip_main.dat       53.316.318 bytes

再次运行 SFalmanac python sfalmanac.py- 现在可以了吗?

It is already running normally. What is the calculation time range of this ephemeris? You have to change the ephemeris data beyond this time range, right?

aendie commented 2 years ago

Good. The next step is to change line 31 in config.py to useIERS = False. Otherwise it will attempt to download finals2000A.all again in 30 days from the file date, i.e. end of December.

The time range of de421.bsp is 1900 to 2050. This is perfectly adequate for navigation on the ocean.

Apparently something is interfering with your download mechanism, which is not a problem in SFalmanc, and also not a problem in the underlying astronomical library. I will close this issue after a few days. Kind Regards.

yangyang-studio commented 2 years ago

好的。下一步是将_config.py 中的_第 31 行更改为useIERS = False. 否则,它将在文件日期后的 30 天内(即 12 月底)再次尝试下载finals2000A.all

_de421.bsp_的时间范围是 1900 到 2050。这对于海上航行来说是完全足够的。

显然有些东西干扰了您的下载机制,这在 SFalmanc 中不是问题,在基础天文库中也不是问题。几天后我会关闭这个问题。亲切的问候。

Thank you very much for your patient answer, a lot of harvest. I have always been more fond of astronomy, I would like to know about the astronomical ephemeris python code, if you have relevant resources, I hope to share.

Thanks again and good luck to you!

yangyang-studio commented 2 years ago

Pyalmanac-Py3 SFalmanac-Py3 What is the main difference between the two python codes?

yangyang-studio commented 2 years ago

de421.bsp 16.788.480 bytes finals2000A.all 3.437.204 bytes hip_main.dat 53.316.318 bytes

Does Palmanac-Py3 also need these three packets? Still not the same?

aendie commented 2 years ago

Pyalmanac is the old original program - fast, simplest and reasonably accurate. It does not need the three files you copied. Pyalmanac is based on Ephem. SFalmanac is based on Skyfield (modern and most accurate). To learn how to use Ephem, start here: https://rhodesmill.org/pyephem/ To learn how to use Skyfield, start here: https://rhodesmill.org/skyfield/ To learn about astronomical algorithms, read "Astronomical Algorithms by Jean Meeus".

yangyang-studio commented 2 years ago

mmexport1638422687369 mmexport1638422691402 Pyalmanac-Py3 The operation is stuck and I don't know how to deal with it.

aendie commented 2 years ago

I would have asked you to report this under Pyalmanac-Py3 (where it belongs), but there is no need. This error simply doesn't happen on a correctly configured and installed system. It's up to you to find out what you did wrong. If you try this on another computer or operating system, it will work (unless there is something generally wrong with Chinese systems that I do not know about).

When reporting an error, I need more facts: what hardware are you using; what operating system. Then what Python are you using - I only use the official Python from https://www.python.org/ and none other. Which version of Python are you using (e.g. 3.9.4)? And if it gets through the code, then which program converts it to PDF, e.g. MiKTeX or TeX Live?

Then I need to know what kind of Pyalmanac you are executing - the files from this web site with python pyalmanac.py or the PyPI package with python -m pyalmanac. These have slightly different Python code. I see from the screenshot that you ran the raw files with python pyalmanac.py.

Now, these programs have undergone hours of testing, so something that crashes so badly is a fault on your system. It may be your Python installation - I don't know. If you look up the error in Internet, you see the mathematical number supplied on that line is invalid. But no one in Europe of the States has ever reported such a problem - and I have never seen it either.

Is it possible that you find someone that understands Python and programming to help you? You need expert local assistance.

Finally, I would appreciate it if you copy/paste errors not as screenshots that leave out some information - look at my second post in this Issue above - copy everything from the command line until the next command line prompt appears and mark it as code (in the forum answer),

A general word of advice is: keep everything "clean", i.e. if you work with Anaconda Python and switch to Python 3.9.9 from https://www.python.org/, then obviously you stand a high chance of corrupting your system if you don't uninstall Anaconda Python first.... cleanly, and check that it has been removed 100% including all PATH additions into your environment variables. This is not a smartphone where everyone installs as many apps as they want. A development system must be kept clean. I would never install MiKTeX and TeX Live together. Some people prefer to work in virtual environments in order to keep things clean. You may try this, but I'm not here to guide you how to do this.

One final tip is to rebuild your computer, which I do every now and then - especially with Windows. That does not mean "use backup software - insert a new drive - and restore everything" because you have the same situation again, no, I really mean install a completely new operating system with nothing else on it. This is a lot of work, so developers are trained to keep their computers correctly configured without any programs that could "compete with each other" or even "overwrite each other".

So I hope you have the patience to try Pyalmanac on another computer - anywhere - just to prove to you that it does run correctly (certainly for the years 2020 to 2050). Then you may be motivated to look into the reason why it failed on the first computer.

NOTE: the original issue you reported here IS NOT SOLVED, because we cannot reproduce this problem. I have "cheated" by giving you the three files that your computer cannot download. Maybe a local expert can find out more about the cause that the download fails? I wish you good luck!