<jupyter_start><jupyter_text>Example data analysis notebookThis notebook downloads and analyses some surface air temperature anomaly data from [Berkeley Earth](http://berkeleyearth.org/). Import the required libraries.<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
import requests
import warnings
from data_analysis import *
help(download_data)<jupyter_output>Help on function download_data in module data_analysis:

download_data(location)
    downloads temperature data anomaly from Berkeley Earth for a given location
    
    :param location: name of the region
    :type location: str
     
    
    :return: data table
    :rtype: 2D numpy float array<jupyter_text>Load the data using numpy (skip the header records which are marked with a `%`).<jupyter_code>data = download_data('australia')<jupyter_output><empty_output><jupyter_text>Extract the monthly temperature anomaly and calculate an approximate "decimal year" to use in plotting.<jupyter_code>#decimal_year = data[:, 0] + 1/12*(data[:, 1] - 1)
#temperature_anomaly = data[:, 2]

decimal_year, temperature_anomaly = extract_monthly_anomaly(data)<jupyter_output><empty_output><jupyter_text>Plot the data so we can see what it's like.<jupyter_code>plt.figure(figsize=(10, 6))
plt.title("Temperature anomaly for Australia")
plt.plot(decimal_year, temperature_anomaly)
plt.xlabel('year')
plt.ylabel('temperature anomaly (C)')
plt.grid()
plt.xlim(decimal_year.min(), decimal_year.max())<jupyter_output><empty_output><jupyter_text>The data are kind of noisy at this scale so let's calculate a 12-month moving average for a smoother time series.<jupyter_code>plt.figure(figsize=(10, 6))
plt.title("Temperature anomaly for Australia")
plt.plot(decimal_year, temperature_anomaly, label="anomaly")
plt.plot(decimal_year, moving_avg(temperature_anomaly, 6), label="12-month moving average", linewidth=3)
plt.xlabel('year')
plt.ylabel('temperature anomaly (C)')
plt.legend()
plt.grid()
plt.xlim(decimal_year.min(), decimal_year.max())<jupyter_output>C:\Users\ishan\Box\Grad School Stuff\Research\Talks\Coding_bunker\package_tutorial_demo\data_analysis.py:49: UserWarning: NAN alert!!!
  warnings.warn('NAN alert!!!')
{'fraction_non_alphanumeric': 0.1083676268861454, 'fraction_numerical': 0.010059442158207591, 'mean_word_length': 6.898916967509026, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '252123', 'license': 'MIT', 'n_tokens_mistral': 746, 'n_tokens_neox': 687, 'n_words': 184, 'path': 'example-data-analysis.ipynb', 'repo_name': 'ishan-mishra/package_tutorial_demo', 'size': '2187'}