function pp_readfits::init,file
compile_opt idl2,logical_predicate
self.data=ptr_new(!null)
self.header=ptr_new(!null)
self.variables=hash()
self.descriptions=hash()
data=readfits(file,header)
if array_equal(data,-1L) then return,0
foreach el,header do begin
tmp=strsplit(el,'=',/extract)
if (n_elements(tmp) ge 2) then begin
key=strtrim(tmp[0],2)
tmp=strsplit(strjoin(tmp[1:*],'='),'/',/extract)
(self.variables)[key]=strtrim(strjoin(tmp[0:-2],'/'),2)
(self.descriptions)[key]=strtrim(tmp[-1],2)
endif
endforeach
self.file=file
*self.data=temporary(data)
*self.header=temporary(header)
return,1
end
pro pp_readfits::getproperty,file=file,data=data,header=header,variables=variables,$
descriptions=descriptions
compile_opt idl2,logical_predicate
if arg_present(file) then file=self.file
if arg_present(data) then data=*self.data
if arg_present(header) then header=*self.header
if arg_present(variables) then variables=(self.variables)[*]
if arg_present(descriptions) then descriptions=(self.descriptions)[*]
end
function pp_readfits::_overloadBracketsRightSide, isRange, $
sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8
compile_opt idl2,logical_predicate
ret=hash()
if (n_elements(isrange) ne 1) || (isrange[0] ne 0) then return,ret
keys=(self.variables.keys()).toarray()
foreach el,sub1 do begin
w=where(strmatch(keys,el,/fold_case),nw)
if (nw eq 1) then ret[keys[w]]=(self.variables)[keys[w]]
if (nw gt 1) then ret+=(self.variables)[keys[w]]
endforeach
return,ret
end
pro pp_readfits__define
compile_opt idl2,logical_predicate
!null={pp_readfits,file:'',data:ptr_new(),header:ptr_new(),$
variables:obj_new(),descriptions:obj_new(),$
inherits IDL_Object}
end