astropy / SPISEA

Stellar Population Synthesis Modeling
https://spisea.readthedocs.io/en/stable/index.html
64 stars 32 forks source link

Missing fits files for some evo models #19

Closed robertfoster550 closed 4 years ago

robertfoster550 commented 4 years ago

Hello!

First, I want to thank you for such a great package. Overall it is extremely well done and versatile.

However, I ran into an issue when I tried to use the Parsec isochrones. When attempting to use the 'synthetic.IsochronePhot(evo_model=evolution.Parsec() )' (I also have the other necessary inputs, but didn't want to clutter the message with too much code), I receive a FileNotFoundError for 'PyPopStar-master/grp/hst/evolution/ParsecV1.2s/iso/z04/iso_6.70.fits'. Now obviously I went to check that file path, and found a corresponding .dat file, but no .fits file, like it is asking for. In fact for z04 and z005 in ParsecV1.2s, there are no .fits files at all. The z015 file has both .dat and .fits files, which I imagine the others are supposed to have as well.

This wasn't a huge issue; I just write a script to load each .dat file and save it as a .fits file in the same folder. But, it also seems like an easy thing to fix that will hopefully help future users.

Again, thank you for the package and the great work.

All the best, Robert

robertfoster550 commented 4 years ago

Just as a follow-up; I was able to convert each of the .dat files that were present in the Parsec model files, which were what were present in the 'popstar_models.tar.gz' file, I believe. However, now when I ask it to make a synthetic.IsochronePhot() it has started asking for files numbers that are different than what is present; i.e. 'iso_6.88.fits' and 'iso_6.78.fits'. I only have ones that are multiples of 10, like 'iso_6.70', 'iso_6.80', etc. Where might I find these files? Or is there a work-around that I can use?

Thank you again for your help! Robert

mwhosek commented 4 years ago

Hi Robert,

Thank you for your feedback! We are glad that you are finding PyPopStar useful in your work.

The reason for your error is that we haven't yet fully implemented non-solar metallicity Parsec models into the pre-packaged set of PyPopStar isochrones. This is on our to-do list. With the current setup, only the MIST models have non-solar metallicity support (-4.0 <= [Fe/H] <= 0.5, in steps of 0.5). Would this be sufficient, or do you need the Parsec models specifically?

As you've identified, the framework for non-solar metallicity Parsec models (or any other type of evolution models, for that matter) is already built in. The general steps to implement additional models are:

  1. Download the raw isochrones from the evolution model website. Ideally, you would use same age sampling as is present in the solar metallicity models (this will cause problems that require a more complex fix later, otherwise).
  2. Reformat the raw isochrones into PyPopStar format, i.e. save as fits files in the appropriate sub-directory corresponding to its metallicity under /iso/. There should be one isochrone (i.e., one age) per file.
  3. Edit the evolution object in evolution.py so it knows about the new isochrones and where they live. The following variables in the init function need to be updated: -self.z_list: add the new metallicities -self.z_file_map: edit dictionary to connect each metallicity in z_list to the name of the appropriate sub-directory in /iso/ where the isochrones live
  4. (optional, but recommended if planning to merge local edits into PyPopStar development branch for community use) Add a test function to popstar/tests/test_synthetic.py to make sure everything is working properly.

So, to answer your follow-up question: you'd need to download the isochrones at the finer age sampling from the Parsec website (see Parsec model class on https://pypopstar.readthedocs.io/en/latest/evo_models.html for details) and then do step 2 above. The z04 and z005 sub-directories already exist, so you wouldn't need to do step 3 unless you wanted to implement other metallicities.

Let me know if you are interested in implementing yourself and we can discuss more details as questions arise. Otherwise, I am happy to implement them (~1 week timescale).

Thanks, Matt

robertfoster550 commented 4 years ago

Hi Matt,

Thank you for your detailed and quick response! It has helped, though I have a bit of further questioning.

Unfortunately I do need to use the Parsec models, as these models are the ones being used elsewhere in the project. Because of this, however, I am quite familiar with the website, and would have no trouble downloading the base isochrone models myself; so thank you for the steps to add them.

My two biggest remaining questions are:

  1. What is the notation used in the files to differentiate metallicities/ages? For example for file 'z04/iso_5.90.fits' is the 04 the metallicity? Or is it the mass range? And then the 5.90 is the logAge, so just under 1Myr? Sorry for the detailed probing, but I have glanced through the notes and am not sure, and if I'm going to be adding more, I want to make sure I give them the correct locations/names. In case it helps, I will be using metalicity of about -0.22 dex to -0.37 dex (I could simplify it to just -0.25 and -0.3), and logAges from 6.0 to 7.0.

  2. Inside the .fits/.dat files, the columns are given the generic names of 'col1', 'col2', ... . That is fine if I am just using them, but if I have to build my own, I will likely need to know what information is supposed to go in which columns. It looks like the Parsec ones have 15 columns each, so if you could point me to documentation with what those are, that would be great.

Of course, if you can think of any other information I might need to implement them, please let me know. Again, thank you so much for your help and support. I really appreciate it!

Cheers, Robert

mwhosek commented 4 years ago

Hi Robert,

Sounds good! To answer your questions:

1) You are correct; in this case the "04" corresponds to the metallicity in terms of the mass fraction of metals, and the "5.90" corresponds to the log(age), where the age is in years. While the metallicity can be any number of digits you want, PyPopStar requires that the logAge only go to 2 places after the decimal in the iso_*.fits file names.

