Skip to content

Instantly share code, notes, and snippets.

View smutch's full-sized avatar

Simon Mutch smutch

View GitHub Profile
@smutch
smutch / monitor_memory.py
Created July 6, 2018 09:53
Monitor the total memory of a process and its children
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from subprocess import run, PIPE
import os
from time import sleep
import click
@click.command()
@smutch
smutch / meraxes-on-raijin.md
Last active July 21, 2020 01:20
Running Meraxes on Raijin with a new input sim

Meraxes on Raijin

Tested with the following modules:

- Package -----------------------------+- Versions -+- Last mod. ------
gcc/4.9.0                                            2014/07/03  4:40:12
openmpi/4.0.0                                        2019/01/30  4:13:57
cmake/3.14.4                                         2019/05/16 23:37:18
gsl/2.5 2018/06/21 0:53:02
@smutch
smutch / calculate_rates.py
Created June 7, 2019 18:35
py: photo ionisation and heating rates for given UV spectral slope
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Calculate photo ionisation and photo heating rates for J21 = 1.0 and a given
UV spectral slope value, α.
Sorry for the current lack of comments!
"""
__author__ = "Simon Mutch"
@smutch
smutch / cic.py
Last active August 28, 2019 00:49
py: CIC gridding
#!/usr/bin/env python
"""A faster-than-pure-python+numpy cloud-in-cell gridding implementation.
**THIS IS A WORK IN PROGRESS AND NOT FULLY TESTED.**
Several assumptions are made:
1. All particles have the same mass (weight)
2. The volume being gridded is an N-dimensional cartesian
@smutch
smutch / test.py
Created September 24, 2019 08:45
py: test swift grid writing
import numpy as np
import h5py as h5
import xarray as xa
from pathlib import Path
import numba
import pytest
SNAP = 12
@smutch
smutch / cmake_prefix_path
Created September 30, 2019 04:10
sh: Generate the appropriate contents of CMAKE_PREFIX_PATH for the loaded set of modules.
#!/usr/bin/env bash
# Generate the appropriate contents of CMAKE_PREFIX_PATH for the loaded set of modules.
# Author: S. Mutch (2019)
#
# Usage:
# CMAKE_PREFIX_PATH=`cmake_prefix_path` cmake ..
cmake_prefix_path=""
@smutch
smutch / std_conda_environment.yml
Last active January 3, 2020 07:09
Standard conda environment for astro work on HPC system
# invoke with:
# env CC=`which mpicc` HDF5_MPI="ON" MPICC=`which mpicc` conda env create -f=std_conda_environment.yml
name: std
channels:
- conda-forge
- defaults
dependencies:
- nomkl
- pip
- black
@smutch
smutch / test_blackbox.py
Created February 14, 2020 06:08
py: blackbox testing
"""
Testing of blackbox package. How well does it work and making sure I understand its use.
"""
import sys
sys.path.insert(0, "../3rd_party/blackbox") # noqa: E402
import blackbox as bb
from scipy import stats
@smutch
smutch / check_density_totals.py
Created March 18, 2020 02:45
py: check VELOCIraptor density grids totals against theory
#!/usr/bin/env python
"""Test the Genesis grids totals against cosmology. This is to help K Ren (see email 2020-03-17)."""
__author__ = "Simon Mutch"
__date__ = "2020-03-18"
from pathlib import Path
import logging
@smutch
smutch / read_grid.py
Created July 8, 2020 09:24
py: read postprocess grid
import numpy as np
import xarray as xa
import h5py as h5
PATH_IN = "/fred/oz078/smutch/intensity_mapping/baseline/imapping_testrun/HIMass_grids.h5"
SNAPSHOT = 250 # z=0
with h5.File(PATH_IN, "r") as fp:
ds = fp[f"Snap{SNAPSHOT:03d}"]
box_size = ds.attrs["box_size"][:]