# -*- coding: utf-8 -*- """ @author: John Rachlin @date : September 13, 2021 @file : cherry.py Analysis of the full-flowering day-of-year for cherry blossums in Kyoto Japan. Why is this significant? Scientists are interested in understanding periodic biological phenomena (flowering, breeding, migration) especially as it relates to climatic conditions. (The scientific study of these types of phenomena is known as PHENOLOGY.) Data source: https://www.ncei.noaa.gov/pub/data/paleo/historical/phenology/japan/LatestVersion/KyotoFullFlower7.xls Data for 2020 and 2021 added to data set. 2020: March 30 - based on Japan Meterological Corporation (JMC) 2020 forecast. 2021: March 26 - based on reported actual (Osaka University) """ import dataproc as dp import matplotlib.pyplot as plt def plot_blossum_day_history(data): """ Plot the day-of-year full blossuming by year for all available years """ years = dp.extract_column(data, 0) doys = dp.extract_column(data, 1, impute=True) moving = dp.moving_average(doys, window_size = 30) plt.figure(figsize=(10,6), dpi=200) plt.title("Cherry Blossoms: Full Blossom Date (Kyoto, Japan)") plt.xlabel("Year") plt.ylabel("Date") plt.scatter(years, doys, marker='.', color='#FF66B2', label='Full blossom date') # The color of cherry blossums! plt.plot(years, moving, color='b', label='30 year moving avg') plt.yticks([80,90,100,110,120], ['Mar 21', 'Mar 31', 'Apr 10', 'Apr 20', 'Apr 30']) # Highlight 2021 (Record) plt.text(1940, 84.5, '2021') # Outliers are interesting! # There was a global temperature reduction at that time. # See global_temps.png plt.text(1333,124, '1323 (May 4th)') plt.text(1416, 86, '1409') # Until 2021, this was the previous record year # Annotate figure with "The little ice-age" - a period of cooling # occurring between 1400-1800, though, according to wikipedia, # some experts prefer the alternative timespan of 1300-1850 plt.text(1300,84, '<- - - - - -------- The "Little Ice Age" ---------- - ->') # Include a legend plt.legend(facecolor='lightgrey', edgecolor='black') plt.ylim(80,130) plt.grid() plt.savefig('cherry.png') plt.show() def main(): # Read the data into a dictionary (year -> doy) data = dp.read_table('cherry.csv', coltypes = [int, int]) # Visualize full-blossum day-of-year (Kyoto, Japan) plot_blossum_day_history(data) if __name__ == '__main__': main()