Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- import pandas as pd
- import netCDF4 as nc
- #-- open net-cdf and read in variables
- data = nc.Dataset('test.nc')
- time = nc.num2date(data.variables['Time'][:],
- data.variables['Time'].units)
- df = pd.DataFrame(data.variables['mgpp'][:,0,0], columns=['mgpp'])
- df['dates'] = time
- df = df.set_index('dates')
- print(df.head())
- mgpp
- dates
- 1901-01-01 0.040735
- 1901-02-01 0.041172
- 1901-03-01 0.053889
- 1901-04-01 0.066906
- df_cp = df[df.index.year == 2001]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement