Re: ellipse function in ncl?

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed, 20 Sep 2006 10:36:04 -0600 (MDT)

>Does NCL have a function to create a graphical ellipse for data?
>I've looked.
>Before, I build one, would anyone happen to have already created such a script?
>
>I am in the middle of trying to create one based of the Matlab code below.

Seems to me the gsn_xy does what u want.

   http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_xy.shtml
   
Just plug in x and y

If u want the major tick marks to be included

   res_at_tmXMajorGrid = True
   res_at_tmYMajorGrid = True
   res_at_mXMajorGridLineDashPattern = 1 ; or 2 ...
   res_at_mYMajorGridLineDashPattern = 1 ; or 2 ...
>
>Erik
>
>**********************************************
>function C=drawellipse(a,b,th,xc,yc,lt)
>%function C=drawellipse(a,b,th,xc,yc,lt)
>%
>% Input: a=semimajor axis length, b=semiminor axis length
>% th=angle between semimajor axis and positive x axis.
>% (xc,yc) are optional inputs specifying the ellipse center
>% lt is an optional input specifying the line type
>% Output: rotation matrix
>% Author: E. Noble, University of Colorado 2/2005
>
>E=0:pi/100:2*pi;
>x=a*cos(E);
>y=b*sin(E);
>
>C=[cos(th) -sin(th); sin(th) cos(th)];
>
>z=C*[x;y];
>
>if (nargin == 4)
> ltt=xc;
>elseif (nargin == 6)
> ltt=lt;
>else
> ltt='g';
>end
>
>if (nargin > 4)
> z=[z(1,:)+xc; z(2,:)+yc];
>end
>
>plot(z(1,:),z(2,:),ltt)
>_______________________________________________

I don't know matlab.

   procedure rotate (x,y,theta)
   ; return the rotated coordinates
   local xtmp, ytmp, th
   begin
     xtmp = x
     ytmp = y
     
     rad = 4.*atan(1.)/180.
     th = theta*rad
     
     x = xtmp*cos(th) - ytmp*sin(th)
     y = xtmp*sin(th) + ytmp*cos(th)
   end
      
or

   function rotate (x,y,theta)
   ; return the rotated coordinates
   local xtmp, ytmp, th
   begin
     N = dimsizes(x)
     xy = new ( (/N,2/), typeof(x) )
     
     rad = 4.*atan(1.)/180.
     th = theta*rad
     
     xy(:,0) = x*cos(th) - y*sin(th)
     xy(:,1) = x*sin(th) + y*cos(th)
     return(xy)
   end

         
   

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 20 2006 - 10:36:04 MDT

This archive was generated by hypermail 2.2.0 : Mon Sep 25 2006 - 11:45:07 MDT