;+ ; NAME: ; CR2LAZ ; PURPOSE: ; Calculation of Polar Camera look directions from column ; and row numbers. ; CATEGORY: ; Coordinate transformations. ; CALLING SEQUENCE: ; CR2LAZ, YEAR, MONTH, DAY, CAM, FILT, COL, ROW, AZIM, ZENANG $ ; [, DEGREES=degrees, BIN=bin, SITE=site] ; INPUTS: ; YEAR: Year of observation (2 or 4 digits). ; MONTH: Month of observation (1 - 12). ; DAY: Day of the month (reckoned according to Universal Time). ; CAM: Camera number (0 or 1). ; FILT: Filter number (0 - 4). ; COL: An array of column numbers (typically the same size ; as a Polar Camera image, with each element containing ; its column number). ; ROW: As above, but row numbers. ; OPTIONAL INPUTS: ; None. ; KEYWORD PARAMETERS: ; /DEGREES: Set if angle measure in degrees is desired; ; default is radians. ; BIN: Binning factor applied to initial 512x512 image. ; SITE: A numeric code giving the geographic location of ; the Polar Camera on the specified date: 1 => ; Calgary; 2 => Rabbit Lake, SK; 3 => Eureka, NWT. ; OUTPUTS: ; AZIM: An array of the same dimensions as COL and ROW, ; giving the azimuth angle for each input image ; pixel at image coordinates (column,row). ; ZENANG: As above, giving the zenith angle of each pixel. ; OPTIONAL OUTPUTS: ; None. ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; None. ; RESTRICTIONS: ; COL and ROW must be the same size. The mean parameters ; file for the specified location/date must exist. The AZIM ; and ZENANG arrays are in degrees. ; PROCEDURE: ; Procedure RDMNPARM is used to read in the image transformation ; parameters for the specified date/site. The appropriate ; image size is determined from the maximum column and row ; values input. The column and row numbers are converted to ; 'X' and 'Y' distances (in pixels) from the pixel viewing ; the zenith. The (X,Y) pairs are rotated by the measured ; central column azimuth. Pixel distance from the zenith ; pixel is converted to zenith angle using a non-linear ; transformation: ; ; { ( pix_dist ) / } ; zenith angle = (180/pi) * { arcsin( -------- ) / warp } ; { ( stretch ) / } ; ; where 'stretch' is about 200 pixels (for 2x2-binned images) ; and 'warp' is about 0.63. Azimuth is determined from the ; 'X' and 'Y' values after rotation. Negative azimuths are ; incremented by 360 deg. ; EXAMPLE: ; col=REBIN(INDGEN(256),256,256) ; define the column numbers ; row=TRANSPOSE(col) ; same for row numbers ; cr2laz,1994,9,27,0,0,col,row,az,za ; if SITE omitted, ; ; RDMNPARM will call POCASITE ; ; to guess site code. ; SEE ALSO: ; RDMNPARM, POCASITE, LAZ2CR (which does the inverse transformation) ; MODIFICATION HISTORY: ; Written by: D P Steele/D van der Schee, summer 1993. ; Documented by: D P Steele, Sept. 1994. ;- PRO cr2laz,year,month,day,cam,filt,col,row,az,za $ ,degrees=degrees,bin=bin,site=site,small=small ; Print the documentation? IF N_PARAMS() EQ 0 THEN BEGIN doc_library,'cr2laz' RETURN ENDIF ; Read in the transformation parameters rdmnparm,year,month,day,cam,ccol,crow,stretch,warp,camaz,site=site cl=col rw=row IF N_ELEMENTS(bin) GT 0 THEN BEGIN ; binning factor specified. cl=cl*(bin/2) ; transformation assumes 2x2 rw=rw*(bin/2) ; binning, so convert to that ENDIF ; image format ;IF (MAX([cl,rw]) GT 255) THEN BEGIN ; cl=cl/2 ; treat image coordinates as pertaining to ; rw=rw/2 ; a 256x256 array ; ENDIF dc=cl-ccol ; distances from 'overhead' pixel dr=rw-crow rho=SQRT(dc^2+dr^2) phi=ATAN(dc,-dr); rotate by azimuth of central CCD column xp=COS(phi) yp=SIN(phi) cc=COS(camaz) sc=SIN(camaz) x=xp*cc+yp*sc y=-xp*sc+yp*cc ; Now convert from cartesian to spherical polar coordinates IF KEYWORD_SET(degrees) THEN ff=!RADEG ELSE ff=1. za=ff*(rho/stretch) az=ff*ATAN(-y,x) wn=WHERE(az LT 0.) ; ensure azimuths > 0 IF N_ELEMENTS(wn) GT 1 THEN az(wn)=az(wn)+2.*!PI*ff ; Done RETURN END