sczesla / PyAstronomy

A collection of astronomy-related routines in Python
152 stars 35 forks source link

Kurucz atmosphere model missing #49

Closed MingjieJian closed 4 years ago

MingjieJian commented 4 years ago

I found some models are missing in PyA, as showing by the table indicating the number of models below:

m_h Kurucz# PyAstronomy#
-5.0 387 386
-4.5 393 390
-4.0 396 389
-3.5 397 395
-3.0 403 400
-2.5 401 401
-2.0 401 401
-1.5 406 406
-1.0 409 409
-0.5 410 410
-0.3 410 410
-0.2 410 --
-0.1 410 --
0.0 476 476
0.1 411 411
0.2 407 407
0.3 404 --
0.5 395 395
1.0 375 375

m_h-3 0 m_h-3 5 m_h-4 0 m_h-4 5 m_h-5 0

Also the length of the model is different; in .dat files (e.g., http://kurucz.harvard.edu/grids/gridm30/am30k2.dat), the models with low Teff have a length of 72; but in PyA and .datcd files, all the models have a length of 64. Interestingly, though, the model with Teff=5000, logg=1.0 and [Fe/H]=-3.0 is missing in .dat file.

I guess this is because Kurucz renewed his database after some time. I noticed that when it is the first time to access a grid PyA does some download work, so I thought it access to Kurucz's website every time we use getKuruczmodel method. But if so, they should be same as thouse in the website.

sczesla commented 4 years ago

Hi, Thanks for your thorough analysis!

Download: You are right, the data (individual grids) are being downloaded from the URL http://kurucz.harvard.edu/grids.html when they are first requested. After that, no new download is initiated of the same grids. The code is here (in the KuruczModels class):

https://github.com/sczesla/PyAstronomy/blob/master/src/pyasl/resBased/kuruczModels.py

PyA stores the data in below a directory, which you can find by

::

from PyAstronomy.pyaC import pyaPermanent
pc = pyaPermanent.PyAConfig()
print(pc.getDataRoot())

Which files: PyA downloads the a*k2*.datcd files from the site. I checked some numbers, and they are perfectly in line with your observation. It appears to me that the information in the .dat and .datcd files are not equivalent (as you say an update may be inetween), so it may be a problem of what is downloaded. What is the best option on your opinion?

MingjieJian commented 4 years ago

Hi, I checked the commands and did found the grids. A not so revelant question came to my mind is that how did you decide where these kind of file are stored? I am also writing a package and I need to did some calculation using Kurucz models. I put those files into a hidden folder under ~, but just wondering if there is any rule or convention.

For the model files, Kurucz wrote this in http://kurucz.harvard.edu/grids.html:

The newer models and fluxes and colors should be used instead of those from CDROMs 13, 16, 17, and 19 which files are labelled with an extension ending in CD such as .datCD.

So I think use .dat file should be better. However there are some caveats in the .dat files, please see this issue and the grid points of .dat files in here. The major concern to me in .dat files is the change of length from 72 to 64 as temperature increase, but I did some test for a few models and it show that the 8th-72nd line of the models in .dat is quite similar to those in .datcd. Hope that is not a large issue.

sczesla commented 4 years ago

Hi, Directory for saving: I am not aware of an accepted convention for this. What I ended up doing is (1) shipping small chunks of data (such as abundance tables) along with code and (2) letting the user decide where to put the rest. The default choice is in a "PyAData" directory under home. However, for example the default machines in my institute offer relatively small space under home (because of backup and such things), which is why I allow other choices (basically any path). As PyA needs to know about the choice (you do not usually want to ask the user every time...), it puts a single (hidden) file (.pyaConfigWhere) in the home directory, which contains the data path from where anything else is done. Here is how it is done for PyA

https://github.com/sczesla/PyAstronomy/blob/master/src/pyaC/pyaPermanent/pyaConfig.py

Kurucz models: Right, that seems to be it. I will have a look at the other model grids and keep you posted. BTW, kudos for pymoog. I worked with MOOG in the past and I remember the painful surgery of removing SM dependence from it (we replaced it by gnuplot these days).

sczesla commented 4 years ago

Hi, I did a little update. Now preference is given to .dat over .datcd where available. Before that becomes visible, data need to be purged (so that they are re-downloaded) via

pyasl.purgeKuruczData()

There is no release yet, so the current development version needs to be installed to try pip install git+https://github.com/sczesla/PyAstronomy.git#egg=PyAstronomy[occult]

MingjieJian commented 4 years ago

Thank you for the update!

sczesla commented 4 years ago

Closing for now. Feel free to reopen if you see need. Cheers