artist.raytracing.sampling

Classes

DistortionsDataset

Initialize the dataset.

RestrictedDistributedSampler

Set up a custom distributed sampler to assign data to each rank or leave them idle.

Module Contents

class artist.raytracing.sampling.DistortionsDataset(light_source: artist.scene.light_source.LightSource, number_of_points_per_heliostat: int, number_of_active_heliostats: int, random_seed: int = 7)

Bases: torch.utils.data.Dataset

Initialize the dataset.

This class implements a custom dataset according to the torch interface. The content of this dataset are the distortions. The distortions are used in our version of “heliostat”-tracing to indicate how each incoming ray must be multiplied and scattered on the heliostat. According to torch, this dataset must implement a function to return the length of the dataset and one function to retrieve an element through an index.

Parameters

light_sourceLightSource

The light source used to model the distortions.

number_of_points_per_heliostatint

The number of points on the heliostats for which distortions are created.

number_of_active_heliostatsint

The number of active heliostats in the scenario.

random_seedint

The random seed used for generating the distortions (default is 7).

__len__() int

Calculate the length of the dataset, i.e., the number of items contained.

Returns

int

The length of the dataset.

__getitem__(idx: int) tuple[torch.Tensor, torch.Tensor]

Select an item from the dataset.

Parameters

idxint

The index of the item to select.

Returns

torch.Tensor

The distortions in the up direction for the given index.

torch.Tensor

The distortions in the east direction for the given index.

class artist.raytracing.sampling.RestrictedDistributedSampler(number_of_samples: int, number_of_active_heliostats: int, world_size: int = 1, rank: int = 0)

Bases: torch.utils.data.Sampler

Set up a custom distributed sampler to assign data to each rank or leave them idle.

Parameters

number_of_samplesint

Length of the dataset or total number of samples.

number_of_active_heliostatsint

Number of active heliostats.

world_sizeint

World size or total number of processes (default is 1).

rankint

Rank of the current process (default is 0).

rank_indices = []
__iter__() Iterator[int]

Generate a sequence of indices for the current rank’s portion of the dataset.

Returns

Iterator[int]

An iterator over indices for the current rank.