ArtificialStellarPopulations / ArtPop

✨ ArtPop – Building artificial galaxies one star at a time.
https://artpop.readthedocs.io/en/latest/
MIT License
60 stars 10 forks source link

Gaia filters #17

Closed eilatg closed 7 months ago

eilatg commented 7 months ago

Hello, I am wondering if there is a way to include new filters in addition to those on the phot_system_list I would like to use ArtPop for my stellar astrophysics class and compare with open clusters from Gaia. Is there a way for a user to add filters, like the Gaia filters, if the transmission curves exist?

Thanks!

johnnygreco commented 7 months ago

Hey Eilat!

Yes, it is possible to add new filters. Although, I believe the Gaia filters are included in MIST's UBVRIplus filter set. Will this work for your class?

If not, the easiest way to use a new filter set is to build the stellar population and image using the generic Isochrone, SSP, and SersicSP objects.

There's another way to use arbitrary filters using the FilterSystem object, which you can pass to the Imager, but it's more complicated than it should be. I'd love to make it more straightforward, but it's tough to find time these days!

Here's an example of the first approach that I shared in response to a similar question:

Downloaded MIST VISTA filters

wget https://waps.cfa.harvard.edu/MIST/data/tarballs_v1.2/MIST_v1.2_vvcrit0.4_VISTA.txz
tar Jxvf MIST_v1.2_vvcrit0.4_VISTA.txz
rm MIST_v1.2_vvcrit0.4_VISTA.txz

Create artpop image using generic objects

import os 

import matplotlib.pyplot as plt
from astropy import units as u

import artpop
from artpop.stars._read_mist_models import IsoCmdReader

def read_iso(phot_system, mist_path, log_age, feh, v_over_vcrit=0.4):
    v = f'{v_over_vcrit:.1f}'
    ver = 'v1.2'
    path = os.path.join(mist_path, 'MIST_' + ver + f'_vvcrit{v}_' + phot_system)
    sign = 'm' if feh < 0 else 'p'
    fn = f'MIST_{ver}_feh_{sign}{abs(feh):.2f}_afe_p0.0_vvcrit{v}_{phot_system}.iso.cmd'
    fn = os.path.join(path, fn)
    iso_cmd = IsoCmdReader(fn, verbose=False)
    iso_cmd = iso_cmd.isocmds[iso_cmd.age_index(log_age)]
    return iso_cmd

iso = read_iso("VISTA", ".", 10, -1)

bands = [b for b in iso.dtype.names if b[:5] == "VISTA"]

iso = artpop.Isochrone(
    mini=iso["initial_mass"], 
    mact=iso["star_mass"], 
    mags=iso[bands], 
    eep=iso["EEP"], # optional
    log_L=iso["log_L"], # optional
    log_Teff=iso["log_Teff"] # optional 
)

ssp = artpop.SSP(iso, num_stars=1e5, distance=10*u.Mpc)

source = artpop.SersicSP(
    sp=ssp,
    n=0.8,
    r_eff=100*u.pc,
    theta=0, 
    ellip=0.3, 
    xy_dim=501, 
    pixel_scale=0.2
)

psf = artpop.moffat_psf(0.8)

imager = artpop.IdealImager()
obs = imager.observe(source, "VISTA_Ks", psf=psf)

artpop.show_image(obs.image)
plt.show()

Please let me know if you have any questions!

eilatg commented 7 months ago

Hi Johnny,

Thanks for this reply – you are correct that the Gaia filters are in the UBVRIplus set. I did:

artpop.get_filter_names('UBVRIplus')

and got the list. So that should do it. But I have saved this email for any future case where I do want to add filters.

Thanks for the quick response!

Cheers, Eilat

From: Johnny Greco @.> Date: Sunday, February 4, 2024 at 12:25 PM To: ArtificialStellarPopulations/ArtPop @.> Cc: Glikman, Eilat @.>, Author @.> Subject: Re: [ArtificialStellarPopulations/ArtPop] Gaia filters (Issue #17) You don't often get email from @.*** Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification

Hey Eilat!

Yes, it is possible to add new filters. Although, I believe the Gaia filters are included in MIST's UBVRIplus filter set. Will this work for your class?

If not, the easiest way to use a new filter set is to build the stellar population and image using the generic Isochronehttps://github.com/ArtificialStellarPopulations/ArtPop/blob/main/src/artpop/stars/isochrones.py#L26, SSP<ArtificialStellarPopulations/ArtPop/blob/main/src/artpop/stars/populations.py#L326>, and SersicSPhttps://github.com/ArtificialStellarPopulations/ArtPop/blob/main/src/artpop/source.py#L125 objects.

There's another way to use arbitrary filters using the FilterSystemhttps://github.com/ArtificialStellarPopulations/ArtPop/blob/main/src/artpop/filters.py#L29 object, which you can pass to the Imager, but it's more complicated than it should be. I'd love to make it more straightforward, but it's tough to find time these days!

Here's an example of the first approach that I shared in response to a similar question:

Downloaded MIST VISTA filters

wget https://waps.cfa.harvard.edu/MIST/data/tarballs_v1.2/MIST_v1.2_vvcrit0.4_VISTA.txz

tar Jxvf MIST_v1.2_vvcrit0.4_VISTA.txz

rm MIST_v1.2_vvcrit0.4_VISTA.txz

Create artpop image using generic objects

import os

import matplotlib.pyplot as plt

from astropy import units as u

import artpop

from artpop.stars._read_mist_models import IsoCmdReader

def read_iso(phot_system, mist_path, log_age, feh, v_over_vcrit=0.4):

v = f'{v_over_vcrit:.1f}'

ver = 'v1.2'

path = os.path.join(mist_path, 'MIST_' + ver + f'_vvcrit{v}_' + phot_system)

sign = 'm' if feh < 0 else 'p'

fn = f'MIST_{ver}_feh_{sign}{abs(feh):.2f}_afe_p0.0_vvcrit{v}_{phot_system}.iso.cmd'

fn = os.path.join(path, fn)

iso_cmd = IsoCmdReader(fn, verbose=False)

iso_cmd = iso_cmd.isocmds[iso_cmd.age_index(log_age)]

return iso_cmd

iso = read_iso("VISTA", ".", 10, -1)

bands = [b for b in iso.dtype.names if b[:5] == "VISTA"]

iso = artpop.Isochrone(

mini=iso["initial_mass"],

mact=iso["star_mass"],

mags=iso[bands],

eep=iso["EEP"],

log_L=iso["log_L"],

log_Teff=iso["log_Teff"]

)

ssp = artpop.SSP(iso, num_stars=1e5, distance=10*u.Mpc)

source = artpop.SersicSP(

sp=ssp,

n=0.8,

r_eff=100*u.pc,

theta=0,

ellip=0.3,

xy_dim=501,

pixel_scale=0.2

)

psf = artpop.moffat_psf(0.8)

imager = artpop.IdealImager()

obs = imager.observe(source, "VISTA_Ks", psf=psf)

artpop.show_image(obs.image)

plt.show()

Please let me know if you have any questions!

— Reply to this email directly, view it on GitHubhttps://github.com/ArtificialStellarPopulations/ArtPop/issues/17#issuecomment-1925848210, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AB73GSPG42QYVM5E6EZPYKDYR7ABLAVCNFSM6AAAAABCTVWD3WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRVHA2DQMRRGA. You are receiving this because you authored the thread.Message ID: @.***>