#!/usr/bin/env python # coding: utf-8 # In[1]: DATA_DIR = '/home/notebook/shared-ns1000k/inputs/SEAICE_M/' FILE = 'ci.mon.mean.nc' # In[53]: import pandas as pd import matplotlib.pyplot as plt # In[54]: def load_seaice_xarray(filepath, shift_lons=True): import iris, xarray cube = iris.load_cube(DATA_DIR + FILE) if shift_lons: cube = cube.intersection(longitude=(-180, 180)) return xarray.DataArray.from_iris(cube) # In[55]: xarr = load_seaice_xarray(DATA_DIR + FILE) xarr # In[62]: xarr[0].plot(figsize=(18, 8)); # In[13]: arctic_subset = xarr.sel(latitude=slice(90, 66)) sea_ice_timeseries = arctic_subset.mean(('latitude', 'longitude')) df = sea_ice_timeseries.to_dataframe() df # check groubpy pandas # In[27]: import pandas as pd df['month'] = df.index.month mask = df.month.between(4,9) only_summer = df[mask] only_summer # In[47]: summer_mean = only_summer.groupby(only_summer.index.year).mean() summer_mean # In[52]: ax = summer_mean['ci'].plot(figsize=(8, 8), ylim=(0, 1)) ax.set_title('Blaaaaa');