[ncl-talk] Adding a Legend to Shapefile Plot
Rick Brownrigg
brownrig at ucar.edu
Mon Dec 21 11:44:18 MST 2015
Hi Carlos,
I don't recall the before and after state of your script. But in general,
NCL is what I would call "loosely typed": you don't have to declare the
type of a variable in advance, but once you make an assignment to a
variable name, the variable assumes the type of the right-hand-side. If
the RHS is an array, the variable further assumes the shape of the array.
Attempts to reassign the variable to a RHS of a different type/shape will
lead to the "assignment type mismatch" error. The exception is if the RHS
can be cast to a type of the variable. So for example:
a = 10.5
a = 10 ; OK -- int is cast to a float
b = 10
b = 10.5 ; error -- can't cast a float to an int
If you need/want to reuse a variable name, you "delete()" it first.
Make sense?
Rick
On Mon, Dec 21, 2015 at 10:58 AM, Carlos J. Valle-Diaz <
cj.vallediaz at gmail.com> wrote:
> Hi Rick,
>
> Related to your 3rd suggestion: when I ran the script before I
> incorportated the codes to create the legend, I did not have a mismatch
> error. The script generated the colored markers with the black circles as
> you showed me in a previous conversation. Why would it present a mismatch
> error after adding the codes creating the legend?
>
> Carlos
>
> On Mon, Dec 21, 2015 at 1:37 PM, Carlos J. Valle-Diaz <
> cj.vallediaz at gmail.com> wrote:
>
>> I'll check these right now and will let you know. Thank you very much.
>>
>> I apologize for writing multiple emails on the same topic. Won't happen
>> again!
>>
>> Carlos
>>
>> On Mon, Dec 21, 2015 at 12:45 PM, Rick Brownrigg <brownrig at ucar.edu>
>> wrote:
>>
>>> The script you attached to your original posting has numerous bugs, and
>>> will not even run as is. The do-loop at around line 82 is missing an "end
>>> do". Fixing that problem allows the script to run, but there are 3 other
>>> errors that are likely causing your problem:
>>>
>>> i) the variable "R" is undefined (around line 34)
>>>
>>> ii) xleg (and other related arrays) contain only 8 values, whereas you
>>> are looping over "num_distinct_makers", which is equal to 17 (around line
>>> 90)
>>>
>>> iii) the "assignment type mismatch" at around line 103 arises because in
>>> a previous loop, you set gsMarkerColor to an integer value, and then at
>>> 103, you are setting it to a value from the colortable, which is either a 3
>>> or 4-tuple of floats. You'll want to "delete(gsres at gsMarkerColor)"
>>> between the two do-loops.
>>>
>>> Hope that helps...
>>> Rick
>>>
>>>
>>> On Mon, Dec 21, 2015 at 8:39 AM, Carlos J. Valle-Diaz <
>>> cj.vallediaz at gmail.com> wrote:
>>>
>>>> Hello,
>>>>
>>>> I'm writing to ask if somebody from NCL-talk has read my email and/or
>>>> currently is answering it. I'm kind of in a rush to have these plots ready
>>>> before Christmas. I apologize for my insistence.
>>>>
>>>> Best Regards,
>>>>
>>>> Carlos
>>>>
>>>> On Fri, Dec 18, 2015 at 4:52 PM, Carlos J. Valle-Diaz <
>>>> cj.vallediaz at gmail.com> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I've been running WRF simulations to observe 24hr precipitation in
>>>>> Puerto Rico from (July 12, 2011 12UTC to July 13, 2011 12UTC). I want to
>>>>> compare the model runs with the observed from the National Weather Service.
>>>>> I have their hourly shapefiles, see link to access them:
>>>>> http://www.srh.noaa.gov/ridge2/Precip/qpehourlyshape/2011/201107/20110712/).
>>>>> In the shapefiles, Globvalue refers to precipitation.
>>>>>
>>>>> I've been trying all day to add a legend to my plot, but haven't been
>>>>> successful. I've been using example #7 in the legends section of NCL as a
>>>>> reference. See leg_7.ncl at
>>>>> http://ncl.ucar.edu/Applications/legend.shtml
>>>>>
>>>>> I have attached the script I have at the moment. It plots fine when
>>>>> you take out the lines that codes for the legend and text. What am I
>>>>> missing and/or doing wrong?
>>>>>
>>>>> Thanks beforehand for the help,
>>>>>
>>>>> P.S. I set up the array(arr) data for 16 values because I'm using a
>>>>> color map that displays 17 colors.
>>>>> --
>>>>> Carlos J. Valle Diaz
>>>>> Ph.D. Chemistry Student
>>>>> University of Puerto Rico Rio Piedras Campus
>>>>> Department of Graduate Chemistry and Environmental Sciences
>>>>> cj.vallediaz at gmail.com
>>>>> Tel. 787-764-0000 x88192
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Carlos J. Valle Diaz
>>>> Ph.D. Chemistry Student
>>>> University of Puerto Rico Rio Piedras Campus
>>>> Department of Graduate Chemistry and Environmental Sciences
>>>> cj.vallediaz at gmail.com
>>>> Tel. 787-764-0000 x88192
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> ncl-talk at ucar.edu
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>>
>>>
>>
>>
>> --
>> Carlos J. Valle Diaz
>> Ph.D. Chemistry Student
>> University of Puerto Rico Rio Piedras Campus
>> Department of Graduate Chemistry and Environmental Sciences
>> cj.vallediaz at gmail.com
>> Tel. 787-764-0000 x88192
>>
>
>
>
> --
> Carlos J. Valle Diaz
> Ph.D. Chemistry Student
> University of Puerto Rico Rio Piedras Campus
> Department of Graduate Chemistry and Environmental Sciences
> cj.vallediaz at gmail.com
> Tel. 787-764-0000 x88192
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151221/a0b0afcb/attachment.html
More information about the ncl-talk
mailing list