Skip to content

Instantly share code, notes, and snippets.

@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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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')
# 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
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)
# 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 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
# initialization file (not found)