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
@cphyc
cphyc / load_dyablo.py
Last active July 19, 2024 14:13
Load data from Dyablo
"""Load Dyablo simulation from a hdf5-formatted dataset
Requires yt_experiments to be installed:
$ pip install git+https://github.com/cphyc/yt_experiments@octree-converter
Example:
>>> ds = load("./test_gravity_spheres_3D_iter0008987.h5")
... p = yt.SlicePlot(ds, "x", ("gas","density"))
... p.set_unit("density", "mp/cm**3")
... p.save("/tmp/")
Loading
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
Loading
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
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):