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

Issue 1316: Adding fortuitous variable stars to EXOTIC #1339

Draft
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

tamimfatahi
Copy link
Collaborator

Leaving this as draft for now as I am running into some issues that I'd like some advice on. Here is the thought process of the code:

  1. Using the same comparison star used to determine the magnitude of the host star (original code), EXOTIC also uses it to determine magnitude of other variable stars in the field.
  2. Calculate the target's flux based on the same aperture and annulus of the comparison star.
  3. Calculate the airmass model and coefficients using ordinary least squares.
  4. Detrend and calculate the magnitude similarly to how EXOTIC calculates it currently for the variable star code.

Here are the issue I am running into:

After calculating the airmass model, it seems like the residuals are quite large and needs altering.

Here are the airmass plots for a variable star in the field:
Variable_Airmass_Combined_422_380

Here it the predicted mag for the star (VSX=14.86 - 15.67 V):
Stellar_Variability_422_380

I thought the airmass plot code was off due to the model looking like the inverse. However, on a separate star from a different dataset, I got the following:
Variable_Airmass_Combined_1508_452

where the magnitude was calculated as shown here (VSX=14.43+/-0.42 CV):
Stellar_Variability_1508_452

Both are pretty off in their calculations of the magnitude. Any ideas what I could do differently?

@tamimfatahi tamimfatahi added the enhancement New feature or request label Oct 29, 2024
@tamimfatahi tamimfatahi self-assigned this Oct 29, 2024
Comment on lines +1503 to +1515
def calculate_airmass_model(norm_flux, comparison_star_params):
transformed_norm_flux = np.log(norm_flux)

X = sm.add_constant(comparison_star_params['airmass'])

model = sm.OLS(transformed_norm_flux, X).fit()

a1 = model.params[1]
a2 = model.params[0]

airmass_model = np.exp(a1) * np.exp(a2 * comparison_star_params['airmass'])

return airmass_model, a2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to highlight this function on calculating the airmass model with its coefficients.

Comment on lines +1518 to +1529
def detrend_and_calculate_magnitude(norm_flux, airmass_model, comparison_star_params, a2):
oot_scatter = np.std((norm_flux / airmass_model))
norm_flux_unc = oot_scatter * airmass_model
norm_flux_unc /= np.nanmedian(norm_flux)

model = np.exp(a2 * airmass_model)
detrended = norm_flux / model

Mt = comparison_star_params['Mc'] - (2.5 * np.log10(detrended))
Mt_err = (comparison_star_params['Mc_err'] ** 2 + (-2.5 * norm_flux_unc / (detrended * np.log(10))) ** 2) ** 0.5

return Mt, Mt_err
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function calculates the target magnitude.

Comment on lines +1537 to +1539
norm_flux = target_flux[mask] / comparison_star_params['flux']

norm_flux /= np.nanmedian(norm_flux)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This portion calculate the normalized flux.

@pearsonkyle
Copy link
Collaborator

Can you also show the relative flux on those plots?

It's not clear to me what you're fitting. The airmass model should be compared to the relative flux after dividing out the transit (or on the out of transit baseline) not the actual airmass. The airmass is just used as an input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filter Magnitude Errors >1 for Stellar Variability Performing Photometry on Fortuitous Variable Stars
2 participants