; docformat = 'rst' ; ; NAME: ; K2BoxCoordinates ; PURPOSE: ; Extract the EPIC stamp parameters from all the Target Pixel Data within a K2 Campaign ; ;+ ; :Description: ; Extract the EPIC stamp parameters from all the Target Pixel Data within a K2 Campaign ; ; :Categories: ; K2 ; ; :Params: ; campaign: in, required, type=float/string ; The K2 Campaign number (e.g., 0, 1, 2, '9a', '9b', 10...) ; ; :Keywords: ; init: in, optional, type=string, default='~/.idl/k2/ini' ; Path to the K2 configuration file ; LC: in, optional, type=boolean, default=1 ; Set processing of long cadence stamps ; SC: in, optional, type=boolean, default=0 ; Set processing of short cadence stamps ; verbose: in, optional, type=boolean, default=0 ; Verbose progression to stdout ; ; :Examples: ; Extract box coordinates of all long cadence stamps from Campaign 6:: ; IDL> K2BoxCoordinates, 6, /LC ; ; :Uses: ; K2Init ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Created in July 2016 by B. Carry (OCA) ;- pro K2BoxCoordinates, campaign, init=init, LC=LC, SC=SC, verbose=verbose ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden, idl2 ;--I.1-- Input checks ------------------------------------------------------------------------ if not keyword_set(campaign) and n_elements(campaign) eq 0 then return if not keyword_set(LC) and not keyword_set(SC) then LC=1 if keyword_set(LC) and keyword_set(SC) then SC=0 if keyword_set(LC) then cad='lpd' else cad='spd' if keyword_set(init) then conf=K2Init(init) else conf=K2Init() ;--I.2-- Campaign Labels --------------------------------------------------------------------- dimC = size(campaign) if dimC[dimC[0]+1] eq 2 then begin campLoLab1 = 'c'+strTrim(string(campaign,format='(I)'),2) campUpLab1 = 'C'+strTrim(string(campaign,format='(I)'),2) campLoLab2 = 'c'+strTrim(string(campaign,format='(I02)'),2) campUpLab2 = 'C'+strTrim(string(campaign,format='(I02)'),2) endif else begin campLoLab1 = 'c'+strTrim(campaign,2) campUpLab1 = 'C'+strTrim(campaign,2) campLoLab2 = 'c'+strTrim(campaign,2) campUpLab2 = 'C'+strTrim(campaign,2) endelse ;--I.3-- Directories ------------------------------------------------------------------------- dirFITS = conf.path.root+conf.path.target+campUpLab1+'/' dirBox = conf.path.root+conf.path.box+'/' if not file_test(dirFITS,/Directory) then file_mkdir, dirFITS if not file_test(dirBox,/Directory) then file_mkdir, dirBox ;--I.4-- Preferences ------------------------------------------------------------------------- if conf.user.verbose eq 1 then verbose=1 ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Identify EPIC files to Process -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--II.1-- List of EPIC To Process ------------------------------------------------------------ spawn, 'cd '+dirFITS+' && ls ktwo*'+cad+'*fits -1', listFITS, errFITS spawn, 'cd '+dirFITS+' && ls ktwo*'+cad+'*fits.gz -1', listGZ, errGZ ;--II.2-- Error Handling --------------------------------------------------------------------- ;--II.2.1-- Both Lists are Empty if strCmp(errFITS,'') eq 0 and strCmp(errGZ,'') eq 0 then begin message, 'No files available to process, returning...' return ;--II.2.2-- At least One Lists is Ok endif else begin ;--II.2.3-- Both Lists are Ok if strCmp(errFITS,'') eq 1 and strCmp(errGZ,'') eq 1 then begin listEpic = [listFITS,listGZ] ;--II.2.4-- A single List is Ok endif else if strCmp(errFITS,'') eq 0 then listEpic=listGZ else listEpic=listFITS endelse nbEpic = n_elements(listEpic) ;--II.2-- Prepare Output Arrays -------------------------------------------------------------- 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} box=replicate(empty,nbEpic) ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Compute Coordinates -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; for kE=0, nbEpic-1 do begin ;--III.1-- Progression Information --------------------------------------------------------- if keyword_set(verbose) then print, kE, nbEpic, listEPIC[kE], format='(I6,2x,I6,2x,A-35)' ;--III.2-- Open EPIC File Header ----------------------------------------------------------- head0 = headFits( dirFITS+listEPIC[kE], exten=0 ) head2 = headFits( dirFITS+listEPIC[kE], exten=2 ) ;--III.3-- Store Information in Structure -------------------------------------------------- box[kE].epic = sxpar(head2,'KEPLERID') box[kE].n1 = sxpar(head2,'NAXIS1') box[kE].n2 = sxpar(head2,'NAXIS2') box[kE].pix1 = sxpar(head2,'CRPIX1') box[kE].pix2 = sxpar(head2,'CRPIX2') box[kE].val1 = sxpar(head2,'CRVAL1') box[kE].val2 = sxpar(head2,'CRVAL2') box[kE].cd1 = sxpar(head2,'CDELT1') box[kE].cd2 = sxpar(head2,'CDELT2') box[kE].pc11 = sxpar(head2,'PC1_1') box[kE].pc12 = sxpar(head2,'PC1_2') box[kE].pc21 = sxpar(head2,'PC2_1') box[kE].pc22 = sxpar(head2,'PC2_2') box[kE].chan = sxpar(head0,'CHANNEL') endfor ;--III-- End of loop over EPICs ;--III.3-- Output Information on Disk ------------------------------------------------------ if keyword_set(LC) then nameBox=dirBox+'BoxCoordinates-LC-'+campUpLab1+'.csv' $ else nameBox=dirBox+'BoxCoordinates-SC-'+campUpLab1+'.csv' forprint, box.epic, box.n1, box.n2,box.pix1, box.pix2, box.val1, box.val2, $ box.cd1, box.cd2, box.pc11, box.pc12, box.pc21, box.pc22, box.chan, $ comment='EPIC, NAXIS1, NAXIS2, CRPIX1, CRPIX2, CRVAL1, CRVAL2, CDELT1, CDELT2, PC1_1, PC1_2, PC2_1, PC2_2, CHANNEL', $ format='(I9,", ",I4,", ",I4,", ",D,", ",D,", ",D,", ",D,", ",'+$ 'D,", ",D,", ",D,", ",D,", ",D,", ",D,", ",I3)', $ textOut=nameBox, /Silent end