In [1]:
import pathlib
# Read FM output
import pyugrid
# TODO: use underlying code?
import flowmap.formats
import flowmap.particles
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
# open the netCDF file
path = pathlib.Path('~/Downloads/DFM_OUTPUT_FlowFM/FlowFM_map-run-1.nc').expanduser()
n_particles = 300000
In [3]:
# read the data
grid = flowmap.formats.UGrid(str(path))
grid.options['n_particles'] = n_particles
grid.streamlines(-1)
In [4]:
# convert to VTK polydata
polydata = grid.to_polydata()
# fill in data for current timestep
grid.update_polydata(polydata, -1)
# seed (starting points)
seed = flowmap.particles.make_particles(polydata, n=n_particles)
# tracer pipeline (seed + polydat -> streamtracer -> extract lines)
tracer = flowmap.particles.make_tracer_pipeline(polydata, seed)
In [5]:
# compute the streamlines
tracer.update()
# extract table with lines
lines = flowmap.particles.extract_lines(tracer)
In [6]:
# show the table
lines.tail()
Out[6]:
In [7]:
fig, ax = plt.subplots(figsize=(13, 8))
ax.axis('equal')
def plot_line(line):
ax.plot(line[:, 0], line[:, 1], 'b-', alpha=0.1)
lines.head(n=1000).line.apply(plot_line);
In [8]:
fig, ax = plt.subplots(figsize=(13, 8))
ax.axis('equal')
def plot_line(line):
ax.plot(line[:, 0], line[:, 1], 'b-', alpha=0.1)
ax.set_xlim(7486500, 7488000)
ax.set_ylim(20504000, 20506000)
lines.head(n=1000).line.apply(plot_line);
In [9]:
# open the netCDF file
path = pathlib.Path('~/Downloads/DFM_OUTPUT_FlowFM/FlowFM_map-run-2.nc').expanduser()
n_particles = 30000
In [10]:
# read the data
grid = flowmap.formats.UGrid(str(path))
grid.options['n_particles'] = n_particles
grid.streamlines(-1)
In [11]:
# convert to VTK polydata
polydata = grid.to_polydata()
# fill in data for current timestep
grid.update_polydata(polydata, -1)
# seed (starting points)
seed = flowmap.particles.make_particles(polydata, n=n_particles)
# tracer pipeline (seed + polydat -> streamtracer -> extract lines)
tracer = flowmap.particles.make_tracer_pipeline(polydata, seed)
In [12]:
# compute the streamlines
tracer.update()
# extract table with lines
lines = flowmap.particles.extract_lines(tracer)
In [13]:
fig, ax = plt.subplots(figsize=(13, 8))
ax.axis('equal')
def plot_line(line):
ax.plot(line[:, 0], line[:, 1], 'b-', alpha=0.1)
lines.head(n=1000).line.apply(plot_line);
In [21]:
%matplotlib inline
fig, ax = plt.subplots(figsize=(13, 8))
ax.axis('equal')
def plot_line(line):
ax.plot(line[:, 0], line[:, 1], 'b-', alpha=0.1)
ax.set_xlim(7486500, 7488000)
ax.set_ylim(20504000, 20506000)
lines.head(n=1000).line.apply(plot_line);
In [23]:
%matplotlib notebook
fig, ax = plt.subplots(figsize=(13, 8))
ax.axis('equal')
def plot_line(line):
ax.plot(line[:, 0], line[:, 1], 'b-', alpha=0.1)
ax.set_xlim(7488600, 7489800)
ax.set_ylim(20502000, 20503000)
lines.head(n=1000).line.apply(plot_line);
In [ ]: