Skip to content

Latest commit

 

History

History
246 lines (205 loc) · 14.7 KB

AQ_calving.org

File metadata and controls

246 lines (205 loc) · 14.7 KB

Table of contents

Introduction

  • Antarctic ice shelf calving is from Davison 2023
  • Antarctic non-shelf calving is the difference between Davison 2023 and Rignot 2019
    • Should be updated to Davison ESSD 2023 submitted

Data example

Printout

xr.open_dataset('./dat/AQ_calving.nc')
<xarray.Dataset> Size: 8kB
Dimensions:      (region: 18, time: 25)
Coordinates:
  * time         (time) datetime64[ns] 200B 1997-07-01 1998-07-01 ... 2021-07-01
  * region       (region) int32 72B 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Data variables:
    calving      (region, time) float64 4kB ...
    uncertainty  (region, time) float64 4kB ...
    region_name  (region) <U5 360B ...
Attributes:
    description:   Antarctic region ice shelf calving rate
    date_created:  20241101T153743Z
    title:         Calving per region
    history:       Processed for Schmidt (YYYY; in prep); by Ken Mankoff
    source:        doi:10.5281/ZENODO.8052519
    Conventions:   CF-1.8
    DOI:           https://doi.org/10.5281/zenodo.14020895

Graphic

import xarray as xr
ds = xr.open_dataset('./dat/AQ_calving.nc')
df = ds.sum(dim='region')['calving'].to_dataframe()
ax = df['calving'].plot(drawstyle='steps-post')

unc = (((ds['uncertainty']**2).sum(dim='region'))**0.5).to_dataframe()
unc.plot(drawstyle='steps-post', ax=ax)
_ = ax.set_ylabel('Calving [Gt yr$^{-1}$]')

./fig/AQ_calving.png

Calving by region

import xarray as xr
import matplotlib.pyplot as plt

ds = xr.open_dataset('dat/AQ_calving.nc')
ds = ds.assign_coords(region=[_[0] + ' ['+str(_[1])+']' for _ in zip(ds['region_name'].values,ds['region'].values)])
df = ds['calving'].to_dataframe()
df = df['calving'].unstack().T
df['AQ'] = df.sum(axis='columns')
df.loc['Mean'] = df.mean(axis='rows')
df.index = [_[0:10] for _ in df.index.astype(str)]
df.round()
A-Ap [1]Ap-B [2]B-C [3]C-Cp [4]Cp-D [5]D-Dp [6]Dp-E [7]E-Ep [8]Ep-F [9]F-G [10]G-H [11]H-Hp [12]Hp-I [13]I-Ipp [14]Ipp-J [15]J-Jpp [16]Jpp-K [17]K-A [18]AQ
1997-07-01563742931411142643108832003748451013993481363
1998-07-015637429314111426431088320037484510199593483219
1999-07-01563742931411142643108832003748451013993481363
2000-07-0111301153304280294419129222152456820640116125
2001-07-0110522711179296170114129134302475671387537153102612776
2002-07-01301709062341013134230214343610821033
2003-07-01174202279142101058051176233327101031750
2004-07-0110455641551781354268108130289488364111548401636
2005-07-011521224109281802552603446347203726850
2006-07-016928049155723619941022738162541717910
2007-07-0119271130173803493885103404212301024739
2008-07-012138033152371201175847286334004744
2009-07-0161513194204136481776147167071935888569552974
2010-07-0112466111128614216327923081255362017451722
2011-07-014522048191642009769264711130025741
2012-07-01320124812174210209718039544401410722
2013-07-01620057121381002346986167330451130
2014-07-0126374163163682152067488938052131433261374
2015-07-01782608856436703148220711071335057986
2016-07-013720042116291971051302344914226925791
2017-07-016682054176774509152307344914394221102
2018-07-01314816652165221010107207355013253112202219
2019-07-0125360601264320638936136433246721917
2020-07-011936367561531115208116210284350400151269
2021-07-014939214325350027427127292316623109101971762895
Mean4742267614912431581539329945841271322927331654

Processing

import numpy as np
import pandas as pd
import geopandas as gpd
import xarray as xr
import datetime

# shelf name with longitude and latitude
df = pd.read_excel("~/data/Davison_2023/adi0186_table_s2.xlsx",
                   sheet_name = 'Total mass changes',
                   usecols = (1,2,3), index_col = 0, skiprows = 4)
df = df.dropna()
shelf = gpd.GeoDataFrame(
    geometry=gpd.points_from_xy(df.longitude, df.latitude, crs="EPSG:4326"), data=df)
shelf = shelf.to_crs('EPSG:3031')

# region name
region = gpd.read_file("~/data//IMBIE/Rignot/ANT_Basins_IMBIE2_v1.6.shp")
region = region[region['Regions'] != 'Islands']

# find regions nearest each shelf
shelf_region = gpd.sjoin_nearest(shelf,region)
shelf_region = shelf_region.drop(columns=['index_right','latitude','longitude','Regions'])

# load calving time series per shelf
calving = pd.read_excel("~/data/Davison_2023/adi0186_table_s2.xlsx",
                        sheet_name='Calving', index_col=1, skiprows=3, header=(0,1))
