Skip to content

Instantly share code, notes, and snippets.

# initialization file (not found)
import unyt
import xmltodict
import sys
import os
class VTKUnitChecker(object):
"""a recursive unit checker for xml vtu/pvtu files from ASPECT
This module recursively searches the elements of an xml vtk files, looking for
# based on callbacks from https://yt-project.org/doc/visualizing/callbacks.html#overplot-halo-annotations
import yt
# annotation markers and text
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
s = yt.SlicePlot(ds, "x", ("gas", "density"))
s.set_axes_unit("kpc")
import yt
from yt_idv import render_context
from yt_idv.scene_data.block_collection import BlockCollection
from yt_idv.scene_components.blocks import BlockRendering
ds = yt.load('m1.0_p16_b2.0_300k_plt50/multitidal_hdf5_plt_cnt_0200')
ad = ds.all_data()
rc = render_context(height=800, width=800, gui=True)
sg = rc.add_scene(ds, None)
# running mypy on this file fails:
# error: Only concrete class can be given where "Type[Student]" is expected
import abc
import functools
# https://docs.python.org/3/library/functools.html#functools.total_ordering
@functools.total_ordering
class Student(abc.ABC):
def __init__(self, firstname: str, lastname: str):
self.firstname = firstname
@chrishavlin
chrishavlin / IRIS_data_xr_to_yt.py
Created July 28, 2022 20:22
function for loading IRIS data into yt from xarray
import xarray as xr
import yt
import os
import numpy as np
import cartopy.feature as cfeature
import cartopy.crs as ccrs
ddir = os.path.join(yt.config.ytcfg.get('yt','test_data_dir'), 'sample_nc')
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chrishavlin
chrishavlin / rio_with_jpeg.ipynb
Created November 10, 2022 17:40
using rasterio to load a jpeg and reproject in memory
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
diff --git a/yt/_typing.py b/yt/_typing.py
index 0062c63dd..15fcd8a6f 100644
--- a/yt/_typing.py
+++ b/yt/_typing.py
@@ -1,4 +1,4 @@
-from typing import List, Optional, Tuple, Union
+from typing import Any, Callable, Dict, List, Optional, Tuple, Union
import unyt as un
from numpy import ndarray
import sys
import numpy as np
import yt
import yt_idv
# yt reminder: phi is the polar angle (0 to 2pi)
# theta is the angle from north (0 to pi)