pyRadPlan.scenarios#

Base class#

class ScenarioModel(ct=None, **kwargs)[source]#

Bases: PyRadPlanBaseModel

Abstract base class for scenario models.

range_rel_sd#

The relative standard deviation for range.

Type:

float

range_abs_sd#

The absolute standard deviation for range.

Type:

float

shift_sd#

The standard deviation for shift in x, y, and z directions.

Type:

Tuple[float]

wc_sigma#

The sigma value for the wc_factor.

Type:

float

ct_scen_prob#

The probability of each CT scenario.

Type:

list[Tuple[int,float]]

update_scenarios() np.ndarray[float][source]#

Abstract method to update scenarios.

extract_single_scenario(scen_num: int) ScenarioModel[source]#

Extracts a single scenario based on its number.

list_all_scenarios()[source]#

Lists all scenarios.

sub2scenIx(ctScen: int, shift_scen: int, range_shift_scen: int) int#

Converts CT scenario, shift scenario, and range shift scenario to scenario index.

scenNum(fullScenIx: int) int#

Converts full scenario index to scenario number.

Attributes:
abs_range_shift

Absolute range shift value.

ct_scen_ix

CT scenario indices of the used CT scenarios.

iso_shift

Isocenter shift values.

linear_mask

Linear mask matrix for scenario selection.

max_abs_range_shift

Maximum absolute range shift value.

max_rel_range_shift

Maximum relative range shift value.

model_extra

Get extra fields set during validation.

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

num_of_available_ct_scen

Number of totally available CT scenarios in the CT.

num_of_ct_scen

Number of CT scenarios in the model.

rel_range_shift

Relative range shift value.

scen_for_prob

Scenarios organized for probability calculation.

scen_mask

Scenarios mask matrix describing how scenarios should be stored.

scen_prob

Scenarios probability matrix.

scen_weight

Scenarios weight matrix.

tot_num_range_scen

Total number of range shift scenarios.

tot_num_scen

Total number of scenarios.

tot_num_shift_scen

Total number of shift scenarios.

Methods

copy(*[, include, exclude, update, deep])

Returns a copy of the model.

extract_single_scenario(scen_num)

Extract a single scenario based on its number.

list_all_scenarios()

Print a list of all scenarios.

model_construct([_fields_set])

Creates a new instance of the Model class with validated data.

model_copy(*[, update, deep])

!!! abstract "Usage Documentation"

model_dump(*[, mode, include, exclude, ...])

!!! abstract "Usage Documentation"

model_dump_json(*[, indent, ensure_ascii, ...])

!!! abstract "Usage Documentation"

model_json_schema([by_alias, ref_template, ...])

Generates a JSON schema for a model class.

model_parametrized_name(params)

Compute the class name for parametrizations of generic classes.

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

model_rebuild(*[, force, raise_errors, ...])

Try to rebuild the pydantic-core schema for the model.

model_validate(obj, *[, strict, extra, ...])

Validate a pydantic model instance.

model_validate_json(json_data, *[, strict, ...])

!!! abstract "Usage Documentation"

model_validate_strings(obj, *[, strict, ...])

Validate the given object with string data against the Pydantic model.

scen_num(full_scen_ix)

Return the scenario number given the scenario ray index.

sub2scen_ix(ct_scen, shift_scen, ...)

Convert a subscript index to a linear scenario index.

to_matrad([context])

Perform matRad compatible serialization.

update_scenarios()

Update scenario data from uncertainty model settings.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

property abs_range_shift: float#

Absolute range shift value.

property ct_scen_ix: uint16'>)]#

CT scenario indices of the used CT scenarios.

ct_scen_prob: list[Tuple[int, float]]#
abstractmethod extract_single_scenario(scen_num)[source]#

Extract a single scenario based on its number.

Return type:

ScenarioModel

property iso_shift: float64'>)]#

Isocenter shift values.

property linear_mask: uint16'>)]#

Linear mask matrix for scenario selection.

list_all_scenarios()[source]#

Print a list of all scenarios.

This method prints the details of all scenarios in a formatted table. The table includes the following columns: - xShift: The x-axis shift value - yShift: The y-axis shift value - zShift: The z-axis shift value - absRng: The absolute range value - relRng: The relative range value - prob: The probability value

Example output: # xShift yShift zShift absRng relRng prob. 1 0.000 0.000 0.000 0.000 0.000 0.000 2 0.100 0.200 0.300 0.400 0.500 0.600 3 0.700 0.800 0.900 1.000 1.100 1.200

property max_abs_range_shift: float#

Maximum absolute range shift value.

property max_rel_range_shift: float#

Maximum relative range shift value.

model_config: ClassVar[ConfigDict] = {'alias_generator': AliasGenerator(alias=<function to_camel>, validation_alias=None, serialization_alias=None), 'arbitrary_types_allowed': True, 'from_attributes': True, 'populate_by_name': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)#

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Return type:

None

name: ClassVar[str]#
property num_of_available_ct_scen: int#

Number of totally available CT scenarios in the CT.

property num_of_ct_scen: int#

Number of CT scenarios in the model.

range_abs_sd: float#
range_rel_sd: float#
property rel_range_shift: float#

Relative range shift value.

property scen_for_prob: float64'>)]#

Scenarios organized for probability calculation.

property scen_mask: bool]#

Scenarios mask matrix describing how scenarios should be stored.

