Comments (5)
Hello @lnadolski,
In Matlab, atloadlattice
works as expected with V7.3 lattice files: load
(and consequently atloadlattice
) automatically detects the format.
However in python, we rely on SciPy which state: "v4 (Level 1.0), v6 and v7 to 7.2 matfiles are supported.". In addition, SciPy mentions:
"You will need an HDF5 Python library to read MATLAB 7.3 format mat files. Because SciPy does not supply one, we do not implement the HDF5 / 7.3 interface here."
Decoding the private Matlab structure starting with a plain HDF5 reader looks difficult. So for file exchange with python, you must stick to the V7 format.
from at.
Dear @lfarv
This is good to know.
Maybe we should add a note in pyAT.
from at.
I found the hdf5storage project which claims to support V7.3 .mat files. The project does not seem to be alive any more, but it may work. I would not like to have PyAT depend on this package, but if it works (still to be checked), we could have PyAT check that if the package is available (the user explicitly installed it), it will use it, otherwise it will stick to SciPy.
from at.
Forget hdf5storage, I could not make it work: it hangs forever…
from at.
Hello both,
When I try and load a v7.3 .mat
lattice file using at.load_lattice
I get the error: NotImplementedError: Please use HDF reader for matlab v7.3 files, e.g. h5py
. To me that's clearly telling the user that the v7.3 file is the issue; however, if we wanted to be more specific we could catch that error from scipy
and reraise it with a message telling the user that they need to save the lattice file in Matlab using an earlier version.
Alternatively, if there is significant demand, we could write new functions specifically to support v7.3 files. I briefly tried loading a v7.3 file using h5py
and it seemed feasible as it, at least partially, decodes the data but it's significantly more convoluted than using scipy
:
>>> import h5py
>>> f = h5py.File("test_73_lattice.mat", "r")
>>> ring = f["RING"][0]
>>> len(ring)
2190
>>> f[ring[0]].keys()
<KeysViewHDF5 ['Class', 'Energy', 'FamName', 'Length', 'Limits', 'PassMethod']>
>>> list(f[ring[1]]['Length'])
[array([4.38])]
>>> "".join(chr(i) for i in numpy.asarray(f[ring[12]]['FamName']).flatten())
'Q3D'
>>> list(f[ring[12]]['PolynomB'])
[array([0.]), array([-0.9750889])]
from at.
Related Issues (20)
- beamloading set point not correct for simple_ring HOT 16
- pyAT 'Multipole has no attribute PolynomB' exception for loading multipoles from a .mat file with both PolynomB and K value defined HOT 1
- ATX makes matlab crash when Exact* integrators are used. HOT 3
- python get_1d_acceptance: return 0.0 instead of error if no particle survives HOT 2
- np.float gives error in acceptance/touschek.py HOT 1
- Improve element rotation help HOT 1
- python windows version installation HOT 4
- synoptics not visible in atplot when vertical values are above zero HOT 1
- pyat shift_elem ignores R1,R2 and the effect of bending angles HOT 5
- pyAT Distinguish between a sector bending magnet and a rectangular bending magnet HOT 1
- Reduce behaves differently in Matlab and python
- B0 added twice in exactkickrad HOT 2
- python: ringparam not well identified by lattice_load HOT 6
- bug is saving lattice HOT 3
- Bug: atwiggler HOT 13
- problem with display of correctly initialised VariableMultipole element HOT 1
- Change Legend Labels for plot_trajectory() function HOT 12
- fast_ring when having harmonic cavities in the lattice HOT 4
- AT_2_Elegant uses deprecated N_KICKS
- Factor 4 missing in Touschek scattering B2 expression HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from at.