<div dir="ltr">Hi Rabah,<div><br></div><div>As far as I know, gsn_define_colormap does not support RGBA colors, but I can't immediately find that in the documentation. If you want to use all of the colors in your color array, directly assign res@cnFillColors = colors (or colors(:,0:2) if you only want the first three colors) and this will set all of the colors in that array to be used in the FillColors. However, I believe the "more proper" way is to use cnFillPalette, as specified in the link I sent you in the last email.</div>
<div><br></div><div><br></div><div>Kyle</div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">----------------------------------------<div>Kyle S. Griffin</div><div>Department of Atmospheric and Oceanic Sciences</div>
<div>University of Wisconsin - Madison</div><div>Room 1421</div><div>1225 W Dayton St, Madison, WI 53706</div><div>Email: <a href="mailto:ksgriffin2@wisc.edu" target="_blank">ksgriffin2@wisc.edu</a></div></div></div>
<br><br><div class="gmail_quote">On Thu, Aug 28, 2014 at 10:17 PM, Rabah Hachelaf <span dir="ltr"><<a href="mailto:hachelaf@sca.uqam.ca" target="_blank">hachelaf@sca.uqam.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi Kyle,<div><br></div><div>I think your suggestion doesn't work because when i add the 4th values for opacity i get this message ; </div><div><div>(0) Warning: gsn_define_colormap: cmap must either be an n x 3 float array,</div>
<div>(0) a single pre-defined colormap name, or a 1-dimensional string array of named colors.</div></div><div><br></div><div>i simplified my script like this : </div><div><br></div><div><div>colors = (/ (/255,255,255,1/), (/163,255,163,125/), (/255,178,102,200/) /) * 1.0</div>
<div>colors= colors/255.</div><div>print(colors)</div><div> </div><div>gsn_define_colormap(wks,colors)</div></div><div>......</div><div>......<br></div><div><div>.........</div><div class=""><div>res@cnLevelSelectionMode = "ExplicitLevels" <span style="white-space:pre-wrap">                        </span>; set explicit contour levels</div>
<div>res@cnLevels = (/ 40,70,100/)<span style="white-space:pre-wrap">        </span>; set levels</div></div><div>res@cnFillColors = (/ 0,1,2/)</div></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2014-08-28 22:42 GMT-04:00 Kyle Griffin <span dir="ltr"><<a href="mailto:ksgriffin2@wisc.edu" target="_blank">ksgriffin2@wisc.edu</a>></span>:<div><div class="h5"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">You should be able to just add a fourth value to your RGB triplets to make them RGBA (A for alpha) quadruplets. Since you already divide the numbers out of 255, you can simply add the alpha on the same scale, with 0 = transparent and 1=opaque (or 255, in your case).<div>
<br></div><div>More of the problem is that you don't seem to be assigning the color array you create at the beginning of the script to the cnFillColors resource you set later on. Look at some of the examples on the NCL website discussing how to work with the new color capabilities at: <a href="http://www.ncl.ucar.edu/Applications/rgbacolor.shtml" target="_blank">http://www.ncl.ucar.edu/Applications/rgbacolor.shtml</a></div>
<div><br></div><div><br></div><div>Kyle</div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">----------------------------------------<div>Kyle S. Griffin</div><div>Department of Atmospheric and Oceanic Sciences</div>
<div>University of Wisconsin - Madison</div><div>Room 1421</div><div>1225 W Dayton St, Madison, WI 53706</div><div>Email: <a href="mailto:ksgriffin2@wisc.edu" target="_blank">ksgriffin2@wisc.edu</a></div></div></div>
<br><br><div class="gmail_quote"><div><div>On Thu, Aug 28, 2014 at 8:44 PM, Rabah Hachelaf <span dir="ltr"><<a href="mailto:hachelaf@sca.uqam.ca" target="_blank">hachelaf@sca.uqam.ca</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
<div dir="ltr"><div class="gmail_quote"><br><div dir="ltr">Hi all ,<div><br></div><div>I am using the script below to plot humidity between 40-70%(green) and 70-100% (orange).</div><div><br></div><div>I want to know if i can set the opacity for each color for example opacity 50% for the green color and 100% for the orange. </div>
<div><br></div><div>Thanks for help.</div><div><br></div><div><div>;************************************************</div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" </div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" </div>
<div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" </div><div>;************************************************</div><div>begin</div><div> a = addfile("gfs.t00z.pgrb2f00.grib2","r")</div>
<div> lon = a->lon_0</div><div> lat = a->lat_0</div><div> icing = short2flt(a->RH_P0_L100_GLL0({50000},:,:))</div><div><br></div><div>print(icing(1:4,1:4))</div><div>;********************************************************</div>
<div>; Display parameters</div><div>;***************************************</div><div>zoom="test"</div><div>pixel=2048</div><div>;***************************************************</div><div><br></div><div>wks_type="png"</div>
<div><br></div><div> wks_type@wkWidth = pixel</div><div> wks_type@wkHeight = pixel</div><div> wks_type@wkBackgroundOpacityF = 0.0</div><div>wks = gsn_open_wks(wks_type,"icing_test")</div><div><br></div><div>
colors = (/ (/255,255,255/),(/0,0,0/),(/255,255,255/), (/244,255,244/), \</div><div> (/217,255,217/), (/163,255,163/), (/106,255,106/), \</div><div> (/43,255,106/), (/0,224,0/), (/0,134,0/),(/255,145,0/),\</div>
<div> (/255,178,102/) /) * 1.0 ; we multiply by 1 to make colors float</div><div><br></div><div>colors = colors/255.</div><div><br></div><div> </div><div>gsn_define_colormap(wks,colors)</div><div><br></div>
<div>
<br></div><div>res = True</div><div> res@mpProjection = "Mercator" ; choose projection</div><div> res@mpGridAndLimbOn = False ; turn on lat/lon lines</div><div> res@mpPerimOn = False ; turn off box around plot</div>
<div> res@mpFillOn = False</div><div> res@mpOutlineOn = True </div><div> res@cnFillOn = True ; color plot desired</div><div> res@cnLineLabelsOn = False ; turn off contour lines</div>
<div> res@mpLimitMode = "LatLon"</div><div> res@mpMinLatF = -85.0</div><div> res@mpMaxLatF = 85.0 </div><div> res@mpMinLonF = -180</div><div> res@mpMaxLonF = 180</div>
<div> res@vpXF = 0 ; make plot bigger</div><div> res@vpYF = 1 </div><div> res@vpWidthF = 1</div><div> res@vpHeightF = 1</div><div><br></div><div>res@cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour levels</div>
<div>res@cnLevels = (/ 40,70,100/)<span style="white-space:pre-wrap">        </span>; set levels</div><div>res@cnFillColors = (/ -1,5,11/)</div><div><br></div><div>;res@cnFillOpacityF=0.5</div></div><div> <br clear="all">
<div>contour0 = gsn_csm_contour_map(wks,icing,res) ; create the plot<span><font color="#888888"><br></font></span></div><span><font color="#888888">-- <br><div dir="ltr"><div>------------------------------</div>
Cordialement,<br>Best regards,<br>Rabah Hachelaf <br> <br><br></div>
</font></span></div></div><span><font color="#888888">
<br></font></span></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><div>------------------------------</div>Cordialement,<br>Best regards,<br>Rabah Hachelaf <br></div>
</font></span></div>
<br></div></div>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div></div></div><div><div class="h5"><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><div>------------------------------</div>Cordialement,<br>Best regards,<br>Rabah Hachelaf <br></div>
</div></div></div>
</blockquote></div><br></div>