Commit 87fc4ae7462f0e5b8ae04179fd86318a7cd0c936

Authored by Annie Hughes
1 parent 1e69909c
Exists in master

removed worst bugs

Showing 1 changed file with 52 additions and 28 deletions   Show diff stats
src/idl/dustem_init_params.pro
... ... @@ -163,7 +163,7 @@ if keyword_set(fpd) then begin
163 163 stop
164 164 end
165 165 ;== CHECK IF USER HAS MADE SOMETHING FIXED AND FREE
166   - match,pd,fpd,a,b,count=ct
  166 + match,strupcase(pd),strupcase(fpd),a,b,count=ct
167 167 if ct ne 0 then begin
168 168 message, 'Parameter(s) that are both free and fixed?',/info
169 169 print,'Matching free parameters: '+pd[a]
... ... @@ -225,13 +225,18 @@ if par_status eq 1 and not keyword_set(force_reset) then begin
225 225 old_ulims[i]=(old_parinfo[i].limits[1])*old_iv[i]
226 226 old_llims[i]=(old_parinfo[i].limits[0])*old_iv[i]
227 227 endfor
228   - match,new_pd,old_pd,a,b,count=ndups
  228 + ; check for duplicates
  229 + noldpars=n_elements(old_pd)
  230 + match,strupcase(new_pd),strupcase(old_pd),a,b,count=ndups
229 231 if ndups gt noldpars then begin
230   - message, 'Number of duplicates exceeds number of parameters. This should not happen ?'/info
  232 + message, 'Number of duplicates exceeds number of existing parameters. This should not happen ?'/info
231 233 stop
232 234 endif
233   - if ndups gt 0 and ndups lt noldpars then begin
234   - if !dustem_verbose NE 0 then message,string(ndups)+' matching parameters found. Updating values for '+old_pd[b],/info
  235 + if ndups gt 0 and ndups le noldpars then begin
  236 + if !dustem_verbose NE 0 then begin
  237 + message,string(ndups)+' matching parameters found. Updating values...',/info
  238 + for i=0,ndups-1 do print,old_pd[b[i]]
  239 + end
235 240 remove,b,old_pd
236 241 remove,b,old_iv
237 242 remove,b,old_parinfo
... ... @@ -241,29 +246,35 @@ if par_status eq 1 and not keyword_set(force_reset) then begin
241 246 remove,b,old_llims
242 247 remove,b,old_fixed
243 248 remove,b,old_tied
244   - pd=[new_pd,old_pd]
245   - iv=[new_iv,old_iv]
246   - ulimed=[new_ulimed,old_ulimed]
247   - llimed=[new_llimed,old_llimed]
248   - ulims=[new_ulims,old_ulims]
249   - llims=[new_llims,old_llims]
250   - fixed=[new_fixed,old_fixed]
251   - tied=[new_tied,old_tied]
252 249 endif
253   - ; if ndups eq noldpars, then this is equivalent to a reset
254   - if ndups eq noldpars and !dustem_verbose NE 0 then $
255   - message,'Updating existing parameters to their new values',/info
  250 + ;merge the structures
  251 + pd=[new_pd,old_pd]
  252 + iv=[new_iv,old_iv]
  253 + ulimed=[new_ulimed,old_ulimed]
  254 + llimed=[new_llimed,old_llimed]
  255 + ulims=[new_ulims,old_ulims]
  256 + llims=[new_llims,old_llims]
  257 + fixed=[new_fixed,old_fixed]
  258 + tied=[new_tied,old_tied]
256 259 endif
257 260  
  261 +
  262 +;; stop
  263 +;; message,'line 262',/info
  264 +;; if ptr_valid((*!dustem_fit).param_descs) then print,(*(*!dustem_fit).param_descs)
  265 +;; if ptr_valid((*!dustem_fit).fixed_param_descs) then print,(*(*!dustem_fit).fixed_param_descs)
  266 +;; stop
  267 +
