Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slice explorer v2 #121

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/slice_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pan3d import DatasetBuilder
from pan3d import SliceExplorer


def serve():
parser = ArgumentParser(
prog="Pan3D",
Expand All @@ -20,5 +21,6 @@ def serve():
viewer = SliceExplorer(builder)
viewer.start()


if __name__ == "__main__":
serve()
3 changes: 2 additions & 1 deletion pan3d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
try:
from .dataset_viewer import DatasetViewer
from .explorers.slice_explorer import SliceExplorer

__all__ = [DatasetBuilder, DatasetViewer, SliceExplorer]
except Exception:
# Trame is not installed, DatasetViewer will not be accessible
__all__ = [DatasetBuilder]
__all__ = [DatasetBuilder]
32 changes: 17 additions & 15 deletions pan3d/dataset_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,35 +320,33 @@ def t_index(self, t_index: int) -> None:
self._viewer._mesh_changed()

@property
def t_num(self) -> int:
def t_size(self) -> int:
"""Returns the number of time slices available"""
if not self.t:
raise ValueError(
"Cannot set time index > 0 without setting t array first."
)
raise ValueError("Cannot set time index > 0 without setting t array first.")
t_coords = self.dataset[self.data_array_name].coords[self.t]
return t_coords.size

@property
def t_range(self) -> Tuple[Any]:
"""Returns the min and max values for the temporal coordinate"""
if not self.t:
raise ValueError(
"Cannot set time index > 0 without setting t array first."
)
raise ValueError("Cannot set time index > 0 without setting t array first.")
t_coords = self.dataset[self.data_array_name].coords[self.t].to_numpy().tolist()
return (t_coords[0], t_coords[-1])

@property
def t_values(self) -> List:
"""Returns the values for the temporal dimension"""
if not self.t:
raise ValueError(
"Cannot set time index > 0 without setting t array first."
)
raise ValueError("Cannot set time index > 0 without setting t array first.")
t_coords = self.dataset[self.data_array_name].coords[self.t]
return t_coords.to_numpy().tolist()
return list(t_coords.values)

@property
def var_ranges(self) -> map:
range_map = {}
"""Returns a map with variable names as keys and their ranges as values"""
range_map = {}
for var in self.dataset.data_vars:
arr = self.dataset[var].to_numpy()
range_map[var] = (arr.min(), arr.max())
Expand All @@ -362,9 +360,13 @@ def slicing(self) -> Dict[str, List]:
integers or floats representing start value, stop value, and step.
"""
return self._algorithm.slicing

@property
def extents(self) -> map:
"""
Returns a map with dimension name as keys and their range (extents)
as values
"""
extents = {}
dims = [self.x, self.y, self.z]
for i, dim in enumerate(dims):
Expand Down
295 changes: 295 additions & 0 deletions pan3d/explorers/Presets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
[
{
"ColorSpace" : "Diverging",
"Name" : "Cool to Warm",
"NanColor" : [ 1, 1, 0 ],
"RGBPoints" : [
0,
0.23137254902,
0.298039215686,
0.752941176471,
0.5,
0.865,
0.865,
0.865,
1,
0.705882352941,
0.0156862745098,
0.149019607843
]
},
{
"ColorSpace" : "RGB",
"Name" : "Rainbow Desaturated",
"NanColor" : [ 1, 1, 0 ],
"RGBPoints" : [
0,
0.278431372549,
0.278431372549,
0.858823529412,
0.143,
0,
0,
0.360784313725,
0.285,
0,
1,
1,
0.429,
0,
0.501960784314,
0,
0.571,
1,
1,
0,
0.714,
1,
0.380392156863,
0,
0.857,
0.419607843137,
0,
0,
1,
0.8784313725489999,
0.301960784314,
0.301960784314
]
},
{
"ColorSpace" : "RGB",
"Name" : "Cold and Hot",
"NanColor" : [ 1, 1, 0 ],
"RGBPoints" : [
0,
0,
1,
1,
0.45,
0,
0,
1,
0.5,
0,
0,
0.501960784314,
0.55,
1,
0,
0,
1,
1,
1,
0
]
},
{
"ColorSpace" : "RGB",
"Name" : "Black-Body Radiation",
"NanColor" : [ 0, 0.498039215686, 1 ],
"RGBPoints" : [
0,
0,
0,
0,
0.4,
0.901960784314,
0,
0,
0.8,
0.901960784314,
0.901960784314,
0,
1,
1,
1,
1
]
},
{
"ColorSpace" : "RGB",
"Name" : "Black, Blue and White",
"NanColor" : [ 1, 1, 0 ],
"RGBPoints" : [
0,
0,
0,
0,
0.333,
0,
0,
0.501960784314,
0.666,
0,
0.501960784314,
1,
1,
1,
1,
1
]
},
{
"ColorSpace" : "RGB",
"Name" : "Black, Orange and White",
"NanColor" : [ 1, 1, 0 ],
"RGBPoints" : [
0,
0,
0,
0,
0.333,
0.501960784314,
0,
0,
0.666,
1,
0.501960784314,
0,
1,
1,
1,
1
]
},{
"ColorSpace" : "Lab",
"Name" : "erdc_rainbow_bright",
"RGBPoints" : [
-1,
0.32549,
0.14902,
0.960784,
-0.866221,
0.297047,
0.375586,
0.963836,
-0.732441,
0.180302,
0.536818,
0.964627,
-0.598662,
0.1302,
0.649207,
0.929647,
-0.464883,
0.0445143,
0.749654,
0.855998,
-0.331104,
0.0271325,
0.830713,
0.721527,
-0.197324,
0.259504,
0.8661450000000001,
0.543555,
-0.0635452,
0.428364,
0.890725,
0.329819,
0.07023409999999999,
0.568503,
0.898508,
0.187623,
0.204013,
0.738259,
0.890317,
0.0825461,
0.337793,
0.84546,
0.86136,
0.0147555,
0.471572,
0.912191,
0.808018,
0,
0.605351,
0.962848,
0.710445,
0,
0.73913,
0.9994690000000001,
0.600258,
0.0176284,
0.87291,
0.994156,
0.445975,
0.193912,
1,
0.980407,
0.247105,
0.262699
]
},
{
"ColorSpace" : "Lab",
"Name" : "erdc_rainbow_dark",
"RGBPoints" : [
-1,
0,
0,
0.423499,
-0.866221,
0,
0.119346,
0.529237,
-0.732441,
0,
0.238691,
0.634976,
-0.598662,
0,
0.346852,
0.68788,
-0.464883,
0,
0.45022,
0.718141,
-0.331104,
0,
0.553554,
0.664839,
-0.197324,
0,
0.651082,
0.519303,
-0.0635452,
0.115841,
0.72479,
0.352857,
0.07023409999999999,
0.326771,
0.781195,
0.140187,
0.204013,
0.522765,
0.798524,
0.0284624,
0.337793,
0.703162,
0.788685,
0.00885756,
0.471572,
0.845118,
0.7511330000000001,
0,
0.605351,
0.955734,
0.690825,
0,
0.73913,
0.995402,
0.567916,
0.0618524,
0.87291,
0.987712,
0.403398,
0.164851,
1,
0.980407,
0.247105,
0.262699
]
}
]
Loading