Skip to content

Instantly share code, notes, and snippets.

@matthewturk
matthewturk / new_script.py
Last active August 16, 2022 20:32
Test script for allocating EnzoE Blocks using the new EnzoEOctreeContainer and the Check-00900 dataset.
import yt
import h5py
import glob
import numpy as np
from collections import defaultdict
from yt.geometry.oct_container import EnzoEOctreeContainer
nroot = 16
octree = EnzoEOctreeContainer([16, 16, 16], [0.0, 0.0, 0.0], [1.0, 1.0, 1.0], 16)
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.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matthewturk
matthewturk / highlights.md
Last active June 30, 2021 20:33
draft yt-4 PR changelog

yt 4.0 highlights

This is a manually curated list of pull requests that went in to yt 4.0, representing a subset of the full list.

New Functions

@matthewturk
matthewturk / main.tour
Created June 5, 2021 13:45
Particle Indexing Code Tour
{
"$schema": "https://aka.ms/codetour-schema",
"title": "particle indexing",
"steps": [
{
"title": "Introduction",
"description": "We're going to walk through how particle indexing works in yt 4.0.\n\nImagine you've got a bunch of LEGO blocks that you know build up a model. (For fun, let's pretend it's the Arendelle castle.) They're all separated into little bags, and you don't exactly know which pieces are in which bags, but maybe you vaguely know that there's some organizational scheme to them.\n\nWhen you build your castle, you *could* read the instructions step by step and inspect every single piece in every single bag until you find the one you're looking for. But that wouldn't be terribly efficient! Wouldn't it be easier if you had some way of saying, \"I know that this piece is in one of *these* bags, so I'll only look in those bags until I find it.\"\n\nThat's what we do with indexing in yt, and why particle indexing is particularly tricky -- because when we want to select da
[
{
"redshift": 25.751117757703,
"m": 12917.596499489899,
"x": 0.842004501419555,
"y": 0.16423811137914449,
"z": 0.749396924313566
},
{
"redshift": 25.751117757703,
@matthewturk
matthewturk / halo_catalog.csv
Created February 9, 2021 15:18
An example halo catalog
We can't make this file beautiful and searchable because it's too large.
# particle_position_x, particle_position_y, particle_position_z, particle_velocity_x, particle_velocity_y, particle_velocity_z, virial_radius, vrms, particle_mass, spin, vmax, rvmax, energy, kin_to_pot
4.6957e-01, 4.9250e-01, 5.0414e-01, 2.9442e-02, -6.2840e-04, 4.3845e-02, 1.2281e-04, 3.9032e-03, 3.3128e+02, 7.0283e-02, 2.7754e-03, 1.4261e-03, 3.3593e+07, 1.4581e+00
4.6945e-01, 4.9315e-01, 5.0462e-01, 2.7579e-02, -3.8346e-04, 4.3776e-02, 3.1911e-05, 1.8293e-02, 5.7614e+00, 0.0000e+00, 8.4188e-04, 2.7192e-04, 1.2574e+02, 0.0000e+00
4.6927e-01, 4.9356e-01, 5.0481e-01, 2.8701e-02, 1.9386e-04, 4.5392e-02, 3.6529e-05, 1.4660e-02, 8.6421e+00, 4.0685e-01, 8.4173e-04, 4.0802e-04, 2.1872e+05, 8.3015e+00
4.6917e-01, 4.9441e-01, 5.0378e-01, 2.7373e-02, -4.1200e-03, 4.7373e-02, 7.3059e-05, 3.1449e-03, 6.9137e+01, 6.4265e-02, 1.6662e-03, 8.3301e-04, 2.4131e+06, 1.4974e+00
4.5829e-01, 4.9516e-01, 4.3323e-01, 3.0024e-02, -2.6513e-02, 7.1958e-02, 6.3823e-05, 5.2920e-03, 4.6091e+01, 3.8393e-02, 1.4468e-03, 7.3660e-04, 1.1614
# coding: utf-8
import pprint
import yt
import numpy as np
import re
import netCDF4 as nc4
poor_regex = re.compile(r'([a-zA-Z]+)(.*)')
def poor_parser(s):
@matthewturk
matthewturk / datasetviewer_tutorial.ipynb
Created September 18, 2020 16:07
Dataset viewer in widgyts
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.