# Re: [ferret_users] Trying to understand logic behind stick plot

Thank you mam for reply, I understood it in ferret since it has inbuild function which takes care about line segment but at the end you have used

GO stick_vectors plot ucomp, vcomp

How function "stick_vectors" generates line segments, how it replaces actual U values in x axis with timestamp ?

My array would look something like this, if I take number say starts from 0 - 3, I actually want to replace it with time, otherwise x axis will be negative as it contains U component -3.969 to 3.593

stick1->             [0, 0],[-3.969 + 0,-1.001]

stick2->             [1, 0],[-4.578 + 1, 0.596]

stick3->             [2, 0],[1.593  + 2, 0.484]

stick4->             [3, 0],[-1.622 + 3, 1.580]

The same example in case of ferret

let u = {-3.969,-4.578,1.593,-1.622}
let v = {0.596,-1.001,0.484,1.580}
plot/set/vlim=-2:2:0.1/hlim=-4:4:0.5/vgrat=line/hgrat=line/color=red/thickness=2 u,v
ppl plotuv

- Dona

On Tuesday, July 1, 2014 10:10 PM, Ansley Manke <ansley.b.manke@xxxxxxxx> wrote:

still, you'll need to know the units and origin of the time data, then all of the times can be translated to dates and times inside Ferret.  Is 379987200000 expressed as milliseconds since the start of some year?  Or seconds since some time?  379987200000  is about 12 years' worth of milliseconds, so is this milliseconds since the start of 1970?  This is just a guess. I don't know for sure.

In Ferret, divide by number of days/year, hours/day, minutes/hour, seconds/hour, milliseconds/second:
yes? list 379987200000 /(365.2425*24*3600*1000)
VARIABLE : 379987200000 /(365.2425*24*3600*1000)
12.04
The logic for the time definitions is to convert time coordinates and time origin to calendar time. Maybe that's all you need for what you're doing.  I know that Java has time libraries that will handle these kinds of conversions.

To proceed in Ferret, we would divide the input data by 1000 for time units of seconds:
yes? file/var="t_in, zero, u, v" my_data.dat
yes? define axis/t/units=seconds/t0="1-jan-1970" timeax = t_in/1000

yes? list t[gt=timeax]yes? list t[gt=timeax]
VARIABLE : T
axis TIMEAX
SUBSET   : 4 points (TIME)
16-JAN-1982 00 / 1:  3.800E+08
16-FEB-1982 00 / 2:  3.827E+08
16-MAR-1982 00 / 3:  3.851E+08
16-APR-1982 00 / 4:  3.878E+08

yes? let ucomp = reshape(u,t[gt=timeax])
yes? let vcomp = reshape(v,t[gt=timeax])

yes? GO stick_vectors plot ucomp, vcomp

On 6/30/2014 10:14 PM, Don DNA wrote:
Thank you so much madom for your prompt reply, and sorry for not being clear, actually I am developing application in my school using java, for that I need to understand logic to calcuate timeshift, I need to generate date something like this for line segments

stick = > from [ date , 0 ] to [ newtimeshift_date, v-component ]

will be

stick => from [379987200000 , 0 ] to [ ? , 0.596 ]

and 379987200000 is actually Sat, 16 Jan 1982 00:00:00

I hope you will understand my problem now

- Dona

On Tuesday, July 1, 2014 6:19 AM, Ansley Manke <ansley.b.manke@xxxxxxxx> wrote:

Hi,
Have you been able to read your data into Ferret? UTC simply means Coordinated Universal Time, but what is the data unit?  Seconds, maybe?  and since what time origin? Your data source should tell you more than just "UTC".

Ferret will be able to convert those data to time steps once one knows that.  You would read in the three variables, define a time axis using the first one, and RESHAPE your u and v components to that time axis. Fill in the right things in the DEFINE AXIS command, and you should be set.
yes? file/var="tsec, zero, u, v" my_data.dat
yes? define axis/t/units=seconds/t0="???" timeax = tsec
yes? let ucomp = reshape(u,t[gt=timeax])
yes? let vcomp = reshape(v,t[gt=timeax])
It would be a good idea  to add /UNITS=  on the  LET commands to give the velocity components their correct units.  Then you should be able to try the stick_vectors script to make a plot.

Ansley

On 6/30/2014 5:42 AM, 'Don DNA' via _OAR PMEL Ferret Users wrote:
I read answer from ferret userlist regarding stick plot from here, and I don't have much knowledge about ferret, even to read source code

http://www.pmel.noaa.gov/maillists/tmap/ferret_users/fu_2011/msg00591.html

 View on www.pmel.noaa.gov Preview by Ya

I have "UTC date, u - component, v-component " I am interested to calculate time shift, can someone please help me to calculate time shift for line segments,

My data looks something like this

UTC data, Zero, U-comp, V-component
379987200000,0, -3.969,0.596
382665600000,0, -4.578,-1.001
385084800000,0,1.593,0.484
387763200000,0, -1.622,1.58

Can someone please explain me, time shift for above input, I actually did not understand this "from (c*t, 0) to (c*t+u(t), v(t))", if I just add utc date to U(t) - component I will get very close value and I will not get slope, please help me..

- Dona