One potential source of confusion: when you are using PyPopStar, note that the "metallicity" input keyword provided by the user (to the Isochrone call, for example) is in units of [Z]:

[Z] = log10( Z_desired / Z_solar )

Where Z_solar is the mass fraction of metals at solar metallicity in the given set of evolution models. PyPopStar translates between these inside the code, so you want to make sure that they match up the way you expect. The Z_solar value for each evolution model is defined as the z_solar variable on the evolution model class. For the Parsec models, z_solar = 0.015.

2) Unfortunately PyPopStar expects the generic column names in the Parsec isochrone files. It changes the column names to more descriptive titles inside the code itself, in the evolution.py --> Parsec object --> isochrone() function. If you look at that section of evolution.py (lines 399 - 407), you'll see that 'col1' gets mapped to 'Z', 'col2' gets mapped to 'logAge', etc. So, you'll have to ensure that this mapping is still valid for the new isochrone files you create.

That ought to be everything you need to implement the new isochrones, but let us know if you run into problems. We hadn't set up documentation for this yet, so you are our first test-case!

-Matt

robertfoster550 commented 4 years ago

Matt,

Thank you so much for all that help! It seems to have worked really well.

My Z_desired was 0.008, so I made that file and added isochrones for 1 to 10Myr at that metalicity, and it ran perfectly!

The only remaining issues I had, which were nothing major:

  1. Thank you for pointing out lines 399-407 in the evolution.py code, to map col1-col7 and col15. However I kind of had to guess at col8-col14. I figure they are HST filters (in mag) but the info given in the Parsec class was not quite specific enough to determine exactly which. Comparing them to the files I already had, I believe I was able to determine most of the columns; it seems to have worked well at least. Col14 I'm still fairly lost on, but I don't think it is vitally important. Obviously if you have those filters, I wouldn't mind getting them just to double check.

  2. I tried to use the 'format_isochrones' function that is part of the Parsec class, but ran into errors that I could not fix. That may just be a personal problem, but I simply downloaded the files from the Parsec website, and told the function where to find them, and it got an error that it couldn't find the End tag for the header. It would have been nice if that had worked, but again, it was easy to just write a quick program to make my own.

Sincerely, thank you for the wonderful help. I look forward to using your package extensively (and will of course cite you and your great work should we manage to get this paper published).

All the best, Robert

mwhosek commented 4 years ago

Excellent! I am in the process of adding documentation on how to add models based on this thread.

One final note about the un-labeled columns in the Parsec isochrone you refer to (e.g. cols 8 - 16): PyPopStar doesn't actually use them, which is why they don't get re-labeled within the code. PyPopStar calculates its own synthetic photometry by convolving the stellar SED (obtained via the atmosphere model) with the desired photometric filter.

Thanks for letting us know about the format_isochrone() function. It sounds like it is trying to read a fits file as an ascii file, or vice versa. We'll check it out.

-Matt