[Ifeffit] Larch as python library

Sean Fackler swfackler at lbl.gov
Tue Nov 1 13:39:58 CDT 2016


Dear Matt,

I’ve been working to implement Larch functions as a Python library. During the implementation I found a number of things I needed to do including:

1. Identifiying a functions’ python callable name, i.e. _group as a python callable function instead of group as the larch function. 

2. The need to pass '_larch = mylarch’ in the said function or I get the 'AttributeError: 'NoneType' object has no attribute ‘symtable’ ‘

3. The need to run the script through the Python console as oppose to running as a script. 

You can see my sample script with data attached. Keep in mind I am a Python novice. So for point 3 in particular I don’t understand the difference between running some selected code in the Python console and running the whole script in the shell (I am using PyCharm CE). I checked my Python interpreter with sys.executable (path) and sys.version_info (version) which are the same between the console and interpreter which were initial issues I found online. Is the interpreter somehow not seeing the xraylarch library?

Finally: 1. Is there an easier way to use the larch functions as a python library? 
	2. Is a larch group basically a python dictionary? If so, this could be made clearer in the documentation. I am interested to contribute to the documentation if that’s of interest/help.

I am running MacOS Sierra 10.12.1 on a mid-2015 15" MacBook Pro with Python 2.7.

Ron and Alpha: Maybe you have some ideas to the above points?

Thanks everyone for any help.
 
Sean



> On Oct 12, 2016, at 7:19 PM, Matt Newville <newville at cars.uchicago.edu> wrote:
> 
> Hi Sean,
> 
> On Wed, Oct 12, 2016 at 7:36 PM, Sean Fackler <swfackler at lbl.gov <mailto:swfackler at lbl.gov>> wrote:
> Dear Larch developers (Matt),
> 
> I believe I found an error in the mback function where I get a NameError saying the name ‘f1_chantler’ is not defined. I found that simply adding f1_chantler to the larch_plugins.xray import section in mback.py fixes the problem. I have included the modified mback.py code, my input data (SigScan226827.txt), project code (mback_test.py), and the error I received (mback_error.txt).
> 
> I am running python 2.7 with anaconda as my manager, macOS Sierra v10.12, on a mid-2015 15” MacBook pro. I hope this report is correct and helpful.
>  
> Regards,
> 
> Sean
> 
> Sean Fackler, PhD
> Joint Center for Artificial Photosynthesis
> Lawrence Berkeley National Lab
> 1 Cyclotron Rd Mail Stop 30R0205
> Berkeley CA, 94720
> Mobile: 609-613-8734 <tel:609-613-8734>
>  
> 
> Sorry for the trouble and thanks for the complete report.  You're absolutely right, f1_chantler was just missing.  Fix in github master.
> 
> --Matt
> 
> 
> _______________________________________________
> Ifeffit mailing list
> Ifeffit at millenia.cars.aps.anl.gov
> http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
> Unsubscribe: http://millenia.cars.aps.anl.gov/mailman/options/ifeffit

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20161101/78db4788/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: import_fit.py
Type: text/x-python-script
Size: 3519 bytes
Desc: not available
URL: <http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20161101/78db4788/attachment-0001.bin>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20161101/78db4788/attachment-0004.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: TrajScan21930_swf.txt
URL: <http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20161101/78db4788/attachment-0001.txt>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20161101/78db4788/attachment-0005.html>


More information about the Ifeffit mailing list