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

Dennis Shea shea at ucar.edu
Wed Oct 15 09:15:57 MDT 2014


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.
>> thanks in advance,
>> Dave
>>
>> ;*********************************
>> ; read variable
>> ;*********************************
>>    f    = addfile("/home/dadams/Mini_Campaign_NAME/2013_GOES_data/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
>>> lat/lon grids). The documentation is not clear about this unfortunately.
>>>
>>> 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
>>>>   f     = addfile (fili , "r")             ; add file
>>>>  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?
>>>>
>>>> thanks in advance,
>>>> 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/20141015/d2119133/attachment.html 


More information about the ncl-talk mailing list