scen_num(full_scen_ix)[source]#

Return the scenario number given the scenario ray index.

This corresponds to the first occurrence of full_scen_ix in self.scen_mask.

Parameters:

full_scen_ix (int) – The value to search for in self.scen_mask.

Returns:

The index of the first occurrence of full_scen_ix in self.scen_mask.

Return type:

int

property scen_prob: float64'>)]#

Scenarios probability matrix.

property scen_weight: float64'>)]#

Scenarios weight matrix.

shift_sd: Tuple[float, float, float]#
short_name: ClassVar[str]#
sub2scen_ix(ct_scen, shift_scen, range_shift_scen)[source]#

Convert a subscript index to a linear scenario index.

Parameters:
  • (int) (range_shift_scen)

  • (int)

  • (int)

Return type:

int

Returns:

int: The corresponding scenario index.

Raises:

None

Examples

# Example usage sub2scenIx(1, 2, 3) # Returns: 1

property tot_num_range_scen: int#

Total number of range shift scenarios.

property tot_num_scen: int#

Total number of scenarios.

property tot_num_shift_scen: int#

Total number of shift scenarios.

abstractmethod update_scenarios()[source]#

Update scenario data from uncertainty model settings.

Return type:

ndarray[float]

wc_sigma: float#
class NominalScenario(ct=None, **kwargs)[source]#

Bases: ScenarioModel

NominalScenario class represents an example scenario.

name#

The name of the scenario.

Type:

str

short_name#

The short name of the scenario.

Type:

str

update_scenarios()[source]#

Updates the scenarios.

extract_single_scenario(scen_num: int) ScenarioModel[source]#

Extracts a single scenario.

Attributes:
abs_range_shift

Absolute range shift value.

ct_scen_ix

CT scenario indices of the used CT scenarios.

iso_shift

Isocenter shift values.

linear_mask

Linear mask matrix for scenario selection.

max_abs_range_shift

Maximum absolute range shift value.

max_rel_range_shift

Maximum relative range shift value.

model_extra

Get extra fields set during validation.

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

ndim

Dimensionality of the scenario model.

num_of_available_ct_scen

Number of totally available CT scenarios in the CT.

num_of_ct_scen

Number of CT scenarios in the model.

rel_range_shift

Relative range shift value.

scen_for_prob

Scenarios organized for probability calculation.

scen_mask

Scenarios mask matrix describing how scenarios should be stored.

scen_prob

Scenarios probability matrix.

scen_weight

Scenarios weight matrix.

tot_num_range_scen

Total number of range shift scenarios.

tot_num_scen

Total number of scenarios.

tot_num_shift_scen

Total number of shift scenarios.

Methods

copy(*[, include, exclude, update, deep])

Returns a copy of the model.

extract_single_scenario(scen_num)

Extract a single scenario based on its number.

list_all_scenarios()

Print a list of all scenarios.

model_construct([_fields_set])

Creates a new instance of the Model class with validated data.

model_copy(*[, update, deep])

!!! abstract "Usage Documentation"

model_dump(*[, mode, include, exclude, ...])

!!! abstract "Usage Documentation"

model_dump_json(*[, indent, ensure_ascii, ...])

!!! abstract "Usage Documentation"

model_json_schema([by_alias, ref_template, ...])

Generates a JSON schema for a model class.

model_parametrized_name(params)

Compute the class name for parametrizations of generic classes.

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

model_rebuild(*[, force, raise_errors, ...])

Try to rebuild the pydantic-core schema for the model.

model_validate(obj, *[, strict, extra, ...])

Validate a pydantic model instance.

model_validate_json(json_data, *[, strict, ...])

!!! abstract "Usage Documentation"

model_validate_strings(obj, *[, strict, ...])

Validate the given object with string data against the Pydantic model.

scen_num(full_scen_ix)

Return the scenario number given the scenario ray index.

sub2scen_ix(ct_scen, shift_scen, ...)

Convert a subscript index to a linear scenario index.

to_matrad([context])

Perform matRad compatible serialization.

update_scenarios()

Update scenario data from uncertainty model settings.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

extract_single_scenario(scen_num)[source]#

Extract a single scenario based on its number.

Return type:

ScenarioModel

model_config: ClassVar[ConfigDict] = {'alias_generator': AliasGenerator(alias=<function to_camel>, validation_alias=None, serialization_alias=None), 'arbitrary_types_allowed': True, 'from_attributes': True, 'populate_by_name': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)#

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Return type:

None

name: ClassVar[str] = 'Nominal Scenario'#
property ndim: int#

Dimensionality of the scenario model.

short_name: ClassVar[str] = 'nomScen'#
update_scenarios()[source]#

Update scenario data from uncertainty model settings.

Return type:

ndarray[float]

Helper functions

available_scenario_models()[source]#

Return a list of available scenario models.

Return type:

list[str]

create_scenario_model(model_def='nomScen', ct=None)[source]#

Return a scenario model object.

Parameters:

model_name (str) – The name of the scenario model.

Returns:

The scenario model object.

Return type:

ScenarioModel

validate_scenario_model(model_def, ct=None)[source]#

Validate a scenario model input and returns a scenario model object.

Parameters:

model_def (Union[ScenarioModel, str, dict]) – The scenario model object.

Returns:

The scenario model object.

Return type:

ScenarioModel