This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib.animation import FuncAnimation | |
from os import path, makedirs | |
CSD = path.dirname(__file__) | |
def rotate_points(xy: np.ndarray, theta: float = 0.0, pivot_point: tuple[float, float] = (0.0, 0.0), ): | |
""" Rotate the points `x` and `y` by specified angle about the point (xc, yc). """ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import path, listdir | |
import cv2 | |
import imageio | |
import argparse | |
from tqdm import tqdm | |
class MovieMaker: | |
""" Helper definitions for making videos """ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
It prepares and saves .npy array to the specified path. | |
""" | |
import os | |
import numpy as np | |
import sys | |
from PIL import Image | |
from tqdm import tqdm | |
import argparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def remove_outliers(arr, col_indices=None, k=1.5): | |
""" | |
Removes outliers from the given 2D array using inter-quartile range. | |
arr: np.ndarray | |
a 2D numpy array | |
col_indices=[0,] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# shuffling arrays concurrently | |
def shuffle_arrays(*arr, order=1): | |
num_rows = arr[0].shape[0] | |
assert all([i.shape[0] == num_rows for i in arr]) | |
indicies = np.array(list(range(num_rows)), dtype=np.int64) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import os | |
from scipy import integrate | |
CFD = os.path.dirname(__file__) | |
def get_chunks(x: np.ndarray[float], y: np.ndarray[float], pivot: float = 0.0): | |
sort_indices = np.argsort(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
def clip_histogram(data, get_indices=False, **hist_kwargs): | |
n, bns = np.histogram(data, **hist_kwargs) | |
bin_pairs = [(bns[i], bns[i+1]) for i in range(len(bns)-1)] | |
new_data = [] | |
indices = [] | |
for (i, (bnl, bnu)) in enumerate(bin_pairs): | |
bin_width = bnu - bnl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import os | |
class ProgressBar: | |
def __init__(self, num_iters, header=None) -> None: | |
self.t0 = time.time() | |
self.n = num_iters | |
self.term_cols = (os.get_terminal_size().columns)*0.25 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from PIL import Image | |
import os | |
num_chunks = 6 | |
img_size = (64, 64) | |
container_ID = "CIRCLES_VF10_RS10_R5" | |
cfd = os.path.dirname(__vsc_ipynb_file__) | |
container_dir = os.path.join(cfd, "containers", "rve", f"container_{container_ID}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h5open(data_set_path, "w") do h5file_id | |
attributes(h5file_id)["eqrad"] = 1.0 | |
attributes(h5file_id)["inclusion_volume_fraction"] = 32.0 | |
attributes(h5file_id)["rve_xlb"] = bbox[1] | |
attributes(h5file_id)["rve_ylb"] = bbox[2] | |
attributes(h5file_id)["rve_xub"] = bbox[3] | |
attributes(h5file_id)["rve_yub"] = bbox[4] | |
end |
NewerOlder