<jupyter_start><jupyter_text>Combining ice dataFor this project we have multiple ice datasets. This notebook is used to combine them to a new dataset:    Antarctic Ice Concentration (AIC)    The Land ice data comes from this source and is explained well at this [link](https://grace.jpl.nasa.gov/data/monthly-mass-grids/)[data source](https://podaac.jpl.nasa.gov/dataset/TELLUS_GRAC-GRFO_MASCON_CRI_GRID_RL06_V2?ids=Collections:Availability&values=GRACE%20RL06:DELAY_MODE)First let's start by loading our relevant module.<jupyter_code>from modules import combine_ice as ci
from modules import week5 as w5
import matplotlib.pyplot as plt
import cartopy.crs as ccrs

# autoreload so I can easily modify the code without running this cell repetitively
%load_ext autoreload
%autoreload 2<jupyter_output><empty_output><jupyter_text>Let's inspect the two datasets<jupyter_code>SIC = ci.load_seaice()
# SIC
LIC = ci.load_landice()
LIC = LIC.sel(lat=slice(-90,-55))<jupyter_output><empty_output><jupyter_text>Our first problem here is that the units in each dataset are different. This is because they are measuring different things.The sea ice data is measuring concentration of sea ice by measuring the albedo of different ocean regions. Where the albedo is high we associate this with more ice. Whereas the land ice data is measuring the mass of liquid water equivilent (LWE). The unit used is m as the researchers using this associate the thickness of LWE with its mass.To overcome this, we will normalise each dataset at each gridpoint so our units become standard deviations of change.<jupyter_code>LIC = ci.latlon_to_polarstereo(LIC)
# import xarray as xr
# IC = SIC.fillna(LIC)

# Ice = xr.Dataset(dict(SIC=SIC, LIC=LIC
#                         ))
# Ice = (Ice.sel(time=slice('2002-01-01','2019-12-31'))
#       .pipe(w5.find_anomalies)
#       .pipe(w5.yearly_average)
#       .pipe(w5.normalise_indepenant)

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax2 = ax.twinx()
# ax.plot(Ice.IC.time,Ice.IC.mean(dim=('x','y')), label='Total Ice', lw=3)
l1 = ax.plot(SIC.time,SIC.mean(dim=('x','y')), label='Sea Ice')
ax2.plot([],[])
l2 = ax2.plot(LIC.time,LIC.mean(dim=('x','y')), label='Land Ice')
lines = l1 + l2
labels = [line.get_label() for line in lines]
ax.legend(lines, labels)
plt.savefig('images/week7/ice_timeseries.pdf')
plt.show()
SIC_trends = SIC.polyfit(dim='time', deg=1).sel(degree=1).polyfit_coefficients * 1e9*60*60*24*365
SIC_trends = SIC_trends.where(abs(SIC_trends) != 0.0)

LIC_trends = LIC.polyfit(dim='time', deg=1).sel(degree=1).polyfit_coefficients * 1e9*60*60*24*365
LIC_trends = LIC_trends.where(abs(LIC_trends) != 0.0)
fig = plt.figure(figsize=(10,5))
ax = fig.add_subplot(121, projection = ccrs.SouthPolarStereo())
contor = ax.contourf(SIC_trends.x, SIC_trends.y, 100/250 *SIC_trends.values, cmap = 'RdBu', transform=ccrs.SouthPolarStereo())
ax.coastlines()
ax.set_axis_off()
cbar = plt.colorbar(contor)
cbar.set_label('Trend [$\%$ yr$^{-1}$]')
ax.set_title('Sea Ice Trend')

ax = fig.add_subplot(122, projection = ccrs.SouthPolarStereo())
contor = ax.contourf(LIC_trends.x, LIC_trends.y, LIC_trends.values, cmap = 'RdBu', transform=ccrs.SouthPolarStereo())
ax.coastlines()
ax.set_axis_off()
cbar = plt.colorbar(contor)
cbar.set_label('Trend [$m$ yr$^{-1}$]')
ax.set_title('Land Ice Trend')
fig.suptitle('Trends in Antarctic Ice 2002-2018')
plt.savefig('images/week7/ice_trends.pdf')
fig = plt.figure(figsize=(5,5))
ax = fig.add_subplot(projection = ccrs.SouthPolarStereo())
contor = ax.contourf(SIC_trends.x, SIC_trends.y, SIC_trends.values+LIC_trends.values, cmap = 'RdBu', transform=ccrs.SouthPolarStereo())
ax.coastlines()
ax.set_axis_off()
cbar = plt.colorbar(contor)
cbar.set_label('Trend [$\sigma$ yr$^{-1}$]')
ax.set_title('Combined Ice Trend')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13795811518324608, 'fraction_numerical': 0.02643979057591623, 'mean_word_length': 5.774822695035461, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '382764', 'license': 'MIT', 'n_tokens_mistral': 1530, 'n_tokens_neox': 1439, 'n_words': 328, 'path': 'combining ice data.ipynb', 'repo_name': 'hjelleyman/Antarctica-M.2', 'size': '3820'}