1313import matplotlib .pyplot as plt
1414
1515rhoi = 910.0
16-
16+ rhosw = 1028.
1717
1818print ("** Gathering information. (Invoke with --help for more details. All arguments are optional)" )
1919parser = OptionParser (description = __doc__ )
4040
4141if options .units == "m3" :
4242 massUnit = "m$^3$"
43+ scaleVol = 1.
4344elif options .units == "kg" :
4445 massUnit = "kg"
46+ scaleVol = 1. / rhoi
4547elif options .units == "Gt" :
4648 massUnit = "Gt"
49+ scaleVol = 1.0e12 / rhoi
4750else :
4851 sys .exit ("Unknown mass/volume units" )
4952print ("Using volume/mass units of: " , massUnit )
9598plt .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\n equivalent (mm)' )
110+
98111def 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