[ncl-talk] Data projected in a Wrong Location on Map

Mansur Ali Jisan jisan.mansur at gmail.com
Mon Dec 3 17:05:12 MST 2018


Thanks a lot, Dennis. It worked!

On Mon, Dec 3, 2018 at 4:36 PM Dennis Shea <shea at ucar.edu> wrote:

> The most important rule of data processing is to *look at your data*.
> In your case 'u' has the following structure and contents.
>
> Variable: u
> Dimensions and sizes:   [time | 97] x [lat | 1202] x [lon | 1202]
> Coordinates:
>             time: [ 0.. 0]
>
> *            lat: [   1..1202]     <=== This is wrong*
>
> *            lon: [   1..1202]    <=== This is wrong*
>
> *These are sequential integer values not latitudes and longitudes.*
>
> If you want a basic contour map with no georeferencing, then use:
>
>   plot = *gsn_csm_contour*
> <http://test.www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_csm_contour.shtml>
> (wks,u(3,:,:),res)
> =========================================
>
> Since, you are plotting over a map
>
>   plot = *gsn_csm_contour_map*
> <http://test.www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_csm_contour_map.shtml>
> (wks,u(3,:,:),res)
>
> The *function is looking for lat/lon coordinate variables with
> appropriate units.*
>
> ============================================
> Try something like:
> ++++++++++++++++++++++++++++++++++++++++
> ;;u   = f1->u10   ;g different variables 97 x 1202 x 1202
>
>   ntim = 97
>   nlat = 1202
>   mlon = 1202
>   u    = random_normal(-10,50,(/ntim,nlat,mlon/))
>   lat  = fspan(13,47,nlat)
>   lon  = fspan(-95,-48,mlon)
>
>   lat!0= "lat"                   ; name dimension
>   lat at units = "degrees_north"    ; associate units attribute
>   lat&lat   = lat                ; coordinate variable
>
>   lon!0= "lon"
>   lon at units = "degrees_east"
>   lon&lon   = lon
>
>   u!0 = "time"
>   u!1 = "lat"
>   u!2 = "lon"
>
>   u&lat = lat
>   u&lon = lon
>
>  printVarSummary(lat)
>  print("-----")
>  printVarSummary(lon)
>  print("-----")
>  printVarSummary(u)
>  print("-----")
> ++++++++++++++++++++++++
> OUTPUT: Please examine
> +++++++++++++++++++++++++
> Variable: lat
> Type: float
> Total Size: 4808 bytes
>             1202 values
> Number of Dimensions: 1
> Dimensions and sizes:    [lat | 1202]
>
> *Coordinates:             lat: [13..47]*
> Number Of Attributes: 1
>   *units :    degrees_north*
> (0)    -----
>
> Variable: lon
> Type: float
> Total Size: 4808 bytes
>             1202 values
> Number of Dimensions: 1
> Dimensions and sizes:    [lon | 1202]
>
> *Coordinates:             lon: [-95..-48]*
> Number Of Attributes: 1
>   units :    degrees_east
> (0)    -----
>
> *Variable: u*
> Type: float
> Total Size: 560583952 bytes
>             140145988 values
> Number of Dimensions: 3
> Dimensions and sizes:    [time | 97] x [lat | 1202] x [lon | 1202]
>
>
> *Coordinates:             lat: [13..47]            lon: [-95..-48]*
> (0)    -----
>
>
>
> On Mon, Dec 3, 2018 at 1:30 PM Mansur Ali Jisan <jisan.mansur at gmail.com>
> wrote:
>
>> Dear Mary,
>>
>> Thank you for the suggestions. I made modifications according to the
>> suggestion but now the storm center is not showing in the domain (figure
>> attached). It looks to me that the lat long values are still not attached
>> with the variable u that I'm trying to plot. I also looked at the example
>> plots in the NCL website but couldn't able to figure it out.
>>
>> The *PrintVarSummary* for *u *variable is:
>>
>> Variable: u
>> Type: float
>> Total Size: 560583952 bytes
>>             140145988 values
>> Number of Dimensions: 3
>> Dimensions and sizes:   [time | 97] x [lat | 1202] x [lon | 1202]
>> Coordinates:
>>             time: [ 0.. 0]
>>             lat: [   1..1202]
>>             lon: [   1..1202]
>> Number Of Attributes: 1
>>   units :       m/s
>>
>> The *PrintVarSummary *for *lat *is:
>>
>> Variable: lat
>> Type: float
>> Total Size: 4808 bytes
>>             1202 values
>> Number of Dimensions: 1
>> Dimensions and sizes:   [1202]
>> Coordinates:
>>
>> The *PrintVarSummary *for *lon *is:
>>
>> Variable: lon
>> Type: float
>> Total Size: 4808 bytes
>>             1202 values
>> Number of Dimensions: 1
>> Dimensions and sizes:   [1202]
>> Coordinates:
>>
>>
>>
>> And here's the *modified code*:
>>
>> 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
>>   lat   = fspan(13,47,1202)
>>   lon  = fspan(-95,-48,1202)
>>
>>  printVarSummary(lat)
>>  printVarSummary(lon)
>>
>>   u!1="lat"
>>   u!2="lon"
>>
>>   u&lat at units = "degrees_north"
>>   u&lon 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 = "ManualLevels"
>>   res at cnMinLevelValF       = 0
>>   res at cnMaxLevelValF       = 40
>>   res at cnLevelSpacingF      = 5
>>
>>   res at mpProjection                = "CylindricalEquidistant"      ;
>> projection
>>   res at mpDataBaseVersion           = "MediumRes"
>>
>>
>>   res at mpLimitMode = "LatLon"
>>   res at mpMinLatF = 13.0
>>   res at mpMaxLatF = 47.0
>>   res at mpMinLonF = -95.0
>>   res at mpMaxLonF = -48.0
>>
>>
>>   plot = gsn_csm_contour_map(wks,u(3,:,:),res)
>>
>> end
>>
>>
>> On Mon, Dec 3, 2018 at 11:10 AM Mary Haley <haley at ucar.edu> wrote:
>>
>>> 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
>>>>
>>>
>>
>> --
>> *Mansur Ali Jisan*
>> Ph.D. Student
>> URI Graduate School of Oceanography, RI 02882
>> http://jisan-mansur.com/
>>
>> <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
>>
>

-- 
*Mansur Ali Jisan*
Ph.D. Student
URI Graduate School of Oceanography, RI 02882
http://jisan-mansur.com/

<hasancee at iut-dhaka.edu>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181203/4aeca5fc/attachment-0001.html>


More information about the ncl-talk mailing list