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

gurbrinder aulakh gurbrinderaulakh at yahoo.co.in
Thu Jun 1 01:38:09 MDT 2017



 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 caseu&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->latitudev&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 LinearAxiswarning: AutoComputeMajorTickMarks: min and max are so close together or so far apart that arithmetic error may cause problems, proceed at own riskwarning: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 tickmarkswarning: AutoComputeMajorTickMarks: min and max are so close together or so far apart that arithmetic error may cause problems, proceed at own riskwarning: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 tickmarkswarning: StreamlinePlotInitialize: coordinate spacing is irregular; linear spacing only possible using index coordinates for Y Axiswarning: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





   

   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170601/08906e78/attachment-0001.html 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ncldump output of uwind.nc.txt
Url: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170601/08906e78/attachment-0001.txt 


More information about the ncl-talk mailing list