Skip to content

Instantly share code, notes, and snippets.

View cphyc's full-sized avatar

Corentin Cadiou cphyc

  • Lund University
  • Lund, Sweden
  • X @cphyc
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cphyc
cphyc / extract_tracer_data.py
Last active September 6, 2023 08:32
Extract tracer data from a RAMSES simulation.
import argparse
import gc
from pathlib import Path
from typing import List, Optional, Sequence, Tuple
import h5py
import numpy as np
import yt
from yt import mylog as logger
from yt.fields.derived_field import ValidateSpatial
@cphyc
cphyc / extract.py
Created August 12, 2023 22:02
Read RAMSES log files and outputs. For each output, print the value of the timestep.
"""Read RAMSES log files and outputs. For each output, print the value of the timestep."""
import argparse
import os
import re
import sys
from collections import defaultdict
from scipy.interpolate import interp1d
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cphyc
cphyc / Load subset.ipynb
Created March 29, 2023 13:40
Extract data from a simulation into .h5 file, then load them and gather them using xarray.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cphyc
cphyc / check_signature.py
Last active May 28, 2021 11:16
Python script to programmatically check that the docstring agree with the signature with some simple rules.
# %%
from typing import Callable
import ast
from docstring_parser import parse
from pathlib import Path
# %%
def check_non_existing_params(dp_names: list[str], sp_names: list[str], *, has_args, has_kwargs, ctx: str):
for dp in dp_names:
@cphyc
cphyc / .XCompose
Created April 12, 2021 17:15 — forked from guiambros/.XCompose
.XCompose
#-#-#-#-#-#-#-#
# ~/.XCompose
# To change the US International keyboard layout to behave like the
# Microsoft Windows (TM) version of the layout
# version: 0.2 edit 6 (20110403-6)
# by @tamh [48bytes at gmail com]
#
# Released under LGPL v2.1. Please refer to it by going to:
# <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>
@cphyc
cphyc / solve.py
Last active December 8, 2020 17:06
from collections import defaultdict, namedtuple
from typing import Dict, List, Set
import numpy as np
Instruction = namedtuple("Instruction", ("code", "val", "line"))
Edge = namedtuple("Edge", ("l", "instruction"))
def make_link(tree, inst, fp, instructions, all_instructions):
@cphyc
cphyc / colorblind-4.mplstyle
Last active November 6, 2020 16:07
Matplotlib palettes
# Colorblind palette - 4 items
# From https://davidmathlogic.com/colorblind/
axes.prop_cycle: cycler("color", ["E69F00", "56B4E9", "009E73", "F0E442"])