; docformat = 'rst' ;+ ;This procedure calculates the viewing geometry angles. ; ; :Examples: ; viewgeometry, sc_pos, xyz, suntime, lla=lla, ssa=ssa, sva=sva, sun=sun, _extra=extra, cva=cva, pol=polm cam_ref_x=cam_ref_x ;- ;+ ; :Params: ; sc_pos : in, required, type=array of double ; 3 element array with spacecraft position in cartesian coordinates in ; the ECEF frame. ; xyz : in, required, type=array of double ; Grid of cartesian vectors for each point on the cloud deck in the ; ECEF frame. ; suntime : in, required, type=double ; Time of exposure, in GPS microseconds. Used to calculate the ; position of the sun. ; ; :Keywords: ; sun : out, required, type=array of double ; Unit vector from the center of the Earth towards the center of the ; Sun, in the ECEF frame. ; ssa : out, required, type=array of double ; Single scattering angle of each point on the cloud deck, in radians. ; Pi minus the measure of the angle from the cloud to the spacecraft. ; Grid of scalars in the same shape as the xyz grid of vectors. ; sva : out, required, type=array of double ; Spacecraft view angle of each point on the cloud deck, in radians. ; Measure of angle from the spacecraft nadir to the spacecraft to the ; cloud. ; sza : out, required, type=array of double ; Solar Zenith angle of each point, in radians. Measure of the angle ; from the Sun to the cloud to the cloud zenith. ; cva : out, required, type=array of double ; Cloud View Angle of each point, in radians. Measure of the angle ; from the spacecraft to the cloud to the cloud zenith. ; lla : in, optional, type=array of double ; Longitude Latitude Altitude navigation coordinates. ; _extra : in, optional, type=boolean ; Passed into xyz2llagrid. ; pol : out, optional, type=array of double ; View geometry in polar coordinates. ; cam_ref_x : in, optional, type=array of double ; Camera reference in the x-coordinate. ;- pro viewGeometry,sc_pos,xyz,suntime,lla=lla,ssa=ssa,sva=sva,sza=sza,sun=sun,_extra=extra,cva=cva,pol=pol,cam_ref_x=cam_ref_x ;Unit vector from center of Earth towards Sun sun=sunvec(suntime,/ecef); sc_lla=xyz2llagrid(sc_pos,_extra=extra) if n_elements(lla) eq 0 then lla=xyz2llagrid(xyz,_extra=extra) llr=lla llr[*,*,2]=llr[*,*,2]*0d +1d ;pay attention to this when unit testing xyz_z=llr_to_xyz(llr) ; Unit vector for each pixel at the deck normal to ellipsoid at this point sc_lla[2]=1 nadir=-llr_to_xyz(sc_lla) ;Nadir vector normal to ellipsoid beneath spacecraft resolve_grid,xyz,x=x,y=y,z=z v=compose_grid(x-sc_pos[0],y-sc_pos[1],z-sc_pos[2]) v=normalize_grid(v) ;unit Vector along each pixel ray ;calculate solar scattering angle ssa=vangle(sun ,v); ;Calculate spacecraft view angle sva=vangle(nadir ,v); ;calculate solar zenith angle sza=vangle(sun ,xyz_z); ;calculate cloud view angle cva=vangle(-v,xyz_z) ;calculate polarization angle if n_elements(cam_ref_x) gt 0 then begin n_sca=crossp_grid(v,sun) n_sca=normalize_grid(n_sca) n_ref=crossp_grid(cam_ref_x,v) n_ref=normalize_grid(n_ref) pol=vangle(n_sca,n_ref) end end