From 5083d62f8de8b3c0861eca77d0f7b3fa2dad4f68 Mon Sep 17 00:00:00 2001 From: chrishavlin Date: Mon, 26 Jun 2023 15:27:43 -0500 Subject: [PATCH] in progress (will fail tests) --- src/yt_napari/_data_model.py | 25 ++++- src/yt_napari/schemas/yt-napari_0.0.2.json | 101 ++++++++++++++++++++- 2 files changed, 123 insertions(+), 3 deletions(-) diff --git a/src/yt_napari/_data_model.py b/src/yt_napari/_data_model.py index c5f77ac..6ebf4ef 100644 --- a/src/yt_napari/_data_model.py +++ b/src/yt_napari/_data_model.py @@ -34,11 +34,34 @@ class SelectionObject(BaseModel): ) +class ytWidth(BaseModel): + value: float = Field(None, description="The value for the width.") + unit: str = Field("code_length", description="The length unit of the width value.") + + +class Slice(BaseModel): + fields: List[ytField] = Field( + None, description="list of fields to load for this selection" + ) + normal: Union[int, str] = Field(None, description="the normal axis of the slice") + center: Optional[Tuple[float, float, float]] = Field( + None, description="The center point of the slice" + ) + width: Optional[ytWidth] = Field( + None, description="The slice width, defaults to full domain" + ) + resolution: Optional[Tuple[int, int]] = Field( + (400, 400), + description="the resolution at which to sample the slice", + ) + + class DataContainer(BaseModel): filename: str = Field(None, description="the filename for the dataset") selections: List[SelectionObject] = Field( - None, description="list of selections to load in this dataset" + None, description="list of 3D selections to load in this dataset" ) + slices: List[Slice] = Field(None, description="list of 2D slices to load.") edge_units: Optional[str] = Field( "code_length", description="the units to use for left_edge and right_edge in the selections", diff --git a/src/yt_napari/schemas/yt-napari_0.0.2.json b/src/yt_napari/schemas/yt-napari_0.0.2.json index 17be7b8..6bb4792 100644 --- a/src/yt_napari/schemas/yt-napari_0.0.2.json +++ b/src/yt_napari/schemas/yt-napari_0.0.2.json @@ -117,6 +117,95 @@ } } }, + "ytWidth": { + "title": "ytWidth", + "type": "object", + "properties": { + "value": { + "title": "Value", + "description": "The value for the width.", + "type": "number" + }, + "unit": { + "title": "Unit", + "description": "The length unit of the width value.", + "default": "code_length", + "type": "string" + } + } + }, + "Slice": { + "title": "Slice", + "type": "object", + "properties": { + "fields": { + "title": "Fields", + "description": "list of fields to load for this selection", + "type": "array", + "items": { + "$ref": "#/definitions/ytField" + } + }, + "normal": { + "title": "Normal", + "description": "the normal axis of the slice", + "anyOf": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + }, + "center": { + "title": "Center", + "description": "The center point of the slice", + "type": "array", + "minItems": 3, + "maxItems": 3, + "items": [ + { + "type": "number" + }, + { + "type": "number" + }, + { + "type": "number" + } + ] + }, + "width": { + "title": "Width", + "description": "The slice width, defaults to full domain", + "allOf": [ + { + "$ref": "#/definitions/ytWidth" + } + ] + }, + "resolution": { + "title": "Resolution", + "description": "the resolution at which to sample the slice", + "default": [ + 400, + 400 + ], + "type": "array", + "minItems": 2, + "maxItems": 2, + "items": [ + { + "type": "integer" + }, + { + "type": "integer" + } + ] + } + } + }, "DataContainer": { "title": "DataContainer", "type": "object", @@ -128,12 +217,20 @@ }, "selections": { "title": "Selections", - "description": "list of selections to load in this dataset", + "description": "list of 3D selections to load in this dataset", "type": "array", "items": { "$ref": "#/definitions/SelectionObject" } }, + "slices": { + "title": "Slices", + "description": "list of 2D slices to load.", + "type": "array", + "items": { + "$ref": "#/definitions/Slice" + } + }, "edge_units": { "title": "Edge Units", "description": "the units to use for left_edge and right_edge in the selections", @@ -142,7 +239,7 @@ }, "store_in_cache": { "title": "Store In Cache", - "description": "if enabled, will store references to yt datasets to avoid reloading.", + "description": "if enabled, will store references to yt datasets.", "default": true, "type": "boolean" }