示例#1
0
class VariableModel(BaseModel):
    """This represents a variable definition with values and labels"""
    name: str = pyField(..., description="Name of the variable.")
    description: str = pyField(None,
                               description="Description of the variable.")
    unit: str = pyField(
        ...,
        description="The unit of the variable.",
        examples=[{
            "unit": "m"
        }, {
            "unit": "NDVI"
        }, {
            "unit": "Watt"
        }])
    values: List[Union[float, int]] = pyField(
        ...,
        description="The variable values that must be numeric.",
        examples=[{
            "values": [1, 2, 3]
        }])
    labels: List[str] = pyField(...,
                                description="Label for each variable value.",
                                examples=[{
                                    "labels": ["a", "b", "c"]
                                }])
示例#2
0
class VariablesCollectionModel(BaseModel):
    """A collection of variables that all have the same size"""
    name: str = pyField(..., description="Name of the variables collection.")
    size: List[int] = pyField(
        ...,
        description="The size of the variables collection. Each variable of "
        "this collection must have the same size. The size of "
        "the variable can be mutli-dimensional. However, variables are stored "
        "as one dimensional arrays and must be "
        "re-shaped in the multi-dimensional form for processing.",
        examples=[{
            "size": [100]
        }, {
            "size": [3, 3, 3]
        }])
    number_of_variables: int = pyField(
        ..., description="The number of variables in this collection.")
    variables: List[VariableModel] = pyField(
        ..., description="A list of variables with the same size.")
示例#3
0
class FTGField(BaseRepoModel):
    field_type: str
    subfields: FTGSubfields = pyField(default_factory=FTGSubfields)
    field_annotation: FTGFieldAnnotation = pyField(default_factory=FTGFieldAnnotation)

    @classmethod
    def from_resource(cls, resource: t.Type[Field]) -> 'FTGField':
        safe_mod = resource.__module__.split('.')[0].replace('_', '').lower()

        ftg_field =  cls(fieldType = resource._RESOURCE_ID)

        for p in resource._SUB_FIELDS:
            ftg_field.subfields.subfield.append(
                FTGSubfield(
                    name=to_camel(p.name),
                    type=field_type_str(p.field_type)
                )
            )

        return ftg_field
示例#4
0
class FTGPatch(BaseRepoModel):
    """
    FTG Patch
    """
    stitches_version: str = '0.6'
    field_additions: t.List[FTGFieldAddition] = pyField(default_factory=list)
示例#5
0
class FTGFieldAnnotation(BaseRepoModel):
    max_serialized_size_bytes: t.Any = pyField(default_factory=default_mssb)
    nested_types: dict = pyField(default_factory=dict)
示例#6
0
class FTGSubfields(BaseRepoModel):
    subfield: t.List[FTGSubfield] = pyField(default_factory=list)