dustem_init_parinfo.pro 2.15 KB
PRO dustem_init_parinfo,pd,iv, $
                        fixed=fixed,tied=tied, $
                        up_limited=up_limited,lo_limited=lo_limited,up_limits=up_limits,lo_limits=lo_limits, $
                        relstep=relstep,step=step

(*!dustem_fit).param_descs=ptr_new(pd)
;A chance to include a plugin dependency here since pd is not really used in this routine

(*!dustem_fit).param_init_values=ptr_new(iv)
;stop
dustem_set_func_ind,pd,iv


one_parinfo={value:0.D0, fixed:0, limited:[0,0], limits:[0.D0,0], parname:'', relstep:0., step:0., mpside:0, tied:''}
Npar=n_elements(pd)
dustem_parinfo=replicate(one_parinfo,Npar)
FOR i=0L,Npar-1 DO BEGIN
;  dustem_parinfo[i].value=iv(i)/(*!init_value)(i)
  dustem_parinfo[i].value=iv(i)/(*(*!dustem_fit).param_init_values)(i)
  IF keyword_set(fixed) THEN dustem_parinfo[i].fixed=fixed[i]
  dustem_parinfo[i].limited[0]=0
  dustem_parinfo[i].limited[1]=0
  dustem_parinfo[i].limits[0]=0.
  dustem_parinfo[i].limits[1]=0.
  dustem_parinfo[i].parname=pd[i]
  IF keyword_set(relstep) THEN dustem_parinfo[i].relstep=relstep[i]
  IF keyword_set(step) THEN dustem_parinfo[i].step=step[i]
  dustem_parinfo[i].mpside=0
  IF keyword_set(tied) THEN dustem_parinfo[i].tied=tied[i]
ENDFOR

IF keyword_set(up_limited) THEN BEGIN
  ind=where(up_limited EQ 1,countup)
  IF countup EQ 0 THEN goto,suite1
  IF NOT keyword_set(up_limits) THEN BEGIN
    print,'up_limits must be set with up_limited'
    stop
  ENDIF
  IF countup NE 0 THEN BEGIN
    FOR i=0L,countup-1 DO BEGIN
      dustem_parinfo[ind(i)].limited[1]=1
      dustem_parinfo[ind(i)].limits[1]=up_limits[ind(i)]/(*(*!dustem_fit).param_init_values)(ind(i))
    ENDFOR
  ENDIF
ENDIF
suite1:
IF keyword_set(lo_limited) THEN BEGIN
  ind=where(lo_limited EQ 1,countlo)
  IF countlo EQ 0 THEN goto,suite2
  IF NOT keyword_set(lo_limits) THEN BEGIN
    print,'lo_limits must be set with lo_limited'
    stop
  ENDIF
  IF countlo NE 0 THEN BEGIN
    FOR i=0L,countlo-1 DO BEGIN
      dustem_parinfo[ind(i)].limited[0]=1
      dustem_parinfo[ind(i)].limits[0]=lo_limits[ind(i)]/(*(*!dustem_fit).param_init_values)(ind(i))
    ENDFOR
  ENDIF
ENDIF
suite2:

defsysv,'!dustem_parinfo',ptr_new(dustem_parinfo)

END