0

I am trying to import a .mat (not human readable) file in python I imported it using a package called AT.

import at
from at.plot import plot_beta
import time
import matplotlib.pyplot as plt

r = at.load_mat('FCCee_z_512_nosol_10.mat', key='RING')

Now, I want to access the data inside this .mat file and also to add some values to it using python and to save the updated file in .py format.

The result of printing the r is :

Lattice(<11470 elements>, name='l000015', energy=45600000000.0, particle=Particle('electron'), `periodicity=1, harmonic_number=121657, mat_key='RING', mat_file='N:\\musa\\1\\1\\General-`quistions\\MAD-X_Python\\fccV8_AT\\FCCee_z_512_nosol_10.mat', key='ring')`

Ho can i edit the valus of this file and save in in python format ?

Wolfie
  • 27,562
  • 7
  • 28
  • 55
Esalah
  • 27
  • 1
  • 5

1 Answers1

1

You can use scipy loadmat method to read .mat files.

https://docs.scipy.org/doc/scipy-1.8.0/html-scipyorg/reference/generated/scipy.io.loadmat.html?highlight=loadmat#scipy.io.loadmat

import scipy.io
r = scipy.io.loadmat('FCCee_z_512_nosol_10.mat')
r['data'] # you want to access