Source code for shapelets_detect_diamond.pro:

function shapelets_detect_diamond, structure, silent=silent


;+
; NAME:
;      SHAPELETS_DETECT_DIAMOND
;
; CATEGORY:
;      Shapelets.
;
; PURPOSE:
;      Detect if a shapelet structure has been created using the diamond
;      shape or not
; 
; INPUTS:
;      STRUCTURE  - A shapelet decomp structure or shapecat structure.
;
; OPTIONAL INPUTS:
;      None.
;
; KEYWORD PARAMETERS:
;      None.
;
; OUTPUTS:
;      1 if the structure has been created with /diamond
;      0 if the structure has been created without /diamond
; 
; MODIFICATION HISTORY:
;      Nov 06 - bug when dealing with bad flag fixed by JB
;      February 2006 - Written by Joel Berge
;-


if not shapelets_structure_type(structure,message=message) then message,message

if structure.type ne "shapecat" and structure.type ne "decomp" then $
  message,"Structure type not recognized"

if not tag_exist(structure,"polar") then begin
    if not keyword_set(silent) then $
      message,"No polar tag in structure, so assumed to be cartesian shapelets, and diamond is not set",/continue
    return,0B
endif

if tag_exist(structure,"polar") then if structure.polar eq 0 then begin 
    if not keyword_set(silent) then $
      message,"Cartesian shapelets, no diamond",/continue
    return,0B
endif

if structure.type eq "shapecat" then begin
;hope that all objects are diamond, and so extract the first one
;however, make sure its flags are okay, so as all its coefficients are
;not zero
    shcat=1B
    structure_in=structure
    id=0
    while structure.flag(id,0) gt 2 or structure.flag(id,1) gt 8 do id=id+1
    structure=shapelets_shapecat2decomp(structure,id)
endif else shcat=0B

if structure.type eq "decomp" then begin
    shapelets_make_nvec,structure.n_max,n1,n2,/polar
    tocheck=where(n1+abs(n2) gt structure.n_max,ntocheck)
 
;if all coefficients indexed by tocheck are zero, that means that
;diamond was used, else ir wasn't used
    if ntocheck gt 0 then begin
        allzero=size(uniq(structure.coeffs(tocheck)),/dim)
    
        if allzero eq 0 and structure.coeffs(tocheck(0)) eq 0 then begin
            if shcat then structure=structure_in
            return,1B
        endif else begin
            if shcat then structure=structure_in
            return,0B
        endelse
    endif else begin  ;this is a weird, degenerated case... crap !
        if shcat then structure=structure_in
        return,1B
    endelse

endif

end

Return to the shapelets web page or the code help menu.





Valid HTML 4.01!

Valid CSS!