;+ ; NAME: ; RemoteView_Init_View ; PURPOSE: ; ; CATEGORY: ; CALLING SEQUENCE: FUNCTION RemoteView_Init_View, $ view_rect = view_rect, $ ecliptic = ecliptic, $ location = location, $ direction = direction, $ time = time, $ view_time = view_time, $ fovsize = FovSize, $ fovtilt = FovTilt, $ degrees = degrees, $ ngrid = nGrid, $ stereo = Stereo, $ eqdistance = EqDistance, $ eqangle = EqAngle, $ eqarea = EqArea, $ earth = Earth, $ silent = silent ; OPTIONAL INPUT PARAMETERS: ; (only one of location, direction, view_time, fovsize and ; fovtilt needs to be specified as an array with trailing ; dimension K to set up an array of views, e.g. if the same ; view is needed for different times then view_time will be an ; array[K], while location is an array[3], direction an ; array[2] and fovsize and fovtilt are scalars). ; ; /degrees ; if set then all angles are in degrees (default is radians) ; /view_rect ; By default, spherical coordinates are used (longitude, ; latitude, heliocentric distance). If /view_rect is set ; rectangular coordinates are used. ; This applies to Location and Direction ; ; /ecliptic ; By default, a heliographic coordinates are used. If /ecliptic is ; set an ecliptic coordinate system is used. ; This applies to Location, Direction and FovTilt ; ; location = location ; array[3] or array[3,K]; type: float ; viewing locations ; Longitude, latitude, heliocentric distance (if /view_rect NOT set), ; or x, y and z coordinates relative to Sun (if /view_rect set). ; The distance unit is AU. The unit for angles depends on the /degree setting. ; If location is not set then a default location is selected ; based on the location of Earth. Currently the default location ; has the same ecliptic longitude as Earth, ecliptic latitude ; of 30 degrees, and a distance of 3 times the Sun-Earth distance. ; ; If keyword location is also specified then parts of location ; that are not set to bad will be inserted in the default viewing ; location. ; ; /earth selects the position of Earth as the viewing location ; If keyword location is also specified then parts of location ; that are not set to bad will be inserted in the viewing ; location. ; ; direction = direction ; array[2] or array[2,K] (if /view_rect NOT set); type: float ; viewing direction for center of field of view as longitude and latitude ; array[3] or array[3,K] (if /view_rect set); type: float ; viewing direction in rectangular coordinates (in AU). Only the direction ; will be used. ; ; The direction is specified in the same coordinate system as the viewer ; location, but with the viewer in the origin. If no direction is specified ; then the direction towards the origin is used. ; ; view_time = view_time ; array[1] or array[K]; type: time structure ; times for all views; if not specified then keyword 'time' is used; ; if this also is not specified the the system time is used. ; ; fovsize = FovSize ; scalar, array[2], array[2,K]; type: float ; Angular half-widths (horizontal and vertical) of rectangular field of view ; If scalar is specified then horizontal and vertical ; size are assumed to be the same. ; ; fovtilt = FovTilt ; scalar or array[K]; type: float ; ??? Tilt angle of field of view. Zero tilt means that the horizontal ; direction in the image is parallel to the ecliptic or solar ; equator (depending on the setting of keyword /ecliptic) ; Tilt angle increases counterclockwise. ; ; nGrid = nGrid ; scalar or array[3]; type: integer; default: [31,31,31] ; dimension of the 3D matrix describing the view. The first and second ; dimension is the 'horizontal' and 'vertical' direction in the field of view. ; The third is the 'depth' dimension (along the lines of sight) ; ; ; /stereo ; stereo = [Angle,Distance] ; /stereo if set, stereo pairs are produced using default ; settings for stereo angle (6 degrees) and ; distance (Sun-viewer distance) ; stereo=[Angle, Distance] ; if specified as a two-element array, the first ; element is used as stereo angle, the second as ; stereo distance. If the distance is set to zero ; then the viewer-origin distance Loc[2,*] is used. ; ; /eqdistance preserve distance to line of sight through center of image ; /eqangle preserve angular distance to line of sight through center of image ; /eqarea preserve area on sky; ; ; OUTPUTS: ; Result array[1]; type: SMEIremoteView structure ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; ToRadians, TimeSystem, big_eph, jpl_body, AngleRange ; RemoteView_FovTilt, CvSky, RemoteView_StereoStates ; Carrington, RemoteView_EqTrans, IsType, SuperArray ; InitVar ; PROCEDURE: ; nview # views ; ; time time structure (pointer) ; Loc viewing location: heliographic lng, lat (radians) ; and r (AU) (pointer) ; Dir viewing direction: heliographic lng, lat (radians) ; ; Fov angular half-width field of view (radians) ; Tilt field of view tilt angle (radians) ; ; nDim dimensions of fov cube ; rNear AU ; ; eqtrans int scalar 1,2 or 3 ; 1: preserve distance to line of sight through center of image ; 2: preserve angular distance to line of sight through center of image ; 3: preserve area on sky; ; stereo 0: stereo off; 1: stereo on (with left image in even, ; and right image in odd view locations) ; ; silent=silent controls display of informational messages ; MODIFICATION HISTORY: ; MAY-2000, Paul Hick (UCSD/CASS) ; DEC-2000, Paul Hick (UCSD/CASS) ; adapted to handle matrix sequences from time-dependent tomography. ; NOV-2001, Paul Hick (UCSD/CASS) ; fixed bug processing /ecliptic keyword when no viewing location is specified ; APR-2002, Paul Hick (UCSD/CASS) ; fixed bug processing location when specified explicitly with keyword /ecliptic ; JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Made sure that input is converted to double precision to avoid problems ; with integer input. ;- InitVar, ecliptic , /key InitVar, view_rect , /key InitVar, Earth , /key InitVar, silent , 0 rpm = ToRadians(degrees=degrees) EqTrans = RemoteView_EqTrans(eqdistance=EqDistance,eqangle=EqAngle,eqarea=EqArea) CASE 1 OF IsType(view_time,/defined): TT = Carrington(view_time,/get_time) IsType(time ,/defined): TT = Carrington(time ,/get_time) ELSE : TT = TimeSystem(/utc,/silent) ENDCASE ; The default location (based on the location of Earth ) is used if no ; location is specified or if at least one of the longitudes if set to NaN. ; Note that if location is not defined then the default location is used ; also if /view_rect is set. UseDefaultLoc = IsType(location, /undef) IF NOT view_rect AND NOT UseDefaultLoc THEN $ UseDefaultLoc = total( 1-finite(location[0,*]) ) NE 0 IF Earth THEN BEGIN ; Take location of Earth ; If /earth is set then any input location is ignored and instead ; the location of Earth is used. ; Get position of Earth at TT (spherical ecliptic coordinates) Loc = big_eph( TT, $ body = jpl_body(/earth,/string) , $ to_ecliptic = ecliptic , $ to_heliographic = 1-ecliptic , $ /to_sphere , $ /precess , $ degrees=degrees , $ /onebody , $ /silent ) ; If location is defined than insert latitudes and distances into ; default location, retaining only the longitude of Earth. IF IsType(Location,/defined) THEN BEGIN FOR i=0,2 DO BEGIN j = where(finite(location[i,*])) IF j[0] NE -1 THEN Loc[i,j] = location[i,j] ENDFOR ENDIF ENDIF ELSE IF UseDefaultLoc THEN BEGIN ; The default location is a position at the longitude of Earth, ; at ecliptic/heliographic latitude 30 degrees and 3-times the Sun-Earth distance. ; Set up default location in ecliptic coordinates. Loc = big_eph( TT, $ body = jpl_body(/earth,/string) , $ to_ecliptic = ecliptic , $ to_heliographic = 1-ecliptic , $ /to_sphere , $ /precess , $ degrees=degrees , $ /onebody , $ /silent ) Loc[1,*] = !pi/6/rpm Loc[2,*] = 3.0*Loc[2,*] ; If location is defined than insert latitudes and distances into ; default location, retaining only the longitude of Earth. ;IF IsType(Location,/defined) THEN BEGIN ;Loc = [Loc[0,*], location[1:2,*]] ;ENDIF IF IsType(Location,/defined) THEN BEGIN FOR i=0,2 DO BEGIN j = where(finite(location[i,*])) IF j[0] NE -1 THEN Loc[i,j] = location[i,j] ENDFOR ENDIF ENDIF ELSE BEGIN ; If /view_rect is set Location and Direction are assumed to ; be specified in rectangular coordinates. Convert to ; spherical coordinates, retaining only the angular ; information for the viewing direction. CASE view_rect OF 0: Loc = double(Location) 1: Loc = cv_coord(from_rect=double(Location), /to_spherical, degrees=degrees) ENDCASE ENDELSE ; Look back at Sun if no viewing direction specified: ; If it is specified, convert to spherical coordinates if view_rect is set CASE 1 OF IsType(Direction,/undefined): Dir = [AngleRange(Loc[0,*]+!pi/rpm, degrees=degrees),-Loc[1,*]] view_rect : Dir = (cv_coord(from_rect=double(Direction), /to_spherical, degrees=degrees))[0:1,*] ELSE : Dir = double(Direction[0:1,*]) ENDCASE ; A field of view of zero is set to a default value by RemoteView_Init_FOV sz = size(FovSize) nn = sz[sz[0]+2] ;IF nn EQ 0 THEN $ IF IsType(FovSize, /undefined) THEN $ Fov = [0.0,0.0]/rpm $ ELSE IF nn EQ 1 THEN $ Fov = [FovSize, FovSize] $ ELSE IF nn GT 2 AND sz[0] EQ 1 THEN $ Fov = SuperArray(FovSize,2,/lead) $ ELSE $ Fov = FovSize InitVar, FovTilt, 0.0/rpm, set=Tilt nView = max([ n_elements(TT ) , $ n_elements(Loc )/3 , $ n_elements(Dir )/2 , $ n_elements(Fov )/2 , $ n_elements(Tilt ) ]) Loc[0:1,*] *= rpm ; Convert all angles to radians Dir *= rpm Fov *= rpm Tilt *= rpm IF ecliptic THEN BEGIN ; Convert to heliographic coordinates Loc = CvSky(TT, from_ecliptic=Loc, /to_heliographic, /silent) Dir = CvSky(TT, from_ecliptic=Dir, /to_heliographic, /silent) Tilt -= RemoteView_FovTilt(TT, Dir) ENDIF ; Calculate stereo states. This will double the number of states to be calculated StereoOn = RemoteView_StereoStates(nView,TT,Loc,Dir,Fov,Tilt,stereo=Stereo) CASE n_elements(nGrid) OF 0 : nDim = 31*[1L,1L,1L] 1 : nDim = replicate(nGrid[0],3) 2 : nDim = [nGrid,31] ELSE: nDim = nGrid[0:2] ENDCASE nDim = nDim/2*2+1 ; Make the dimensions odd (why ???) IF silent LE 0 THEN message, /info, 'Viewing space dimension:'+ $ strjoin(strcompress(nDim),' x')+' preserving '+RemoteView_EqTrans(EqTrans) rNear = 0.0 ; Create and fill structure rtn = {SMEIremoteView} rtn.nview = nView ; # views rtn.Time = ptr_new(TT , /no_copy) ; Viewing time rtn.Loc = ptr_new(Loc , /no_copy) ; Viewing location: lng, lat and r (AU) rtn.Dir = ptr_new(Dir , /no_copy) ; Viewing direction: lng, lat rtn.Fov = ptr_new(Fov , /no_copy) ; Angular width field of view rtn.Tilt = ptr_new(Tilt, /no_copy) ; Field of view tilt angle rtn.nDim = nDim rtn.rNear = rNear ; AU rtn.eqtrans = EqTrans rtn.stereo = StereoOn RETURN, rtn & END