shredx.utils.sensors.generate_static_sensors_from_mask#
- shredx.utils.sensors.generate_static_sensors_from_mask(n_sensors: int, mask: Float[Tensor, 'rows cols dim'], dim_agnostic: bool = True) list[tuple[int, int]] | list[tuple[int, int, int]]#
Generate random locations for static sensors from a tensor.
- Parameters:
- n_sensorsint
The number of sensors to generate.
- maskFloat[torch.Tensor, “rows cols dim”]
The mask to use to generate sensors. 0 means a sensor can be placed there, otherwise means it cannot.
- dim_agnostic: bool, optional
Whether to generate sensors in a dimension-agnostic manner. Default is True. If True, sensor locations are only on rows, cols where all dims are valid. If false, sensor locations are on rows, cols, dims where at least one dim is valid.
- Returns:
- list[tuple[int, int]] | list[tuple[int, int, int]]
If
dim_agnosticis True, returns (row, col) locations where all dimensions are valid. If False, returns (row, col, dim) locations for each valid dimension.
- Raises:
- ValueError
If there are fewer valid positions than n_sensors.