Personal tools

##### Sektionen
You are here: Home / Beispiele und Aufgaben Teil IV - Querschnitte
Info
Our docs have moved to https://docs.dkrz.de This portal will be shutdown as soon the last content is migrated.

# Beispiele und Aufgaben Teil IV - Querschnitte

NCL Skripte zur Erzeugung von Querschnitten (slices).

Einfacher Querschnitt:

```begin
var   = f->t(0,:,{40},{0:60})     ;-- first time step, latitude=40N, longitude=0-60E.
lon_t = f->lon({0:60})            ;-- longitude=0-60E
lev_t = f->lev                    ;-- currently 17 levels

;-- define workstation
wks = gsn_open_wks("png","part_IV_simple_slice")

;-- set resources
res                          =  True
res@tiMainString             = "Simple slice plot" ;-- draw title

res@sfXArray                 =  lon_t              ;-- uses lon_t as plot x-axis
res@sfYArray                 =  lev_t              ;-- uses lev_t in hPa as plot y-axis

;-- generate the plot
plot = gsn_csm_contour(wks,var,res)

end```

Konturlinien Plot über Querschnitt gelegt:

```begin
t      = f->t(0,:,{40},{0:60})          ;-- first time step, latitude=40N, longitude=0-60E.
rhum   = f->rhumidity(0,:,{40},{0:60})  ;-- first time step, latitude=40N, longitude=0-60E.
lon_t  = f->lon({0:60})                 ;-- longitude=0-60E
lev_t  = f->lev/100                     ;-- currently 17 levels; convert to hPa units

llabels = ""+lev_t

;-- define workstation
wks = gsn_open_wks("png","part_IV_slice_rhumidity_overlay")
gsn_define_colormap(wks,"WhiteBlue")               ;-- set the colormap to be used

;-- set resources
res                          =  True
res@gsnDraw                  =  False
res@gsnFrame                 =  False
res@gsnSpreadColors          =  True               ;-- use full colormap

res@tiMainString = "Slice at latitude = 40~S~o~N~N~C~~Z70~contour lines: " + rhum@long_name

res@cnFillOn                 =  True               ;-- turn on color fill
res@cnLineLabelsOn           =  False              ;-- turns off contour line labels
res@cnInfoLabelOn            =  False              ;-- turns off contour info label

res@lbOrientation            = "vertical"          ;-- vertical label bar

res@sfXArray                 =  lon_t              ;-- uses lon_t as plot x-axis
res@sfYArray                 =  lev_t              ;-- uses lev_t in hPa as plot y-axis

res@trYReverse               =  True               ;-- reverses y-axis

res@tmXBTickSpacingF         =  10.                ;-- label x-axis every 10 degrees

res@tmYLMode                 = "Explicit"          ;-- set y-axis labeling to explicit
res@tmYLValues               =  lev_t              ;-- values for y-axis tickmarks
res@tmYLLabels               =  llabels            ;-- set labels equal to values (type string)

res@tiXAxisString            =  f->lon@long_name   ;-- draw y-axis title
res@tiYAxisString            =  f->lev@long_name + "  [hPa]"  ;-- draw y-axis title

;-------------------------------------------------------------------------------------
;-- generate plot1, but don't draw it yet
;-------------------------------------------------------------------------------------
plot1 = gsn_csm_contour(wks,t,res)

;-- change resources for the overlayed plot
res@cnFillOn                 =  False              ;-- turn off color fill
res@cnLineLabelsOn           =  True               ;-- turns on contour line labels
res@gsnLeftString            = ""                  ;-- don't draw left string

;-------------------------------------------------------------------------------------
;-- generate plot2, but don't draw it yet
;-------------------------------------------------------------------------------------
plot2 = gsn_csm_contour(wks,rhum,res)

;-- overlay plot2 on plot1
overlay(plot1, plot2)

;-- draw the plot and advance the frame
draw(plot1)
frame(wks)

end```

## Für die Aufgabe:

part_IV_Overlay_slice_rhumidity.ncl

```begin
t      = f->t(0,:,{40},{0:60})          ;-- first time step, latitude=40N, longitude=0-60E.
rhum   = f->rhumidity(0,:,{40},{0:60})  ;-- first time step, latitude=40N, longitude=0-60E.
lon_t  = f->lon({0:60})                 ;-- longitude=0-60E
lev_t  = f->lev/100                     ;-- currently 17 levels; convert to hPa units

llabels = ""+lev_t

;-- define workstation
wks = gsn_open_wks("png","part_IV_slice_rhumidity_overlay")
gsn_define_colormap(wks,"WhiteBlue")               ;-- set the colormap to be used

;-- set resources
res                          =  True
res@gsnDraw                  =  False
res@gsnFrame                 =  False
res@gsnSpreadColors          =  True               ;-- use full colormap

res@tiMainString = "Slice at latitude = 40~S~o~N~N~C~~Z70~contour lines: " + rhum@long_name

res@cnFillOn                 =  True               ;-- turn on color fill
res@cnLineLabelsOn           =  False              ;-- turns off contour line labels
res@cnInfoLabelOn            =  False              ;-- turns off contour info label

res@lbOrientation            = "vertical"          ;-- vertical label bar

res@sfXArray                 =  lon_t              ;-- uses lon_t as plot x-axis
res@sfYArray                 =  lev_t              ;-- uses lev_t in hPa as plot y-axis

;   res@gsnYAxisIrregular2Linear =  True               ;-- converts y-axis irregular to linear depth
res@trYReverse               =  True               ;-- reverses y-axis

res@tmXBTickSpacingF         =  10.                ;-- label x-axis every 10 degrees

res@tmYLMode                 = "Explicit"          ;-- set y-axis labeling to explicit
res@tmYLValues               =  lev_t              ;-- values for y-axis tickmarks
res@tmYLLabels               =  llabels            ;-- set labels equal to values (type string)
;   res@tmYLLabelStride          =  5                  ;-- draw every 5th label

res@tiXAxisString            =  f->lon@long_name   ;-- draw y-axis title
res@tiYAxisString            =  f->lev@long_name + "  [hPa]"  ;-- draw y-axis title

;-------------------------------------------------------------------------------------
;-- generate plot1, but don't draw it yet
;-------------------------------------------------------------------------------------
plot1 = gsn_csm_contour(wks,t,res)

;-- change resources for the overlayed plot
res@cnFillOn                 =  False              ;-- turn off color fill
res@cnLineLabelsOn           =  True               ;-- turns on contour line labels
res@gsnLeftString            = ""                  ;-- don't draw left string

;-------------------------------------------------------------------------------------
;-- generate plot2, but don't draw it yet
;-------------------------------------------------------------------------------------
plot2 = gsn_csm_contour(wks,rhum,res)

;-- overlay plot2 on plot1
overlay(plot1, plot2)

;-- draw the plot and advance the frame
draw(plot1)
frame(wks)

end```

Document Actions