Re: Change mpLimitMode

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Thu Oct 18 2012 - 17:08:16 MDT

Hi Yann,
I am attaching a version of your script that does what you want. I added some hopefully helpful comments.
You cannot use standard coordinate array syntax as you tried to do with the 'speed' variable because you are working with 2d lat/lon coordinates.
 -dave

On Oct 18, 2012, at 9:16 AM, Yann Bertrand wrote:

>
> Thanks Dave for your answer,
> i still can not plot the "subfield" of vectors determined by "lat lon"
> here's my full script today, and a part of the result of "ncl_filedump mygrib2 file":
> I also tried to add somethings like these:
>
> speed!0 = "lat";
> speed!1 = "lon";
> speed&lat = u&gridlat_0
> speed&lon = v&gridlon_0
>
> ;*******************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> begin
> ;************************************************
> ; open file and read in data
> ;************************************************
> fili = "grib.grib2"
> f = addfile (fili, "r")
> u = f->UGRD_P0_L103_GLC0
> v = f->VGRD_P0_L103_GLC0
> speed = sqrt(u^2+v^2)*1.943846
> ;lat2d = f->gridlat_0
> ;lon2d = f->gridlon_0
> printVarSummary(u)
> ;************************************************
> ; create plot
> ;************************************************
> wks = gsn_open_wks("ps","grib2out") ; open a workstation
> gsn_define_colormap(wks, "ncl_default") ; choose colormap
> res = True ; plot mods desired
> ;************************************************
> MINLON = -5
> MAXLON = 0
> MINLAT = 47
> MAXLAT = 49
>
> res@mpLimitMode = "LatLon"
>
> res@mpMinLonF = MINLON
> res@mpMaxLonF = MAXLON
> res@mpMinLatF = MINLAT
> res@mpMaxLatF = MAXLAT
>
> res@vfXCStartV = MINLON
> res@vfXCEndV = MAXLON
> res@vfYCStartV = MINLAT
> res@vfYCEndV = MAXLAT
>
> ;************************************************
> res@mpProjection = "LambertConformal"
> res@mpLambertMeridianF = (res@mpMinLonF + res@mpMaxLonF) / 2
> res@pmTickMarkDisplayMode = "Always"
> res@mpFillOn = False ; turn off map fill
> res@mpOutlineDrawOrder = "PostDraw" ; draw continental outline last
> res@mpOutlineBoundarySets = "GeophysicalAndUSStates" ; state boundaries
> ;****************************************************************************
> res@tfDoNDCOverlay = True
> ;****************************************************************************
>
> plot = gsn_csm_vector_scalar_map(wks,u,v,speed,res)
> end
>
>
>
>
>
> float UGRD_P0_L103_GLC0 ( ygrid_0, xgrid_0 )
> center : US National Weather Service - NCEP (WMC)
> production_status : Operational products
> long_name : U-component of wind
> units : m s-1
> _FillValue : 1e+20
> coordinates : gridlat_0 gridlon_0
> grid_type : Lambert Conformal can be secant or tangent, conical or bipolar
> parameter_discipline_and_category : Meteorological products, Momentum
> parameter_template_discipline_category_number : ( 0, 0, 2, 2 )
> level_type : Specified height level above ground (m)
> level : 10
> forecast_time : 3
> forecast_time_units : hours
> initial_time : 10/18/2012 (06:00)
>
>
> De : David Brown <dbrown@ucar.edu>
> À : Yann Bertrand <yann74@yahoo.fr>
> Cc : NCL Talk <ncl-talk@ucar.edu>
> Envoyé le : Mercredi 17 octobre 2012 0h30
> Objet : Re: [ncl-talk] Change mpLimitMode
>
> You have attached the 2d coordinate attributes to the 'speed' variable but you need (also) to attach them to u and v variables. Alternatively you can set
>
> res@vfXArray = lon2d ; vector field coordinate resources
> res@vfYArray = lat2d
>
> -dave
>
> On Oct 16, 2012, at 10:07 AM, Yann Bertrand wrote:
>
>> hello,
>> I managed to create a map with a wind grib file as input (WRF NNM)
>> it works fine! but I want to know how to create a map of a subdomain of my domain pricipal.
>> If I change corners (lat,lon) I get the right map in the background (the right subdomain) but the vectors are those of the primary domain.
>> How can I get the correct vectors in the subdomain?
>> Thanks in advance.
>>
>> .................
>>
>> f = addfile ("mygrib.grib2", "r")
>> wks = gsn_open_wks("ps","out")
>>
>> u = f->UGRD_P0_L103_GLC0
>> v = f->VGRD_P0_L103_GLC0
>> speed = sqrt(u^2+v^2)*1.943846
>> lat2d = f->gridlat_0
>> lon2d = f->gridlon_0
>>
>> speed@lat2d = lat2d
>> speed@lon2d = lon2d
>> corners : ( 44.3, -3.5, 44.17, 45.9 )
>> res@mpLimitMode = "Corners" ; choose range of map
>>
>> ;full map (display correctly the whole grib2 datas)
>> ;res@mpLeftCornerLatF = lat2d@corners(0)
>> ;res@mpLeftCornerLonF = lon2d@corners(0)
>> ;res@mpRightCornerLatF = lat2d@corners(2)
>> ;res@mpRightCornerLonF = lon2d@corners(2)
>>
>> ;My subdomain (vectors not working)
>> res@mpLeftCornerLatF = 50.3
>> res@mpLeftCornerLonF = -3.5
>> res@mpRightCornerLatF = 46.1
>> res@mpRightCornerLonF = 1
>>
>> res@mpProjection = "LambertConformal"
>>
>> plot = gsn_csm_vector_scalar_map(wks,u,v,speed,res)
>>
>>
>>
>> Variable: u
>> Type: float
>> Total Size: 35956 bytes
>> 8989 values
>> Number of Dimensions: 2
>> Dimensions and sizes: [ygrid_0 | 89] x [xgrid_0 | 101]
>> Coordinates:
>> Number Of Attributes: 14
>> center : US National Weather Service - NCEP (WMC)
>> production_status : Operational products
>> long_name : U-component of wind
>> units : m s-1
>> _FillValue : 1e+20
>> coordinates : gridlat_0 gridlon_0
>> grid_type : Lambert Conformal can be secant or tangent, conical or bipolar
>> parameter_discipline_and_category : Meteorological products, Momentum
>> parameter_template_discipline_category_number : ( 0, 0, 2, 2 )
>> level_type : Specified height level above ground (m)
>> level : 10
>> forecast_time : 1
>> forecast_time_units : hours
>> initial_time : 10/15/2012 (12:00)
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Oct 18 17:08:26 2012

This archive was generated by hypermail 2.1.8 : Tue Oct 23 2012 - 11:10:04 MDT