Re: overlay different maps

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu, 23 Aug 2007 10:17:57 -0600 (MDT)

Hi Ufuk,

Thanks for providing more details. I'll take a closer look at this
and get back to you and the group.

--Mary

On Wed, 22 Aug 2007 turuncu_at_be.itu.edu.tr wrote:

> hi Mary,
>
> thanks for you help. ok, i try to define the problem much more clearly,
>
> i have two different data set which is in different non-uniform grid (the
> lat and lon values is in 2d array). You can think that there are two
> different nested atmospheric model domain and i want to plot terrain
> height data for them in same plot.
>
> Each of the data is in different resolution, so same plot must be contain
> each one of the domain data. The finer domain data must be overlay into
> coarser one. I write following code to do this after posting mail to list,
>
> ...
> ...
> res.tfDoNDCOverlay = True
> ...
> ...
> ## first domain plot
> dims = m1t.shape
> r = m1t.rank
> r1 = dims[r-1]
> r2 = dims[r-2]
> res.mpLeftCornerLatF = float(m1lat[0][r1-1])
> res.mpLeftCornerLonF = float(m1lon[0][r1-1])
> res.mpRightCornerLatF = float(m1lat[r2-1][0])
> res.mpRightCornerLonF = float(m1lon[r2-1][0])
> plot1 = Ngl.contour_map(wks, transpose(m1t[0]), res)
>
> ## second domain plot
> res2 = Ngl.Resources()
> list = Ngl.crt_dict(res)
> for key in list.keys():
> if (key[0:2] == 'cn' or key[0:2] == 'sf' or key[0:3] == 'ngl'):
> setattr(res2,key,list[key])
>
> m2lon = m2.variables["lon"]
> m2lat = m2.variables["lat"]
> dims = m2t.shape
> r2 = m2t.rank
> r21 = dims[r-1]
> r22 = dims[r-2]
> res2.sfYArray = m2lat[0,:]
> res2.sfXArray = m2lon[:,0]
> plot2 = Ngl.contour(wks, transpose(m2t[0]), res2)
> Ngl.overlay(plot1, plot2)
>
> in this script m1lon and m1lat represents the domain 1 data and m2lat and
> m2lon for domain2. I don't use the overlay for two Ngl.contor_map plot as
> you know. For this reason i try to define sfXArray and sfYArray but in
> this case lat and lon values is in 2 dimensional array and i could not
> give the positions of the grids correctly. as a result, inner plot is not
> fit into second one.
>
> You can find sample plot in,
>
> http://kullanici.be.itu.edu.tr/~turuncu/terrain.ps
>
> so, i hope this help you.
>
> best regards,
>
> ufuk
>
>>> hi,
>>>
>>> is it possible to overlay to different contour_map plot? generic overlay
>>> function does not allow this kind of plot.
>>>
>>> best regards,
>>>
>>> ufuk utku turuncoglu
>>
>>>
>>
>> Hi Ufuk,
>>
>> I'm not sure what you mean by "different contour_map plot". I believe
>> once you've overlaid an object on another one, you can't then overlay
>> it on different one. You will need to recreate it.
>>
>> That is, if you have something like this:
>>
>> map1 = Ngl.map(wks,res1)
>> map2 = Ngl.map(wks,res2)
>> contour = Ngl.contour(wks,t,cnres)
>> Ngl.overlay(map1,contour)
>>
>> You can't then do this:
>>
>> Ngl.overlay(map2,contour)
>>
>> as you will get an error:
>>
>> fatal:NhlAddOverlay: tranform is already an annotation or overlay: 84
>>
>> You will instead need to do this:
>>
>> map1 = Ngl.map(wks,res1)
>> map2 = Ngl.map(wks,res2)
>> contour1 = Ngl.contour(wks,t,cnres) ; contour1 and contour2
>> contour2 = Ngl.contour(wks,t,cnres) ; are identical
>> Ngl.overlay(map1,contour1)
>> Ngl.overlay(map2,contour2)
>>
>> Some more background: when you call Ngl.contour_map, what's returned
>> is effectively the id for the map plot. Since you can't overlay one
>> map on another map, you can't overlay two Ngl.contour_maps on each
>> other.
>>
>> You don't really need to generate the map multiple times anyway. What
>> you want to do is generate a map plot once, with a call to something
>> like Ngl.contour_map or Ngl.map, and then generate the second plot you
>> want to overlay with a call to something like Ngl.contour.
>>
>> Please see the "overlay1.py" example at:
>>
>> http://www.pyngl.ucar.edu/Examples/gallery.shtml
>>
>> In this script you will see the code:
>>
>> map_plot = Ngl.map(wks,mpres)
>> vector_plot = Ngl.vector(wks,ua,va,vcres)
>> line_contour_plot = Ngl.contour(wks,pa,clres)
>> fill_contour_plot = Ngl.contour(wks,ta,cfres)
>> #
>> # Overlay everything on the map plot.
>> #
>> Ngl.overlay(map_plot,fill_contour_plot)
>> Ngl.overlay(map_plot,line_contour_plot)
>> Ngl.overlay(map_plot,vector_plot)
>>
>> Note that the map_plot is being used as the base for all of the
>> overlays. This is necessary when you do overlays involving a map.
>>
>> --Mary
>>
>>
>> On Wed, 22 Aug 2007, [BE] Ufuk Utku Turuncoglu wrote:
>>
>
>
>
_______________________________________________
pyngl-talk mailing list
pyngl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Thu Aug 23 2007 - 10:17:57 MDT

This archive was generated by hypermail 2.2.0 : Thu Aug 23 2007 - 10:48:58 MDT