[ncl-talk] Another ncl-python related question

Barry Lynn barry.h.lynn at gmail.com
Wed Mar 6 11:17:54 MST 2024


The answer is: since the python program is displaying every other interval,
you need to make sure that your total number of intervals is a multiple of
two (not -100 to 5, but -100 to 10, for example).

I am not sure how to explicitly print out the number of intervals defined
by the plotting program, as can be done in NCL.

On Tue, Mar 5, 2024 at 2:01 PM Barry Lynn <barry.h.lynn at gmail.com> wrote:

>  Hello:
>
>
> If someone has experience with using python for setting contours and label
> bar (boxes with labels), I can't seem to drop the right most label bar box
> -- it says no_label. I don't believe it should be plotted, as the contour
> ends at 5.
>
>
> min_val = -25.
>
>  max_val = 5.
>
>  space_val = 3.
>
>  res.cnMinLevelValF = min_val
>
>  res.cnMaxLevelValF = max_val
>
>  res.cnLevelSpacingF = space_val
>
>  res.cnLineThicknessF = 0. # Don't draw contour lines
>
>  res.cnLinesOn = False
>
>  res.lbLabelBarOn = True #-- draw a labelbar
>
> #res.lbTitleString = "olr Reflectivity (dBZ)"
>
> #res.lbTitleFontHeightF= .015
>
> #res.lbTitleOffsetF =   -0.25 # plus is up
>
> #res.lbTitleOffsetF =   -0.75 # plus is up
>
>  res.lbLabelAlignment = "BoxCenters"
>
>  res.lbLabelStrings = list(range(-25,5,3))
>
> # Calculate the levels
>
>  num_intervals = max_val - min_val
>
> #levels = np.linspace(min_val * space_coef, (max_val+2) * space_coef,
> num_intervals + 1)[1:-1]
>
> #levels = np.linspace(min_val * space_coef, max_val * space_coef,
> num_intervals)
>
>  levels = np.linspace(min_val , max_val+space_val )
>
>
> # Convert levels to string and assign to label bar
>
>  string_levels = [str(level) for level in levels]  # Convert levels to
> strings
>
>  res.lbLabelStrings = string_levels
>
>  print(res.lbLabelStrings)
>
>
> --
>
> Barry H. Lynn, Ph.D
> Senior Scientist, Lecturer,
> The Institute of Earth Sciences,
> The Hebrew University of Jerusalem,
> Givat Ram, Jerusalem 91904, Israel
> Tel: 972 547 231 170
> Fax: (972)-25662581
>
> Weather It Is, LTD
> Weather and Climate Focus
> https://weather-it-is.com <http://weather-it-is.com>
> Jerusalem, Israel
> Local: 02 930 9525
> Cell: 054 7 231 170
> Int-IS: x972 2 930 9525
>
>

-- 

Barry H. Lynn, Ph.D
Senior Scientist, Lecturer,
The Institute of Earth Sciences,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581

Weather It Is, LTD
Weather and Climate Focus
https://weather-it-is.com <http://weather-it-is.com>
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20240306/369a1662/attachment.htm>


More information about the ncl-talk mailing list