Advertisement
peth31

temp_anomalies

Dec 16th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. #Importing Modules
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4.  
  5.  
  6. #The file 'nh_temperature.txt' is a compilation of Monthly Temperature Anomalies for the Northern Hemisphere that covers #1850 - 2015. First column is the years and next columns are the Months (Jan, Feb, Mar, Apr,..etc)
  7.  
  8. #Reading the txt file
  9. data = np.genfromtxt('nh_temperature.txt')  #Here you read ALL the data from the TXT
  10. data  #This prints the data that you just read
  11.  
  12. #Extracting the years column
  13. years = data[:,0]  # [row, column] -> this means we are extracting all ROWS from column 0
  14. years
  15.  
  16. #Extracting January
  17. jan = data[:,1]  #All rows from column 1
  18.  
  19.  
  20. #Plotting the data of January as a time series
  21. plt.figure(figsize =(12,7))   #Size of the figure
  22. plt.plot(years, jan) #plt.plot(x,y)
  23. plt.xlabel('Years')
  24. plt.ylabel('Temperature Anomaly')
  25. plt.title('Temperature Anomalies for NH of January 1850-2015')
  26.  
  27. #Now try to extract and plot all the other months one by one
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement