Skip to content

Commit 10012a6

Browse files
committed
updating api
1 parent df01c30 commit 10012a6

3 files changed

Lines changed: 107 additions & 4 deletions

File tree

src/calibration.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Calibration data structures and functions."""
22

33
import copy
4+
import os
45
from pathlib import Path
56
from typing import Optional
67

@@ -129,7 +130,7 @@ def __init__(
129130
self.mmlut_data = mmlut_data
130131

131132
@classmethod
132-
def from_file(cls, ori_file: Path, add_file: Path | None):
133+
def from_file(cls, ori_file: Path | str | bytes, add_file: Path | str | bytes | None):
133134
"""
134135
Read exterior and interior orientation, and if available, parameters for distortion corrections.
135136
@@ -143,6 +144,9 @@ def from_file(cls, ori_file: Path, add_file: Path | None):
143144
-------
144145
- ext_par, int_par, glass, addp: Calibration object parts without multimedia lookup table.
145146
"""
147+
ori_file = Path(os.fsdecode(os.fspath(ori_file)))
148+
add_file = None if add_file is None else Path(os.fsdecode(os.fspath(add_file)))
149+
146150
if not ori_file.exists():
147151
raise IOError(f"File {ori_file} does not exist")
148152

src/parameters.py

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,19 @@ class SequencePar(Parameters):
138138
# 'last': self.last,
139139
# }
140140

141-
def set_img_base_name(self, new_name: List[str]):
142-
"""Set the image base name for each camera."""
143-
self.img_base_name[:] = new_name
141+
def set_img_base_name(self, new_name, value: str | None = None):
142+
"""Set the image base name for each camera.
143+
144+
Accepts either a full list of names or a legacy (index, value) call.
145+
"""
146+
if value is None:
147+
self.img_base_name[:] = list(new_name)
148+
return
149+
150+
index = int(new_name)
151+
while len(self.img_base_name) <= index:
152+
self.img_base_name.append("")
153+
self.img_base_name[index] = value
144154

145155
def get_img_base_name(self, icam: int = 0):
146156
"""Get the image base name for each camera."""
@@ -239,38 +249,74 @@ def get_dvxmin(self):
239249
"""Return the minimum velocity in x direction."""
240250
return self.dvxmin
241251

252+
def set_dvxmin(self, value):
253+
"""Set the minimum velocity in x direction."""
254+
self.dvxmin = value
255+
242256
def get_dvxmax(self):
243257
"""Return the maximum velocity in x direction."""
244258
return self.dvxmax
245259

260+
def set_dvxmax(self, value):
261+
"""Set the maximum velocity in x direction."""
262+
self.dvxmax = value
263+
246264
def get_dvymin(self):
247265
"""Return the minimum velocity in y direction."""
248266
return self.dvymin
249267

268+
def set_dvymin(self, value):
269+
"""Set the minimum velocity in y direction."""
270+
self.dvymin = value
271+
250272
def get_dvymax(self):
251273
"""Return the maximum velocity in y direction."""
252274
return self.dvymax
253275

276+
def set_dvymax(self, value):
277+
"""Set the maximum velocity in y direction."""
278+
self.dvymax = value
279+
254280
def get_dvz_min(self):
255281
"""Return the minimum velocity in z direction."""
256282
return self.dvzmin
257283

284+
def set_dvzmin(self, value):
285+
"""Set the minimum velocity in z direction."""
286+
self.dvzmin = value
287+
258288
def get_dvz_max(self):
259289
"""Return the minimum velocity in z direction."""
260290
return self.dvzmax
261291

292+
def set_dvzmax(self, value):
293+
"""Set the maximum velocity in z direction."""
294+
self.dvzmax = value
295+
262296
def get_dangle(self):
263297
"""Return the maximum angle."""
264298
return self.dangle
265299

300+
def set_dangle(self, value):
301+
"""Set the maximum angle."""
302+
self.dangle = value
303+
266304
def get_dacc(self):
267305
"""Return the maximum acceleration."""
268306
return self.dacc
269307

308+
def set_dacc(self, value):
309+
"""Set the maximum acceleration."""
310+
self.dacc = value
311+
270312
def get_add(self):
271313
"""Return the adding new particles parameter."""
272314
return self.add
273315

316+
def set_add(self, value):
317+
"""Set the adding new particles parameter."""
318+
self.add = value
319+
274320
def get_dsumg(self):
275321
"""Return the maximum sum of the gradient."""
276322
return self.dsumg
@@ -369,10 +415,22 @@ def set_z_min_lay(self, z_min_lay: list[float]) -> None:
369415
"""Set the minimum z coordinate of the layers."""
370416
self.z_min_lay = z_min_lay
371417

418+
def set_Zmin_lay(self, z_min_lay: list[float]) -> None:
419+
"""Legacy alias for set_z_min_lay()."""
420+
self.set_z_min_lay(z_min_lay)
421+
372422
def set_z_max_lay(self, z_max_lay: list[float]) -> None:
373423
"""Set the maximum z coordinate of the layers."""
374424
self.z_max_lay = z_max_lay
375425

426+
def set_Zmax_lay(self, z_max_lay: list[float]) -> None:
427+
"""Legacy alias for set_z_max_lay()."""
428+
self.set_z_max_lay(z_max_lay)
429+
430+
def set_X_lay(self, x_lay: list[float]) -> None:
431+
"""Legacy setter for x-layer bounds."""
432+
self.x_lay = x_lay
433+
376434
def set_cn(self, cn: float) -> None:
377435
"""Set the refractive index."""
378436
self.cn = cn
@@ -381,6 +439,10 @@ def set_cnx(self, cnx: float) -> None:
381439
"""Set the refractive index in x direction."""
382440
self.cnx = cnx
383441

442+
def set_cny(self, cny: float) -> None:
443+
"""Set the refractive index in y direction."""
444+
self.cny = cny
445+
384446
def set_csumg(self, csumg: float) -> None:
385447
"""Set the maximum sum of the gradient."""
386448
self.csumg = csumg
@@ -393,6 +455,18 @@ def set_corrmin(self, corrmin: float):
393455
"""Set the minimum correlation value of all criteria."""
394456
self.corrmin = corrmin
395457

458+
def get_X_lay(self) -> list[float]:
459+
"""Legacy getter for x-layer bounds."""
460+
return self.x_lay
461+
462+
def get_Zmin_lay(self) -> list[float]:
463+
"""Legacy getter for z min layer bounds."""
464+
return self.z_min_lay
465+
466+
def get_Zmax_lay(self) -> list[float]:
467+
"""Legacy getter for z max layer bounds."""
468+
return self.z_max_lay
469+
396470
@classmethod
397471
def from_file(cls, filename: Path):
398472
"""Read volume parameters from file.
@@ -689,22 +763,46 @@ def get_grey_thresholds(self):
689763
"""Return the grey thresholds."""
690764
return self.gvthresh
691765

766+
def set_grey_thresholds(self, thresholds: list[int]) -> None:
767+
"""Set the grey thresholds."""
768+
self.gvthresh = list(thresholds)
769+
692770
def get_pixel_count_bounds(self):
693771
"""Return the pixel count bounds."""
694772
return (self.nnmin, self.nnmax)
695773

774+
def set_pixel_count_bounds(self, bounds: tuple[int, int]) -> None:
775+
"""Set the pixel count bounds."""
776+
self.nnmin, self.nnmax = bounds
777+
696778
def get_xsize_bounds(self):
697779
"""Return the xsize bounds."""
698780
return (self.nxmin, self.nxmax)
699781

782+
def set_xsize_bounds(self, bounds: tuple[int, int]) -> None:
783+
"""Set the xsize bounds."""
784+
self.nxmin, self.nxmax = bounds
785+
700786
def get_ysize_bounds(self):
701787
"""Return the ysize bounds."""
702788
return (self.nymin, self.nymax)
703789

790+
def set_ysize_bounds(self, bounds: tuple[int, int]) -> None:
791+
"""Set the ysize bounds."""
792+
self.nymin, self.nymax = bounds
793+
704794
def get_min_sum_grey(self):
705795
"""Return the sum grey bounds."""
706796
return self.sumg_min
707797

798+
def set_min_sum_grey(self, value: int) -> None:
799+
"""Set the minimum sum grey value."""
800+
self.sumg_min = value
801+
802+
def set_max_discontinuity(self, value: int) -> None:
803+
"""Set the maximum discontinuity."""
804+
self.discont = value
805+
708806

709807
def read_target_par(filename: Path) -> TargetPar:
710808
"""Read target parameters from file and returns target_par object."""

src/pyptv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit bf69c604ebf34c45c94c28782a36bafd50bd36de

0 commit comments

Comments
 (0)