simonrw / ttvfast-python

Python interface to the TTVFast library
GNU General Public License v2.0
15 stars 6 forks source link

output of RVs with ttvfast. #21

Open svaverbe opened 1 year ago

svaverbe commented 1 year ago

All,

How should I switch on the radial velocity output option in ttvfast ? I have, for example,

Calculate TTVs using the generate_ttv_model() function

stellar_mass = 1.0 # Stellar mass in solar masses start_time = 0.0 # Start time in days end_time = 200.0 # End time in days time_step = 0.1 # Time step in days rv_times=np.linspace(start_time,end_time,1000,endpoint=True)

ttv_data,rv_data = generate_ttv_model(planets, stellar_mass, start_time, end_time, time_step,rv_times)

and

def generate_ttv_model(planets, stellar_mass, start_time, end_time, time_step,rv_times): results = ttvfast.ttvfast(planets, stellar_mass, start_time, time_step, end_time,rv_times=rv_times) print(results) ttv_data = results['positions'] rv_data=results['rv'] return ttv_data,rv_data

But it does not appear to work:

TypeError: bad argument type for built-in operation

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "ttv_model.py", line 193, in ttv_data,rv_data = generate_ttv_model(planets, stellar_mass, start_time, end_time, time_step,rv_times) File "ttv_model.py", line 29, in generate_ttv_model results = ttvfast.ttvfast(planets, stellar_mass, start_time, time_step, end_time,rv_times) File "/home/siegfried/anaconda3/envs/science/lib/python3.8/site-packages/ttvfast/init.py", line 49, in ttvfast positions, rv = _ttvfast_fn( SystemError: returned a result with an error set

simonrw commented 1 year ago

Hi, thanks for reporting this issue. I'm afraid it's been a while since I have worked on this code (or even run it!) so please bear with me!

The only thing missing from your example is the planets argument - do you have a quick example that I can use during my testing?

Generally I think you're doing the right thing passing an array of times for the rv_times argument. Once we fix the crash, your code should work :crossed_fingers:

svaverbe commented 1 year ago

Simon,

The planets argument is initialized like this:

Define planet parameters

planet1_params = {

'mass': 0.001,  # Planet mass in solar masses

'period': 10.0,  # Orbital period in days

'ecc': 0.01,  # Eccentricity

'inc': 90.0,  # Inclination in degrees

'longnode': 0.0,  # Longitude of ascending node in degrees

'argument': 0.0,  # Argument of periastron in degrees

'mean_anomaly': 0.0  # Mean anomaly at epoch in degrees

}

planet2_params = {

'mass': 0.0002,

'period': 20.0,

'ecc': 0.02,

'inc': 90.0,

'longnode': 0.0,

'argument': 0.0,

'mean_anomaly': 0.0

}

Create planet instances

planet1 = ttvfast.models.Planet(

mass=planet1_params['mass'],

period=planet1_params['period'],

eccentricity=planet1_params['ecc'],

inclination=planet1_params['inc'],

longnode=planet1_params['longnode'],

argument=planet1_params['argument'],

mean_anomaly=planet1_params['mean_anomaly']

)

planet2 = ttvfast.models.Planet(

mass=planet2_params['mass'],

period=planet2_params['period'],

eccentricity=planet2_params['ecc'],

inclination=planet2_params['inc'],

longnode=planet2_params['longnode'],

argument=planet2_params['argument'],

mean_anomaly=planet2_params['mean_anomaly']

)

List of planets

planets = [planet1, planet2]

Siegfried

Van: Simon Walker @.> Verzonden: woensdag 5 april 2023 22:07 Aan: simonrw/ttvfast-python @.> CC: svaverbe @.>; Author @.> Onderwerp: Re: [simonrw/ttvfast-python] output of RVs with ttvfast. (Issue #21)

Hi, thanks for reporting this issue. I'm afraid it's been a while since I have worked on this code (or even run it!) so please bear with me!

The only thing missing from your example is the planets argument - do you have a quick example that I can use during my testing?

Generally I think you're doing the right thing passing an array of times for the rv_times argument. Once we fix the crash, your code should work 🤞

— Reply to this email directly, view it on GitHub https://github.com/simonrw/ttvfast-python/issues/21#issuecomment-1498061767 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AF5RR44QNWVXGF6A27JIS4TW7XGHZANCNFSM6AAAAAAWSNAU5Y . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AF5RR427YCK6EEMELSYEOE3W7XGHZA5CNFSM6AAAAAAWSNAU52WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSZJKN4O.gif Message ID: @. @.> >

simonrw commented 1 year ago

Currently ttvfast does not handle numpy arrays. If you cast rv_times in your example to a list then the code runs.

I will work on adding numpy support but this may take a little while.

svaverbe commented 1 year ago

Ok, that could have been the mistake. I will check this soon.

Regards,

Siegfried

Van: Simon Walker @.> Verzonden: donderdag 6 april 2023 7:24 Aan: simonrw/ttvfast-python @.> CC: svaverbe @.>; Author @.> Onderwerp: Re: [simonrw/ttvfast-python] output of RVs with ttvfast. (Issue #21)

Currently ttvfast does not handle numpy arrays. If you cast rv_times in your example to a list then the code runs.

I will work on adding numpy support but this may take a little while.

— Reply to this email directly, view it on GitHub https://github.com/simonrw/ttvfast-python/issues/21#issuecomment-1498508854 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AF5RR4ZTAUBQ6GYSBIOKT4TW7ZHOZANCNFSM6AAAAAAWSNAU5Y . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AF5RR45DWYOLKUTUGCJXMVDW7ZHOZA5CNFSM6AAAAAAWSNAU52WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSZKFXDM.gif Message ID: @. @.> >

svaverbe commented 1 year ago

Simon,

I checked the code. The errors are removed by turning rv_times into a list, but I get only zeros in the rv output:

def generate_ttv_model(planets, stellar_mass, start_time, end_time, time_step,rv_times):

results = ttvfast.ttvfast(planets, stellar_mass, start_time, time_step, end_time,rv_times=rv_times)

print(results)

ttv_data = results['positions']

rv_data=results['rv']

return ttv_data,rv_data

print(rv_data,len(rv_data))

[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] 100

So it is not running correctly yet.

Siegfried

Van: Simon Walker @.> Verzonden: woensdag 5 april 2023 22:07 Aan: simonrw/ttvfast-python @.> CC: svaverbe @.>; Author @.> Onderwerp: Re: [simonrw/ttvfast-python] output of RVs with ttvfast. (Issue #21)

Hi, thanks for reporting this issue. I'm afraid it's been a while since I have worked on this code (or even run it!) so please bear with me!

The only thing missing from your example is the planets argument - do you have a quick example that I can use during my testing?

Generally I think you're doing the right thing passing an array of times for the rv_times argument. Once we fix the crash, your code should work 🤞

— Reply to this email directly, view it on GitHub https://github.com/simonrw/ttvfast-python/issues/21#issuecomment-1498061767 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AF5RR44QNWVXGF6A27JIS4TW7XGHZANCNFSM6AAAAAAWSNAU5Y . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AF5RR427YCK6EEMELSYEOE3W7XGHZA5CNFSM6AAAAAAWSNAU52WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSZJKN4O.gif Message ID: @. @.> >