pyOPALTools issueshttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues2021-12-19T23:37:51+01:00https://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/101tex font cannot be used in matplotlib after import pyOPAL2021-12-19T23:37:51+01:00ext-piot_ptex font cannot be used in matplotlib after import pyOPALThere seems to be an issue with adding tex symbols in matplotlib after import pyOPAL. The simple code snippet below
```
from matplotlib import rc
from opal.opal import load_dataset
import matplotlib.pyplot as plt
FontSize=22
FontSizeLab...There seems to be an issue with adding tex symbols in matplotlib after import pyOPAL. The simple code snippet below
```
from matplotlib import rc
from opal.opal import load_dataset
import matplotlib.pyplot as plt
FontSize=22
FontSizeLabelAxis=22
rc('xtick',labelsize=FontSize)
rc('ytick',labelsize=FontSize)
rc('text', usetex=True)
x=np.linspace(-10,10,100)
plt.plot (x,x**2)
plt.xlabel (r'$x$ ')
```
give the error
```
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-11cccf49f543> in <module>
14 x=np.linspace(-10,10,100)
15 plt.plot (x,x**2)
---> 16 plt.xlabel (r'$x$ ')
/usr/lib64/python3.9/site-packages/matplotlib/pyplot.py in xlabel(xlabel, fontdict, labelpad, loc, **kwargs)
3113 @_copy_docstring_and_deprecators(Axes.set_xlabel)
3114 def xlabel(xlabel, fontdict=None, labelpad=None, *, loc=None, **kwargs):
-> 3115 return gca().set_xlabel(
3116 xlabel, fontdict=fontdict, labelpad=labelpad, loc=loc,
3117 **kwargs)
/usr/lib64/python3.9/site-packages/matplotlib/axes/_axes.py in set_xlabel(self, xlabel, fontdict, labelpad, loc, **kwargs)
245 elif loc == 'right':
246 kwargs.update(x=1, horizontalalignment='right')
--> 247 return self.xaxis.set_label_text(xlabel, fontdict, **kwargs)
248
249 def get_ylabel(self):
/usr/local/lib/python3.9/site-packages/opal-1.0.0-py3.9.egg/opal/utilities/wrapper.py in run(*args, **kwargs)
35 @functools.wraps(fun)
36 def run(*args, **kwargs):
---> 37 return new_fun(fun, *args, **kwargs)
38 return run
39
/usr/local/lib/python3.9/site-packages/opal-1.0.0-py3.9.egg/opal/utilities/wrapper.py in new_label(fun, *args, **kwargs)
67 # we need to add the signs otherwise LaTex formulas
68 # are not properly compiled
---> 69 re._alphanum_str = re._alphanum_str.union(signs)
70 lst[idx] = re.escape(lst[idx])
71 # remove signs again
AttributeError: module 're' has no attribute '_alphanum_str'
```ext-piot_pext-piot_phttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/99Update LossParser after update2021-06-01T09:40:31+02:00snuverink_jjochem.snuverink@psi.chUpdate LossParser after updatein src!494 (for OPAL 2.6) the ASCII loss output was updated from:
```
# Element: NAME , x (m), y (m), z (m), px ( ), py ( ), pz ( ), id
```
to
```
# x (m), y (m), z (m), px ( ), py ( ), pz ( ), id;
```
The LossParser should b...in src!494 (for OPAL 2.6) the ASCII loss output was updated from:
```
# Element: NAME , x (m), y (m), z (m), px ( ), py ( ), pz ( ), id
```
to
```
# x (m), y (m), z (m), px ( ), py ( ), pz ( ), id;
```
The LossParser should be adapted such that it reads in the new and the old format.snuverink_jjochem.snuverink@psi.chsnuverink_jjochem.snuverink@psi.chhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/98Integrate UQ interface2020-09-15T11:38:14+02:00frey_mIntegrate UQ interfaceUpgrade the surrogate package with the new UQ interface.Upgrade the surrogate package with the new UQ interface.frey_mfrey_mhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/97Missing colon2020-11-06T08:42:54+01:00frey_mMissing colonfrey_mfrey_mhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/96Simplify file type checking2020-07-21T10:13:46+02:00frey_mSimplify file type checkingThe file type checking is quite error-prone. I suggest simplifying the interface with a function `check_file` for each parser.The file type checking is quite error-prone. I suggest simplifying the interface with a function `check_file` for each parser.frey_mfrey_mhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/95index mask evaluated at wrong location in FieldPlotter2020-11-06T08:42:54+01:00frey_mindex mask evaluated at wrong location in FieldPlotterThe index mask is evaluated at the wrong location in the line plot funtion of `FieldPlotter`.The index mask is evaluated at the wrong location in the line plot funtion of `FieldPlotter`.frey_mfrey_mhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/93Update on FieldDataset2020-06-18T13:29:01+02:00frey_mUpdate on FieldDatasetThis issue should
- add the file FieldAnalysis.py
- provide the line plot functionality to FieldPlotter
- do some changes on FieldParser and FieldDatasetThis issue should
- add the file FieldAnalysis.py
- provide the line plot functionality to FieldPlotter
- do some changes on FieldParser and FieldDatasetfrey_mfrey_mhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/92Missing sphinx entries for FieldDataset2020-11-06T08:42:53+01:00frey_mMissing sphinx entries for FieldDatasetfrey_mfrey_mhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/91Installation with setup.py fails2020-11-06T08:42:53+01:00frey_mInstallation with setup.py failsThe installation with `setup.py` fails with the error message:
```bash
package init file 'jobhandler\__init__.py' not found (or not a regular file)
error: package directory 'opal\visualization\stylesoptPilot' does not exist
```
The reaso...The installation with `setup.py` fails with the error message:
```bash
package init file 'jobhandler\__init__.py' not found (or not a regular file)
error: package directory 'opal\visualization\stylesoptPilot' does not exist
```
The reason is a missing comma in the `PACKAGES` list.frey_mfrey_mhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/90Follow-up from "Resolve "H5Parser method to close files""2020-06-09T15:31:26+02:00frey_mFollow-up from "Resolve "H5Parser method to close files""The following discussion from !51 should be addressed:
- [ ] @frey_m started a [discussion](https://gitlab.psi.ch/OPAL/pyOPALTools/merge_requests/51#note_22727): (+12 comments)
> @snuverink\_j I get an error when `H5Parser.close` ...The following discussion from !51 should be addressed:
- [ ] @frey_m started a [discussion](https://gitlab.psi.ch/OPAL/pyOPALTools/merge_requests/51#note_22727): (+12 comments)
> @snuverink\_j I get an error when `H5Parser.close` is called. My script only loads a H5 file and calls the print function. I use the h5py version 2.10.0. Have you experienced any error like this?
>
> ```bash
> Exception ignored in: <bound method H5Dataset.__del__ of <opal.datasets.H5Dataset.H5Dataset object at 0x7f08da008f98>>
> Traceback (most recent call last):
> File "/home/matthias/Documents/projects/pyOPALTools/opal/datasets/H5Dataset.py", line 98, in __del__
> File "/home/matthias/Documents/projects/pyOPALTools/opal/parser/H5Parser.py", line 59, in close
> File "/home/matthias/Documents/projects/pyOPALTools/pyOPALTools.venv/lib/python3.5/site-packages/h5py/_hl/files.py", line 432, in close
> File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
> File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
> File "h5py/h5f.pyx", line 267, in h5py.h5f.get_obj_ids
> File "h5py/h5i.pyx", line 37, in h5py.h5i.wrap_identifier
> SystemError: Parent module 'h5py' not loaded, cannot perform relative import
> ```
**Possible fix:**
Replacing the line `self.__h5f.close()` in `H5Parser.close` by `del self.__h5f`.frey_mfrey_mhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/89Wrong implementation of functions in H5Dataset.2020-11-06T08:42:53+01:00frey_mWrong implementation of functions in H5Dataset.`H5Dataset.getMonitorDataFrame` and `H5Dataset.getH5DataFrame` are not properly implemented.`H5Dataset.getMonitorDataFrame` and `H5Dataset.getH5DataFrame` are not properly implemented.frey_mfrey_mhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/87Labels with # not correctly interpreted by tex2020-11-06T08:42:53+01:00snuverink_jjochem.snuverink@psi.chLabels with # not correctly interpreted by texplot labels like `plt.ylabel('#cores')` are not correctly interpreted in Tex mode (see, e.g. http://amas.web.psi.ch/docs/pyOPALTools/RingMultiBunch.html).
In https://gitlab.psi.ch/OPAL/pyOPALTools/blob/master/opal/visualization/SamplerP...plot labels like `plt.ylabel('#cores')` are not correctly interpreted in Tex mode (see, e.g. http://amas.web.psi.ch/docs/pyOPALTools/RingMultiBunch.html).
In https://gitlab.psi.ch/OPAL/pyOPALTools/blob/master/opal/visualization/SamplerPlotter.py#L201 we do
```python
isTex = mpl.rcParams['text.usetex']
xlabel = '#samples'
if isTex:
xlabel = '\\' + xlabel
```
Do we need to do this everywhere, or should we create an "escape_tex" method, or is there a better solution?
cc: @frey\_mfrey_mfrey_mhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/86Add new dataset for field data on grid2020-06-08T16:50:33+02:00frey_mAdd new dataset for field data on gridOPAL writes the field data on the grid to file if `DBG_SCALARFIELD` is enabled. We should provide a parser, dataset and plotting functions.OPAL writes the field data on the grid to file if `DBG_SCALARFIELD` is enabled. We should provide a parser, dataset and plotting functions.frey_mfrey_mhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/85requirements.txt and setup.py out of date2020-11-06T08:42:53+01:00snuverink_jjochem.snuverink@psi.chrequirements.txt and setup.py out of dateThe requirements.txt and setup.py are out of date.The requirements.txt and setup.py are out of date.snuverink_jjochem.snuverink@psi.chsnuverink_jjochem.snuverink@psi.chhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/84Documentation: add last changed date2020-11-06T08:42:53+01:00snuverink_jjochem.snuverink@psi.chDocumentation: add last changed dateThe documentation is now automatically generated (#81), however there is no last changed date, so one is not sure if an update was successful.The documentation is now automatically generated (#81), however there is no last changed date, so one is not sure if an update was successful.snuverink_jjochem.snuverink@psi.chsnuverink_jjochem.snuverink@psi.chhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/83Documentation: import opal error for jupyter notebooks2020-11-06T08:42:53+01:00snuverink_jjochem.snuverink@psi.chDocumentation: import opal error for jupyter notebooksThe jupyter notebooks (e.g. http://amas.web.psi.ch/docs/pyOPALTools/Cyclotron.html) have import errors:
```python
from opal.opal import load_dataset, filetype
ds = load_dataset('./../../tests/testData/', ftype=filetype.TRACK_ORBIT)
---...The jupyter notebooks (e.g. http://amas.web.psi.ch/docs/pyOPALTools/Cyclotron.html) have import errors:
```python
from opal.opal import load_dataset, filetype
ds = load_dataset('./../../tests/testData/', ftype=filetype.TRACK_ORBIT)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-2f139e8985fc> in <module>
----> 1 from opal.opal import load_dataset, filetype
ModuleNotFoundError: No module named 'opal'
```
The jupyter notebooks are generated by nbsphinx, but this doesn't copy the sys.path from sphinx, but only the environment variables, so the PYTHONPATH should be set in the main script `conf.py`. See also the documentation: https://nbsphinx.readthedocs.io/en/0.7.0/configuring-kernels.html#Environment-Variablessnuverink_jjochem.snuverink@psi.chsnuverink_jjochem.snuverink@psi.chhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/82Sampler and Optimizer files of OPAL-2.2.0 cannot be loaded2020-04-22T16:05:30+02:00frey_mSampler and Optimizer files of OPAL-2.2.0 cannot be loadedSampler and optimizer files that are generated with OPAL-2.2.0 cannot be loaded due to the version number. Adding the line
```Python
self.__version_support = {
'2.1.0': self.__parse_version_2_1_0,
'2.2.0': self.__parse_version_2_...Sampler and optimizer files that are generated with OPAL-2.2.0 cannot be loaded due to the version number. Adding the line
```Python
self.__version_support = {
'2.1.0': self.__parse_version_2_1_0,
'2.2.0': self.__parse_version_2_1_0 # OPAL-2.2.0 support
}
```
would fix the problem. However, we should do a more general approach in order to avoid this error in future.frey_mfrey_mhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/81Auto deploy sphinx documentation2020-05-28T09:45:23+02:00snuverink_jjochem.snuverink@psi.chAuto deploy sphinx documentationSimilar to the OPAL manual, the sphinx documentation (#32) for pyOPALTools should be generated automatically on http://amas.web.psi.ch/docs/pyOPALTools/index.html
Note that the jupyter notebooks are now included (#79 !57) in the documen...Similar to the OPAL manual, the sphinx documentation (#32) for pyOPALTools should be generated automatically on http://amas.web.psi.ch/docs/pyOPALTools/index.html
Note that the jupyter notebooks are now included (#79 !57) in the documentation. The python package `nbsphinx` is needed, as well as `pandoc` and `latex`. There are some issues with the latex labels with matplotlib, therefore not all notebooks might build without problems, but this will then be fixed later.gsellgsellhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/80module uq : chaospy (3.2.9) chaospy.dot does not exist2020-04-14T10:44:11+02:00snuverink_jjochem.snuverink@psi.chmodule uq : chaospy (3.2.9) chaospy.dot does not existWhen I run the confidence_interval notebook I get the following error:
```
AttributeError Traceback (most recent call last)
<ipython-input-2-637cb2ef6afe> in <module>
16
17 y_train, y_pred, y_lo, y_...When I run the confidence_interval notebook I get the following error:
```
AttributeError Traceback (most recent call last)
<ipython-input-2-637cb2ef6afe> in <module>
16
17 y_train, y_pred, y_lo, y_up = uq.confidence_interval(x_train, y_train, alpha=alpha,
---> 18 n_boot=n_boot, sample=sample)
19
20 plt.figure(figsize=(16, 9))
~/Documents/OPAL/pyOPALTools/surrogate/uq.py in confidence_interval(self, x, y, alpha, **kwargs)
129
130 lo, up = bs.confidence_interval(alpha=alpha)
--> 131 lo_pce = cp.dot(poly, np.asarray(lo))
132 up_pce = cp.dot(poly, np.asarray(up))
133
AttributeError: module 'chaospy' has no attribute 'dot'
```
For this I had to add the following fix to bootstrap.py:
```diff
- return 2.0 * fitted - qlo, 2.0 * fitted - qhi
+ return 2.0 * np.asarray(fitted) - qlo, 2.0 * np.asarray(fitted) - qhi
```frey_mfrey_mhttps://gitlab.psi.ch/OPAL/pyOPALTools/-/issues/79Add Jupyter Notebooks to Sphinx documentation2020-04-20T11:08:56+02:00snuverink_jjochem.snuverink@psi.chAdd Jupyter Notebooks to Sphinx documentationAs discussed in https://gitlab.psi.ch/OPAL/pyOPALTools/issues/32#note_19574, it would be good to include the jupyter notebooks in the sphinx documentation.As discussed in https://gitlab.psi.ch/OPAL/pyOPALTools/issues/32#note_19574, it would be good to include the jupyter notebooks in the sphinx documentation.snuverink_jjochem.snuverink@psi.chsnuverink_jjochem.snuverink@psi.ch