[ncl-talk] I can't manage to create a plot with multiple lines on it, each line having different x and y values. Attribute assignment type issue.

Rick Brownrigg brownrig at ucar.edu
Thu Mar 31 11:27:48 MDT 2016


Hi Maxine,

A couple of comments:

i) for each plot, you first set "opt = True", then either "res = opt" or
"res2 = opt", and then assign a bunch of resources for the plot.  But after
the first plot., performing "res = opt" doesn't affect the values or
presence of resources associated with "res" from the previous plots.  So
for example, in one plot, you've set "res at xyLineThickness = 8", a scalar
integer value. In a subsequent plot, where the error message arises, you
set "res at xyLineThickness = (/ ..... /), an array of floats, and as you
likely know NCL won't allow reassignment of incompatible types.

The solution would be to "delete(res)" for each  plot.

ii) In a similar vein, you are re-opening the workstation for each plot and
assigning it to "wks".  I'm not totally certain what the behavior is there,
and whether the previous plots get written and closed out properly.  As odd
as it seems, performing "delete(wks)" will close the plot/workstation.
Alternatively, if the workstation is the same for each plot, its not
necessary to reopen a new instance for each plot -- just open once at the
top, and it will get closed properly when the script terminates.

Hope that helps...
Rick


On Thu, Mar 31, 2016 at 10:57 AM, Maxime Colin <m.colin at unsw.edu.au> wrote:

>
>
> Dear NCL gurus,
>
>
> I've used NCL for more than a year, but this problem seems to be
> particularly tough to solve, so I think I need to refer to you.
>
>
> I've been working on a script for days, I've turned it in different ways
> (array of data, overlay, using a single y-axis, etc...), but I can't seem
> to find the solution. I had a script to plot several lines on the same
> graph, but these lines had exactly the same x-axis. That was working fine.
> Now I'm trying to plot several profiles, that all have different x and y
> values, but I always receive the following error (after a bunch of warnings
> due to the fact that I'm plotting several types of plots with the same
> script):
>
>
> warning:MainTitle is not a valid resource in
> plot_theta_hor_ave_fct_time_and_z_0130_3D_No_strong_nudg_CONTROL_ALL90d_v1_contour
> at this time
> warning:MainTitle is not a valid resource in
> plot_temp_hor_ave_fct_time_and_z_0130_3D_No_strong_nudg_CONTROL_ALL90d_v1_contour
> at this time
> warning:MainTitle is not a valid resource in
> plot_eth_hor_ave_fct_time_and_z_0130_3D_No_strong_nudg_CONTROL_ALL90d_v1_contour
> at this time
> warning:cnFillOn is not a valid resource in
> plot_T500_hor_ave_0130_3D_No_strong_nudg_CONTROL_ALL90d_v1_xy at this time
> warning:gsnSpreadColors is not a valid resource in
> plot_T500_hor_ave_0130_3D_No_strong_nudg_CONTROL_ALL90d_v1_xy at this time
> warning:cnLineLabelsOn is not a valid resource in
> plot_T500_hor_ave_0130_3D_No_strong_nudg_CONTROL_ALL90d_v1_xy at this time
> warning:cnLevelSelectionMode is not a valid resource in
> plot_T500_hor_ave_0130_3D_No_strong_nudg_CONTROL_ALL90d_v1_xy at this time
> warning:MainTitle is not a valid resource in
> plot_T500_hor_ave_0130_3D_No_strong_nudg_CONTROL_ALL90d_v1_xy at this time
>
>
> fatal:["NclAtt.c":262]:Attribute assignment type mismatch.
>
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 589 in
> file plot_temperature.ncl
>
>
>
> I attach the whole script if needed (plot_temperature.ncl), but here is
> the relevant part (the error I receive refering to line
> res at xyLineThicknesses = (/8.0,8.0,8.0/) ):
>
>
> "
>
> ; PLOT NUMBER 11
> ;  type at wkPaperSize = "A4"
>   wks =
> gsn_open_wks(type,"plot_prof_theta_ALL_0130_3D_No_strong_nudg_CONTROL_ALL90d_v1")
> ; Create a plot workstation + TITLE OF THE FILE TO SAVE
>   opts = True
>   res = opts
>   res at lbOrientation   = "Vertical"
>   res at gsnMaximize = True
>   res at tmXTOn         = False
>
>   res at pmLegendDisplayMode = "Always"
>   res at pmLegendSide = "Top"
>   res at pmLegendOrthogonalPosF = -0.58  ;-0.02 (too high), 0.15 the same,
> -0.15 half box is too high
>   res at pmLegendParallelPosF = .67     ; 0.2 is very good
>   res at pmLegendWidthF = 0.0375
>   res at pmLegendHeightF = 0.28
>   res at lgLabelFontHeightF = 0.02
>   res at xyExplicitLegendLabels = (/legend_theta(0), legend_theta(1),
> legend_theta(2)/)
>
>   res at xyLineThicknesses = (/8.0,8.0,8.0/)
>   res at xyLineColor    =  (/"cyan","blue","green"/)
>   res at xyDashPatterns    = (/0,0,0/)
>   res at trXMinF        =  200.
>   res at trXMaxF        =  800.
>   res at trYMinF        =  0.
>   res at trYMaxF        =  30.   ;30000
>   res at tiXAxisString = "Pot. temp (K)"
>   res at tiYAxisString = "z (km)"
>   res at tiMainString = "Pot. Temp. profiles"
>
>   plot  = gsn_csm_xy(wks,array_of_theta_prof,array_of_heights,res)
>
> "
>
>
> The netcdf files I'm using are just standard WRF output from an idealized
> quarter_ss type simulation. They are big files (~30GB) so I'd rather not
> add them now. If necessary, I'll put a few of them online.
>
>
> NOTE: If you wish to try the script on a smaller number of wrfout files,
> just change the num_day_max variable to a small number (I receive the same
> error in any case). If you don't use 90 files (as the target is), then some
> of the profiles in array_of_heights and array_of_theta_prof may be
> undefined. But I have checked that this is not the reason for my issue, as
> I get the same errors when running on the full 90 files. To avoid this
> slight issue, you may run the cleaned version: plot_temperature_cleaned.ncl
>
>
> For information, I'm using NCL v6.3.0.
>
> And "uname -a" returns: Linux monsoon.ccrc.unsw.edu.au
> 2.6.32-573.8.1.el6.x86_64 #1 SMP Tue Nov 10 18:01:38 UTC 2015 x86_64 x86_64
> x86_64 GNU/Linux
>
>
> Thank you very much for your assistance.
>
>
> Maxime.
>
> _______________________________________________
> 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/20160331/e200f2fb/attachment.html 


More information about the ncl-talk mailing list