[ncl-talk] Hovmoller Plot with 2d lat/lon (Y coordinates out of data range)

Thu Oct 16 09:11:08 MDT 2014

```Thanks Mary, Dennis,
I made a really big mistake not getting the regular gridded data from the
GOES people at Wisconsin.

Looking at the example
http://www.ncl.ucar.edu/Applications/narr.shtml
Example 6

to set the x-labels (with actual longitude values), I have to consider both
dimensions (x,y) of the longitude dimension, correct?
I would have to do something like this in the example 6

ml = 200
resx at tmXBValues         := toint( fspan(0,nlat-1,nLabels) )
do i=0,nLabels-1
x = lon2d(resx at tmXBValues(i),ml)
y = lat2d(resx at tmXBValues(i),ml)
resx at tmXBLabels(i) = sprintf("%5.1f", y)+"~C~"+sprintf("%5.1f", x)
end do

where lon2d would be
lon2d= new_lon(0,:,:)
lat2d= new_lat(0,:,:)

(I made another mistake with ncecat and ncrcat. somehow adding a time
dimension to lat and lon)

Dave

On Wed, Oct 15, 2014 at 10:15 AM, Dennis Shea <shea at ucar.edu> wrote:

> See the following: example of subscripting 2-dimensional array coordinates
> http://www.ncl.ucar.edu/Applications/narr.shtml
> Example 6
>
> ---
> To get a 'classic' cross section (ie, a vertical profile ata  constant
> latitude or longitude), you must interpolate the curvilinear grid to to a
> rectilinear grid.
>
> http://www.ncl.ucar.edu/Applications/ESMF.shtml
> Example 30
>
> To use the weight file generated by Example 30,
>
> http://www.ncl.ucar.edu/Applications/narr.shtml
> Example 5
>
> This shows classic cross sections (constant lat ot lon) AND
> an arbitrary slice
>
> Good luck
>
>
> On Wed, Oct 15, 2014 at 9:02 AM, Mary Haley <haley at ucar.edu> wrote:
>
>> Dave,
>>
>> I think the issue here is simply that "new_temp" is dimensioned time x
>> lat x lon, and since you want a time x lon plot, you need to subscript the
>> "lat" dimension somehow.
>>
>> i.e.
>>
>>   plot = gsn_csm_contour(wks,new_temp(:,0,:), res)
>>
>> I'm just selecting the first latitude dimension, but you need to set this
>> to whatever you want.
>>
>> --Mary
>>
>> On Tue, Oct 14, 2014 at 11:41 AM, David Adams <dave.k.adams at gmail.com>
>> wrote:
>>
>>> Hi Mary et al.
>>> I think I am misunderstanding how
>>>
>>>   res at sfYArray = new_time
>>>    res at sfXArray = new_lon
>>>
>>> work.  Do I have to redefine the original variable new_temp in terms of
>>> these dimensions?  And, if so, how?
>>>
>>> I am getting this error.
>>>
>>>     gsn_csm_contour: Fatal: the input data array must be 1D or 2D
>>> fatal:Illegal right-hand side type for assignment
>>> fatal:Execute: Error occurred at or near line 74 in file
>>> lon_time_plots.ncl
>>>
>>> Here is the code.
>>> Dave
>>>
>>> ;*********************************
>>> ;*********************************
>>> test.nc","r")
>>>    new_temp    = f->new_temp          ; float new_temp(time, yc, xc)
>>> ;   printVarSummary(new_temp)
>>> ;*********************************
>>> ;
>>> ;*********************************
>>>    new_lat  = f->new_lat
>>>    new_lon  = f->new_lon
>>>    time = f->time
>>>    new_time = conform(new_lon(:,0,:),time,0)
>>>
>>> ;*********************************
>>> ; create plot
>>> ;*********************************
>>>    pltName = "goes"
>>>    pltType = "pdf"                             ; "ps", "eps", "pdf",
>>> "png"
>>>    pltDir  = "./"
>>>
>>>    wks = gsn_open_wks(pltType, pltDir+pltName)
>>>    gsn_define_colormap(wks,"BlAqGrYeOrReVi200"); choose a color map
>>>
>>>    res                     = True
>>>    res at cnFillOn            = True            ; turn on color
>>>    res at cnFillMode          = "RasterFill"    ; cell mode
>>>    res at cnLinesOn           = False           ; Turn off contour lines
>>>
>>>    res at sfYArray = new_time
>>>    res at sfXArray = new_lon
>>>
>>>    res at gsnSpreadColors     = True            ; use full colormap
>>>    res at gsnAddCyclic        = False           ; data not cyclic
>>>    res at gsnMaximize         = True            ; ps, pdf, pdf
>>>    res at pmTickMarkDisplayMode = "Always"      ; use NCL default
>>>    res at lbLabelAutoStride   = True            ; let NCL decide spacing
>>>    res at cnLevelSelectionMode = "ManualLevels"  ;"ExplicitLevels"
>>>    res at cnMinLevelValF       = 200.                            ; set the
>>> minimum contour level
>>>    res at cnMaxLevelValF       = 300.                          ; set the
>>> maximum contour level
>>>    res at cnLevelSpacingF      = 5.0                            ; set the
>>> contour interval
>>>    res at cnRasterSmoothingOn  = True
>>>   res at lbLabelStride        = 5.0             ; every other label bar
>>> label
>>>
>>>   plot = gsn_csm_contour(wks,new_temp, res)
>>>
>>> On Mon, Oct 13, 2014 at 11:29 PM, Mary Haley <haley at ucar.edu> wrote:
>>>
>>>> Dave,
>>>>
>>>> The gsn_csm_hov script is meant to only be for rectilinear grids, and
>>>> you are trying to use it on a curvilinear grid (i.e., one represented by 2D
>>>>
>>>> My suggestion is to just use gsn_csm_contour, and pass in the time and
>>>> longitude arrays via the sfYArray and sfXArray resources:
>>>>
>>>> new_time = conform(new_lon(:,0,:),time,0)
>>>> res at sfYArray = new_time
>>>> res at sfXArray = new_lon
>>>>
>>>> --Mary
>>>>
>>>>
>>>> On Thu, Oct 9, 2014 at 8:28 PM, David Adams <dave.k.adams at gmail.com>
>>>> wrote:
>>>>
>>>>> HI NCLers,
>>>>> I am trying to make a hovmoller plot but it does appear that my
>>>>> coordinates are correct.
>>>>>
>>>>> warning:ContourPlotInitialize: Y coordinates out of data range:
>>>>> defaulting
>>>>> warning:ContourPlotInitialize: Zero Y coordinate span:
>>>>> defaulting:[errno=1104]
>>>>>
>>>>> and then a blank plot.  The code is from the NCL website with slight
>>>>> modification
>>>>>
>>>>>
>>>>> --------------------------------------------------------------------------------
>>>>> begin
>>>>> ;=============================================
>>>>> ; data processing
>>>>> ;===========================================
>>>>>  fili  = "test.nc"                 ; filename
>>>>>  new_temp   = f->new_temp                                ; get chi
>>>>>  new_lat  = f->new_lat
>>>>>  new_lon  = f->new_lon
>>>>> ;==============================================
>>>>> ; creat plot: Reverse time axis; contour labels horizontal
>>>>> ; Dash negative contours; double width of Zero
>>>>> ;==============================================
>>>>>  wks  = gsn_open_wks ("pdf", "hov")
>>>>>  res                     = True                ; plot mods desired
>>>>>  res at gsnContourZeroLineThicknessF = 2.         ; doubles thickness of
>>>>> zero contour
>>>>>  res at gsnContourNegLineDashPattern = 1          ; sets negative
>>>>> contours to dash pattern 1
>>>>>  res at trYReverse          = True                ; reverse y axis
>>>>>  res at tiMainString        = "Reverse Time"      ; title
>>>>>  res at cnLineLabelAngleF   = 0.0                 ; [cn] label horizontal
>>>>>
>>>>> ;new_temp at lat2d = new_lat(0,:,:)
>>>>> ;new_temp at lon2d = new_lon(0,:,:)
>>>>>
>>>>>  plot  = gsn_csm_hov(wks, new_temp(:,0,:), res )           ; default
>>>>> hovmueller
>>>>> end
>>>>>
>>>>> --------------------------------------------------------------------------------------------
>>>>> Here is an ncdump -h on the data file
>>>>>
>>>>> netcdf test {
>>>>> dimensions:
>>>>>     yc = 221 ;
>>>>>     xc = 141 ;
>>>>>     time = UNLIMITED ; // (130 currently)
>>>>> variables:
>>>>>     float new_temp(time, yc, xc) ;
>>>>>         new_temp:time = 1372896900 ;
>>>>>         new_temp:units = "K" ;
>>>>>         new_temp:coordinates = "lon lat" ;
>>>>>         new_temp:type = "GVAR" ;
>>>>>         new_temp:long_name = "Temperature" ;
>>>>>     float new_lat(time, yc, xc) ;
>>>>>         new_lat:units = "degrees_north" ;
>>>>>         new_lat:long_name = "lat" ;
>>>>>     float new_lon(time, yc, xc) ;
>>>>>         new_lon:units = "degrees_east" ;
>>>>>         new_lon:long_name = "lon" ;
>>>>>     int time(time) ;
>>>>>         time:units = "seconds since 2013-185 00:15" ;
>>>>>
>>>>>
>>>>> any obvious errors?
>>>>>
>>>>> Dave
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141016/4052f9cd/attachment.html
```