Skip to content

Draft: Create a ProxyParam

Valentin Valls requested to merge proxy-param into main

In draft until the branching of the 2.7 dev.

This is a step to simplify the sequences. And let use

  • Create a ProxyParam class which mimick a FScanParamBase
    • This allows to proxify a set of FScanParamBase
    • As result a pars can be setup to point to multiple redis stores
  • Replace create_parameters, by _create_parameters -> try not to expose this protected API to the user
  • _create_parameters now returns the created params -> this provides a better API for overriding
  • .config_pars, .basic_pars, .sequnece_pars are not anymore exposed -> everything is hidden by .pars and _create_parameters
  • Rework the pars from the sequences with ProxyParam
    • This abstract the location of the parameter storage (sometimes from tomo_config.pars, or tomo.pars...)
  • Drop get_parameters, set_parameter, set_parameters from sequences. Use .pars.to_dict/from_dict instead
  • Drop get_parameters, set_parameter, set_parameters from TomoConfig. Use .pars.to_dict/from_dict instead

Example with ProxyParam

from tomo.helpers.proxy_param import ProxyParam
from fscan.fscantools import FScanParamBase

class FooPars(FScanParamBase):
    def __init__(self, name):
        FScanParamBase.__init__(
            self,
            name,
            {"foo": 0},
            value_list={},
            no_settings=[],
        )
class BarPars(FScanParamBase):
    def __init__(self, name):
        FScanParamBase.__init__(
            self,
            name,
            {"bar": 0},
            value_list={},
            no_settings=[],
        )
foopars = FooPars("foopars")
barpars = BarPars("barpars")
pars = ProxyParam(foopars, barpars)
Parameters

  FooPars [redis-key=foopars_pars]

    .foo = 0

  BarPars [redis-key=barpars_pars]

    .bar = 0

Result from zseries.pars

DEMO_SESSION [14]: zseries_id16a.pars
         Out [14]: Parameters

                     ConfigTomoPars  [redis-key=id16a_config_pars]

                       .start_pos     = 0
                       .range         = 360
                       .flat_n        = 21
                       .dark_n        = 20
                       .tomo_n        = 999
                       .energy        = 0.0
                       .exposure_time = 0.5
                       .comment       =
                       .latency_time  = 1e-05

                     FullTomoPars    [redis-key=fulltomo_id16a_pars]

                       .return_images_aligned_to_flats = False
                       .save_flag                      = True
                       .display_flag                   = True
                       .return_to_start_pos            = True
                       .projection_groups              = False
                       .flat_on                        = 500
                       .dark_at_start                  = False
                       .flat_at_start                  = True
                       .dark_at_end                    = False
                       .flat_at_end                    = False
                       .images_on_return               = True
                       .scan_type                      = CONTINUOUS
                       .half_acquisition               = False
                       .full_frame_position            = 0.0
                       .acquisition_position           = 0.0
                       .shift_in_fov_factor            = 0.0
                       .shift_in_mm                    = 0.0
                       .shift_in_pixels                = 0
                       .shift_type                     = Field-of-view factor
                       .return_to_full_frame_position  = False
                       .move_to_acquisition_position   = False
                       .beam_check                     = False
                       .wait_for_beam                  = False
                       .refill_check                   = False
                       .activate_sinogram              = False
                       .round_position                 = False
                       .rand_disp_y                    = 0
                       .rand_disp_z                    = 0

                     ZSeriesPars     [redis-key=zseries_id16a_pars]

                       .nb_digits               = 3
                       .nb_scans                = 1
                       .step_start_pos          = [0.0]
                       .start_nb                = 1
                       .delta_pos               = 1
                       .sleep                   = 0.0
                       .one_collection_per_z    = True
                       .one_dataset_per_z       = False
                       .back_and_forth          = False
                       .iter_nb_in_scan_name    = False
                       .check_field_of_view     = True
                       .dark_flat_for_each_scan = False
Edited by Valentin Valls

Merge request reports