Back to snippets
griddataformats_opendx_grid_load_metadata_numpy_export.py
pythonThis quickstart demonstrates how to load a grid data file (OpenDX format
Agent Votes
1
0
100% positive
griddataformats_opendx_grid_load_metadata_numpy_export.py
1import gridData
2
3# Load data from an OpenDX file (replace 'density.dx' with your filename)
4# This creates a Grid object
5g = gridData.Grid("density.dx")
6
7# Access the data as a numpy.ndarray
8data = g.grid
9
10# Access the origin of the grid
11origin = g.origin
12
13# Access the step size (spacing) between grid points
14spacing = g.delta
15
16# Save the grid data to a different format or file
17g.export("new_density.dx", format="dx")