; docformat = 'rst' ; ; NAME: ; K2ReadBox ; PURPOSE: ; Read box coordinates information for a K2 campaign ; ;+ ; :Description: ; Read box coordinates information for a K2 campaign ; ; :Categories: ; K2 ; ; :Returns: ; A structure with the box coordinates. ; ; :Params: ; file: in, required, type=string ; Path to the box coordinates file ; ; :Keywords: ; ; :Examples: ; Read the box coordinates for all long cadence stamps in C0:: ; IDL> box = K2ReadBox( 'BoxCoordinates-LC-C0.csv' ) ; ; :Uses: ; readcol ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Created in July 2016 by B. Carry (OCA) ;- function K2ReadBox, file ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden, idl2 ;--I.1-- Input checks ------------------------------------------------------------------------ if not keyword_set(file) then begin message, /ioError, 'Input missing: File' return, -1 endif ;--I.2-- File Exists on Disk ----------------------------------------------------------------- if not file_test(file,/read) then begin message, /ioError, 'Input file cannot be read: '+strTrim(file,2) return, -2 endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Read , Store, and Return Box File -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--I.1-- Input checks ------------------------------------------------------------------------ readcol, file, delimiter=',', /Silent, skipLine=1, $ format='(D,I,I,D,D,D,D'+$ 'D,D,D,D,D,D,I)', $ id, n1, n2, pix1, pix2, val1, val2, cd1, cd2, pc11, pc12, pc21, pc22, chan ;--I.2-- Prepare Output Structure ------------------------------------------------------------ n=n_elements(id) empty={epic:0.d, n1:0, n2:0, pix1:0.d, pix2:0.d, val1:0.d, val2:0.d, $ cd1:0.d, cd2:0.d, pc11:0., pc12:0., pc21:0., pc22:0., chan:0} res=replicate(empty,n) ;--I.3-- Fill Output Structure --------------------------------------------------------------- res.epic = id res.n1 = n1 res.n2 = n2 res.pix1 = pix1 res.pix2 = pix2 res.val1 = val1 res.val2 = val2 res.cd1 = cd1 res.cd2 = cd2 res.pc11 = pc11 res.pc12 = pc12 res.pc21 = pc21 res.pc22 = pc22 res.chan = chan ;--I.4-- Return Output Structure ------------------------------------------------------------- return, res end