[ncl-talk] Data projected in a Wrong Location on Map
Mary Haley
haley at ucar.edu
Mon Dec 3 09:09:56 MST 2018
Dear Mansur,
There are a couple of issues with your script.
The first is that you are setting:
res at tfDoNDCOverlay = True ; do not transform
data
This tells NCL to ignore any lat/lon information attached to your data, and
to instead assume that the map resources (res at mpXXXX) have been set up
exactly to match the projection of your data. Remove that line.
The second is that you are providing conflicting information to the
plotting program by adding too much lat/lon information to your data
variable. You have:
lat2d = fspan(13,47,1202)
lon2d = fspan(-95,-58,1202)
printVarSummary(u)
printVarSummary(lat2d)
printVarSummary(lon2d)
u!1="lat2d"
u!2="lon2d"
u at lat2d=lat2d
u at lon2d=lon2d
u&lat2d at units = "degrees_north"
u&lon2d at units = "degrees_east"'
The first issue is that these two lines should NOT be set at all:
u at lat2d=lat2d
u at lon2d=lon2d
They are only to be used in the case where you have curvilinear data, which
is data represented by two-dimensional lat/lon arrays. The way you are
setting up your lat/lon arrays is for rectilinear data, which means you
have one-dimensional latitudes for all your Y locations, and
one-dimensional longitudes for your X locations.
While it's not wrong, I suggest not using "lat2d" and "lon2d" for your lat
/ lon variable names, because this is misleading. Instead, I suggest:
lat = fspan(13,47,1202)
lon = fspan(-95,-58,1202)
printVarSummary(u)
printVarSummary(lat)
printVarSummary(lon)
u!1="lat"
u!2="lon"
u&lat at units = "degrees_north"
u&lon at units = "degrees_east"'
To learn more about rectilinear versus curvilinear, you might want to see
the "plotting data on a map" examples page:
http://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml
Regards,
--Mary
On Sun, Dec 2, 2018 at 9:28 PM Mansur Ali Jisan <jisan.mansur at gmail.com>
wrote:
> Dear NCL Community,
>
> I'm facing some problems in projecting my data properly on a map. I'm
> working with a NetCDF file from a parametric wind model for the case of
> Hurricane Irma. The variable that I'm trying to plot is u10. The problem is
> that it doesn't have any coordinate values attached to it. But from the
> input data, I know the extent of latitude and longitude. So, I defined that
> in the NCL script but from the visualization, the location of the center
> position was shown in a wrong position.
>
> Following is the script that I tried:
>
> *load *"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> *load* "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> begin
> ;---Read data
> f1 = addfile("boundary_parametric.nc","r")
> u = f1->u10 ; 97 x 1202 x 1202
> lat2d = fspan(13,47,1202)
> lon2d = fspan(-95,-58,1202)
> printVarSummary(u)
> printVarSummary(lat2d)
> printVarSummary(lon2d)
> u!1="lat2d"
> u!2="lon2d"
>
> u at lat2d=lat2d
> u at lon2d=lon2d
>
> u&lat2d at units = "degrees_north"
> u&lon2d at units = "degrees_east"
>
> printVarSummary(u)
>
>
> ;---Start the graphics
> wks = gsn_open_wks("png","irma-u10")
> gsn_define_colormap(wks,"matlab_jet")
> ;---Set some resources
> res = True
> res at gsnMaximize = True ; maximize plot in frame
> res at gsnAddCyclic = False
> res at cnFillOn = True ; turn on contour fill
> res at cnLinesOn = False ; turn off contour lines
> res at cnLineLabelsOn = False ; turn off contour line labels
> res at gsnScalarContour = True ; contours desired
> res at tiMainString = "Hurricane Irma"
> res at trGridType = "TriangularMesh"
> res at gsnScalarContour = True
> res at cnLevelSelectionMode = "AutomaticLevels"
> res at mpProjection = "CylindricalEquidistant" ;
> projection
> res at mpDataBaseVersion = "MediumRes" ; use more
> detailed maps
> res at mpLimitMode = "LatLon"
> res at mpMinLatF = 13.0
> res at mpMaxLatF = 47.0
> res at mpMinLonF = -95.0
> res at mpMaxLonF = -58.0
> res at tfDoNDCOverlay = True ; do not
> transform data
>
> plot = gsn_csm_contour_map(wks,u(3,:,:),res)
>
> end
>
> *NCL_Filedump* for the input file is the following:
>
> Variable: f
> Type: file
> filename: boundary_parametric
> path: boundary_parametric.nc
> file global attributes:
> time-units : start time: 2017-09-10 00:06:00 +00:00
> dimensions:
> y_axis = 1202
> x_axis = 1202
> time = 97 // unlimited
> variables:
> double y_axis ( y_axis )
> units : unit-less
>
> double x_axis ( x_axis )
> units : unit-less
>
> float time ( time )
> units : hours
>
> float utx ( time )
> units :
>
> float uty ( time )
> units :
>
> float rmax ( time )
> units :
>
> float wsmax ( time )
> units :
>
> float u10 ( time, y_axis, x_axis )
> units : m/s
>
> float v10 ( time, y_axis, x_axis )
> units : m/s
>
> float utop ( time, y_axis, x_axis )
> units : m/s
>
> float vtop ( time, y_axis, x_axis )
> units : m/s
>
> Please let me know if any additional information needed.
>
> Thanks in advance!
>
> Mansur
>
> --
> *Mansur Ali Jisan*
> Ph.D. Student
> URI Graduate School of Oceanography, RI 02882
>
> <hasancee at iut-dhaka.edu>
> _______________________________________________
> 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/20181203/ca3f88d0/attachment.html>
More information about the ncl-talk
mailing list