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

How to add photometry from UKIRTS/WFCAM #15

Open
pjchen3 opened this issue Jan 12, 2025 · 8 comments
Open

How to add photometry from UKIRTS/WFCAM #15

pjchen3 opened this issue Jan 12, 2025 · 8 comments

Comments

@pjchen3
Copy link

pjchen3 commented Jan 12, 2025

Hi Joris,
I am a new user of speedyfit. Could you please advise on how to incorporate JHK photometry from UKIRT/WFCAM into the fitting? The object is not included in existing Vizier catalogs such as UKIDSS-DR7, but I have extracted the photometry directly from images.

@vosjo
Copy link
Owner

vosjo commented Jan 13, 2025

Hi,
You can add your photometry directly to the photometry file. Just make sure that you provide the flux and flux error in units of "erg/s/cm2/AA". For a bit more info on the photometry file: https://speedyfit.readthedocs.io/en/latest/userguide/photometry_file.html

Let me know if you need more info.

@pjchen3
Copy link
Author

pjchen3 commented Jan 13, 2025

Thank you for the reply.
I tried adding the flux and flux error to the photometry file using the following format:
| WFCAM.J | flux | flux error |

However, when I ran the command, it returned: “Passband WFCAM.J missing from table”.

@vosjo
Copy link
Owner

vosjo commented Jan 13, 2025

Hi,
You will have to add those bands to the integrated grids you want to use because WFCAM is not included by default. Speedyfit has the transmission curves for WFCAM included in the package. So you do have everything you need to make a new integrated grid with WFCAM included. To do this. Look in the source code of speedyfit. There is a file called integrate_grid.py At the very bottom of the file there is a section like this:

if __name__=="__main__":

    responses = ['GALEX', 'IUE', 'STROMGREN', 'JOHNSON', 'GAIA3E', 'GAIA2', 'SKYMAPPER', 'APASS', 'SDSS', '2MASS', 'WISE']
    evbs = np.r_[0:1.02:0.05]

    # Kurucz
    calc_integrated_grid(threads=6, ebvs=evbs, law='fitzpatrick2004', Rv=3.1,
                         responses=responses, grid='kurucz')

Add the grid you want to the responses list:
responses = ['GALEX', 'IUE', 'STROMGREN', 'JOHNSON', 'GAIA3E', 'GAIA2', 'SKYMAPPER', 'APASS', 'SDSS', '2MASS', 'WISE', 'WFCAM']

Then run that script and it will make a new integrated grid that you can use. This will take quite a lot of time depending on the computer you are running it on.

@pjchen3
Copy link
Author

pjchen3 commented Jan 13, 2025

Many thanks!

@vosjo vosjo closed this as completed Jan 13, 2025
@pjchen3
Copy link
Author

pjchen3 commented Jan 14, 2025

Hi Joris,
I added commands to the code (lines 196 and 206 of “plotting.py”) to save the synthetic model and flux values. I then tried to recalculate the flux values from the synthetic model using the “synthetic_flux()” function in “filters.py.” However, I noticed that the recalculated flux values are consistently slightly smaller than those returned by the algorithm, and I haven’t been able to identify the cause. Could you please help me understand what might be causing this discrepancy?

In the attached image, the red crosses represent the synthetic fluxes returned by the algorithm, while the blue crosses represent the flux values I recalculated. Observed fluxes from SDSS are marked with green circles.
Screenshot 2025-01-14 at 16 46 28

@vosjo
Copy link
Owner

vosjo commented Jan 14, 2025 via email

@pjchen3
Copy link
Author

pjchen3 commented Jan 14, 2025

Thank you for the reply. We might consider using the case of HIP_4618 (with constraints) from https://speedyfit.readthedocs.io/en/stable/userguide/quickstart.html.
Below is the code I used to calculate the synthetic flux in the 2MASS J band (utilizing the transmission curve in the package) from the synthetic spectrum (file “binary_model.txt”) returned by the algorithm:

wave = wave_model # synthetic spectrum from the file "binary_model.txt"
flux = flux_model # synthetic spectrum from the file "binary_model.txt"
waver, transr = np.loadtxt('path_to_the_transmission_curve/2MASS_J.txt', unpack=True)
region = ((waver[0] - 0.4 * waver[0]) <= wave) & (wave <= (2 * waver[-1]))

wave_ = wave[region]
flux_ = flux[region]

if (np.searchsorted(wave_, waver[-1]) - np.searchsorted(wave_, waver[0])) < 5:
    wave__ = np.sort(np.hstack([wave_, waver]))
    flux_ = np.interp(wave__, wave_, flux_)
    wave_ = wave__

# -- interpolate response curve onto model grid
transr = np.interp(wave_, waver, transr, left=0, right=0)

# -- integrated flux: different for bolometers and CCDs
# -- WE WORK IN FLAMBDA
F_band = np.trapz(flux_ * transr * wave_, x=wave_) / np.trapz(transr * wave_, x=wave_)

print("Flux in J band: {:.4e} erg/s/cm^2/Å".format(F_band))

The synthetic flux (file “synthetic_flux.txt”) returned by the algorithm in the 2MASS J band is approximately 1.398e-12, while I obtained a value of 1.474e-12 using the code above.
binary_model.txt
synthetic_flux.txt

@vosjo
Copy link
Owner

vosjo commented Jan 16, 2025 via email

@vosjo vosjo reopened this Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants