-
Notifications
You must be signed in to change notification settings - Fork 7
Fix bugs to run tutorial CLI, update python, matplotlib API #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
76f4465
00d84fa
262c262
59fbe54
9d70d65
c92fdd8
f2b65ad
f23a361
39bf65c
af6f485
a8d47c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
**Added:** | ||
|
||
* <news item> | ||
|
||
**Changed:** | ||
|
||
* <news item> | ||
|
||
**Deprecated:** | ||
|
||
* <news item> | ||
|
||
**Removed:** | ||
|
||
* <news item> | ||
|
||
**Fixed:** | ||
|
||
* Configure entry point in pyproject.toml to run CLI commands | ||
|
||
**Security:** | ||
|
||
* <news item> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
**Added:** | ||
|
||
* <news item> | ||
|
||
**Changed:** | ||
|
||
* <news item> | ||
|
||
**Deprecated:** | ||
|
||
* <news item> | ||
|
||
**Removed:** | ||
|
||
* <news item> | ||
|
||
**Fixed:** | ||
|
||
* Update Python, matploblib API to run documentation CLI tutorials | ||
|
||
**Security:** | ||
|
||
* <news item> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -419,82 +419,87 @@ def main(): | |
from diffpy.srmise.pdfpeakextraction import PDFPeakExtraction | ||
from diffpy.srmise.srmiseerrors import SrMiseDataFormatError, SrMiseFileError | ||
|
||
try: | ||
options.peakfunction = eval("peaks." + options.peakfunction) | ||
except Exception as err: | ||
print(err) | ||
print("Could not create peak function '%s'. Exiting." % options.peakfunction) | ||
return | ||
|
||
try: | ||
options.modelevaluator = eval("modelevaluators." + options.modelevaluator) | ||
except Exception as err: | ||
print(err) | ||
print("Could not find ModelEvaluator '%s'. Exiting." % options.modelevaluator) | ||
return | ||
|
||
if options.bcrystal is not None: | ||
if options.peakfunction: | ||
sbillinge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
try: | ||
options.peakfunction = eval("peaks." + options.peakfunction) | ||
except Exception as err: | ||
print(err) | ||
print("Could not create peak function '%s'. Exiting." % options.peakfunction) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These error messages could be improved by giving the user hints about how to fix them. Let's make an issue to make them more informative for the user, but don't worry about closing that issue in this release. In general we need tests in srmise (please can you make an issue for that too?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue created |
||
return | ||
|
||
if options.modelevaluator: | ||
try: | ||
options.modelevaluator = eval("modelevaluators." + options.modelevaluator) | ||
except Exception as err: | ||
print(err) | ||
print("Could not find ModelEvaluator '%s'. Exiting." % options.modelevaluator) | ||
return | ||
|
||
if options.bcrystal: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to use |
||
from diffpy.srmise.baselines.polynomial import Polynomial | ||
|
||
bl = Polynomial(degree=1) | ||
options.baseline = parsepars(bl, [options.bcrystal, "0c"]) | ||
options.baseline.pars[0] = -4 * np.pi * options.baseline.pars[0] | ||
elif options.bsrmise is not None: | ||
elif options.bsrmise: | ||
# use baseline from existing file | ||
blext = PDFPeakExtraction() | ||
blext.read(options.bsrmise) | ||
options.baseline = blext.extracted.baseline | ||
elif options.bpoly0 is not None: | ||
elif options.bpoly0: | ||
from diffpy.srmise.baselines.polynomial import Polynomial | ||
|
||
bl = Polynomial(degree=0) | ||
options.baseline = parsepars(bl, [options.bpoly0]) | ||
elif options.bpoly1 is not None: | ||
elif options.bpoly1: | ||
from diffpy.srmise.baselines.polynomial import Polynomial | ||
|
||
bl = Polynomial(degree=1) | ||
options.baseline = parsepars(bl, options.bpoly1) | ||
elif options.bpoly2 is not None: | ||
elif options.bpoly2: | ||
from diffpy.srmise.baselines.polynomial import Polynomial | ||
|
||
bl = Polynomial(degree=2) | ||
options.baseline = parsepars(bl, options.bpoly2) | ||
elif options.bseq is not None: | ||
elif options.bseq: | ||
from diffpy.srmise.baselines.fromsequence import FromSequence | ||
|
||
bl = FromSequence(options.bseq) | ||
options.baseline = bl.actualize([], "internal") | ||
elif options.bspherical is not None: | ||
elif options.bspherical: | ||
from diffpy.srmise.baselines.nanospherical import NanoSpherical | ||
|
||
bl = NanoSpherical() | ||
options.baseline = parsepars(bl, options.bspherical) | ||
|
||
try: | ||
|
||
print(options.baseline) | ||
options.baseline = eval("baselines." + options.baseline) | ||
|
||
except Exception as err: | ||
print(err) | ||
print("Could not create baseline '%s'. Exiting." % options.baseline) | ||
return | ||
|
||
filename = args[0] | ||
|
||
if filename is not None: | ||
if filename: | ||
ext = PDFPeakExtraction() | ||
try: | ||
ext.read(filename) | ||
except (SrMiseDataFormatError, SrMiseFileError, Exception): | ||
ext.loadpdf(filename) | ||
|
||
pdict = {} | ||
if options.peakfunction is not None: | ||
if options.peakfunction: | ||
pdict["pf"] = [options.peakfunction] | ||
if options.baseline is not None: | ||
if options.baseline: | ||
pdict["baseline"] = options.baseline | ||
if options.cres is not None: | ||
if options.cres: | ||
pdict["cres"] = options.cres | ||
if options.dg_mode is None: | ||
if options.dg is not None: | ||
if options.dg: | ||
options.dg_mode = "absolute" | ||
elif ext.dy is None: | ||
options.dg_mode = "max-fraction" | ||
|
@@ -510,17 +515,17 @@ def main(): | |
pdict["effective_dy"] = options.dg * ext.y.ptp() * np.ones(len(ext.y)) | ||
elif options.dg_mode == "dG-fraction": | ||
pdict["effective_dy"] = options.dg * ext.dy | ||
if options.rng is not None: | ||
if options.rng: | ||
pdict["rng"] = list(options.rng) | ||
if options.qmax is not None: | ||
if options.qmax: | ||
pdict["qmax"] = options.qmax if options.qmax == "automatic" else float(options.qmax) | ||
if options.nyquist is not None: | ||
if options.nyquist: | ||
pdict["nyquist"] = options.nyquist | ||
if options.supersample is not None: | ||
if options.supersample: | ||
pdict["supersample"] = options.supersample | ||
if options.scale is not None: | ||
if options.scale: | ||
pdict["scale"] = options.scale | ||
if options.modelevaluator is not None: | ||
if options.modelevaluator: | ||
pdict["error_method"] = options.modelevaluator | ||
|
||
if options.liveplot: | ||
|
@@ -532,23 +537,24 @@ def main(): | |
cov = None | ||
if options.performextraction: | ||
cov = ext.extract() | ||
print(cov) | ||
|
||
if options.savefile is not None: | ||
if options.savefile: | ||
try: | ||
ext.write(options.savefile) | ||
except SrMiseFileError as err: | ||
print(err) | ||
print("Could not save result to '%s'." % options.savefile) | ||
|
||
if options.pwafile is not None: | ||
if options.pwafile: | ||
try: | ||
ext.writepwa(options.pwafile) | ||
except SrMiseFileError as err: | ||
print(err) | ||
print("Could not save pwa summary to '%s'." % options.pwafile) | ||
|
||
print(ext) | ||
if cov is not None: | ||
if cov: | ||
print(cov) | ||
|
||
if options.plot: | ||
|
Uh oh!
There was an error while loading. Please reload this page.