wbalmer / backtracks

Python package to fit relative astrometry with background star motion tracks.
https://backtracks.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
6 stars 2 forks source link

Added plot_radec parameter and removed envelope from trackplot #13

Closed tomasstolker closed 9 months ago

tomasstolker commented 9 months ago

Hi @wbalmer,

I was trying to fix the envelope in de left panel of the figure from trackplot. However, I realized that this is not feasible I think. The fill_between function from pyplot requires shared x values for the lower and upper y values. That would require interpolating the Dec values of the +1 sigma line on the RA values of the -1 sigma line (or the other way around). However, that will not work because of the helix-shaped curve. For each RA position the curve has two or more Dec positions.

So I don't think that there is a straightforward way to include the envelope and perhaps there would anyway be too much overlap of the envelope. I have removed it from the plot and instead added the plot_radec parameter to generate_plots (default: False). If set to True, trackplot will shown deltaRA en deltaDEC in the right panels instead of sep and PA.

As I was going through the code, I have also been making some minor style improvements here and there. And also added a requirements.txt file with the dependencies.

Let me know in case you have any feedback/questions!

tomasstolker commented 9 months ago

Hereby an example for HD 131399A, using trackplot with plot_radec=True:

HD_131399A_model_bgstar

gotten commented 9 months ago

There is a computationally inefficient approach (that you probably thought about). Simulate many realizations of delRA and delDEC and make a 1 sigma contour from the cloud of points. It will look noisy with low numbers. The delRA, delDECs should already be generated by the fitting process, storing a subset might be possible?. Perhaps it is a step that we accept it looks noisy (or is not generated) for initial plots and only generated for a "paper worthy" run where we generate more points.

Edit: I now realize they need a denser time coverage than the fit provides. In any case we could generate it for a "paper" run.

tomasstolker commented 9 months ago

Good idea, but might indeed be quite computationally intensive. I had tried simply adding a bunch of posterior samples in the deltaRA-deltaDEC plot, but calculating a single background track for a sample of parameters takes already several seconds with the currently implemented step size of 1 day.

tomasstolker commented 9 months ago

The last commit addresses issue #14 and also generalized the reading of the input file a bit. Having an extra column with the instrument names in the CSV file will also work.

gotten commented 9 months ago

The new default days_forward and days_backward for generate_plots are not good matches in the example, so we should also make a change in hd131339a.py, to set these parameters to 2600 days backward and -1200 days forward when we call generate_plots in the example. (although with these parameters the year axis labels get a bit dense)

location in your repo if i'm not mistaken: https://github.com/tomasstolker/backtrack/blob/f1c92d6bef08c49aaba4f358182be188228e459c/tests/hd131339a.py#L8

The stationary background plot was commented away so that plot is no longer made. (do we want to integrate the stationary scenario in the regular plot as an optional line )?