@@ -419,82 +419,85 @@ def main():
419419 from diffpy .srmise .pdfpeakextraction import PDFPeakExtraction
420420 from diffpy .srmise .srmiseerrors import SrMiseDataFormatError , SrMiseFileError
421421
422- try :
423- options .peakfunction = eval ("peaks." + options .peakfunction )
424- except Exception as err :
425- print (err )
426- print ("Could not create peak function '%s'. Exiting." % options .peakfunction )
427- return
428-
429- try :
430- options .modelevaluator = eval ("modelevaluators." + options .modelevaluator )
431- except Exception as err :
432- print (err )
433- print ("Could not find ModelEvaluator '%s'. Exiting." % options .modelevaluator )
434- return
435-
436- if options .bcrystal is not None :
422+ if options .peakfunction :
423+ try :
424+ options .peakfunction = eval ("peaks." + options .peakfunction )
425+ except Exception as err :
426+ print (err )
427+ print ("Could not create peak function '%s'. Exiting." % options .peakfunction )
428+ return
429+
430+ if options .modelevaluator :
431+ try :
432+ options .modelevaluator = eval ("modelevaluators." + options .modelevaluator )
433+ except Exception as err :
434+ print (err )
435+ print ("Could not find ModelEvaluator '%s'. Exiting." % options .modelevaluator )
436+ return
437+
438+ if options .bcrystal :
437439 from diffpy .srmise .baselines .polynomial import Polynomial
438440
439441 bl = Polynomial (degree = 1 )
440442 options .baseline = parsepars (bl , [options .bcrystal , "0c" ])
441443 options .baseline .pars [0 ] = - 4 * np .pi * options .baseline .pars [0 ]
442- elif options .bsrmise is not None :
444+ elif options .bsrmise :
443445 # use baseline from existing file
444446 blext = PDFPeakExtraction ()
445447 blext .read (options .bsrmise )
446448 options .baseline = blext .extracted .baseline
447- elif options .bpoly0 is not None :
449+ elif options .bpoly0 :
448450 from diffpy .srmise .baselines .polynomial import Polynomial
449451
450452 bl = Polynomial (degree = 0 )
451453 options .baseline = parsepars (bl , [options .bpoly0 ])
452- elif options .bpoly1 is not None :
454+ elif options .bpoly1 :
453455 from diffpy .srmise .baselines .polynomial import Polynomial
454456
455457 bl = Polynomial (degree = 1 )
456458 options .baseline = parsepars (bl , options .bpoly1 )
457- elif options .bpoly2 is not None :
459+ elif options .bpoly2 :
458460 from diffpy .srmise .baselines .polynomial import Polynomial
459461
460462 bl = Polynomial (degree = 2 )
461463 options .baseline = parsepars (bl , options .bpoly2 )
462- elif options .bseq is not None :
464+ elif options .bseq :
463465 from diffpy .srmise .baselines .fromsequence import FromSequence
464466
465467 bl = FromSequence (options .bseq )
466468 options .baseline = bl .actualize ([], "internal" )
467- elif options .bspherical is not None :
469+ elif options .bspherical :
468470 from diffpy .srmise .baselines .nanospherical import NanoSpherical
469471
470472 bl = NanoSpherical ()
471473 options .baseline = parsepars (bl , options .bspherical )
472474
473475 try :
474476 options .baseline = eval ("baselines." + options .baseline )
477+
475478 except Exception as err :
476479 print (err )
477480 print ("Could not create baseline '%s'. Exiting." % options .baseline )
478481 return
479482
480483 filename = args [0 ]
481484
482- if filename is not None :
485+ if filename :
483486 ext = PDFPeakExtraction ()
484487 try :
485488 ext .read (filename )
486489 except (SrMiseDataFormatError , SrMiseFileError , Exception ):
487490 ext .loadpdf (filename )
488491
489492 pdict = {}
490- if options .peakfunction is not None :
493+ if options .peakfunction :
491494 pdict ["pf" ] = [options .peakfunction ]
492- if options .baseline is not None :
495+ if options .baseline :
493496 pdict ["baseline" ] = options .baseline
494- if options .cres is not None :
497+ if options .cres :
495498 pdict ["cres" ] = options .cres
496499 if options .dg_mode is None :
497- if options .dg is not None :
500+ if options .dg :
498501 options .dg_mode = "absolute"
499502 elif ext .dy is None :
500503 options .dg_mode = "max-fraction"
@@ -510,17 +513,17 @@ def main():
510513 pdict ["effective_dy" ] = options .dg * ext .y .ptp () * np .ones (len (ext .y ))
511514 elif options .dg_mode == "dG-fraction" :
512515 pdict ["effective_dy" ] = options .dg * ext .dy
513- if options .rng is not None :
516+ if options .rng :
514517 pdict ["rng" ] = list (options .rng )
515- if options .qmax is not None :
518+ if options .qmax :
516519 pdict ["qmax" ] = options .qmax if options .qmax == "automatic" else float (options .qmax )
517- if options .nyquist is not None :
520+ if options .nyquist :
518521 pdict ["nyquist" ] = options .nyquist
519- if options .supersample is not None :
522+ if options .supersample :
520523 pdict ["supersample" ] = options .supersample
521- if options .scale is not None :
524+ if options .scale :
522525 pdict ["scale" ] = options .scale
523- if options .modelevaluator is not None :
526+ if options .modelevaluator :
524527 pdict ["error_method" ] = options .modelevaluator
525528
526529 if options .liveplot :
@@ -532,23 +535,24 @@ def main():
532535 cov = None
533536 if options .performextraction :
534537 cov = ext .extract ()
538+ print (cov )
535539
536- if options .savefile is not None :
540+ if options .savefile :
537541 try :
538542 ext .write (options .savefile )
539543 except SrMiseFileError as err :
540544 print (err )
541545 print ("Could not save result to '%s'." % options .savefile )
542546
543- if options .pwafile is not None :
547+ if options .pwafile :
544548 try :
545549 ext .writepwa (options .pwafile )
546550 except SrMiseFileError as err :
547551 print (err )
548552 print ("Could not save pwa summary to '%s'." % options .pwafile )
549553
550554 print (ext )
551- if cov is not None :
555+ if cov :
552556 print (cov )
553557
554558 if options .plot :
0 commit comments