; docformat = 'rst' ; ; NAME: ; K2GetTarget ; PURPOSE: ; Download all the Target Pixel Data from a K2 Campaign ; ;+ ; :Description: ; Download all the Target Pixel Data from a K2 Campaign ; ; :Categories: ; K2 ; ; :Returns: ; A structure with the configuration parameters for K2/IDL ; processing. Fields are:: ; path.root - The root Directory for the Project ; path.box - The Directory of Box Coordinates ; path.sso - The directory with SSO predictions ; path.epic - The directory with the list of EPIC targets ; path.target - The directory for the FITS data files (Target Pixel Data) ; ; :Params: ; campaign: in, required, type=float/string ; The K2 Campaign number (e.g., 0, 1, 2, 9a, 9b, 10...) ; ; :Keywords: ; ; :Examples: ; Read the base configuration file:: ; IDL> config = K2Init() ; Read a local configuration file:: ; IDL> config = K2Init('./my_own_ini_file') ; ; :Uses: ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Created in July 2016 by B. Carry (OCA) ;- function K2Init, file ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Variables Declaration and Definition -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden, idl2 ;--I.1-- Input checks ------------------------------------------------------------------------ if not keyword_set(file) then file='~/.idl/k2.ini' if not file_test(file,/Read) then begin message, /ioError, 'Initialization file cannot be read: '+strTrim(file,2) endif ;--I.2-- Output Structure -------------------------------------------------------------------- path = {root: '', $ ;-Root Directory for the Project box: '', $ ;-Directory of Box Coordinates sso: '' , $ ;-Directory with SSO predictions epic: '', $ ;-Directory with the list of EPIC targets target: ''} ;-Directory for the FITS data files (Target Pixel Data) user = {verbose:0 } ;-Verbose boolean mjd = 2454833.D ;-K2 MJD to JD conversion ;--I.3-- Open Configuration File ------------------------------------------------------------- openR, idIn, file, /GET_LUN line = ' ' section = ' ' ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Read and Parse Configuration File -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; while ~EOF(idIn) do begin ;--II.1-- Read Current Line------------------------------------------------------------------ readf, idIn, line ;--II.2-- Selection of Section ------------------------------------------------------------- if strMid(line,0,1) eq '[' then begin split = strSplit(line, '[]', /Extract) section = strLowCase(strTrim(split[0],2)) ;--II.3-- Analysis of Section -------------------------------------------------------------- endif else begin ;--II.3.1-- Parse Current Line ---------------------------------------------------------- split=strsplit(line, '=,;', /EXTRACT, count=nbField ) key = strLowCase(strTrim(split[0],2)) CASE section OF ;--II.3.2-- Working Directories 'directory': BEGIN CASE key OF 'root' : path.root = strTrim(split[1],2)+'/' 'boxes': path.box = strTrim(split[1],2)+'/' 'ssos' : path.sso = strTrim(split[1],2)+'/' 'epic' : path.epic = strTrim(split[1],2)+'/' 'tpd' : path.target= strTrim(split[1],2)+'/' ELSE: ENDCASE END ;--II.3.3-- User Preferences 'kepler characteritics': BEGIN CASE key OF 'mjd' : mjd = double(split[1]) ELSE: ENDCASE END ;--II.3.4-- User Preferences 'user preferences': BEGIN CASE key OF 'verbose' : user.verbose = round(float(split[1])) ELSE: ENDCASE END ;--II.3.X-- Something else? :-) else: ENDCASE endelse ;--II.3-- End of Section Analysis endwhile ;--II-- End of Loop over Lines return, {path:path, user:user, mjd:mjd} end