tomcat blender up to date
This commit is contained in:
@@ -62,7 +62,7 @@ class volume_maker:
|
||||
def clean_binary_image(self, im, clean = True, remove_small=True, minsize = 20, fp_radius = 1, i=0, GPU = True, GPU_avail=GPU_avail):
|
||||
if clean or remove_small:
|
||||
if GPU and GPU_avail:
|
||||
gpu_id = i%4+1 #num_GPU #use gpus 1 through 4, leaving the big A40 (0) alone or i%5 to use all 5
|
||||
gpu_id = i%5 #num_GPU #use gpus 1 through 4, leaving the big A40 (0) alone or i%5 to use all 5
|
||||
|
||||
with cp.cuda.Device(gpu_id):
|
||||
im = cp.array(im)
|
||||
@@ -87,7 +87,7 @@ class volume_maker:
|
||||
mask = self.data[self.mask_name].sel(timestep = ts).data
|
||||
|
||||
if GPU and GPU_avail:
|
||||
gpu_id = i%4+1 #num_GPU #use gpus 1 through 4, leaving the big A40 (0) alone or i%5 to use all 5
|
||||
gpu_id = i%5 #num_GPU #use gpus 1 through 4, leaving the big A40 (0) alone or i%5 to use all 5
|
||||
|
||||
with cp.cuda.Device(gpu_id):
|
||||
mask = cp.array(mask)
|
||||
|
||||
46
04_CL_npy_to_openvdb_in_blender.py
Normal file
46
04_CL_npy_to_openvdb_in_blender.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Tue Jun 20 14:53:48 2023
|
||||
|
||||
converts numpy array to openvdb
|
||||
|
||||
run within blender to use pyopenvdb, it would eventually be nice to use pyopenvdb outside blender to have the conversion in one go
|
||||
|
||||
@author: fische_r
|
||||
"""
|
||||
|
||||
import os
|
||||
import numpy as np
|
||||
import pyopenvdb as openvdb
|
||||
|
||||
|
||||
sample = '3II'
|
||||
ts = 28
|
||||
|
||||
inpath = os.path.join('/mpc/homes/fische_r/NAS/DASCOELY/processing/06_anode_CL', sample, str(ts)+'_cropped_to_membrane_ML.npy')
|
||||
outpath = os.path.join('/mpc/homes/fische_r/NAS/DASCOELY/processing/06_anode_CL', sample, str(ts)+'_cropped_to_membrane_ML.vdb')
|
||||
#modified crops, comment out
|
||||
x1 = 20
|
||||
x2 = -20
|
||||
y1 = 0
|
||||
y2 = -1
|
||||
z1 = 20
|
||||
z2 = -20
|
||||
|
||||
def convert_npy_to_vdb(inpath, outpath, x1, x2, y1,y2, z1, z2):
|
||||
im = np.load(inpath)
|
||||
im = im[x1:x2,y1:y2,z1:z2]
|
||||
|
||||
|
||||
grid = openvdb.FloatGrid()
|
||||
grid.copyFromArray(im.astype(float))
|
||||
grid.gridClass = openvdb.GridClass.FOG_VOLUME
|
||||
grid.name = 'density'
|
||||
|
||||
openvdb.write(outpath, grid)
|
||||
|
||||
|
||||
|
||||
convert_npy_to_vdb(inpath, outpath, x1, x2, y1,y2, z1, z2)
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ import numpy as np
|
||||
import pyopenvdb as openvdb
|
||||
|
||||
|
||||
toppath = '/mpc/homes/fische_r/NAS/DASCOELY/processing/04_membrane_ML/5II/all_phases_npy'
|
||||
topoutpath = '/mpc/homes/fische_r/NAS/DASCOELY/processing/04_membrane_ML/5II/combined_vdb'
|
||||
toppath = '/mpc/homes/fische_r/NAS/DASCOELY/processing/04_membrane_ML/4/all_phases_npy'
|
||||
topoutpath = '/mpc/homes/fische_r/NAS/DASCOELY/processing/04_membrane_ML/4/combined_vdb'
|
||||
|
||||
if not os.path.exists(topoutpath):
|
||||
os.mkdir(topoutpath)
|
||||
|
||||
21
npy_to_vdb.py
Normal file
21
npy_to_vdb.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import bpy
|
||||
import pyopenvdb as openvdb
|
||||
import numpy as np
|
||||
|
||||
Volume = np.load('/mpc/homes/fische_r/NAS/DASCOELY/processing/02_registered_3p1D/3II_ts_4_registered.npy')
|
||||
Volume = Volume/25000
|
||||
Volume = Volume[20:-20,20:-20,200:-500]
|
||||
|
||||
grid = openvdb.FloatGrid()
|
||||
|
||||
grid.copyFromArray(Volume.astype(float))
|
||||
|
||||
|
||||
#grid.transform = openvdb.createLinearTransform([[1, 0, 0, 0,], [0, 1, 0, 0], [0,0,1,0],[0,0,0,1]])
|
||||
|
||||
grid.gridClass = openvdb.GridClass.FOG_VOLUME
|
||||
grid.name = 'density'
|
||||
|
||||
openvdb.write('/mpc/homes/fische_r/NAS/DASCOELY/processing/02_registered_3p1D/3II_ts_4_registered.vdb', grid)
|
||||
|
||||
bpy.ops.object.volume_import(filepath = '/mpc/homes/fische_r/NAS/DASCOELY/processing/02_registered_3p1D/3II_ts_4_registered.vdb', files=[])
|
||||
Reference in New Issue
Block a user