[ncl-talk] where am I getting wrong in plotting the values please help....

Mary Haley haley at ucar.edu
Thu Jun 1 15:04:56 MDT 2017


Dear Grubinder,

It looks like your latitude / longitude values are two-dimensional rather
than one-dimensional, which means you can't treat them as coordinate arrays:

  float longitude ( YCells, XCells )                   <------  This is a
2d array!
         long_name :    longitude coordinate
         units :        degrees_east
         precision :    6
         grid_mapping : MapProjection
         standard_name :        longitude
         _CoordinateAxisType :  Lon

      float latitude ( YCells, XCells )                   <------  This is
a 2d array!
         long_name :    latitude coordinate
         units :        degrees_north
         precision :    6
         grid_mapping : MapProjection
         standard_name :        latitude
         _CoordinateAxisType :  Lat

Your data is on a "curvilinear" grid which is data represented by 2D
lat/lon arrays.

Because of this, you also cannot use uv2dvg or uv2vrg to calculate
divergence and vorticity, because these are meant to be used with gaussian
grids only. It looks like you are not using these calculations for anything
anyway, so I'm not sure why they are in there.

To plot u and v which on a curvilinear grid, you need to replace this code:

lat=uf->latitude(:,0)
lon=uf->longitude(0,:)

u&YCells = uf->latitude(: ,0)
u&XCells = uf->longitude(0,:)

v&YCells = vf->latitude(:,0)
v&XCells= vf->longitude(0,:)

with:

delete(u&YCells)    ; Remove these coordinate arrays since
delete(u&XCells)    ; they don't represent latitude/longitude
delete(v&YCells)
delete(v&XCells)

u at lat2d = uf->latitude     ; lat2d/lon2d are recognized by the
gsn_csm_xxxx_map
u at lon2d = uf->longitude    ; routines for plotting curvilinear data.
v at lat2d = vf->latitude
v at lon2d = vf->longitude

For more information about plotting U,V on a curvilinear grid, please see
dataonmap_4.ncl at:

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

If you are new to NCL, I recommend reading the NCL User Guide:

http://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/

--Mary



On Thu, Jun 1, 2017 at 1:38 AM, gurbrinder aulakh <
gurbrinderaulakh at yahoo.co.in> wrote:

