Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solar metallicity value saved in sp object #172

Closed
dnarayanan opened this issue Nov 8, 2021 · 4 comments
Closed

solar metallicity value saved in sp object #172

dnarayanan opened this issue Nov 8, 2021 · 4 comments
Assignees

Comments

@dnarayanan
Copy link

Hi,

[Feature request]

Would it be possible to save the value used for solar metallicity in the sp object? These are different for different isochrones, which makes code on our end kind of clunky like appended below :). If this were in the sp object it would be super convenient on our end for powderday.

thanks!
-desika

print(f'\n----------------------------------------------\nSetting solar metallicity value')
if 'mist' in isochrone:
    print('isochrone = mist')
    cfg.par.solar = 0.0142
    print(f'solar metallicity = {cfg.par.solar}')
elif 'bsti' in isochrone:
    print('isochrone = basti')
    cfg.par.solar = 0.020
    print(f'solar metallicity = {cfg.par.solar}')
elif 'gnva' in isochrone:
    print('isochrone = geneva')
    cfg.par.solar = 0.020
    print(f'solar metallicity = {cfg.par.solar}')
elif 'prsc' in isochrone:
    print('isochrone = parsec')
    cfg.par.solar = 0.01524
    print(f'solar metallicity = {cfg.par.solar}')
elif 'pdva' in isochrone:
    print('isochrone = padova')
    cfg.par.solar = 0.019
    print(f'solar metallicity = {cfg.par.solar}')
elif 'bpss' in isochrone:
    print('isochrone = bpass')
    cfg.par.solar = 0.020
    print(f'solar metallicity = {cfg.par.solar}')
print('----------------------------------------------')
@bd-j bd-j self-assigned this Nov 8, 2021
@moustakas
Copy link

@dnarayanan it looks like @bd-j has already self-assigned this (useful) suggestion, but for the time being a one-time dictionary might simplify your code a bit. In case it's useful, something like:

Ziso = {'mist': ('mist', 0.0142), 'bsti': ('basti', 0.020), 
  'gnva': ('geneva', 0.020), 'prsc': ('parsec', 0.01524), 
  'pdva': ('padova', 0.019)}

iso, Zsun = Ziso[isochrone]
cfg.par.solar = Zsun
print('isochrone, solar metallicity = {} ({}), {:.4f}'.format(iso, isochrone, Zsun))

@dnarayanan
Copy link
Author

that is much nicer -- thanks John!

@dnarayanan
Copy link
Author

(I should note -- for the purposes of this enhancement request -- is that one thing I'm worried about is that if the definition of 'solar' changes for a set of isochrones one day, that if I have it hardcoded in powderday, we'll be making an error. that's why I'd love to be able to grab it directly from the sp object)

@bd-j
Copy link
Collaborator

bd-j commented Aug 11, 2022

As of #182 there is a solar_metallicity attribute of StellarPopulation that gives the isochrone solar metallicity definition being used in FSPS. Hope this addresses the issue, but please do reopen if there is some other behavior or functionality you had in mind @dnarayanan, thanks.

@bd-j bd-j closed this as completed Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants