Carbonate-Script

From coral
Jump to: navigation, search

Carbonate.png

The above chart was generated with the NCL script below. The data used in the chart was generated here. Newlines have been inserted into the script's data for formatting, but will need to be removed for NCL as they break its parser (!!!).

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

begin

; Data generated by generateBjerrumData(28, 35, 4, 10, 20)
pH = (/4,4.3,4.6,4.9,5.2,5.5,5.8,6.1,6.4,6.7,7,7.300000000000001,7.6,7.9,8.2,8.5,8.8,9.1,9.4,9.7,10/)
data = (/
(/0.984521075526212,0.969583696419006,0.9410933224090265,0.8889700081106523,0.8004947579655667,0.6678369658227451,
  0.5018130225484696,0.3353017888106607,0.20155084443942506,0.11199784775270286,0.059111131571207697,
  0.03016884139968606,0.014996011673134002,0.0072358410873917985,0.0033421465853907114,0.0014422309477453872,
  0.0005649467721451165,0.00019708664968350493,0.00006147748027210752,0.000017571226527866345,
  0.000004741199864460002/),
(/0.015478732301200735,0.030415550135701457,0.05890376620951796,0.1110190434169304,0.19946599336739915,
  0.3320326764218774,0.49779702797022,0.663660916176523,0.7959668739977576,0.8825108405413283,0.9293507313926659,
  0.9463875181866063,0.9386120851525606,0.9036482091746433,0.8327906985033544,0.7170429702231562,0.5604255200611997,
  0.39009248044595485,0.24278756027814646,0.13845621325410828,0.07454158708511233/),
(/1.9217258716646177e-7,7.534452924028192e-7,0.000002911381455470726,0.000010948472417309967,
  0.00003924866703411113,0.00013035775537761956,0.00038994948131036125,0.0010372950128162079,0.0024822815628172544,
  0.00549131170596871,0.011538137036126519,0.023443640413707827,0.04639190317430532,0.08911594973796505,
  0.1638671549112548,0.2815147988290984,0.4390095331666552,0.6097104329043617,0.7571509622415813,0.8615262155193639,
  0.9254536717150231/)
/)

wks = gsn_open_wks("png","carbon")

res = True
res@tiMainString = "Carbonate Species (T=28, S=35)"

res@lgJustification = "TopRight"
res@lgLabelJust = "CenterLeft"
res@lgLabelFontHeightF = 0.01
res@lgBoxMinorExtentF = 0.16

res@tiXAxisString = "pH"
res@tiYAxisString = "Fraction"

res@xyLineColors = (/ "darkgreen", "blue", "red" /)
res@xyExplicitLabels = (/ "CO~B~2~N~", "HCO~B~3~N~~S~-~N~", "CO~B~3~N~~S~2-~N~" /)
res@xyDashPatterns = (/ 0, 0, 0 /)
res@xyLineThicknessF = 5

res@pmLegendDisplayMode = "Always"
res@pmLegendWidthF = 0.08
res@pmLegendHeightF = 0.1
res@pmLegendOrthogonalPosF = -.7
res@pmLegendParallelPosF = 0.6

plot = gsn_csm_xy(wks, pH, data, res)

end