Skip to content

Latest commit

 

History

History
188 lines (156 loc) · 5.02 KB

AQ_mass_change.org

File metadata and controls

188 lines (156 loc) · 5.02 KB

Table of contents

Introduction

Antarctic mass loss is repackaged from:

Data example

Printout

<xarray.Dataset> Size: 352B
Dimensions:       (time: 22)
Coordinates:
  * time          (time) datetime64[ns] 176B 1994-01-01 ... 2015-01-01
Data variables:
    mass_balance  (time) float64 176B ...
Attributes:
    title:          Antarctic ice sheet mass balance
    history:        TBD
    Conventions:    CF-1.8
    summary:        Antarctic ice sheet mass balance
    creator_name:   Ken Mankoff
    creator_email:  [email protected]
    institution:    NASA GISS
    references:     TBD
    DOI:            https://doi.org/10.5281/zenodo.14020895

Plot: Annual mass change per region (5 year smooth)

import xarray as xr
ds = xr.open_dataset('dat/AQ_mass_change.nc')
df = ds['mass_balance'].to_dataframe()['mass_balance']
ax = df.rolling(window=5, center=True).mean().plot(drawstyle='steps-post')
_ = ax.set_ylabel('Mass balance [Gt yr$^{-1}$]')

./fig/AQ_mass.png

Table: Annual mass change per region

import xarray as xr
ds = xr.open_dataset('dat/AQ_mass_change.nc')
df = ds['mass_balance'].to_dataframe()['mass_balance']
df.round().astype(int)
time
1994-01-01    -37
1995-01-01    -29
1996-01-01    -32
1997-01-01    -22
1998-01-01    -79
1999-01-01    -28
2000-01-01    -21
2001-01-01    -29
2002-01-01    -96
2003-01-01    -79
2004-01-01    -17
2005-01-01    -95
2006-01-01   -208
2007-01-01   -114
2008-01-01    -89
2009-01-01   -229
2010-01-01   -148
2011-01-01   -209
2012-01-01   -270
2013-01-01   -262
2014-01-01   -255
2015-01-01    -67
Name: mass_balance, dtype: int64
df.describe().round()
count     22.0
mean    -110.0
std       89.0
min     -270.0
25%     -193.0
50%      -84.0
75%      -30.0
max      -17.0
Name: mass_balance, dtype: float64

Reprocess

import numpy as np
import pandas as pd
import xarray as xr

df = pd.read_csv('~/data/Slater_2021/AIS_cumul_1994_2017_annual.csv', index_col=0, parse_dates=True)
df = df.rename(columns={'Cumulative mass change (Gt)':'mass_balance'})
df.index.name = 'time'

# Data is cumulative change. We want annual. Take the derivative and shift by a year
df = df.diff()
df['mass_balance'] = df['mass_balance'].shift(-1)
df = df.dropna()

ds = df.to_xarray()

ds['mass_balance'].attrs['units'] = 'Gt yr-1'
# ds['err'].attrs['units'] = 'Gt yr-1'

ds['mass_balance'].attrs['long_name'] = 'Mass balance'

ds['mass_balance'].attrs['standard_name'] = 'tendency_of_ice_mass'
ds['mass_balance'].attrs['units'] = 'Gt yr-1'
# ds['err'].attrs['standard_name'] = 'tendency_of_ice_mass'

ds['time'].attrs['long_name'] = 'time'

ds.attrs['title'] = 'Antarctic ice sheet mass balance'
ds.attrs['history'] = 'TBD'
ds.attrs['Conventions'] = 'CF-1.8'

ds.attrs['summary'] = 'Antarctic ice sheet mass balance'
ds.attrs['creator_name'] = 'Ken Mankoff'
ds.attrs['creator_email'] = '[email protected]'
ds.attrs['institution'] = 'NASA GISS'
ds.attrs['references'] = 'TBD'
ds.attrs['DOI'] = 'https://doi.org/10.5281/zenodo.14020895'

comp = dict(zlib=True, complevel=5)
encoding = {} # var: comp for var in items}
encoding['time'] = {'dtype': 'i4'}

!rm ./dat/AQ_mass_change.nc
ds.to_netcdf('./dat/AQ_mass_change.nc', encoding=encoding)
!ncdump -h ./dat/AQ_mass_change.nc
netcdf AQ_mass_change {
dimensions:
	time = 22 ;
variables:
	double mass_balance(time) ;
		mass_balance:_FillValue = NaN ;
		mass_balance:units = "Gt yr-1" ;
		mass_balance:long_name = "Mass balance" ;
		mass_balance:standard_name = "tendency_of_ice_mass" ;
	int time(time) ;
		time:long_name = "time" ;
		time:units = "days since 1994-01-01 00:00:00" ;
		time:calendar = "proleptic_gregorian" ;

// global attributes:
		:title = "Antarctic ice sheet mass balance" ;
		:history = "TBD" ;
		:Conventions = "CF-1.8" ;
		:summary = "Antarctic ice sheet mass balance" ;
		:creator_name = "Ken Mankoff" ;
		:creator_email = "[email protected]" ;
		:institution = "NASA GISS" ;
		:references = "TBD" ;
		:DOI = "https://doi.org/10.5281/zenodo.14020895" ;
}