Re: How to plot a small area from a global data set

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Jul 02 2012 - 08:53:07 MDT

On Jul 2, 2012, at 3:32 AM, brick wrote:

> 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.

Hi Brick,

You can try setting these resources:

 res@mpMinLatF = min(rcoef&lat_173)
 res@mpMaxLatF = max(rcoef&lat_173)
 res@mpMinLonF = min(rcoef&lon_173)
 res@mpMaxLonF = max(rcoef&lon_173)

This basically tells NCL what the min/max area of a lat/lon box that you want to look at.
I'm using the actual mins and maxs of your lat/lon coordinate arrays, but you can
also hard-code these values to whatever you want. It's better to set these
values programatically, rather than hard-coding them, though.

If you start using other map projections, like LambertConformal, then you can go
to the examples page:

http://www.ncl.ucar.edu/Applications/

Click on the word "tips" near the top, which takes you to this page:

http://www.ncl.ucar.edu/Applications/concepts_list.shtml

and then search on the word "zoom". This will list several pages that
do different kinds of map zooms, like zooming in on an orthographic
or lambert conformal map.

--Mary

>

> 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

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

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