Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import pandas as pd
  4. import netCDF4 as nc
  5.  
  6. #-- open net-cdf and read in variables
  7. data = nc.Dataset('test.nc')
  8.  
  9. time = nc.num2date(data.variables['Time'][:],
  10. data.variables['Time'].units)
  11.  
  12. df = pd.DataFrame(data.variables['mgpp'][:,0,0], columns=['mgpp'])
  13.  
  14. df['dates'] = time
  15. df = df.set_index('dates')
  16. print(df.head())
  17.  
  18. mgpp
  19. dates
  20. 1901-01-01 0.040735
  21. 1901-02-01 0.041172
  22. 1901-03-01 0.053889
  23. 1901-04-01 0.066906
  24.  
  25. df_cp = df[df.index.year == 2001]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement