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

plot_phase_fold raise error when run without data #125

Open
guosufen opened this issue Dec 20, 2023 · 1 comment
Open

plot_phase_fold raise error when run without data #125

guosufen opened this issue Dec 20, 2023 · 1 comment

Comments

@guosufen
Copy link

the function plot_phase_fold raise error.
In the plot.py file the funciton plot_phase_fold are defined as:
def plot_phase_fold(sample, data=None, ax=None,
with_time_unit=False, n_phase_samples=4096,
add_labels=True, show_s_errorbar=True, residual=False,
remove_trend=True, plot_kwargs=None, data_plot_kwargs=None)

this function will raise a error when run like :
tj.plot_phase_fold(joker_samples, ax=ax) # without data input

the error message:
Traceback (most recent call last):
File "***.py", line ***, in
tj.plot_phase_fold(joker_samples, ax=ax)
File "/Users/sky/opt/miniconda3/envs/py39tj/lib/python3.9/site-packages/thejoker/plot.py", line 329, in plot_phase_fold
orbit.radial_velocity(t0 +
UnboundLocalError: local variable 't0' referenced before assignment

the error is raised because in the plot.py file the line "t0 = sample.get_t0()" is inside the " if data is not None:"

    if data is not None:
        rv = data.rv

        if remove_trend:
            # HACK:
            trend = orbit._vtrend
            orbit._vtrend = lambda t: 0.
            rv = rv - trend(data.t)

        v0_offset_names = get_v0_offsets_equiv_units(sample.n_offsets).keys()
        for i, offset_name in zip(range(1, sample.n_offsets+1),
                                  v0_offset_names):
            _tmp = sample[offset_name].item()
            rv[ids == i] -= _tmp

        t0 = sample.get_t0()

but in the source I downloaded from github, the line "t0 = sample.get_t0()" are outside the if condition:

    P = sample['P'].item()
    t0 = sample.get_t0()

    if data is not None:
        rv = data.rv

So I hope in the following version, this would be fixed.

PS:
I installed thejoker by pip: pip install thejoker and installed thejoker 1.2.2

@adrn
Copy link
Owner

adrn commented Jan 2, 2024

Hi @guosufen! Thanks for the issue. Could you try installing the latest development version instead?

pip install git+https://github.com/adrn/thejoker

and see if it has the same issue?

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

No branches or pull requests

2 participants