-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathdataset_example.py
More file actions
54 lines (46 loc) · 1.47 KB
/
dataset_example.py
File metadata and controls
54 lines (46 loc) · 1.47 KB
1
2
3
4
5
6
7
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
# %% [md]
#
# # Opening Datasets
#
# Vapor supports a variety of scientific data formats.
# This notebook shows how to open a dataset and query its metadata.
#
# %%
import example_utils
from vapor import session, renderer, dataset, camera
# %%
print("Supported dataset types:", dataset.Dataset.GetDatasetTypes())
# %%
ses = session.Session()
data = example_utils.OpenExampleDataset(ses)
# Examples of opening real data
#
# data = ses.OpenDataset(dataset.WRF, ["data/wrf_out.0001", "data/wrf_out.0002"])
# data = ses.OpenDataset(dataset.VDC, ["master.vdc"])
# data = ses.OpenDataset(dataset.MPAS, ["x1.static.nc", "diag.2021-03-04_10.30.00.nc"])
# %% [md]
#
# ## Dump the dataset metadata
#
# %%
print("Time Coordinate Variable Name:", data.GetTimeCoordVarName())
print("Coordinate Variable Names:", data.GetCoordVarNames())
print("Dimensions:")
for dim in data.GetDimensionNames():
print(f" {dim}:", data.GetDimensionLength(dim, 0))
print("Data Variables:")
for var in data.GetDataVarNames():
print(f" {var}")
print(f" Time Varying:", bool(data.IsTimeVarying(var)))
print(f" Dimensionality:", data.GetVarGeometryDim(var))
print(f" Coordinates:", data.GetVarCoordVars(var, True))
print(" Data Range:", data.GetDataRange(var))
# %% [md]
#
# ## Render the first 2D variable as a wireframe
#
# %%
ren = data.NewRenderer(renderer.WireFrameRenderer)
ren.SetVariableName(data.GetDataVarNames(2)[0]) # Set to first 2D data variable
ses.GetCamera().ViewAll()
ses.Show()