How to plot a small area from a global data set

From: brick <brickflying_at_nyahnyahspammersnyahnyah>
Date: Mon Jul 02 2012 - 03:32:16 MDT

Hi

I'm download a global sst data set in grib2 format and want to plot sst
from lat: 33N to 41N, lon: 117E to 127E. I use template raster_1.ncl
download from www.*ncl*.com. This script plot global sst. How to modify it
to only show the area I concern?Thank you.

The head information of sst data and raster_1.ncl is attached below

Sincerely,

brick
#####################################################
 Copyright (C) 1995-2011 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 6.0.0
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.

Variable: f
Type: file
filename: rtg_sst_grb_hr_0.083.20120627
path: rtg_sst_grb_hr_0.083.20120627.grb2
   file global attributes:
   dimensions:
      lat_173 = 2160
      lon_173 = 4320
   variables:
      float TMP_173_SFC ( lat_173, lon_173 )
         sub_center : Environmental Modeling Center
         center : US National Weather Service - NCEP (WMC)
         long_name : Temperature
         units : K
         _FillValue : 1e+20
         level_indicator : 1
         gds_grid_type : 0
         parameter_table_version : 3
         parameter_number : 11
         model : Sea Surface Temperature Analysis
         forecast_time : 0
         forecast_time_units : days
         initial_time : 06/27/2012 (00:00)

      float lat_173 ( lat_173 )
         long_name : latitude
         GridType : Cylindrical Equidistant Projection Grid
         units : degrees_north
         Dj : 0.08333302
         Di : 0.08333318
         Lo2 : -0.042
         La2 : -89.958
         Lo1 : 0.042
         La1 : 89.958

      float lon_173 ( lon_173 )
         long_name : longitude
         GridType : Cylindrical Equidistant Projection Grid
         units : degrees_east
         Dj : 0.08333302
         Di : 0.08333318
         Lo2 : -0.042
         La2 : -89.958
         Lo1 : 0.042
         La1 : 89.958
##########################################################
;***********************************************
; raster_1.ncl
;
; Concepts illustrated:
; - Drawing raster contours over a map
; - Turning off contour lines
; - Explicitly setting the fill color for land
; - Creating a color map using named colors
; - Using draw order resources to make sure filled map areas are drawn
last
;
;************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;************************************************
begin
;************************************************
; open netCDF file
;************************************************
  a = addfile("rtg_sst_grb_hr_0.083.20120627.grb2","r")
;************************************************
; Read in Regression Coef
;************************************************
  rcoef = a->TMP_173_SFC
  rcoef = rcoef - 273.15
; rcoef1 = a->TMP_173_SFC({lat_173|588:725},{lon_173|1404:1525})
; rcoef1 = a->TMP_173_SFC({lat_173|33:41},{lon_173|117:127})
;************************************************
; create plot
;************************************************
  wks = gsn_open_wks("pdf","raster") ; open a ps file
  res = True ; plot mods desired
;===================================
; you can have the contour lines on in raster mode, but their thickness
; actually make the plot look like is was contoured normally.

  res@cnFillOn = True ; color Fill
  res@cnFillMode = "RasterFill" ; Raster Mode
  res@cnLinesOn = False ; Turn off contour lines

  res@gsnSpreadColors = True ; Use full range of colormap.
  res@gsnSpreadColorStart = 16 ; Start color in colormap.
  res@gsnSpreadColorEnd = 200 ; End color in colormap.
  res@cnInfoLabelOn = False ; Turn off info label.
;================================
; these three resources make the continents look nice. The first two
; make them color, and the later adds continental outlines when
; raster mode is used.

  res@cnLineDrawOrder = "Predraw" ; Draw lines and filled
  res@cnFillDrawOrder = "Predraw" ; areas before map gets set
;=================================
  res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
  res@cnMinLevelValF = -5.0 ; set min contour level
  res@cnMaxLevelValF = 35.0 ; set max contour level
  res@cnLevelSpacingF = 0.2 ; set contour spacing

  res@mpCenterLonF = 122 ; set map center at 180
; res@mpLandFillColor = "light yellow" ; choose color of continents.
                                            ; must be in colormap

; res@gsnCenterString = "Nov 86-Sept 89" ; add center string
; res@gsnRightString = "cm/mb" ; add right string
;===================================
; note that the background and foreground colors must be the first two
; colors listed. If we did not specify mpLandFillColor above, then the
; continents would use the "light grey", since it is the next available
; color.

  colors = \
   (/"white","black","magenta","blue","orange","green","yellow","red",\
     "light grey","light yellow"/)

; gsn_define_colormap(wks,colors)
  gsn_define_colormap(wks,"wh-bl-gr-ye-re") ; Choose colormap.

  plot = gsn_csm_contour_map_ce(wks,rcoef, res) ; create plot
; plot = gsn_csm_contour_map_ce(wks,rcoef({33:41},{0:17}), res) ; create
plot
; plot = gsn_csm_contour_map_ce(wks,rcoef1, res) ; create plot

end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jul 2 03:33:01 2012

This archive was generated by hypermail 2.1.8 : Tue Jul 03 2012 - 15:40:39 MDT