Skip to content

Commit

Permalink
Bug fix in matching routine (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoubelet committed Mar 23, 2021
1 parent 2a3960a commit 36c4399
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 211 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@
♻️ An all-in-one package for Python work in my PhD ♻️
</p>

<p align="center">
<!-- General DOI -->
<a href="https://zenodo.org/badge/latestdoi/227081702">
<img alt="DOI" src="https://zenodo.org/badge/227081702.svg">
</a>
</p>

<p align="center">
<a href="https://www.python.org/">
<img alt="Made With Python" src="https://forthebadge.com/images/badges/made-with-python.svg">
Expand Down
2 changes: 1 addition & 1 deletion docker/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ dependencies:
- pycparser==2.20
- pydantic==1.7
- pygments==2.7.2
- pyhdtoolkit==0.8.4
- pyhdtoolkit==0.8.5
- pyparsing==2.4.7
- pyrsistent==0.17.3
- python-dateutil==2.8.1
Expand Down
403 changes: 206 additions & 197 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyhdtoolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
__title__ = "pyhdtoolkit"
__description__ = "An all-in-one toolkit package to easy my Python work in my PhD."
__url__ = "https://github.com/fsoubelet/PyhDToolkit"
__version__ = "0.8.4"
__version__ = "0.8.5"
__author__ = "Felix Soubelet"
__author_email__ = "felix.soubelet@cern.ch"
__license__ = "MIT"
4 changes: 2 additions & 2 deletions pyhdtoolkit/cpymadtools/latwiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,15 @@ def _plot_machine_layout(

logger.debug("Plotting machine layout")
logger.trace(f"Plotting from axis '{quadrupole_patches_axis}'")
quadrupole_patches_axis.set_ylabel("1/f=K1L [m$^{-1}$]", color="red") # quadrupole in red
quadrupole_patches_axis.set_ylabel("$1/f=K_{1}L$ [m$^{-1}$]", color="red") # quadrupole in red
quadrupole_patches_axis.tick_params(axis="y", labelcolor="red")
quadrupole_patches_axis.set_ylim(k1l_lim)
quadrupole_patches_axis.set_xlim(xlimits)
quadrupole_patches_axis.set_title(title)
quadrupole_patches_axis.plot(twiss_df.s, 0 * twiss_df.s, "k") # 0-level line

dipole_patches_axis = quadrupole_patches_axis.twinx()
dipole_patches_axis.set_ylabel("$\\theta$=K0L [rad]", color="royalblue") # dipoles in blue
dipole_patches_axis.set_ylabel("$\\theta=K_{0}L$ [rad]", color="royalblue") # dipoles in blue
dipole_patches_axis.tick_params(axis="y", labelcolor="royalblue")
dipole_patches_axis.set_ylim(k0l_lim)
dipole_patches_axis.grid(False)
Expand Down
4 changes: 2 additions & 2 deletions pyhdtoolkit/cpymadtools/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ def match(*args, **kwargs):
logger.trace("Performing routine TWISS")
madx.twiss() # prevents errors if the user forget to do so before querying tables

if q1_target and q2_target and dq1_target and dq2_target:
if q1_target is not None and q2_target is not None and dq1_target is not None and dq2_target is not None:
logger.info(
f"Doing combined matching to Qx={q1_target}, Qy={q2_target}, "
f"dqx={dq1_target}, dqy={dq2_target} for sequence '{sequence}'"
)
logger.trace(f"Vary knobs sent are {varied_knobs}")
match(*varied_knobs, q1=q1_target, q2=q2_target, dq1=dq1_target, dq2=dq2_target)

elif q1_target and q2_target:
elif q1_target is not None and q2_target is not None:
logger.info(f"Matching tunes to Qx={q1_target}, Qy={q2_target} for sequence '{sequence}'")
logger.trace(f"Vary knobs sent are {varied_knobs[:2]}")
match(*varied_knobs[:2], q1=q1_target, q2=q2_target) # first two in varied_knobs are tune knobs
Expand Down
2 changes: 1 addition & 1 deletion pyhdtoolkit/cpymadtools/special.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def make_lhc_thin(madx: Madx, sequence: str, slicefactor: int = 1, **kwargs) ->

madx.use(sequence=sequence)
style = kwargs.get("style", "teapot")
makedipedge = kwargs.get("makedipedge", True)
makedipedge = kwargs.get("makedipedge", False) # defaults to False to compensate default TEAPOT style
madx.command.makethin(sequence=sequence, style=style, makedipedge=makedipedge)


Expand Down
12 changes: 6 additions & 6 deletions pyhdtoolkit/utils/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
# ------ Axes ------ #
"axes.linewidth": 0.8, # Linewidth of axes edges
"axes.grid": False, # Do not display grid
"axes.labelsize": 25, # Fontsize of the x and y axis labels
"axes.titlesize": 27, # Fontsize of the axes title
"axes.formatter.limits": (-3, 5), # Switch to scientific notations when order of magnitude reaches 1e3
"axes.labelsize": 30, # Fontsize of the x and y axis labels
"axes.titlesize": 30, # Fontsize of the axes title
"axes.formatter.limits": (-4, 5), # Switch to scientific notations when order of magnitude reaches 1e3
# "axes.formatter.useoffset": False, # Do not use the annoying offset on top of yticks
"axes.formatter.use_mathtext": True, # Format with i.e 10^{4} instead of 1e4
# ------ Date Formats ------ #
Expand Down Expand Up @@ -73,16 +73,16 @@
# ------ Paths ------ #
"path.simplify": True, # Reduce file size by removing "invisible" points
# ------ Saving ------ #
"savefig.dpi": 350, # Saved figure dots per inch
"savefig.dpi": 1000, # Saved figure dots per inch
"savefig.format": "pdf", # Saved figure file format
"savefig.bbox": "tight", # Careful: incompatible with pipe-based animation backends
# ------ Text ------ #
"text.antialiased": True, # Apply anti-aliasing to text elements
"text.color": "black", # Default text color
"text.usetex": False, # Do not use LaTeX for text handling (I don't have a local installation)
# ------ Ticks ------ #
"xtick.labelsize": 20, # Fontsize of the x axis tick labels
"ytick.labelsize": 20, # Fontsize of the y axis tick labels
"xtick.labelsize": 25, # Fontsize of the x axis tick labels
"ytick.labelsize": 25, # Fontsize of the y axis tick labels
}


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyhdtoolkit"
version = "0.8.4"
version = "0.8.5"
description = "An all-in-one toolkit package to easy my Python work in my PhD."
authors = ["Felix Soubelet <felix.soubelet@cern.ch>"]
license = "MIT"
Expand Down

0 comments on commit 36c4399

Please sign in to comment.