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

Add some notes to first part of notebook #8

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Peter9192
Copy link
Contributor

Started running the example notebook and left some notes. Work in progress, I'm about halfway.

In the process I wrote a function that can easily create time handling plots for various precursor/target periods:

image

@semvijverberg
Copy link
Member

Really nice graphic :)

@jannesvaningen
Copy link
Contributor

Awesome graph! So you wrote a function that can create these type of plots?

@Peter9192
Copy link
Contributor Author

Peter9192 commented Apr 7, 2022

So you wrote a function that can create these type of plots?

Yes, I'll copy the code below for reference. I guess it might still need a few tweaks, but you get the idea.

import matplotlib.pyplot as plt
def plot_timehandling(prec_start=-1, prec_end=6, target_start=6, target_end=9):
    """Plot time handling given a target and precursor period.
    
    TODO: handle zero-crossing.
    """ 
    prec_start -= 1
    prec_end -= 1
    target_start -= 1
    target_end -= 1
    with plt.xkcd():
        fig = plt.figure()
        ax = fig.add_subplot(111, projection='polar')

        ax.set_theta_direction(-1)
        ax.set_theta_zero_location('N')
        ax.grid(False)
        ax.set_axisbelow(False)

        ax.set_xticks(np.linspace(0, 2*np.pi*11/12, 12))
        ax.set_xticklabels('JFMAMJJASOND')
        ax.set_ylim(0, 1)
        ax.set_yticks([0, 0.45, 0.85])
        ax.set_yticklabels(['1979', '2002', '2018'])

        r = np.linspace(0, 12*np.pi, 1000)
        th = np.linspace(0, 1, 1000)
        ax.plot(r, th, color='lightgrey')

        th = np.ones(100)
        precursor = np.linspace(prec_start/12, prec_end/12, 100)*np.pi*2
        ax.fill_between(precursor, th, 0, color='lightblue', label='precursor')

        target = np.linspace(target_start/12, target_end/12, 100)*np.pi*2
        ax.fill_between(target, th, 0, color='lightgreen', label='target')

        ax.legend(bbox_to_anchor=(1, 1.07))

        return fig, ax
    
fig, ax = plot_timehandling(1, 6, 6, 9)

Base automatically changed from relative-imports to master April 7, 2022 12:28
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

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

Successfully merging this pull request may close these issues.

3 participants