PRO rd_ssc, infil, dset_arr, index, data, roadmap, nodata=nodata, filidx=filidx, dset_str=dset_arr0, dedupe=dedupe ;+ ;NAME: ; RD_SSC ;PURPOSE: ; Read Yohkoh_Legacy/SXT/SSC images and sort with respect to time. ; A simple wrapper to RD_XDA.PRO to avoid time-ordering upset ; in reading files with different prefix (e.g. ssc_, sst_). ; ;CALLING SEQUENCE: ; RD_SSC, infil, dset_arr, index, data ; RD_SSC, infil, dset_arr, index, /nodata ; RD_SSC, infil, -1, index, data, /dedupe ;INPUT: ; infil : input file specification (SPR... or SFR...) ; "infil" can be a vector of filenames (WARNING - ; do not mix and match FFI and PFI) ; dset_arr: vector of dataset numbers to extract (indices vector) ; * "dset_arr" can be ; 1. An indicie vector ("SS") from a search of the roadmap ; of ALL of the files in "infil". ; 2. a structure with fields ".dset" and ".ifil". ; ".dset" is the dataset number WITHIN THE FILE, and ; ".ifil" is the index of the filename within the ; infil array. The structure is "N" elements long ; where "N" is the total number of datasets to extract. ; * The order that the images are placed in the output ; variable "data" is the same order that they ; appear in "dset_arr" ; * If "-1" is passed, the whole file is read ; and the dset_arr returned is the "indgen(ndset)" ;OPTIONAL INPUT: ; nodata : If present, only the index is read ;OUTPUT: ; index : data-index logical record (one for each ; image requested) ; data : 2D or 3D image array ;OPTIONAL KEYWORD INPUT: ; dedupe ; (switch) if set, remove duplicated index(es). ;OPTIONAL OUTPUT: ; roadmap : summary of data-index logical record, note ; all roadmaps records in the file are returned. ; In the case where "infil" is an array, roadmap ; is the concatenated roadmap for all files that ; are being read for the particular extraction. ;OPTIONAL KEYWORD OUTPUT: ; filidx : a vector the same length as the roadmap ; with the index of the file associated with that entry ; (ie: 0,0,0,0,1,1,1,1,2,2,2,2,...) ; dset_str: the structure form of the requested datasets ; passed in with "dset_arr". If user passes in ; a simple vector ("SS"), "dset_str" is the structure ; form of the output. ;HISTORY: ; 22-Jun-2007 : Aki Takeda(MSU) -- prepared as a RD_XDA wrapper, ; customized for SXT/SSC data. ; 30-Jun-2007 : AkT -- separate roadmap & filidx sorting ; 2-Aug-2007 : AkT -- added /dedupe keyword. ;- if n_params() lt 5 and not keyword_set(filidx) then $ rd_xda, infil, dset_arr, index, data, nodata=nodata, dset_str=dset_arr0 $ else rd_xda, infil, dset_arr, index, data, roadmap, nodata=nodata, $ filidx=filidx, dset_str=dset_arr0 ; if n_elements(index) gt 1 then begin ss_sort=sort(anytim(index,/sec)) index=index(ss_sort) data=data(*,*,ss_sort) dset_arr0=dset_arr0(ss_sort) if size(roadmap,/type) ne 0 then begin if not keyword_set(dedupe) then begin ssrdm=sort(anytim(roadmap,/sec)) roadmap=roadmap(ssrdm) filidx=filidx(ssrdm) endif else begin print,'*** roadmap NOT created with the /dedupe keyword. ***' endelse endif endif ; if keyword_set(dedupe) then begin ss_uniq=uniq(anytim(index,/sec)) ndup=n_elements(index)-n_elements(ss_uniq) if ndup gt 0 then begin ndup_str=strtrim(string(ndup),2) print,'*** '+ndup_str+' duplicated index(es) detected and removed.***' index=index(ss_uniq) data=data(*,*,ss_uniq) if keyword_set(dset_arr0) then dset_str0=dset_arr0(ss_uniq) endif else print,'*** no duplication found ***' endif ; end