1010// -- include nanobind headers
1111#include < nanobind/nanobind.h>
1212#include < nanobind/stl/string.h>
13+ #include < nanobind/stl/optional.h>
1314
1415namespace themachinethatgoesping {
1516namespace algorithms {
@@ -30,6 +31,24 @@ using namespace themachinethatgoesping::algorithms::geoprocessing::datastructure
3031
3132void init_c_beamsamplegeometry (nb::module_& m)
3233{
34+ // Register Bounds struct
35+ nb::class_<BeamSampleGeometry::Bounds>(m, " BeamSampleGeometryBounds" ,
36+ " Bounding box of beam/sample coordinates." )
37+ .def (nb::init<>())
38+ .def_rw (" x_min" , &BeamSampleGeometry::Bounds::x_min)
39+ .def_rw (" x_max" , &BeamSampleGeometry::Bounds::x_max)
40+ .def_rw (" y_min" , &BeamSampleGeometry::Bounds::y_min)
41+ .def_rw (" y_max" , &BeamSampleGeometry::Bounds::y_max)
42+ .def_rw (" z_min" , &BeamSampleGeometry::Bounds::z_min)
43+ .def_rw (" z_max" , &BeamSampleGeometry::Bounds::z_max)
44+ .def (" __eq__" , &BeamSampleGeometry::Bounds::operator ==, nb::arg (" other" ))
45+ .def (" __repr__" , [](const BeamSampleGeometry::Bounds& b) {
46+ return fmt::format (
47+ " BeamSampleGeometryBounds(x=[{}, {}], y=[{}, {}], z=[{}, {}])" ,
48+ b.x_min , b.x_max , b.y_min , b.y_max , b.z_min , b.z_max );
49+ })
50+ ;
51+
3352 nb::class_<BeamSampleGeometry>(m,
3453 " BeamSampleGeometry" ,
3554 DOC (themachinethatgoesping,
@@ -275,6 +294,53 @@ void init_c_beamsamplegeometry(nb::module_& m)
275294 &BeamSampleGeometry::forward_z_flat,
276295 DOC_BeamSampleGeometry (forward_z_flat))
277296
297+ // --- bounds ---
298+ .def (" get_bounds" ,
299+ &BeamSampleGeometry::get_bounds,
300+ DOC_BeamSampleGeometry (get_bounds))
301+
302+ // --- backward mapping ---
303+ .def (" backward_nearest" ,
304+ [](const BeamSampleGeometry& self,
305+ const xt::nanobind::pytensor<float , 2 >& data,
306+ const xt::nanobind::pytensor<float , 1 >& y_coordinates,
307+ const xt::nanobind::pytensor<float , 1 >& z_coordinates,
308+ unsigned int supersampling,
309+ int mp_cores) {
310+ return self.backward_nearest <xt::nanobind::pytensor<float , 2 >>(
311+ data, y_coordinates, z_coordinates,
312+ supersampling, mp_cores);
313+ },
314+ " Backward-map WCI data to (y, z) image via nearest-neighbor.\n "
315+ " Sample numbers use Euclidean range from the sensor to each pixel.\n "
316+ " When supersampling > 1, probes S*S sub-pixel locations per pixel\n "
317+ " and averages (equivalent to render-at-high-res-then-downsample)." ,
318+ nb::arg (" data" ),
319+ nb::arg (" y_coordinates" ),
320+ nb::arg (" z_coordinates" ),
321+ nb::arg (" supersampling" ) = 1 ,
322+ nb::arg (" mp_cores" ) = 1 )
323+ .def (" backward_bilinear" ,
324+ [](const BeamSampleGeometry& self,
325+ const xt::nanobind::pytensor<float , 2 >& data,
326+ const xt::nanobind::pytensor<float , 1 >& y_coordinates,
327+ const xt::nanobind::pytensor<float , 1 >& z_coordinates,
328+ unsigned int supersampling,
329+ int mp_cores) {
330+ return self.backward_bilinear <xt::nanobind::pytensor<float , 2 >>(
331+ data, y_coordinates, z_coordinates,
332+ supersampling, mp_cores);
333+ },
334+ " Backward-map WCI data to (y, z) image via bilinear interpolation.\n "
335+ " Sample numbers use Euclidean range from the sensor to each pixel.\n "
336+ " When supersampling > 1, probes S*S sub-pixel locations per pixel\n "
337+ " and averages (equivalent to render-at-high-res-then-downsample)." ,
338+ nb::arg (" data" ),
339+ nb::arg (" y_coordinates" ),
340+ nb::arg (" z_coordinates" ),
341+ nb::arg (" supersampling" ) = 1 ,
342+ nb::arg (" mp_cores" ) = 1 )
343+
278344 // default copy functions
279345 __PYCLASS_DEFAULT_COPY__ (BeamSampleGeometry)
280346 // default binary functions
0 commit comments