xraypy/xraylarch

Larch install which is compatible with Google Colab

Closed this issue · 2 comments

I am teaching a graduate-level materials science class, and we are using Jupyter notebooks for our data analysis.

It took some effort to install and use Larch successfully on Google Colab.
I am sharing the install script here.

# pip install takes about 1:35
try:
from larch.io import read_athena
except:
!pip install xraylarch

!pip show xraylarch

# this fixed an error arising from calls to a deprecated function.
!pip install pillow==9.4.0

# After doing this, need to restart runtime

# Check the pillow library
# this needs to be 9.4.0 for the plotting to work
import PIL
print(PIL.__version__)

@joelager Thanks -- I'm not 100% sure that I know what is causing the problem with pip install pillow. I think we are not requiring anything version of pillow > 9 explicitly, but some other package might be.

@joelager I gave a try installing larch on Google colab and I got a successful installation by simply doing the following:

!pip install -q condacolab
import condacolab
condacolab.install()
!pip install git+https://github.com/xraypy/xraylarch.git

To test the installation I simply tried the latest Jupyter example with Plotly done recently by Matt:

!git clone https://github.com/xraypy/xraylarch.git
import numpy as np
import larch
from larch.xafs import pre_edge, autobk
from larch.io import read_ascii
from larch.plot.plotly_xafsplots import plot_mu, plot_bkg
cu = read_ascii('xraylarch/examples/xafsdata/cu_metal_rt.xdi')
cu.mu = -np.log(cu.itrans/cu.i0)
pre_edge(cu)
autobk(cu, rbkg=1, kw=2)
figmu = plot_mu(cu, with_deriv=True, show_e0=True, emin=8900, emax=9100)
figbkg = plot_bkg(cu, emin=8900, emax=9600)

Please, could you check this works also for your needs? If not, can you provide an example script that fails? I would like to update the installation accordingly soon.