pykat issueshttps://git.ligo.org/finesse/pykat/-/issues2017-06-19T21:55:08Zhttps://git.ligo.org/finesse/pykat/-/issues/1Put git commit ID into header2017-06-19T21:55:08ZDaniel David Browndaniel.brown@ligo.orgPut git commit ID into headerhttps://github.com/warner/python-ecdsa/blob/9e21c3388cc98ba90877a1e4dbc2aaf66c67d365/setup.py#L33
Above has an interesting way to get and put the git commit of the version pushed to pypi into the header.https://github.com/warner/python-ecdsa/blob/9e21c3388cc98ba90877a1e4dbc2aaf66c67d365/setup.py#L33
Above has an interesting way to get and put the git commit of the version pushed to pypi into the header.https://git.ligo.org/finesse/pykat/-/issues/3constants are not correctly parsed (remembered) when not in the same code block2017-07-28T14:07:08ZAndreas Freiseconstants are not correctly parsed (remembered) when not in the same code blockExample code:
```
from pykat import finesse
from pykat.commands import *
kat = finesse.kat()
kat.verbose = False
code = """
l laser1 1.0 0 n1
s s1 0 n1 n2
pd pow_t n2
const rx 1
#m m1 $rx 0 0 n2 n3
xaxis laser1 P lin ...Example code:
```
from pykat import finesse
from pykat.commands import *
kat = finesse.kat()
kat.verbose = False
code = """
l laser1 1.0 0 n1
s s1 0 n1 n2
pd pow_t n2
const rx 1
#m m1 $rx 0 0 n2 n3
xaxis laser1 P lin 0 1 10
yaxis abs
"""
code2 = "m m1 $rx 0 0 n2 n3"
kat.parseCommands(code)
kat.parseCommands(code2)
out1 = kat.run()
```https://git.ligo.org/finesse/pykat/-/issues/5Operators in Finesse command names2017-08-16T09:33:05ZDaniel David Browndaniel.brown@ligo.orgOperators in Finesse command namesThere's an issue if you have something like:
```
s west-s 1 n2 n3
```
as there is a python operator in the name. Oddly, python allows a property to be named like this, but then script parsing does not work.
Need to add in a check when ...There's an issue if you have something like:
```
s west-s 1 n2 n3
```
as there is a python operator in the name. Oddly, python allows a property to be named like this, but then script parsing does not work.
Need to add in a check when creating pykat objects to check for operator characters (+-*.^@, maybe others too) and raise an exception for the user to handle.https://git.ligo.org/finesse/pykat/-/issues/6Replacing components on parsing2017-08-20T09:09:24ZDaniel David Browndaniel.brown@ligo.orgReplacing components on parsingWe should probably have the default version of parse() not replacing components with the same name:
![image](/uploads/5fd425ca60934fadcb0632d331b54188/image.png)
Otherwise this leads to confusion. Should have keyword argument to switch...We should probably have the default version of parse() not replacing components with the same name:
![image](/uploads/5fd425ca60934fadcb0632d331b54188/image.png)
Otherwise this leads to confusion. Should have keyword argument to switch back to replacing mode if required.https://git.ligo.org/finesse/pykat/-/issues/9Add cavity parameter calculations to Pykat directly2018-04-02T21:27:02ZDaniel David Browndaniel.brown@ligo.orgAdd cavity parameter calculations to Pykat directlyThe following code is a replica of the Finesse cavity parameter calculations. I thought this would be useful to put into Pykat as you don't *need* to call the binary each time to find this stuff out.
Some notes:
* Only works for ring c...The following code is a replica of the Finesse cavity parameter calculations. I thought this would be useful to put into Pykat as you don't *need* to call the binary each time to find this stuff out.
Some notes:
* Only works for ring cavities
* Needs to determine when a two-mirror cavity is used and trace back on itself
* Needs to determine when a cavity is between two different components, like SRX.
* Then this needs to be wrapped up in the cavity command class
```
def finesse(cavity_loss):
assert(cavity_loss> 0)
if cavity_loss == 0.0:
return np.inf
elif cavity_loss == 1.0:
return 0.0
else:
l = np.sqrt(1.0 - cavity_loss);
return (np.pi / (2.0 * np.arcsin((1.0 - l) / (2.0 * np.sqrt(l)))))
node_start = "nMC1trans"
node_end = "nMC1fromMC3"
start_nodes = (base.nodes[node_end], base.nodes[node_start])
comp_list, node_list = base.nodes.getComponentsBetween(*start_nodes[::-1], True)
comp_list = list(comp_list)
node_list = list(node_list)
comp_list.append(base.MC1)
node_list.append(start_nodes)
length_RT = 0
cavity_power = 1 # Start with unit amount of power
M = np.matrix(np.eye(2))
for comp, nodes in zip(comp_list, node_list):
M = comp.ABCD(*nodes) * M
if isinstance(comp, pykat.components.space):
length_RT += comp.L.value * comp.n.value
elif isinstance(comp, (pykat.components.AbstractMirrorComponent)):
# Here we check if the cavity trace involves reflecting or
# transmitting through a mirror or beamsplitter
isRefl = False
if isinstance(comp, (pykat.components.mirror)):
if nodes[0] == nodes[1]:
isRefl = True
else:
isRefl = False
elif isinstance(comp, (pykat.components.beamSplitter)):
# here we use sets to check if the nodes we have are
# in reflection nodes or transmission
if set(nodes) >= set(comp.nodes[2:]) or set(nodes) >= set(comp.nodes[:2]):
isRefl = True
elif set(nodes) >= set(base.MC1.nodes[1::2]) or set(nodes) >= set(base.MC1.nodes[0::2]):
isRefl = False
# Then we adjust the cavity power...
if isRefl:
# Take into account R,T can be None if m1/m2/bs1/bs2 used...
if comp.R.value is None:
cavity_power *= 1-comp.T.value-comp.L.value
else:
cavity_power *= comp.R.value
else:
if comp.T.value is None:
cavity_power *= 1-comp.R.value-comp.L.value
else:
cavity_power *= comp.T.value
A,B,C,D = tuple(M.flatten()[0,i] for i in range(4))
m = (A+D)/2
g = (m + 1)/2
gouyRT = 2*np.arccos(np.sign(B) * np.sqrt(g))
FSR = 299792458 / length_RT
mode_spacing = 2*np.pi*FSR
_finesse = finesse(1-cavity_power)
FWHM = FSR / _finesse
pole = FWHM / 2.0
m, g, gouyRT, FSR, _finesse, cavity_loss, pole
```https://git.ligo.org/finesse/pykat/-/issues/10Syntax error with PyKat-1.1.260, which was installed with the instructed inst...2018-06-11T19:19:25ZKoji AraiSyntax error with PyKat-1.1.260, which was installed with the instructed installation procedureFollowed the default installation procedure on https://pypi.org/project/PyKat/ . This installed 1.1.260 and "import pykat" failed due to beamTrace syntaxerror.
```
def beamTrace(self, q_in, from_node, to_node, *args, direction='x', back_...Followed the default installation procedure on https://pypi.org/project/PyKat/ . This installed 1.1.260 and "import pykat" failed due to beamTrace syntaxerror.
```
def beamTrace(self, q_in, from_node, to_node, *args, direction='x', back_propagating=False):
^
SyntaxError: invalid syntax
```
Installing 1.1.265 solved the issue, but it required to clone the git repo and run "python setup.py install". Wouldn't it be better to officially release 1.1.265 so that the users can install pykat as instructed on the web description?
```
~/Programs$ pip install pykat
Collecting pykat
Downloading https://files.pythonhosted.org/packages/96/15/56c8ccb67b521749b5cd46565f826f465f2d72d479f59865f3ce06917840/PyKat-1.1.260.zip (409kB)
100% |████████████████████████████████| 409kB 2.4MB/s
Requirement already satisfied: numpy>=1.12 in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from pykat) (1.12.1)
Requirement already satisfied: flask>=0.10.1 in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from pykat) (0.12.2)
Requirement already satisfied: scipy in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from pykat) (0.19.1)
Requirement already satisfied: six in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from pykat) (1.10.0)
Requirement already satisfied: h5py in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from pykat) (2.7.0)
Requirement already satisfied: pandas in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from pykat) (0.20.1)
Requirement already satisfied: matplotlib in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from pykat) (2.0.2)
Requirement already satisfied: tabulate in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages/tabulate-0.8.2-py2.7.egg (from pykat) (0.8.2)
Requirement already satisfied: Werkzeug>=0.7 in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from flask>=0.10.1->pykat) (0.12.2)
Requirement already satisfied: Jinja2>=2.4 in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from flask>=0.10.1->pykat) (2.9.6)
Requirement already satisfied: itsdangerous>=0.21 in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from flask>=0.10.1->pykat) (0.24)
Requirement already satisfied: click>=2.0 in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from flask>=0.10.1->pykat) (6.7)
Requirement already satisfied: python-dateutil in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from pandas->pykat) (2.6.0)
Requirement already satisfied: pytz>=2011k in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from pandas->pykat) (2017.2)
Requirement already satisfied: functools32 in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from matplotlib->pykat) (3.2.3.post2)
Requirement already satisfied: subprocess32 in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from matplotlib->pykat) (3.2.7)
Requirement already satisfied: cycler>=0.10 in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from matplotlib->pykat) (0.10.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from matplotlib->pykat) (2.1.4)
Requirement already satisfied: MarkupSafe>=0.23 in /Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages (from Jinja2>=2.4->flask>=0.10.1->pykat) (0.23)
Building wheels for collected packages: pykat
Running setup.py bdist_wheel for pykat ... done
Stored in directory: /Users/karai/Library/Caches/pip/wheels/15/74/ab/3c0957c6b2ac34d7b8c613a9f9010c4b5704c2ba3236ea8aa6
Successfully built pykat
Installing collected packages: pykat
Successfully installed pykat-1.1.260
~/Programs$ ipython
Python 2.7.13 |Anaconda custom (x86_64)| (default, Dec 20 2016, 23:05:08)
Type "copyright", "credits" or "license" for more information.
IPython 5.3.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import pykat
File "/Users/karai/.pyenv/versions/anaconda2-4.4.0/lib/python2.7/site-packages/pykat/finesse.py", line 3451
def beamTrace(self, q_in, from_node, to_node, *args, direction='x', back_propagating=False):
^
SyntaxError: invalid syntax
```https://git.ligo.org/finesse/pykat/-/issues/11Offsets not implemented in BayerHelms Solver2019-06-10T09:50:04ZAaron JonesOffsets not implemented in BayerHelms SolverThe `delta` parameter in `pykat.optics.knm.knmHG` is not passed into the function `bayerhelms_HG_knm` on line 735 of module `pykat.optics.knm`. Neither is it implemented in `bayerhelms_HG_knm`.
Example code:
```python
from pykat.optics....The `delta` parameter in `pykat.optics.knm.knmHG` is not passed into the function `bayerhelms_HG_knm` on line 735 of module `pykat.optics.knm`. Neither is it implemented in `bayerhelms_HG_knm`.
Example code:
```python
from pykat.optics.gaussian_beams import BeamParam
from pykat.optics.knm import knmHG, makeCouplingMatrix, plot_knm_matrix
C = makeCouplingMatrix(3)
q = BeamParam(w0=1e-3,z=0)
Kbh = knmHG(C, q, q, method="bayerhelms", delta = 0.1*w0)
plot_knm_matrix(C, Kbh)
```https://git.ligo.org/finesse/pykat/-/issues/16Pykat plots differently to Finesse for auto-alignment example2019-12-22T17:28:50ZSean LeaveyPykat plots differently to Finesse for auto-alignment example[This code](http://www.gwoptics.org/finesse/examples/autoalignment.php) has different output between direct Finesse and Pykat:
```
%--------------------------------------------------------------------------------------------------------...[This code](http://www.gwoptics.org/finesse/examples/autoalignment.php) has different output between direct Finesse and Pykat:
```
%----------------------------------------------------------------------------------------------------------
% Finesse input file to compute the alignment signals generated from a
% cavity in reflection using the Ward technique
% Paul Fulda 17.02.2012
%----------------------------------------------------------------------------------------------------------
l laser 1 0 nin % Laser P=1W f_offset=0Hz
mod EOM 15M 0.001 1 pm nin n0 % Phase modulator f_mod=15MHz, modulation index=0.001
maxtem 3 % Include HG modes up to order 3
s s0 0 n0 n1
bs pickoff 0.1 0.9 0 45 n1 dump n2 n3 % Beam splitter with R=0.1, T=0.9 at zero tuning
s s1 0.1 n2 n4 % Space 10cm length
m ITM 0.99 0.01 0 n4 n5 % Cavity input mirror with R=0.99, T=0.01, at zero tuning
s scavity 1 n5 n6 % Space 1m length
m ETM 0.99 0.01 0 n6 n7 % Cavity end mirror with R=0.99, T=0.01, at zero tuning
s s2 0.1 n3 n8 % Space 10cm length
bs bsQPD 0.5 0.5 0 45 n8 n9 n10 dump % Beam splitter with R=T=0.5 at zero tuning
s sQPD1 0.1 n9 n11 % Space 10cm length
s sQPD2 0.1 n10 n12 % Space 10cm length
cav cavity ITM n5 ETM n6 % Trace cavity eigenmode for the cavity (mirrors ITM and ETM)
trace 2 % Display results of cavity trace to terminal output
attr ETM Rc 1.3 % Add curvature with radius 1.3m to mirror ETM
attr ETM xbeta 0 % Add a variable for the angular tuning of mirror ETM
attr ITM xbeta 0 % Add a variable for the angular tuning of mirror ITM
pd1 PDrefl 15M 0 n8* % Photodetector with demodulation at 15MHz, demodulation phase 0
attr sQPD1 g 40 % Fix the Gouy phase shift the space QPDsplit2QPDrefl1 to 40 degrees
attr sQPD2 g 130 % Add 90 deg Gouy phase shift to the space QPDsplit2QPDrefl2
pd1 QPDrefl1 15M 0 n11 % Photodetector with demodulation at 15MHz, demod. phase 0 deg
pdtype QPDrefl1 x-split % Specify that QPDrefl1 is a split photodiode
pd1 QPDrefl2 15M 0 n12 % Photodetector with demodulation at 15MHz, demod. phase 0 deg
pdtype QPDrefl2 x-split % Specify that QPDrefl2 is a split photodiode
set err PDrefl re % Define the signal from PDrefl to be used to generate error signal
lock z $err 3000 10n % Generate feedback signal, gain of 3000, lock accuracy of 10ppm
put ETM phi $z % Apply feedback signal to the tuning of mirror ETM
noplot z % Don't plot the feedback signal
%xaxis ITM xbeta lin 0 0.8m 500 % Sweep misalignment of mirror ITM from 0 to 0.8mrad
xaxis ETM xbeta lin 0 0.8m 500 % Sweep misalignment of mirror ETM from 0 to 0.8mrad
```
Finesse:
![Finesse](/uploads/d277e7daf07ae7d49d842e9fe5f14b75/Screenshot_20191222_172543.png)
Pykat:
![Pykat](/uploads/7323649f0d734a68a6cf09d7d9a0036d/Figure_1.png)
Looks like `noplot z` is being ignored by Pykat's `plot` function...https://git.ligo.org/finesse/pykat/-/issues/18Mirror attribute 'rap' not read via attr command2020-06-04T16:52:58ZAndreas FreiseMirror attribute 'rap' not read via attr commandThe aperture of a mirror cannot be set with the attr command.
```
kat = finesse.kat()
kat.verbose = False
code = """
l l1 1 0 n1
gauss g1 l1 n1 1m -1
s s1 1 n1 n2
m m1 0.5 0.5 0 n2 n3
attr m1 rap 0.1
maxtem 0
pd refl n2
xaxi...The aperture of a mirror cannot be set with the attr command.
```
kat = finesse.kat()
kat.verbose = False
code = """
l l1 1 0 n1
gauss g1 l1 n1 1m -1
s s1 1 n1 n2
m m1 0.5 0.5 0 n2 n3
attr m1 rap 0.1
maxtem 0
pd refl n2
xaxis m1 rap lin 0.2m 3m 100
"""
kat.parse(code)
out = kat.run()
```
Gives:
```
Pykat error parsing line: 'attr m1 rap 0.1':
No attribute rap for mirrors
```
The file runs after commenting out that line.https://git.ligo.org/finesse/pykat/-/issues/19Update citation2020-10-12T10:47:40ZSean LeaveyUpdate citationWhen the Pykat paper gets published in SoftwareX, update the instructions for citing Pykat in the readme.When the Pykat paper gets published in SoftwareX, update the instructions for citing Pykat in the readme.https://git.ligo.org/finesse/pykat/-/issues/20Moving output files using os.rename() does not work cross filesystems2020-11-25T13:23:38ZMischa SalleMoving output files using os.rename() does not work cross filesystemsWhen specifying `save_kat` and/or `save_output` in the kat `run` function, the output files are moved using `os.rename()` in respectively [finesse.py#L2395](https://git.ligo.org/finesse/pykat/-/blob/master/pykat/finesse.py#L2395) and [fi...When specifying `save_kat` and/or `save_output` in the kat `run` function, the output files are moved using `os.rename()` in respectively [finesse.py#L2395](https://git.ligo.org/finesse/pykat/-/blob/master/pykat/finesse.py#L2395) and [finesse.py#L2411](https://git.ligo.org/finesse/pykat/-/blob/master/pykat/finesse.py#L2411). That fails in case the src and dest are on different filesystems which is very common since the src is in the /tmp directory.
(Note that according to https://stackoverflow.com/a/43967659 `shutil.move()` would be a good replacement for python3 only. I've tried `shutil.move()` on two linux systems, one with 2.7.5 one with 2.7.17 and both seem to work fine which also matches the documentation https://docs.python.org/2.7/library/shutil.html#shutil.move).https://git.ligo.org/finesse/pykat/-/issues/21conda with python3.9 fails to install current pykat 1.2.812021-02-16T11:59:56ZMischa Salleconda with python3.9 fails to install current pykat 1.2.81With a clean environment and using the now default python3.9, conda wants to install pykat 1.1.331.
If I instead try to install pykat 1.2.81 or 1.2.73 explicitly it cannot fulfill the dependencies:
```
conda create -n testenv
conda activ...With a clean environment and using the now default python3.9, conda wants to install pykat 1.1.331.
If I instead try to install pykat 1.2.81 or 1.2.73 explicitly it cannot fulfill the dependencies:
```
conda create -n testenv
conda activate testenv
conda install jupyter
# Next step works but would give pykat-1.1.331
conda install -c gwoptics pykat
# Next step fails:
conda install -c gwoptics pykat=1.2.81
```
Same result with pykat 1.2.73 (oddly enough no details in the error just that there is an incompatibility).https://git.ligo.org/finesse/pykat/-/issues/22Name of gaussian element changes upon deepcopy()2021-03-04T11:52:18ZMischa SalleName of gaussian element changes upon deepcopy()the name of a `gauss` element changes upon a `deepcopy()`
For example:
```
code = """
l laser 1.5 0 n0
gauss g1 laser n0 10m -1000
"""
kat1 = finesse.kat()
kat1.parse(code)
print(kat1)
kat2 = deepcopy(kat1)
print(kat2)
```
shows that in...the name of a `gauss` element changes upon a `deepcopy()`
For example:
```
code = """
l laser 1.5 0 n0
gauss g1 laser n0 10m -1000
"""
kat1 = finesse.kat()
kat1.parse(code)
print(kat1)
kat2 = deepcopy(kat1)
print(kat2)
```
shows that in copy kat2 the `gauss` element has changed name from `g1` to `g_n0`.
That leads to surprises if you then want to override (overwrite actually) that original `gauss` (you'd get two elements).https://git.ligo.org/finesse/pykat/-/issues/23pykat 1.2.1 incompatible with matplotlib > 3.32022-01-27T23:41:50ZRana Adhikaripykat 1.2.1 incompatible with matplotlib > 3.3the set_clim method for colorbars doesn't work anymore since matplotlib 3.3:
https://github.com/matplotlib/matplotlib/blob/a8831d57207db5e9bf681e30810ce0ea146f4a31/doc/api/prev_api_changes/api_changes_3.3.0/removals.rst
MWE:
https://git...the set_clim method for colorbars doesn't work anymore since matplotlib 3.3:
https://github.com/matplotlib/matplotlib/blob/a8831d57207db5e9bf681e30810ce0ea146f4a31/doc/api/prev_api_changes/api_changes_3.3.0/removals.rst
MWE:
https://git.ligo.org/IFOsim/Finesse_playground/-/blob/master/daniel_brown/cavity_maps.py
I believe this can be fixed by updating
https://git.ligo.org/finesse/pykat/-/blob/master/pykat/optics/maps.py
with the new syntax.https://git.ligo.org/finesse/pykat/-/issues/24Latest Pykat (1.2.81) not compatible with Python 3.122023-12-18T13:51:40ZAaron JonesLatest Pykat (1.2.81) not compatible with Python 3.12PyKat is using the module `imp` which was deprecated in favour of `importlib`. See https://docs.python.org/3.11/library/imp.html
This could be fixed by requiring Python <= 3.11.
Error message reads `ModuleNotFoundsError: No module nam...PyKat is using the module `imp` which was deprecated in favour of `importlib`. See https://docs.python.org/3.11/library/imp.html
This could be fixed by requiring Python <= 3.11.
Error message reads `ModuleNotFoundsError: No module named 'imp'`
![image](/uploads/0429ddfcedbd45d0fee19068ef8d41e0/image.png)