[ncl-talk] Why do I get "warning:gsnLeftString is not a valid resource in Plots00-P850_28_00Z_contour at this time"

Zilore Mumba zmumba at gmail.com
Tue Apr 5 12:24:38 MDT 2022


Joseph, sorry I did not show all the code because I did not want to put too
much text. There are contouring of rh and other variables before the map
overlay. Below is the code I left out before doing the overlays..
      ; Plotting options for RH
        opts = res
        opts at cnFillOn = True
        opts at pmLabelBarOrthogonalPosF = -0.1
        opts at ContourParameters = (/ 10., 90., 10./)
        opts at cnFillColors = (/"White","White","White", \
                              "White","Chartreuse","Green",\
                              "Green3","Green4", \
                              "ForestGreen","PaleGreen4"/)
        contour_rh = wrf_contour(files_all[it],wks,rh_plane,opts)
        delete(opts)

      ; Plotting options for Wind Speed
        opts = res
        opts at cnLineColor = "MediumSeaGreen"
        opts at ContourParameters = (/ 10. /)
        opts at cnInfoLabelOrthogonalPosF = 0.07  ; offset second label
information
        opts at gsnContourLineThicknessesScale = 3.0
        contour_spd = wrf_contour(files_all[it],wks,spd,opts)
        delete(opts)

      ; Plotting options for Wind Vectors
        opts = res
        opts at FieldTitle = "Wind"   ; overwrite Field Title
        opts at NumVectors = 47       ; wind barb density
        vector = wrf_vector(files_all[it],wks,u_plane,v_plane,opts)
        delete(opts)

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, Apr 5, 2022 at 5:24 PM Joseph Clark <jpclark186000 at gmail.com> wrote:

