;+ ; NAME: ; smei_mkc3mask ; PURPOSE: ; Converts J. Tappins mask file into format needed by smei_cal ; CATEGORY: ; CALLING SEQUENCE: PRO smei_mkc3mask, last_only=last_only ; OPTIONAL INPUTS: ; /last_only processes only the most recent mask ; (useful when adding a mask) ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; flt_read, flt_string, InitVar ; PROCEDURE: ; The first line in James' files contain the array dimensions ; (1272 by 256). This line should be commented with a semi-colon first. ; ; The files have rows of 19 numbers (values 0 and 1 only) ; Each row of 1272 mask values is stored in 67 rows with the last ; row missing one number: 66*19+18=1272 ; ; Files are written in format (1272I1) ; MODIFICATION HISTORY: ; FEB-2007, Paul Hick (UCSD/CASS) ; SEP-2007, Paul Hick (UCSD/CASS) ; Added mask 2007_237. ; MAR-2007, Paul Hick (UCSD/CASS) ; Added mask 2008_023. ; OCT-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Added mask 2008_226. Added /last_only keyword ;- InitVar, last_only, /key root = filepath(root=getenv('SMEIDB'), 'c3mask') ; Mask file names provided by James Tappin ; The first line in that file (containing the array dimensions) ; needs to commented with a semi-colon ; The mask has dimensions 1272 x 256. ; flt_read reads a 19 x 17152 array. ; Each row in the mask takes up 67 x 19 = 1273. ; 1 number (1273-1272) is missng in the last row (67). ; For the last calibrations (2008_023 and 2008_226) flt_read ; reads a 20 x 16384 array. ; Each row in the mask takes up 64 x 20 = 1280. ; 8 numbers (1280-1272) are missing in the last row (20). f = 'ff_mask_'+ ['2005_342' ,'2006_215' ,'2006_334' ,'2007_083' ,'2007_237' ,'2008_023' ,'2008_226' ] g = ['t02' ,'t02' ,'t02' ,'t03' ,'t03' ,'t08_03' ,'t01' ] s = [1 ,1 ,1 ,1 ,1 ,8 ,8 ] ilast = n_elements(f)-1 ifirst = ilast*last_only ; 0 or ilast FOR i=ifirst,ilast DO BEGIN IF flt_read(filepath(root=root,f[i]+'_'+g[i]+'.txt'),d,comments=ndim) THEN BEGIN ndim = round( flt_string(ndim) ) nx = ndim[0] ny = ndim[1] whatis, d mask = bytarr(nx,ny) k = 0L FOR j=0,ny-1 DO BEGIN mask[*,j] = d[k:k+nx-1] k += nx+s[i] ; Advance to next row of 1272 (skip the missing number(s)) ENDFOR ; Write in I1 format. openw, /get_lun, iu, filepath(root=root,f[i]+'_000000.txt') printf, iu, format='('+strcompress(nx,/rem)+'I1)', mask free_lun, iu ENDIF ENDFOR RETURN & END