;+
; NAME:
;	v4canon
; PURPOSE:
;	Canonicalize a 4-vector (adjust units to the standard ones)
; AUTHOR:
;	Craig DeForest
; CALLING SEQUENCE:
;	v4out = v4canon(v4in)
; HISTORY: 
;	Written Oct 97
;	9-Dec-97: We force numeric structuresto be doubles!
;-
function v4canon,ina
in = ina
a = getv4type(in)
if(not data_chk(a,/struct)) then return,in

doublify= [0,0,0,0]

for i=0,3 do begin
	if(isnum(in.(i),/real)) then begin
		doublify(i) = (data_chk(in.(i),/type) eq 4)
		z = zunits(a.units(i),in.(i+5))
		if(z(0) eq 0) then begin
			print,"V4CANONICALIZE: Inconsistent units ",a.units(i)," vs. ",in.(i+5)
			return,in
		end
		in.(i) = in.(i) * z
		
		in.(i+5) = a.units(i)
	end
end

if(total(doublify) gt 0) then begin
	if doublify(0) then x0 = double(in.(0)) else x0 = in.(0)
	if doublify(1) then x1 = double(in.(1)) else x1 = in.(1)
	if doublify(2) then x2 = double(in.(2)) else x2 = in.(2)
	if doublify(3) then x3 = double(in.(3)) else x3 = in.(3)
	return,v4(x0,x1,x2,x3,in.(4),in.(5),in.(6),in.(7),in.(8),in.(9))
end else return,in
end
	
	