hippke / tls

Transit Least Squares: An optimized transit-fitting algorithm to search for periodic transits of small planets
MIT License
48 stars 24 forks source link

Period Grid error in stellar mass (maybe radius too?) > 1 #89

Closed rachelbf closed 2 years ago

rachelbf commented 3 years ago

I get this error when I pass the stellar mass to TLS search and the stellar mass is > 1, which some of my stars do have. However, there seems to be no issue when I pass a stellar radius > 1. Is there a particular reason that you set this to 1? I would ideally like the period grid to be determined by the mass and radius and not by defaults Screen Shot 2021-01-22 at 15 29 10

hippke commented 3 years ago

Can you post all parameters of your search? I have seen this in the past and it was caused by an inconsistency in the values. If you specify parameters for mass_min<mass<mass_max, TLS will span a grid between mass_min and mass_max. I assume this is what you want. In this case, mass is irrelevant (but needs to be specified, otherwise an error is thrown). Perhaps a future version of TLS should ignore this error and continue.

rachelbf commented 2 years ago

Oh gosh, I'm so sorry. I never got notifications for your reply or the issue closing.

These are my search parameters:

results = tls.power(u = self.ab, R_star = self.radius, #M_star = self.mass, duration_grid_step = 1.1, period_min = 0.5, period_max = 25, n_transits_min = 2, oversampling_factor = 3, T0_fit_margin = 0.01)

I mostly fixed the aforementioned error by commenting out the mass part of it, but it still persists with the radius (for example TICs 255475779, 318027415, 396137563, 144609763, 390842111, 323245745, 462080292, 162208214, 75540884, 99039842, 374542527, 185053184, 185053184). Stellar parameters come from catalog_info

hippke commented 2 years ago

There is only a hard limit for M_star <= 1000 which should not be relevant here. Can you double check to verify that you set M_star_min < M_star < M_star_max? All 3 values should be set to avoid dubious situations. The original error message looks like you did not set any M_star_max. If you have no uncertainties, you can simply use a multiple like M_star_max=2*M_star to test.

rachelbf commented 2 years ago

So, in my code I just don't pass a mass (commented it out, hence the #) and it runs fine. This error is for the radius and I believe I have the most updated version of TLS. I am more worried about the radius since I need it for transit searchs, more than mass.

As for M_star_min < M_star < M_star_max, I haven't set this any where. Is this hardcoded in TLS?

hippke commented 2 years ago

I'm trying to reproduce your error. Can you provide a minimal example e.g. with hardcoded values? You gave some TICs e.g. 255475779 and wrote that "Stellar parameters come from catalog_info". However, when I do

from transitleastsquares import transitleastsquares, catalog_info, cleaned_array
EPIC_id = 255475779
ab, mass, mass_min, mass_max, radius, radius_min, radius_max = catalog_info(EPIC_id)

I get an error: EPIC_ID ID must be in range 201000001 to 251813738

So, which values are used?

rachelbf commented 2 years ago

I am using TESS data so it would be TIC_ID = 255475779 and not EPIC_id

hippke commented 2 years ago

Ah, sure! Sorry, my bad. However, there is no radius catalog value available for this TIC:

from transitleastsquares.catalog import catalog_info_TIC
TIC_ID = 255475779
Teff, logg, radius, radius_min, radius_max, mass, mass_min, mass_max = catalog_info_TIC(TIC_ID)
print(radius, radius_min, radius_max, mass, mass_min, mass_max)

Yields 64.1776 nan nan nan nan nan

rachelbf commented 2 years ago

In the TLS docs, it says the default is 3.5 for R_star_max, shouldn't that overwrite nans?

hippke commented 2 years ago

What happens if you set R_star=1, R_star_max=10 and R_star_min=0.1 manually for these stars?

hippke commented 2 years ago

I think setting NaNs should overwrite the default. Which causes your issue.

rachelbf commented 2 years ago

That worked! Although, given that catalog_info (with the NaNs) is called before tls.power, I would have assumed that tls.power would overwrite anything in catalog_info if there are no values in there. Why isn't that the case?

hippke commented 2 years ago

Great that it worked! catalog_info is just a helper function that you can use to get some estimates. It is totally independent. You should check the value it delivers (these are just from a catalog which has error and gaps) and correct NaNs and other problems as needed.

rachelbf commented 2 years ago

Okay, thanks Michael!