Moorea-pH-Script

From coral
Jump to: navigation, search

Moorea-ph.png

The above chart was generated with the NCL script below. Newlines have been inserted for formatting.

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

begin

; Data source:
;
; Dunne, John; John, Jasmin; Shevliakova, Elena; Stouffer, Ronald; Griffies, Stephen; Malyshev, Sergey; Milly, P.; Sentman, Lori; Adcroft, Alistair; Cooke, William; Dunne, Krista; Hallberg, Robert; Harrison, Matthew; Krasting, John; Levy, Hiram; Phillips, Peter; Samuels, Bonita; Spelman, Michael; Winton, Michael; Wittenberg, Andrew; Zadeh, Niki
; NOAA GFDL GFDL-ESM2M, rcp85 experiment output for CMIP5 AR5, served by ESGF
;
; Tracking IDs:
; 1b93c61d-3a60-44a8-9677-902a1bb53944
; 02ccb4a2-bba3-47de-bc41-36e358392691
; 8f53dacd-91e5-4ffd-9b8b-98cd2d98ca70
; 5b7d6e51-5359-4cc6-939d-0c6fd3c09ecc
; 428a6510-ad46-4fc1-8add-c371c30faeb7
; 734cb621-3989-4698-a99f-16e4aeb91c89
; f44e5b1a-2b8d-4e19-b310-5676b77f3296
; 93fbd250-e065-4273-9e20-cc116e831941
; d95609b3-e551-4404-adc9-2440efd0f481
; 062362f3-f1c8-48ae-9f81-4917907cae0a
; 4d664227-d499-4017-8738-d6d1b8ca4242
; 9c970fea-1f05-4eb9-8cba-f43079618d16
; 36baf316-c1c6-4eeb-a13f-ba3be98e5924
; 146d9c06-cc3f-4628-a118-c165229ea3ef
; 838ee734-a989-4b99-9c3b-1aba80faf61d
; 43077555-f29f-45e7-b198-ed8500d2e067
; 6d1ef452-bd04-430d-a3c9-952b8a763507
; 66de8332-8457-4351-876e-5b1ccf54f116
; 9c5ddc62-cdc4-42d8-bfea-5c7800031bc1
f = addfiles((/"ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_200601-201012.nc",
"ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_201101-201512.nc","ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_201601-202012.nc",
"ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_202101-202512.nc","ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_202601-203012.nc",
"ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_203101-203512.nc","ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_203601-204012.nc",
"ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_204101-204512.nc","ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_204601-205012.nc",
"ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_205101-205512.nc","ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_205601-206012.nc",
"ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_206101-206512.nc","ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_206601-207012.nc",
"ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_207101-207512.nc","ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_207601-208012.nc",
"ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_208101-208512.nc","ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_208601-209012.nc",
"ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_209101-209512.nc","ph_Omon_GFDL-ESM2M_rcp85_r1i1p1_209601-210012.nc"/), "r")

; Pick the ph grid coordinate closest to Opunohu Bay on Moorea,
; at 17°30' S 149°52' W
;
; print(f->lat_vertices(66,0,0)) 
;  units :	degrees_north
; (0)	-17.10523414611816
;
; print(f->lon_vertices(0,130,0))   
;  units :	degrees_east
; (0)	-150
ph = f[:]->ph(:,66,130)

; Compute a 60 month running average of pH
ph2 = runave_n_Wrap(ph,60,0,0)

; Extract times associated with each data point
time = ph&time

; Compute indexes and values of minimum/maximum running average.
;
; print(dim_maxind(ph2, 0)) 
; (0)	29
; print(ph2(29))
; (0)	8.077968
; print(time(29))
;   units :	days since 2006-01-01 00:00:00
; (0)	 896   (which works out to June 2008)
;
; print(dim_minind(ph2, 0))
; (0)	1109
; print(ph2(1109))
; (0)	7.764075
; print(time(1109))
;   units :	days since 2006-01-01 00:00:00
; (0)	33746  (which works out to May 2098)

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

res = True
res@gsnDraw = False
res@gsnFrame = False
res@tiMainString = "Surface pH at Moorea"
restime = True
restime@ttmFormat = "%Y"

time_axis_labels(time,res,restime)

res@tmXBLabelFontHeightF = 0.01
res@tmXBLabelJust = "CenterRight"
res@tmXBLabelDeltaF = 1.0
res@tmXBLabelAngleF = 50.
res@tmLabelAutoStride = True

plot1 = gsn_csm_xy(wks, time, ph, res)

res@xyLineColor = "blue"

plot2 = gsn_csm_xy(wks, time, ph2, res)

overlay(plot1, plot2)

draw(plot1)
frame(wks)

end