Parameters - Snailz Docs

Skip to content

# Parameters

Data generation parameters.

## `Parameters`

Bases: `BaseModel`

Store all data generation parameters.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`seed` | `int` | RNG seed | `123456`
`precision` | `int` | floating point digits | `2`
`num_persons` | `int` | number of persons | `6`
`num_grids` | `int` | number of sample grids | `3`
`num_samples` | `int` | number of samples | `20`
`locale` | `str` | name generation locale | `'et_EE'`
`grid_size` | `int` | sample grid size | `11`
`grid_spacing` | `float` | grid cell spacing (m) | `20.0`
`grid_gap` | `float` | gap between grids | `1000.0`
`lat0` | `float` | grid reference latitude | `48.8666632`
`lon0` | `float` | grid reference longitude | `-124.1999992`
`sample_mass` | `tuple[float, float]` | sample mass bounds | `(50, 150)`
`sample_date` | `tuple[date, date]` | sampling date bounds | `(datetime.date(2025, 1, 1), datetime.date(2025, 3, 31))`
`pollution_factor` | `float` | pollution effect on mass | `0.3`
`clumsy_factor` | `float | None` | clumsy operator effect on mass (if any) | `0.5`
`num_machines` | `int` | number of machines | `5`

Source code in `src/snailz/parameters.py`

     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    class Parameters(BaseModel):
        """Store all data generation parameters."""

        seed: int = Field(default=123456, description="RNG seed", gt=0)
        precision: int = Field(default=2, gt=0, description="floating point digits")
        num_persons: int = Field(default=6, description="number of persons")
        num_grids: int = Field(default=3, gt=0, description="number of sample grids")
        num_samples: int = Field(default=20, gt=0, description="number of samples")
        locale: str = Field(default="et_EE", description="name generation locale")
        grid_size: int = Field(default=11, gt=0, description="sample grid size")
        grid_spacing: float = Field(default=20.0, gt=0, description="grid cell spacing (m)")
        grid_gap: float = Field(default=1000.0, gt=0, description="gap between grids")
        lat0: float = Field(
            default=48.8666632, ge=-90.0, le=90.0, description="grid reference latitude"
        )
        lon0: float = Field(
            default=-124.1999992,
            ge=-180.0,
            le=180.0,
            description="grid reference longitude",
        )
        sample_mass: tuple[float, float] = Field(
            default=(50, 150), description="sample mass bounds"
        )
        sample_date: tuple[date, date] = Field(
            default=(date(2025, 1, 1), date(2025, 3, 31)),
            description="sampling date bounds",
        )
        pollution_factor: float = Field(
            default=0.3, gt=0, description="pollution effect on mass"
        )
        clumsy_factor: float | None = Field(
            default=0.5, description="clumsy operator effect on mass (if any)"
        )
        num_machines: int = Field(default=5, gt=0, description="number of machines")

        @model_validator(mode="after")
        def validate_clumsy_factor(self):
            """Check clumsiness factor."""

            if self.clumsy_factor is None:
                pass
            elif self.clumsy_factor > 0:
                pass
            else:
                raise ValueError(f"bad clumsy factor {self.clumsy_factor}")
            return self

        @model_validator(mode="after")
        def validate_locale(self):
            """Check locale."""

            if self.locale not in AVAILABLE_LOCALES:
                raise ValueError(f"unknown locale {self.locale}")
            return self

        @model_validator(mode="after")
        def validate_sample_date(self):
            """Check sample dates."""

            if self.sample_date[1] < self.sample_date[0]:
                raise ValueError(f"invalid sample date bounds {self.sample_date}")
            return self

        @model_validator(mode="after")
        def validate_sample_mass(self):
            """Check sample mass."""

            if 0 < self.sample_mass[0] <= self.sample_mass[1]:
                pass
            else:
                raise ValueError(f"invalid sample size bounds {self.sample_mass}")
            return self

### `validate_clumsy_factor()`

Check clumsiness factor.

Source code in `src/snailz/parameters.py`

    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    @model_validator(mode="after")
    def validate_clumsy_factor(self):
        """Check clumsiness factor."""

        if self.clumsy_factor is None:
            pass
        elif self.clumsy_factor > 0:
            pass
        else:
            raise ValueError(f"bad clumsy factor {self.clumsy_factor}")
        return self

### `validate_locale()`

Check locale.

Source code in `src/snailz/parameters.py`

    56
    57
    58
    59
    60
    61
    62
    @model_validator(mode="after")
    def validate_locale(self):
        """Check locale."""

        if self.locale not in AVAILABLE_LOCALES:
            raise ValueError(f"unknown locale {self.locale}")
        return self

### `validate_sample_date()`

Check sample dates.

Source code in `src/snailz/parameters.py`

    64
    65
    66
    67
    68
    69
    70
    @model_validator(mode="after")
    def validate_sample_date(self):
        """Check sample dates."""

        if self.sample_date[1] < self.sample_date[0]:
            raise ValueError(f"invalid sample date bounds {self.sample_date}")
        return self

### `validate_sample_mass()`

Check sample mass.

Source code in `src/snailz/parameters.py`

    72
    73
    74
    75
    76
    77
    78
    79
    80
    @model_validator(mode="after")
    def validate_sample_mass(self):
        """Check sample mass."""

        if 0 < self.sample_mass[0] <= self.sample_mass[1]:
            pass
        else:
            raise ValueError(f"invalid sample size bounds {self.sample_mass}")
        return self