Re: position of the value 0 in cnLevels to be represented by white colour.

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Mar 10 2011 - 08:14:23 MST

Instead of

getvalues plot(ptn)

try

getvalues plot@contour

In the example I gave you, "plot" was a contour plot. In your case, it's a map. The contour plot is "attached" to the "plot" variable via the "contour" attribute.

--Mary

On Mar 10, 2011, at 6:23 AM, gibies george wrote:

>
>
> On 10 March 2011 10:09, gibies george <gibies@tropmet.res.in> wrote:
> Thank you Mary,
>
> This is exactly what I was looking for.
>
>
> But the script
>
> plot(ptn) = gsn_csm_contour_map(wkspnl,\
> data({region@latsouth:region@latnorth},{region@lonwest:region@loneast},j,pos),resc)
> ;---Retrieve contour levels
> getvalues plot(ptn)
> "cnLevels" : levels ;;;; Here is line 1968 in file script1.ncl
> end getvalues
>
> nlevels = dimsizes(levels)
>
> shows an error :
>
> warning:gsnScalarContour is not a valid resource in rain_tropics_dem_ecmwf_Climatology_contour at this time
> warning:cnLevels is not a valid resource in map at this time
> warning:NhlGetValues:Error retrieving cnLevels
> fatal:Execute: Error occurred at or near line 1968 in file script1.ncl
>
>
> On 10 March 2011 01:28, Mary Haley <haley@ucar.edu> wrote:
> Gibies,
>
> Instead of using gsnSpreadXXXX, you will probably need to set the cnFillColors resource to an array of color indexes, so you can control which contour level gets which color index.
>
> If you are setting the contour levels yourself, then you should be able to determine what to set cnFillColors to.
>
> If you are letting NCL select the contour levels, then you will need to let NCL create the plot, and thn afterwards use "getvalues" to retrieve the "cnLevels" resource and construct cnFillColors based on those values.
>
> Something like this:
>
> . . .
> plot = gsn_csm_contour_map(wks,data,res)
>
> ;---Retrieve contour levels
> getvalues plot
> "cnLevels" : levels
> end getvalues
>
> nlevels = dimsizes(levels)
>
> ;---Create array containing fill indexes.
> colors = new(nlevels+1,integer)
> ii = ind(levels.ge.0)
> num_neg = ii(0)
> num_pos = nlevels-num_neg+1
>
> colors(0:num_neg-1) = ispan(2,51,toint(51/(num_neg-1)))
> colors(num_neg:) = ispan(53,103,toint(51/(num_pos-1)))
>
> res@cnFillColors= colors
> plot = gsn_csm_contour_map(wks,data,res)
>
>
>
> You will need to modify this based on whether you have a contour level exactly equal to 0 or not.
>
> --Mary
>
>
> On Mar 9, 2011, at 3:51 AM, gibies george wrote:
>
>> Thank you Mary for the response.
>>
>> I am using gsn_csm_contour_map with "ViBlGrWhYeOrRe" colour-map
>>
>> I wish to have :
>>
>> the colours from 1 to 51 ie "ViBlGr" to be used for negative values.
>> the colour 52 ie "White" to be used for zero.
>> the colours from 53 to 103 ie "YeOrRe" to be used for positive values.
>>
>> I tried to manage it using gsnSpreadColorStart and gsnSpreadColorEnd in the cases when (data_min .gt. 0) or (data_max .lt. 0) but I don't know how to handle the case when (data_min .lt. 0) .and. (data_max .gt. 0) which i really want.
>>
>> I am afraid that I may not get full range of color map while using "gsn_contour_shade"
>>
>>
>> On 9 March 2011 03:57, Mary Haley <haley@ucar.edu> wrote:
>> Maybe "gsn_contour_shade" is what you're looking for:
>>
>> http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_contour_shade.shtml
>>
>>
>>
>>
>> --Mary
>>
>> On Mar 8, 2011, at 5:47 AM, gibies george wrote:
>>
>>> How can I get the position of the value 0 in cnLevels while setting the resources for contour plot ?
>>>
>>> My requirement is as follows.
>>>
>>> I would like to get white to represent the value near to zero in contour interval irrespective of the data range.
>>> ---------
>>> ----------
>>> -----------
>>>
>>> gsn_define_colormap(wkspnl,"ViBlGrWhYeOrRe")
>>> white = 52
>>> data_min = min(data)
>>> data_max = max(data)
>>>
>>> if (data_min .gt. 0)
>>> resc@gsnSpreadColorStart = white
>>> resc@cnLevelSelectionMode = "ManualLevels"
>>> resc@cnMinLevelValF = 0
>>> end if
>>>
>>> if (data_max .lt. 0)
>>> resc@gsnSpreadColorEnd = white
>>> resc@cnLevelSelectionMode = "ManualLevels"
>>> resc@cnMaxLevelValF = 0
>>> end if
>>>
>>> if ((data_min .lt. 0) .and. (data_max .gt. 0))
>>> ----------
>>> ???????
>>> ----------
>>> end if
>>> ----------------------
>>> -----------------------
>>> ----------------------
>>>
>>> How can I implement this?
>>>
>>>
>>> --
>>> Gibies George, CSIR-RF,
>>> Seasonal Scale Prediction Group,
>>> Climate and Global Modelling Division,
>>> Indian Institute of Tropical Meteorology,
>>> Dr. Homi Bhabha Road,
>>> NCL (P. O.), Pashan,
>>> Pune 411008, India.
>>>
>>> http://sites.google.com/site/gibiesge/
>>>
>>> Please Think about the environment. Save paper; Save Trees; and don't print this e-mail unless it is necessary.
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>>
>>
>> --
>> Gibies George, CSIR-RF,
>> Seasonal Scale Prediction Group,
>> Climate and Global Modelling Division,
>> Indian Institute of Tropical Meteorology,
>> Dr. Homi Bhabha Road,
>> NCL (P. O.), Pashan,
>> Pune 411008, India.
>>
>> http://sites.google.com/site/gibiesge/
>>
>> Please Think about the environment. Save paper; Save Trees; and don't print this e-mail unless it is necessary.
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> --
> Gibies George, CSIR-RF,
> Seasonal Scale Prediction Group,
> Climate and Global Modelling Division,
> Indian Institute of Tropical Meteorology,
> Dr. Homi Bhabha Road,
> NCL (P. O.), Pashan,
> Pune 411008, India.
>
> http://sites.google.com/site/gibiesge/
>
> Please Think about the environment. Save paper; Save Trees; and don't print this e-mail unless it is necessary.
>
>
>
> --
> Gibies George, CSIR-RF,
> Seasonal Scale Prediction Group,
> Climate and Global Modelling Division,
> Indian Institute of Tropical Meteorology,
> Dr. Homi Bhabha Road,
> NCL (P. O.), Pashan,
> Pune 411008, India.
>
> http://sites.google.com/site/gibiesge/
>
> Please Think about the environment. Save paper; Save Trees; and don't print this e-mail unless it is necessary.

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Mar 10 08:14:32 2011

This archive was generated by hypermail 2.1.8 : Thu Mar 10 2011 - 21:44:37 MST