Skip to content

Commit da03486

Browse files
Merge pull request #475 from trhille/add_SLR_to_global_stats
Add sea-level equiv axis to VAF plot Add a sea-level equivalent axis in mm to VAF subplot in plot_globalStats.py. Also remove some redundancy in unit conversions.
2 parents cc30d75 + 3601818 commit da03486

File tree

1 file changed

+19
-29
lines changed

1 file changed

+19
-29
lines changed

landice/output_processing_li/plot_globalStats.py

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import matplotlib.pyplot as plt
1414

1515
rhoi = 910.0
16-
16+
rhosw = 1028.
1717

1818
print("** Gathering information. (Invoke with --help for more details. All arguments are optional)")
1919
parser = OptionParser(description=__doc__)
@@ -40,10 +40,13 @@
4040

4141
if options.units == "m3":
4242
massUnit = "m$^3$"
43+
scaleVol = 1.
4344
elif options.units == "kg":
4445
massUnit = "kg"
46+
scaleVol = 1./rhoi
4547
elif options.units == "Gt":
4648
massUnit = "Gt"
49+
scaleVol = 1.0e12 / rhoi
4750
else:
4851
sys.exit("Unknown mass/volume units")
4952
print("Using volume/mass units of: ", massUnit)
@@ -95,6 +98,16 @@
9598
plt.grid()
9699

97100

101+
def VAF2seaLevel(vol):
102+
return vol * scaleVol / 3.62e14 * rhoi / rhosw * 1000.
103+
104+
def seaLevel2VAF(vol):
105+
return vol / scaleVol * 3.62e14 * rhosw / rhoi / 1000.
106+
107+
def addSeaLevAx(axName):
108+
seaLevAx = axName.secondary_yaxis('right', functions=(VAF2seaLevel, seaLevel2VAF))
109+
seaLevAx.set_ylabel('Sea-level\nequivalent (mm)')
110+
98111
def plotStat(fname):
99112
print("Reading and plotting file: {}".format(fname))
100113

@@ -106,46 +119,23 @@ def plotStat(fname):
106119
dt = f.variables['deltat'][:]/3.15e7
107120
print(yr.max())
108121

109-
vol = f.variables['totalIceVolume'][:]
110-
if options.units == "m3":
111-
pass
112-
elif options.units == "kg":
113-
vol = vol * rhoi
114-
elif options.units == "Gt":
115-
vol = vol * rhoi / 1.0e12
122+
vol = f.variables['totalIceVolume'][:] / scaleVol
116123
if options.plotChange:
117124
vol = vol - vol[0]
118125
axVol.plot(yr, vol, label=name)
119126

120-
VAF = f.variables['volumeAboveFloatation'][:]
121-
if options.units == "m3":
122-
pass
123-
elif options.units == "kg":
124-
VAF = VAF * rhoi
125-
elif options.units == "Gt":
126-
VAF = VAF * rhoi / 1.0e12
127+
VAF = f.variables['volumeAboveFloatation'][:] / scaleVol
127128
if options.plotChange:
128129
VAF = VAF - VAF[0]
129130
axVAF.plot(yr, VAF, label=name)
131+
addSeaLevAx(axVAF)
130132

131-
volGround = f.variables['groundedIceVolume'][:]
132-
if options.units == "m3":
133-
pass
134-
elif options.units == "kg":
135-
volGround = volGround * rhoi
136-
elif options.units == "Gt":
137-
volGround = volGround * rhoi / 1.0e12
133+
volGround = f.variables['groundedIceVolume'][:] / scaleVol
138134
if options.plotChange:
139135
volGround = volGround - volGround[0]
140136
axVolGround.plot(yr, volGround, label=name)
141137

142-
volFloat = f.variables['floatingIceVolume'][:]
143-
if options.units == "m3":
144-
pass
145-
elif options.units == "kg":
146-
volFloat = volFloat * rhoi
147-
elif options.units == "Gt":
148-
volFloat = volFloat * rhoi / 1.0e12
138+
volFloat = f.variables['floatingIceVolume'][:] / scaleVol
149139
if options.plotChange:
150140
volFloat = volFloat - volFloat[0]
151141
axVolFloat.plot(yr, volFloat, label=name)

0 commit comments

Comments
 (0)