>
>
> Dear Mary Haley,
> Thanks a lot for your reply... I really appreciate that. Your explanation
> was crystal clear. I have used ncl_filedump and made changes accordingly by
> replacing YCells and XCells with latitude and longitude....Then I have
> warnings like
>
>
> (0)     gsn_add_cyclic: Warning: The range of your longitude data is not
> 360.
> (0)     You may want to set gsnAddCyclic to False to avoid a warning
> (0)     message from the spline function.
> (0)     gsn_add_cyclic: Warning: The range of your longitude data is not
> 360.
> (0)     You may want to set gsnAddCyclic to False to avoid a warning
> (0)     message from the spline function.
> warning:VectorFieldSetValues: irregular coordinate array vfXArray
> non-monotonic: defaulting vfXArray
>
> I have added   res at gsnAddCyclic = False res at gsnAddCyclic = False
> but still left with the last warning.....
> warning:VectorFieldSetValues: irregular coordinate array vfXArray
> non-monotonic: defaulting vfXArray
>
>
> Here is my code with changes
> begin
>
>   uf = addfile("uwind500.nc","r")
>     vf = addfile("vwind500.nc","r")
>
>      u   = uf->UGRD_500_ISBL(0,:,:)
>     v   = vf->VGRD_500_ISBL(0,:,:)
>
>
>
> lat=uf->latitude(:,0)
> lon=uf->longitude(0,:)
>
>
> u&YCells = uf->latitude(: ,0)
> u&XCells = uf->longitude(0,:)
>
>
>
> v&YCells = vf->latitude(:,0)
> v&XCells= vf->longitude(0,:)
>
>
> printVarSummary(u)
>
>
>
>
> div = uv2dvG_Wrap(u,v)                ; u,v ==> divergence
>
>   dv2uvg(div,u,v) ; div  ==> divergent  wind components
>
>
>  u at long_name  = "Zonal Divergent Wind"
>   u at units      = u at units
>   v at long_name  = "Meridional Divergent Wind"
>   v at units      = v at units
>
> ;*************************************************
> ; plot results
> ;*************************************************
>   wks  = gsn_open_wks("png","wind123")           ; send graphics to PNG
> file
>
>   res                 = True
>   res at vcRefMagnitudeF = 3.                    ; make vectors larger
>   res at vcRefLengthF    = 0.050                 ; reference vector length
>   res at vcGlyphStyle    = "CurlyVector"         ; turn on curly vectors
>   res at vcMinDistanceF  = 0.012                 ; thin the vectors
>  res at gsnAddCyclic = False
>   res at gsnLeftString   = "Divergent Wind"
>                                               ; plot 1st time step
>   plot= gsn_csm_vector_map(wks,u(:,:),v(:,:),res)
>
> end
>
>
> output of the uwind500.nc is also attached... please help me to
> understand am i reading the data right...thanks a lot for time and help....
>
> Regards,
> Gurbrinder Kaur
>
>
>
>
> On Tuesday, 30 May 2017 10:04 PM, Mary Haley <haley at ucar.edu> wrote:
>
>
> I think you need to look at your data more closely.
>
> My guess is that YCells and XCells are not actually lat / lon arrays, but
> yet you are trying to use them to plot your data over a map.
>
> You have this code, which looks like you were trying to get NCL to
> recognize YCells and XCells as lat/lon arrays:
>
> lat = uf->u&YCells
> lon = uf->v&XCells
>
> u!0="lat"
> u!1="lon"
>
> u&lat at units="degrees_north"
> u&lon at units="degrees_east"
>
> However, I'm suspicious that YCells and XCells actually represent the
> latitude and longitude values of your array.
>
> ​It helps if you use "printVarSummary" to look at your data before you
> plot it:
>
> printVarSummary(u)
>
> The above should also print the numeric range of the lat / lon arrays, and
> you will see very quickly whether they actually look like lat / lon values.
>
>
> Variable : u Type : float . . . Number of Dimensions: 2 Dimensions and
> sizes: [lat | *some number*] x [lon | *some number*] *Coordinates: lat: [**...you'll
> see a numeric range here...**] lon: [**...ditto...**]* Number Of
> Attributes:
>
> If u has an attribute called "coordinates", then it is very important to
> pay attention to this because this will likely tell you what the name is of
> your lat/lon arrays on the file, which you will need to use to replace
> "YCells" and "XCells". It would look something like this:
>
> Variable : u Type : float . . . Number of Dimensions: 2 Dimensions and
> sizes: [lat | *some number*] x [lon | *some number*] *Coordinates: lat: [**...you'll
> see a numeric range here...**] lon: [**...ditto...**]* Number Of
> Attributes: 5 *coordinates*: "latitude longitude"
>
>
> Important note: the "coordinates" attribute is a different thing than
> "Coordinates", which you *always* see when you do a printVarSummary.  The
> "Coordinates" output from printVarSummary represents coordinate *arrays*
> that may already be attached to your file.
>
> If you do see a "coordinates" attribute, then make note of the names in
> the attribute, then do an "ncl_filedump" on your file on the UNIX command
> line to see if your file contains variables with these names.  If it does,
> then you can replace this code:
>
> lat = uf->u&YCells
> lon = uf->v&XCells
>
> u!0="lat"
> u!1="lon"
>
> u&lat at units="degrees_north"
> u&lon at units="degrees_east"
>
> with:
>
> u!0="lat"
> u!1="lon"
> u&lat := uf->latitude     ; The ":=" forces YCell and XCell to be
> overwritten, in case
> u&lon := uf->longitude    ; they are different types than latitude and
> longitude.
>
> You need to do the same for "v":
>
> v!0="lat"
> v!1="lon"
> v&lat = vf->latitude
> v&lon = vf->longitude
>> If the above doesn't work, then it would help if you could email ncl-talk
> and provide the output from doing an "ncl_filedump" on uwind500.nc.
>
> ​--Mary
>>
>
> On Tue, May 30, 2017 at 3:36 AM, gurbrinder aulakh <
> gurbrinderaulakh at yahoo.co.in> wrote:
>
> I want to compute wind divergence reading u and v wind components but I am
> getting the following warnings when I run the script.Plot is also not as
> expected... Please help tried everything from the earlier queries but not
> finding any solution.... Am I reading the correct values....Thanks in
> advance..
>
>
>
>
> warning:IrTransInitialize: trYCoordPoints contains invalid coordinate
> array: defaulting trYAxisType to LinearAxis
> warning: AutoComputeMajorTickMarks: min and max are so close together or
> so far apart that arithmetic error may cause problems, proceed at own risk
> warning:ComputeMinorTickMarks: The distance between major tickmarks is so
> close or so far apart that arithmetic error may cause problems determining
> the accurate locations of minor tickmarks
> warning: AutoComputeMajorTickMarks: min and max are so close together or
> so far apart that arithmetic error may cause problems, proceed at own risk
> warning:ComputeMinorTickMarks: The distance between major tickmarks is so
> close or so far apart that arithmetic error may cause problems determining
> the accurate locations of minor tickmarks
> warning: StreamlinePlotInitialize: coordinate spacing is irregular; linear
> spacing only possible using index coordinates for Y Axis
> warning:IrTransInitialize: trYCoordPoints contains invalid coordinate
> array: defaulting trYAxisType to LinearAxis
>
>
>
>
>
> ****************************** *******************
> ;
> ; These files are loaded by default in NCL V6.2.0 and newer
> ; 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"
> ;***************************** ********************
> begin
>
>   uf = addfile("uwind500.nc","r")
>     vf = addfile("vwind500.nc","r")
>
>      u   = uf->UGRD_500_ISBL(0,:,:)
>     v   = vf->VGRD_500_ISBL(0,:,:)
>
> lat = uf->u&YCells
>     lon = uf->v&XCells
>
> u!0="lat"
> u!1="lon"
>
> u&lat at units="degrees_north"
> u&lon at units="degrees_east"
>
> printVarSummary(u);
>   div = uv2dvG_Wrap(u,v)                ; u,v ==> divergence
>
>   dv2uvg(div,u,v) ; div  ==> divergent  wind components
>
>
>  u at long_name  = "Zonal Divergent Wind"
>   u at units      = u at units
>   v at long_name  = "Meridional Divergent Wind"
>   v at units      = v at units
>
> ;***************************** ********************
> ; plot results
> ;***************************** ********************
>   wks  = gsn_open_wks("png","wind123")           ; send graphics to PNG
> file
>
>   res                 = True
>   res at vcRefMagnitudeF = 3.                    ; make vectors larger
>   res at vcRefLengthF    = 0.050                 ; reference vector length
>   res at vcGlyphStyle    = "CurlyVector"         ; turn on curly vectors
>   res at vcMinDistanceF  = 0.012                 ; thin the vectors
>
>   res at gsnLeftString   = "Divergent Wind"
>                                               ; plot 1st time step
>   plot= gsn_csm_vector_map(wks,u(:,:), v(:,:),res)
>
> end
>
>
> ______________________________ _________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/ mailman/listinfo/ncl-talk
> <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170601/2c9c81f6/attachment.html 


More information about the ncl-talk mailing list