API Reference¶
PolyscopeApp
¶
Source code in yumo2/app.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
post_load_hook()
¶
post_polyscope_init_hook()
¶
post_scene_setup_hook()
¶
pre_load_hook()
¶
run()
¶
Launch the GUI and drive the full application lifecycle.
Source code in yumo2/app.py
SessionContext
dataclass
¶
Transient state for one session (one loaded dataset + settings pair). Everything here is ephemeral — nothing is persisted outside of Settings.
Populated in stages
_reset_session_context() → settings-derived fields (saved_camera_view, etc.) _load_data() → scalar_field, xs, ys, zs _load_mesh_and_uv() → vertices, faces, UV fields, texture dimensions _rebuild_texture() → uv_mask, original_texture, raw_texture, texture, effective_range
Source code in yumo2/app.py
Settings
¶
Bases: BaseModel
Immutable user-facing settings persisted as a named profile.
All UI-controllable parameters live here. Instances are created by
:func:load_active_profile / :func:load_profile and written to disk by
:func:save_profile. PolyscopeApp._set_settings is the only code path
that should mutate the active settings — it creates a new instance and saves
it atomically.
Source code in yumo2/settings.py
load_mesh(path)
¶
Load a triangular mesh from path using trimesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to a mesh file ( |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If the file does not yield a triangular mesh. |
Source code in yumo2/loader.py
load_scalar_field(path)
¶
Load a scalar field from a plain-text or Tecplot .plt file.
Each data line must contain exactly four whitespace-separated floats
x y z value. Header/comment lines are skipped automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the data file. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray, ndarray, ndarray]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no valid numeric rows are found or the data is not a regular grid. |
Source code in yumo2/loader.py
validate_meshgrid(points)
¶
Validate that points form a regular 3-D grid and build the scalar field array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
ndarray
|
Shape |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
|
ndarray
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the data is not shaped |
Source code in yumo2/loader.py
apply_denoise(texture, uv_mask, sigma)
¶
Apply masked Gaussian blur to texture, preserving UV island boundaries.
Blending is weighted by uv_mask so that smoothing never bleeds across UV seams into uncovered texels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texture
|
ndarray
|
|
required |
uv_mask
|
ndarray
|
|
required |
sigma
|
float
|
Gaussian standard deviation in texels. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Smoothed |
Source code in yumo2/texture.py
bake_texture(vertices_unwrapped, faces_unwrapped, uvs, scalar_field, xs, ys, zs, height, width)
¶
Bake one scalar sample per covered texel.
The texture resolution (height, width) defines the surface sampling grid in
UV space: each covered texel center is mapped back to 3D and sampled once.
Source code in yumo2/texture.py
pad_texture_edges(texture, uv_mask, iterations=16)
¶
Extend valid texel values into nearby uncovered padding texels.
This is a display-only fix for UV atlas filtering artifacts: Polyscope may sample just outside the covered UV region, so we copy nearby valid texel values into the atlas padding instead of leaving zeros there.
Source code in yumo2/texture.py
sample_texture_positions(vertices_unwrapped, faces_unwrapped, uvs, height, width)
¶
Compute the 3-D world position for every covered texel center.
Used by :class:~yumo2.features.scope.Scope for spatial radius queries —
each texel maps to one point on the mesh surface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices_unwrapped
|
ndarray
|
|
required |
faces_unwrapped
|
ndarray
|
|
required |
uvs
|
ndarray
|
|
required |
height, width
|
Atlas texture dimensions. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
|
ndarray
|
|
ndarray
|
|
ndarray
|
|
Source code in yumo2/texture.py
trilinear_sample(positions, scalar_field, xs, ys, zs)
¶
Trilinearly interpolate scalar_field at arbitrary 3-D positions.
Positions outside the grid are clamped to the grid boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
|
required |
scalar_field
|
ndarray
|
|
required |
xs, ys, zs
|
1-D axis coordinate arrays defining the grid. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
|
Source code in yumo2/texture.py
unwrap_uv(vertices, faces, padding=16)
¶
UV-unwrap a triangular mesh using xatlas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
ndarray
|
|
required |
faces
|
ndarray
|
|
required |
padding
|
int
|
Per-chart padding in texels (prevents UV bleeding between islands). |
16
|
Returns:
| Type | Description |
|---|---|
ndarray
|
|
ndarray
|
|
ndarray
|
|
ndarray
|
|
int
|
|
int
|
|
Source code in yumo2/texture.py
freq_time_profiler
¶
Decorator that accumulates timings over a rolling time window and logs stats periodically.
Only active when YUMO2_PROFILE=time|all. Designed for high-frequency functions (e.g. render callbacks) where per-call logging would be too noisy.
Source code in yumo2/profiling.py
mem_profiler
¶
Bases: ContextDecorator
Memory profiler, usable as a context manager or decorator.
Only active when YUMO2_PROFILE=memory|all. Uses :mod:tracemalloc to
capture peak RSS and the top-N allocation sites, logging them as
mem_profile and mem_profile_top events respectively.
Example::
with mem_profiler("my_stage", top_n=5):
big_array = np.zeros((10000, 10000))
Source code in yumo2/profiling.py
time_profiler
¶
Bases: ContextDecorator
Wall-clock timer, usable as a context manager or decorator.
Only active when YUMO2_PROFILE=time|all. Logs a single
profile_elapsed event on exit.
Example::
with time_profiler("my_stage"):
...
@time_profiler("my_func")
def my_func(): ...
Source code in yumo2/profiling.py
Snapshot
¶
Snapshot capture, preview, and export.
Renders the current Polyscope viewport to a cropped, colorbar-composited
image. Maintains two ImGui image windows (overview with crop bounding-box,
and a live preview of the final export) that are refreshed at up to
_PREVIEW_MAX_HZ Hz.
All crop/colorbar geometry is stored in :class:~yumo2.settings.Settings
so parameters survive profile switches.
Source code in yumo2/features/snapshot.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
Scope
¶
Interactive spatial extremum finder.
When enabled, a mouse click registers a world-space center point. The
sphere marker shows the query radius; on release, :meth:query_extremum
searches all texel positions within the radius and returns the texel with
the minimum or maximum raw scalar value. A screen-space-proportional cross
marker is placed at the result and updated every frame as the camera moves.
Source code in yumo2/features/scope.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
Picker
¶
Point-and-click surface value query.
On each left-click inside the "Coord Picker" panel, reports the 3-D world coordinate of the click and, when the click lands on the mesh, uses barycentric interpolation in UV space to look up both the raw and denoised scalar values at that surface point.