;+ ; NAME: ; FRAMEVECTOR_EC2VER ; PURPOSE: ; Convert Ecliptic coordinates to coordinates in a reference frame ; attached to a shape model ; ; CALLING SEQUENCE: ; VECTOR = FRAMEVECTOR_EC2VER( V, SPIN, EP ) ; ; INPUT: ; V = One or several vectors to be converted [3xn array] ; ; SPIN = A structure containing the spin parameters. Required fields are: ; .LON = ECJ2000 longitude of the spin axis ; .LAT = ECJ2000 latitude of the spin axis ; .PD = Sidereal rotation period (day) ; .JD0 = Reference epoch (JD) ; .PHI0 = Rotation phase reference (deg) ; ; EP = Epoch at which the transformation is sought (ISO or JD) ; ; OUTPUT: ; VECTOR = The input vector converted from the ecliptic to the ; shape reference frame ; ; OPTIONAL INPUT KEYWORDS: ; ; MODIFICATION HISTORY: ; Original Version written in November 2013, B. Carry (IMCCE) ; 2013 Nov. - B.Carry (IMCCE) - ;- function frameVector_ec2ver, V, SPIN, EP COMPILE_OPT hidden, idl2 ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--I.1-- Input Vector ----------------------------------------------------------------- dims = size(V) case dims[0] of 1: Nv=1 2: Nv=dims[2] else: begin message, 'Input vector can only have one or two dimensions' return, -1 end endcase if dims[1] ne 3 then begin message, 'Input vector must contain 3-D vector (cartesian xyz coordinates)' return, -1 endif ;--I.2-- Input Spin Structure --------------------------------------------------------- spinFields = tag_names(spin) spinRequis = ['LON', 'LAT', 'PD', 'JD0', 'PHI0'] nbRequis = n_elements(spinRequis) for k=0, nbRequis-1 do begin pField=where( strCmp(spinRequis[k], spinFields, /FOLD) ) if pField[0] eq -1 then begin message, 'Field '+strTrim(spinRequis[k],2)+' missing in spin structure' return, -1 endif endfor ;--I.3-- Input Epoch ------------------------------------------------------------------ epDim = size( ep ) if epDim[1] eq 7 then ep = date_conv(ep,'JULIAN') ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Create the Rotation Matrix -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--II.1-- Rotation from Spin Axis Coordinates ------------------------------------------ T3D, /RESET, matrix=Rz1, rotate=-[0., 0., spin.lon ] T3D, /RESET, matrix=Ry, rotate=-[0., 90.-spin.lat, 0. ] ;--II.2-- Rotation from Period --------------------------------------------------------- T3D, /RESET, matrix=Rz2, rotate=-[0., 0., spin.phi0 + 360. * (ep-spin.jd0)/spin.pd ] ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Rotate Input Vector and Return -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--III.1-- Format Input Vector for VERT_T3D --------------------------------------------- if Nv eq 1 then V0 = [ [V], [V] ] $ else V0 = V ;--III.2-- Apply Rotation Matrix to Input ----------------------------------------------- V1 = vert_t3d( V0, matrix=Rz1 ) V2 = vert_t3d( V1, matrix=Ry ) V3 = vert_t3d( V2, matrix=Rz2 ) ;--III.3-- Return Rotated Vectors ------------------------------------------------------- if Nv eq 1 then return, V3[*,0] $ else return, V3 end