<jupyter_start><jupyter_text>Plotting the PDO<jupyter_code># Import necessary packages
import xarray as xr
import numpy as np
import datetime as dt
import matplotlib.pyplot as plt
import ipywidgets as widgets
from datetime import datetime, timedelta
# Import the PDO region anomaly index dataset
pdo = xr.open_dataset('daily_PDO_1836_2015.nc')
pdo
# Plots entire PDO dataset (1836-2015)
fig = plt.figure(figsize=(12, 6))
plt.plot(pdo.time, pdo.pdostdanom.values, linewidth=2, color='grey')
plt.axhline(0, color='black', lw=2)
plt.xlabel('Year',fontsize=14)
plt.ylabel('Anomaly (°C)',fontsize=14)
plt.title('PDO Region Standardized Anomaly Index from 1836-2015',fontsize=20)<jupyter_output><empty_output><jupyter_text>Choose a start and end date to for plotting the PDO index.- Dates are between 01-01-1836 and 12-31-2015- Make sure the end date is after the start date<jupyter_code># User selects the start date and end date
x = widgets.DatePicker(description='Start Date')
y = widgets.DatePicker(description='End Date')
display(x)
display(y)
def Plot():
    # The start date criteria
    start = f'{x.value}T00:00:00'
    end = f'{y.value}T00:00:00'
    
    # Queries the pdo dataset based on user input
    PDO = pdo.sel(time=slice(start, end))
    
    # Creates the daily anomaly index figure
    plt.figure(figsize=(12, 6))
    plt.plot(PDO.time, PDO.pdostdanom.values, linewidth=2, color='grey')
    plt.axhline(0, color='black', lw=2)
    plt.xlabel('Year',fontsize=14)
    plt.ylabel('Anomaly (°C)',fontsize=14)
    plt.title(f'PDO Region Standardized Anomaly Index: {x.value} to {y.value}',fontsize=20)
    plt.show()

# Calls the plotting function
Plot()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12389380530973451, 'fraction_numerical': 0.044837758112094395, 'mean_word_length': 5.144927536231884, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '141761', 'license': 'MIT', 'n_tokens_mistral': 666, 'n_tokens_neox': 602, 'n_words': 162, 'path': 'pdo_plotting.ipynb', 'repo_name': 'sylviastinnett/20CR', 'size': '1695'}