calving = calving.T.dropna().drop(columns=['Antarctic Ice Shelves'])

# WARNING: Calving < 0 implies error is baseline rate. This happens fairly often (small values) and occasionally (large values)
calving[calving < 0] = 0

obs = calving.xs('observed', level='Ice shelf')
obs.index.name = 'Date'
obs.index = pd.to_datetime(obs.index.astype(int).astype(str)+'-07-01', format="%Y-%m-%d")

# unc = calving.drop('observed', level=1, axis=0).reset_index().set_index('level_0').drop(columns=['Ice shelf'])
unc = calving.xs('uncertainty', level='Ice shelf')
unc.index.name = 'Date'
unc.index = obs.index

da_obs = xr.DataArray(data = obs.values,
                      dims = ['date','shelf'],
                      coords = {'date':obs.index.values, 'shelf':obs.columns})

ds = xr.Dataset({'calving': da_obs})
ds['uncertainty'] = (('date','shelf'), unc)
ds = ds.where(ds['shelf'] != 'Antarctic Ice Shelves', drop=True)
ds['region'] = (('shelf'), shelf_region['Subregion'])

# ds = ds.groupby('region').sum() # Want to agg() with different functions per column...

# uncertainty is sqrt of sum of squares. Not sure how to do this in-place in Xarray.
ds['unc2'] = ds['uncertainty']**2
ds2 = xr.merge([
    ds[['calving','region']].groupby('region').sum(),
    ds[['unc2','region']].groupby('region').sum(),
])
ds2['uncertainty'] = np.sqrt(ds2['unc2'])
ds2 = ds2.drop_vars('unc2')
# uncertainty for all of AQ as (sum(u**2))**0.5 matches Davison 2023 row 168 "Antarctic Ice Shelves"

# need to calculate AQ-wide uncertainty at shelf resolution because step-aggregating is not commutative
# ds2['uncertainty_AQ'] = np.sqrt(ds['unc2'].sum(dim='shelf'))

ds = ds2

ds = ds.rename({'date':'time'})
ds['region'] = np.arange(18).astype(np.int32) + 1

ds['region_name'] = (('region'), ['A-Ap', 'Ap-B', 'B-C', 'C-Cp', 'Cp-D',
                                'D-Dp', 'Dp-E', 'E-Ep', 'Ep-F', 'F-G',
                                'G-H', 'H-Hp', 'Hp-I', 'I-Ipp', 'Ipp-J',
                                'J-Jpp', 'Jpp-K', 'K-A'])

ds.attrs['description'] = 'Antarctic region ice shelf calving rate'
ds['calving'].attrs['units'] = 'Gt yr-1'
ds['calving'].attrs['long_name'] = 'Shelf calving'

# ds['calving'].attrs['standard_name'] = 'water_flux_into_sea_water_from_land_ice'
# https://github.com/orgs/cf-convention/discussions/388
ds['calving'].attrs['standard_name'] = 'ice_transport_across_line'

ds['uncertainty'].attrs['long_name'] = 'Uncertainty of shelf calving'
ds['time'].attrs['standard_name'] = 'time'
ds['region'].attrs['long_name'] = 'IMBIE region'
ds.attrs['date_created'] = datetime.datetime.now(datetime.timezone.utc).strftime("%Y%m%dT%H%M%SZ")
ds.attrs['title'] = 'Calving per region'
ds.attrs['history'] = 'Processed for Schmidt (YYYY; in prep); by Ken Mankoff'
ds.attrs['source'] = 'doi:10.5281/ZENODO.8052519'
ds.attrs['Conventions'] = 'CF-1.8'
ds.attrs['DOI'] = 'https://doi.org/10.5281/zenodo.14020895'

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

!rm ./dat/AQ_calving.nc
ds.to_netcdf('./dat/AQ_calving.nc', encoding=encoding)
!ncdump -h ./dat/AQ_calving.nc
netcdf AQ_calving {
dimensions:
	region = 18 ;
	time = 25 ;
variables:
	double calving(region, time) ;
		calving:_FillValue = NaN ;
		calving:units = "Gt yr-1" ;
		calving:long_name = "Shelf calving" ;
		calving:standard_name = "ice_transport_across_line" ;
	int time(time) ;
		time:standard_name = "time" ;
		time:units = "days since 1997-07-01 00:00:00" ;
		time:calendar = "proleptic_gregorian" ;
	int region(region) ;
		region:long_name = "IMBIE region" ;
	double uncertainty(region, time) ;
		uncertainty:_FillValue = NaN ;
		uncertainty:long_name = "Uncertainty of shelf calving" ;
	string region_name(region) ;

// global attributes:
		:description = "Antarctic region ice shelf calving rate" ;
		:date_created = "20241101T153743Z" ;
		:title = "Calving per region" ;
		:history = "Processed for Schmidt (YYYY; in prep); by Ken Mankoff" ;
		:source = "doi:10.5281/ZENODO.8052519" ;
		:Conventions = "CF-1.8" ;
		:DOI = "https://doi.org/10.5281/zenodo.14020895" ;
}