Https://matsci.org/t/data-output-files/34940/12

Hii Alex,
I was trying to print the mobility data in a text format using --gnuplot. but it does not work.
Then I tried the python script, given in the following link: Data output files - #12 by alex

I replaced “transport_x_y_z.json” with the name of my transport.json file and tried to execute the script as:
python3.8 mobility.py
But I am getting the below error:

with open(transport.json): as f
^
SyntaxError: invalid syntax

I noticed a syntax error on that line. It should be:

with open(transport.json) as f:

E.g., the position of : has changed.

I run it now with “python mobility.py”
Below is the error:

 line 5, in <module>
    with open(transport.json) as f:
NameError: name 'transport' is not defined

The scipt I am using is:

import json
import numpy as np
from amset.util import tensor_average

with open(transport.json) as f:
    transport = json.load(f)

temperatures = transport["temperatures"]
doping = transport["doping"]

# full list of scatterers included is given by
print(transport["mobility"].keys())

mob_total = np.array(transport["mobility"]["overall"])
mob_adp = np.array(transport["mobility"]["ADP"])

# transport given as a numpy array with the shape
# (n_doping, n_temperatures, 3, 3)
# to get the averaged values of transport you can do
mob_adp_avg = tensor_average(mob_adp)

# this array now has the shape (n_doping, n_temperatures)

# i.e., to plot carrier concentration against mobility for the first
# temperature
import matplotlib.pyplot as plt

plt.plot(doping, mob_adp_avg[:, 0])

The file name must be in quotes. Please see the python documentation for how to load files.

Yes, I did that also but same error.