> Oh I see that now.
>
> It looks like you are overlaying contour_tc with plots named contour_rh
> and contour_height. I can't see where these plots are produced in your
> code. Is it possible that contour_rh and contour_height have gsnLeftString
> and gsnRightStrings set to values?
>
> Joe
>
> On Tue, Apr 5, 2022 at 11:08 AM Zilore Mumba <zmumba at gmail.com> wrote:
>
>> Thanks Joseph for your intervention. res at gsn.. are actually being
>> captured. This is through,firstly there is res=True, then before opts is
>> used there is opts=res. I confirm they are captured by printing
>> print(opts). In that print the fields are there. The output of
>> "print(opts)" is
>> Variable: opts
>> Type: logical
>> Total Size: 4 bytes
>>             1 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [1]
>> Coordinates:
>> Number Of Attributes: 10
>>   gsnContourLineThicknessesScale : 2
>>   cnInfoLabelOrthogonalPosF : 0.07
>>   ContourParameters : 5
>>   cnLineColor : Red
>>   MainTitle : WRF MODEL OUTPUT
>>   Footer : False
>>   cnInfoLabelOn : False
>>   gsnCenterString :
>>   gsnLeftString :
>>   gsnRightString :
>> (0) True
>>
>>
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free.
>> www.avast.com
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>> <#m_-8376375158042282936_m_-1919973380634856049_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On Tue, Apr 5, 2022 at 4:28 PM Joseph Clark <jpclark186000 at gmail.com>
>> wrote:
>>
>>> Hi Zilore,
>>>
>>> Just a regular NCL user here. I looked through your code. It doesn't
>>> seem like your variable "res" is being used in the plot. Instead you are
>>> using pltres and mpres. Maybe try adding the following lines anywhere below
>>> the lines that read "mpres = True" and "pltres = True"
>>>
>>> pltres at gsnLeftString = ""
>>> pltres at gsnRightString = ""
>>> pltres at gsnCenterString = ""
>>> mpres at gsnLeftString = ""
>>> mpres at gsnRightString = ""
>>> mpres at gsnCenterString = ""
>>>
>>> Joe
>>>
>>>
>>> On Tue, Apr 5, 2022 at 5:55 AM Zilore Mumba via ncl-talk <
>>> ncl-talk at mailman.ucar.edu> wrote:
>>>
>>>> In my wrf plot script below, I am trying to suppress the left, center
>>>> and right string as well as the label at the bottom right. None of the wrf
>>>> script examples I have seen has these fields suppressed.  My gsn and cn
>>>> resources (marked in blue in the code below) do not seem to have any
>>>> effect, hence the warning message.
>>>> When I print these resources (in purple below) they are captured ok.
>>>> Is it that with this kind of plot one cannot suppress these fields?
>>>>
>>>>
>>>> ;   Example script to produce plots for a WRF real-data run,
>>>> ;   with the ARW coordinate dynamics option.
>>>> ;   Interpolating to specified pressure levels
>>>>
>>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>>>>
>>>> begin
>>>> ;
>>>> ; The WRF ARW input file.
>>>>      DATADir = "/home/zmumba/DA/OUTPUT/2022022800/noda/"
>>>>      FILES = systemfunc (" ls -1 " + DATADir + "wrfout_d01* ")
>>>>      numFILES = dimsizes(FILES)
>>>>
>>>>      files_all = addfiles(FILES+".nc","r")
>>>>
>>>> ; We generate plots, but what kind do we prefer?
>>>> ;  type = "x11"
>>>> ;  type = "pdf"
>>>> ; type = "ps"
>>>> ; type = "ncgm"
>>>>   type = "png"
>>>> ;  wks = gsn_open_wks(type,"plt_PressureLevel1")
>>>>
>>>> ; Set some Basic Plot options
>>>>   res = True
>>>>   res at MainTitle                   = "WRF MODEL OUTPUT"
>>>>   res at Footer = False
>>>>
>>>>   res at cnInfoLabelOn = False ; Suppress text "CONTOUR FROM # TO # by #"
>>>>   res at gsnCenterString = "" ;"gsnCenterString ~C~ ~Z80~ (Default: None)"
>>>>   res at gsnLeftString   = "" ;"gsnRightString ~C~ ~Z80~ (Default:
>>>> Long_Name)"
>>>>   res at gsnRightString  = "" ;"gsnRightString ~C~ ~Z80~ (Default: Units)"
>>>>
>>>>   pltres = True
>>>>   mpres = True
>>>>   mpres at mpFillOn                    = False        ; turn off gray fill
>>>>   mpres at mpOutlineBoundarySets       = "National"   ; turn on country
>>>> boundaries
>>>>   mpres at mpGeophysicalLineColor      = "Navy"       ; color of cont.
>>>> outlines
>>>>   mpres at mpGeophysicalLineThicknessF = 1.5          ; thickness of
>>>> outlines
>>>>   mpres at mpNationalLineColor         = "Black"
>>>>   mpres at mpNationalLineThicknessF    = 2.5          ; turn on country
>>>> boundaries
>>>>
>>>>   mpres at mpDataBaseVersion           = "MediumRes"  ; choose higher
>>>> resolution
>>>>   mpres at mpDataSetName               = "Earth..4"   ; choose most
>>>> recent boundaries
>>>>
>>>>   mpres at mpMaxLatF                   = -4           ; choose subregion
>>>>   mpres at mpMinLatF                   = -21
>>>>   mpres at mpMaxLonF                   =  37
>>>>   mpres at mpMinLonF                   =  21
>>>>
>>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>>
>>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>>
>>>> ; What times and how many time steps are in the data set?
>>>>   times = files_all[:]->Times
>>>>   ntimes = dimsizes(times)         ; number of times in the file
>>>>
>>>> ; The specific pressure levels that we want the data interpolated to.
>>>>   pressure_levels = (/ 850., 700., 500., 300./)   ; pressure levels to
>>>> plot
>>>>   nlevels         = dimsizes(pressure_levels)     ; number of pressure
>>>> levels
>>>>
>>>>
>>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>>
>>>> ;  VTlab = (/ "T+00", T+00", "T+06", "T+12", "T+18", "T+24", "T+30",
>>>> "T+36", "T+42", "T+48"/)   ; Validity for file name
>>>>
>>>> ; get time information and strip out the day and hour
>>>>   times_in_file = files_all[:]->Times
>>>>   dims = dimsizes (times)
>>>>    ntimes = dimsizes (times(:,0))
>>>>
>>>>   times_to_use = new(dims(0),string)
>>>>
>>>>   do i=0,dims(0)-1
>>>>     times_to_use(i) = chartostring(times_in_file(i,8:12))
>>>>   end do
>>>>
>>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>>   do it = 0,ntimes(0)-1,2             ; TIME LOOP
>>>>
>>>>     print("Working on time: " +  times_to_use(it) )
>>>>     res at TimeLabel =  times_to_use(it)   ; Set Valid time to use on
>>>> plots
>>>>
>>>>
>>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>> ; First get the variables we will need
>>>>
>>>>     tc = wrf_user_getvar(files_all,"tc",it)        ; T in C
>>>>     u  = wrf_user_getvar(files_all,"ua",it)        ; u averaged to mass
>>>> points
>>>>     v  = wrf_user_getvar(files_all,"va",it)        ; v averaged to mass
>>>> points
>>>>     p  = wrf_user_getvar(files_all, "pressure",it) ; pressure is our
>>>> vertical coordinate
>>>>     z  = wrf_user_getvar(files_all, "z",it)        ; grid point height
>>>>     rh = wrf_user_getvar(files_all,"rh",it)        ; relative humidity
>>>>
>>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>>     do level = 0,nlevels-1                 ; LOOP OVER LEVELS
>>>>       pressure = pressure_levels(level)
>>>>
>>>>       tc_plane = wrf_user_intrp3d(tc,p,"h",pressure,0.,False)
>>>>       z_plane  = wrf_user_intrp3d( z,p,"h",pressure,0.,False)
>>>>       rh_plane = wrf_user_intrp3d(rh,p,"h",pressure,0.,False)
>>>>       u_plane  = wrf_user_intrp3d( u,p,"h",pressure,0.,False)
>>>>       v_plane  = wrf_user_intrp3d( v,p,"h",pressure,0.,False)
>>>>
>>>>       spd     = (u_plane*u_plane + v_plane*v_plane)^(0.5) ; m/sec
>>>>       spd at description = "Wind Speed"
>>>>       spd at units = "m/s"
>>>>       u_plane = u_plane*1.94386     ; kts
>>>>       v_plane = v_plane*1.94386     ; kts
>>>>       u_plane at units = "kts"
>>>>       v_plane at units = "kts"
>>>>
>>>>       wks = gsn_open_wks(type,"Plots00-" + "P" + pressure_levels(level)
>>>> + "_" + times_to_use(it) + "Z")
>>>>
>>>>       ; Plotting options for T
>>>>         opts = res
>>>>         print(opts))
>>>>
>>>>         opts at cnLineColor = "Red"
>>>>         opts at ContourParameters = (/ 5.0 /)
>>>>         opts at cnInfoLabelOrthogonalPosF = 0.07  ; offset second label
>>>> information
>>>>         opts at gsnContourLineThicknessesScale = 2.0
>>>>         contour_tc = wrf_contour(files_all[it],wks,tc_plane,opts)
>>>>         delete(opts)
>>>>
>>>>        ; MAKE PLOT
>>>>         if ( pressure .eq. 850 ) then   ; plot temp, rh, height, wind
>>>> barbs
>>>>           opts_z at ContourParameters = (/ 20.0 /)
>>>>           contour_height = wrf_contour(files_all[it],wks,z_plane,opts_z)
>>>>           plot =
>>>> wrf_map_overlays(files_all[it],wks,(/contour_rh,contour_tc,contour_height, \
>>>>                                     vector/),pltres,mpres)
>>>>         end if
>>>>
>>>>     end do      ; END OF LEVEL LOOP
>>>>
>>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>>   end do        ; END OF TIME LOOP
>>>> end
>>>>
>>>>
>>>>
>>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free.
>>>> www.avast.com
>>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>>>> <#m_-8376375158042282936_m_-1919973380634856049_m_8223286762302240149_m_4986238943696855104_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> ncl-talk at mailman.ucar.edu
>>>> List instructions, subscriber options, unsubscribe:
>>>> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20220405/51ea1fc3/attachment.html>


More information about the ncl-talk mailing list