258 268 ;== INITIALIZE DUST MODEL PARAMETERS and PLUGIN FREE PARAMETERS
259 269 dustem_init_parinfo,pd,iv,up_limited=ulimed,lo_limited=llimed,up_limits=ulims,lo_limits=llims,fixed=fixed,tied=tied
260 270  
261   -;== INITIALIZE ANY PLUGINS
262   -IF not keyword_set(no_reset_plugin_structure) THEN BEGIN
263   - dustem_init_plugins,pd,fpd=fpd
264   -ENDIF
  271 +;; stop
  272 +;; message,'line 271',/info
  273 +;; if ptr_valid((*!dustem_fit).param_descs) then print,(*(*!dustem_fit).param_descs)
  274 +;; if ptr_valid((*!dustem_fit).fixed_param_descs) then print,(*(*!dustem_fit).fixed_param_descs)
  275 +;; stop
265 276  
266   -;== INITIALIZE ANY FIXED PARAMETERS FOR DUST MODEL AND PLUGINS
  277 +;== Initialize ANY FIXED PARAMETERS FOR DUST MODEL AND PLUGINS
267 278 IF keyword_set(fpd) THEN BEGIN
268 279 ;== PLAY NICE -- check what already exists in the fixed parameter structure
269 280 fpar_status=ptr_valid((*!dustem_fit).fixed_param_descs)
... ... @@ -282,26 +293,39 @@ IF keyword_set(fpd) THEN BEGIN
282 293 old_fiv=(*(*!dustem_fit).fixed_param_init_values)
283 294 noldfixed=n_elements(old_fpd)
284 295  
285   - match,new_fpd,old_fpd,a,b,count=ndups
  296 + match,strupcase(new_fpd),strupcase(old_fpd),a,b,count=ndups
286 297 if ndups gt noldfixed then begin
287 298 message, 'Number of duplicates exceeds number of fixed parameters. This should not happen ?'/info
288 299 stop
289 300 endif
290   - if ndups gt 0 and ndups lt noldfixed then begin
  301 + if ndups gt 0 and ndups le noldfixed then begin
291 302 if !dustem_verbose NE 0 then message,string(ndups)+' matching fixed parameters found. Updating values for '+old_fpd[b],/info
292 303 remove,b,old_fpd
293 304 remove,b,old_fiv
294   - fpd=[new_fpd,old_fpd]
295   - fiv=[new_fiv,old_fiv]
296 305 endif
297   - if ndups eq noldfixed and !dustem_verbose NE 0 then $
298   - message,'Updating fixed parameters to their new values',/info
  306 + fpd=[new_fpd,old_fpd]
  307 + fiv=[new_fiv,old_fiv]
299 308 endif
300   -
301 309 dustem_init_fixed_params,fpd,fiv
302 310 ENDIF
  311 +;; stop
  312 +;; message,'line 312',/info
  313 +;; if ptr_valid((*!dustem_fit).param_descs) then print,(*(*!dustem_fit).param_descs)
  314 +;; if ptr_valid((*!dustem_fit).fixed_param_descs) then print,(*(*!dustem_fit).fixed_param_descs)
  315 +;; stop
  316 +
  317 +;== INITIALIZE ANY PLUGINS
  318 +IF not keyword_set(no_reset_plugin_structure) THEN BEGIN
  319 + dustem_init_plugins,pd,fpd=fpd
  320 +ENDIF
  321 +;; stop
  322 +;; message,'line 322',/info
  323 +;; if ptr_valid((*!dustem_fit).param_descs) then print,(*(*!dustem_fit).param_descs)
  324 +;; if ptr_valid((*!dustem_fit).fixed_param_descs) then print,(*(*!dustem_fit).fixed_param_descs)
  325 +;; stop
303 326  
304 327 if !dustem_verbose NE 0 then message,'Finished initializing free and fixed parameters of dust model and plugins',/info
  328 +;;stop
305 329  
306 330 the_end:
307 331  
... ...