dfreproject.utils¶
Attributes¶
Functions¶
Utility function to get the currently available PyTorch device. |
|
|
Compute gradients (dy, dx) of a 2D tensor using centered differences. |
|
Estimate memory usage per output pixel in bytes. |
|
Calculate optimal chunk size based on memory constraints. |
|
Process a single chunk of the reprojection. |
|
Perform chunked reprojection. |
Module Contents¶
- dfreproject.utils.get_device()[source]¶
Utility function to get the currently available PyTorch device.
- Returns:
Available torch device (either cuda or cpu).
- Return type:
torch.device
- dfreproject.utils.gradient2d(tensor)[source]¶
Compute gradients (dy, dx) of a 2D tensor using centered differences.
- dfreproject.utils.estimate_memory_per_pixel(reproject_instance, interpolation_mode: str) float[source]¶
Estimate memory usage per output pixel in bytes.
- dfreproject.utils.calculate_chunk_size(reproject_instance, output_shape: Tuple[int, int], max_memory_mb: float, safety_factor: float, interpolation_mode: str = 'bilinear') Tuple[int, int][source]¶
Calculate optimal chunk size based on memory constraints.
- Parameters:
reproject_instance (Reproject) – An initialized Reproject instance.
output_shape (Tuple[int, int]) – Shape of the output image (H, W).
max_memory_mb (float) – Maximum memory to use in megabytes.
safety_factor (float) – Safety factor (0-1) for memory calculation.
interpolation_mode (str) – Interpolation mode to use.
- Returns:
Chunk size (chunk_height, chunk_width).
- Return type:
- dfreproject.utils.process_chunk(reproject_instance, y_start: int, y_end: int, x_start: int, x_end: int, interpolation_mode: str = 'bilinear') torch.Tensor[source]¶
Process a single chunk of the reprojection.
- Parameters:
- Returns:
Reprojected chunk.
- Return type:
torch.Tensor
- dfreproject.utils.reproject_chunked(reproject_instance, max_memory_mb: float, safety_factor: float, interpolation_mode: str = 'bilinear', show_progress: bool = True) torch.Tensor[source]¶
Perform chunked reprojection.
- Parameters:
reproject_instance (Reproject) – An initialized Reproject instance.
max_memory_mb (float) – Maximum memory to use in megabytes.
safety_factor (float) – Safety factor for memory calculation.
interpolation_mode (str) – Interpolation mode to use.
show_progress (bool) – Whether to log progress information.
- Returns:
Full reprojected image.
- Return type:
torch.Tensor