FUNCTION MAGSUM, ARG, WC=WC ;+ ; NAME: ; MAGSUM ; ; PURPOSE: ; Sum magnitudes (companion routine to MAGERRSUM) ; ; MODIFICATION HISTORY: ; 27 Jul 2007 Written by Mattia Vaccari ;- if not(keyword_set(wc)) then wc=99.0 if n_elements(arg) eq 0 then begin print,'Argument is undefined! Returning -1...' res=-1 goto,FIN endif else if n_elements(arg) eq 1 then begin print,'Argument has only one element! Returning argument...' res=arg goto,FIN endif res=-1.0 ;j=where(arg ne wc) j=where(abs(arg-wc) gt 1.e-3) ;if (where(arg ne wc))[0] ne -1 then begin if j[0] ne -1 then begin for i=0,n_elements(j)-1 do begin if res eq -1.0 then res=arg[j[i]] else res=-2.5*alog10(10.^(-0.4*res)+10.^(-0.4*arg[j[i]])) endfor endif else print,'No Valid Arguments! Returning -1...' ;if res eq wc then res=-1.0 if abs(res-wc) lt 1.e-3 then res=-1.0 FIN: return, res end