Skip to content

Instantly share code, notes, and snippets.

View pordyna's full-sized avatar

Paweł Ordyna pordyna

  • HZDR
  • Dresden, Germany
View GitHub Profile
@pordyna
pordyna / ExpRampWithPrepulse.py
Last active September 24, 2025 14:14
ExpRampWithPrepulse with sympy
import sympy
import math
class GaussianPulse:
def __init__(self, tau, t_shift=0):
self.tau = tau
self.t_shift = t_shift
def __call__(self, t):

ExpRampWithPrepulse Temporal Envelope for PIConGPU in new interface

This example shows how one can implement the old ExpRampWithPrepulse Temporal Envelope Profile for GaussianPulse for the new Free Functor interface using sympy. The interface change was introduced in #5437.

Steps:

  1. Setup parameters in generate_laser_profile.py and run the script.
  2. Verify the profile by looking at the plot in laserTemporalProfile.png.
@pordyna
pordyna / gist:e0b15e8254f9d05cef7dd8cf18e9e410
Created September 2, 2025 08:32
tail job output for all running slurm jobbs (assuming output is written to a file called stdout)
#!/bin/bash
jobs=$(squeue -u $USER --noheader --format="%A")
for jobid in $jobs; do
job_info=$(scontrol show job $jobid)
workdir=$(echo "$job_info" | grep -oP 'WorkDir=\K\S*')
stdout_file=$(echo "$job_info" | grep -oP 'StdOut=\K\S*')
[ -z "$workdir" ] && workdir="."
[ -z "$stdout_file" ] && stdout_file="slurm-${jobid}.out"
@pordyna
pordyna / transformTuple.cpp
Last active March 19, 2025 10:42
Code snippet showing how to define a transform operation on a std tuple
template <typename T_Func, typename... T_values, std::size_t... I>
inline auto applyToTupleImpl(
T_Func func,
const std::tuple<T_values...> &tuple,
std::index_sequence<I...>)
{
return std::make_tuple(func(std::get<I>(tuple))...);
}
template <typename T_Func, typename... T_values>
@pordyna
pordyna / expand_requirements.py
Last active March 11, 2025 10:31
Create a pythonproject dependencies list from possibly nested requirements.txt files that can be copied to pyproject.toml. This should be used as help for switching to the TOML project specification.
import os
import sys
def expand_requirements(file_path, visited=None):
"""
Reads the file_path line by line.
For each line:
- If it's '-r something.txt', recursively expand that file's lines.
- Otherwise, keep it.
Only adds a comment if the nested file actually provides content.
@pordyna
pordyna / settings.json
Last active August 26, 2025 10:57
rsync with vscode that ignores all git ignored files
{
/* workspace settings
Put this in your worspace settings (.vscode/settings.json)
*/
"customsettings.rsync-tasks.remote_folder": "~/your_project",
}
import ipywidgets as widgets
import openpmd_api as io
from pint import UnitRegistry
ureg = UnitRegistry()
class IterationSlider:
def __init__(self, series):
iterations = list(series.iterations)
times = [series.iterations[it].time_unit_SI
@pordyna
pordyna / plot.py
Last active June 8, 2023 14:04
plot 2D hydrogen plasma simulation density and temperature
def handle_plt_log_error(func):
def wrapped(log, *args, **kwargs):
try:
func(log, *args, **kwargs)
except ValueError as err:
if log:
func(False, *args, **kwargs)
else:
raise err
return wrapped