Issue 1316: Adding fortuitous variable stars to EXOTIC#1339
Issue 1316: Adding fortuitous variable stars to EXOTIC#1339tamimfatahi wants to merge 13 commits intodevelopfrom
Conversation
…, calculating photometry values for fortuitous stars.
…als and measured.
| 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 |
There was a problem hiding this comment.
I'd like to highlight this function on calculating the airmass model with its coefficients.
| 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 |
There was a problem hiding this comment.
This function calculates the target magnitude.
| norm_flux = target_flux[mask] / comparison_star_params['flux'] | ||
|
|
||
| norm_flux /= np.nanmedian(norm_flux) |
There was a problem hiding this comment.
This portion calculate the normalized flux.
|
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. |
|
Just checking in on this ... Any changes ready for release? Is it ready for code review? |
|
Not ready for release, I still need to do some more testing and pick up where I left off. I'll need about a month before doing if that's okay |
|
@tamimfatahi Is this ready? |
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:
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:

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

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:

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

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