uxarray icon indicating copy to clipboard operation
uxarray copied to clipboard

Issue on page /getting-started/UXarray in 10 Lines

Open DrCMet opened this issue 3 months ago • 4 comments

Dear Developers, I have been following along the UXarray in 10 Lines tutorial on my own machine, working with a Mediterranean model run from the latest MPAS tutorial.

Everything works until the plot. My code is below along with output. MSLP is the variable in my MPAS output rather than PSI. Am hoping you can help me troubleshoot the error? Thanks, Frank Colby Professor of Meteorology UMass Lowell

CODE: import uxarray as ux grid_path = "Mediterranean.init.nc" data_path = "diag.2019-09-01_12.00.00.nc" uxds = ux.open_dataset(grid_path, data_path) print(uxds) print(uxds.uxgrid) print(uxds.uxgrid.node_lon) print("before mslp") print(uxds["mslp"]) print("before mean") print(uxds["mslp"].mean()) print("after mean") uxds["mslp"].plot()

OUTPUT: (base) mpasuser@stratus:.../MPAS-Model/Mediterranean$ python testux.py <xarray.UxDataset> Size: 4MB Dimensions: (Time: 1, n_face: 7912, n_node: 16152, nIsoLevelsT: 5, nIsoLevelsZ: 13) Coordinates:

  • Time (Time) datetime64[ns] 8B 2019-09-01T12:00:00 Dimensions without coordinates: n_face, n_node, nIsoLevelsT, nIsoLevelsZ Data variables: (12/108) initial_time |S64 64B ... xtime (Time) |S64 64B ... mslp (Time, n_face) float32 32kB ... relhum_50hPa (Time, n_face) float32 32kB ... relhum_100hPa (Time, n_face) float32 32kB ... relhum_200hPa (Time, n_face) float32 32kB ... ... ... t_oml_initial (Time, n_face) float32 32kB ... t_oml_200m_initial (Time, n_face) float32 32kB ... h_oml (Time, n_face) float32 32kB ... h_oml_initial (Time, n_face) float32 32kB ... hu_oml (Time, n_face) float32 32kB ... hv_oml (Time, n_face) float32 32kB ... <uxarray.Grid> Original Grid Type: MPAS Grid Dimensions:
  • n_node: 16152
  • n_edge: 24063
  • n_face: 7912
  • n_max_face_nodes: 10
  • n_max_face_edges: 10
  • n_max_face_faces: 10
  • n_max_node_faces: 3
  • two: 2 Grid Coordinates (Spherical):
  • node_lon: (16152,)
  • node_lat: (16152,)
  • edge_lon: (24063,)
  • edge_lat: (24063,)
  • face_lon: (7912,)
  • face_lat: (7912,) Grid Coordinates (Cartesian):
  • node_x: (16152,)
  • node_y: (16152,)
  • node_z: (16152,)
  • edge_x: (24063,)
  • edge_y: (24063,)
  • edge_z: (24063,)
  • face_x: (7912,)
  • face_y: (7912,)
  • face_z: (7912,) Grid Connectivity Variables:
  • face_node_connectivity: (7912, 10)
  • edge_face_connectivity: (24063, 2)
  • edge_node_connectivity: (24063, 2)
  • node_face_connectivity: (16152, 3)
  • face_face_connectivity: (7912, 10)
  • face_edge_connectivity: (7912, 10) Grid Descriptor Variables:
  • face_areas: (7912,)
  • edge_face_distances: (24063,)
  • edge_node_distances: (24063,)

<xarray.DataArray 'node_lon' (n_node: 16152)> Size: 65kB array([41.219387, 40.87472 , 40.768932, ..., 27.331116, 22.93844 , 5.047055], dtype=float32) Dimensions without coordinates: n_node Attributes: standard_name: longitude long name: Longitude of the corner nodes of each face units: degrees_east before mslp <xarray.UxDataArray 'mslp' (Time: 1, n_face: 7912)> Size: 32kB [7912 values with dtype=float32] Coordinates:

  • Time (Time) datetime64[ns] 8B 2019-09-01T12:00:00 Dimensions without coordinates: n_face Attributes: units: Pa long_name: Mean sea-level pressure before mean <xarray.UxDataArray 'mslp' ()> Size: 8B array(101190.859375) after mean Traceback (most recent call last): File "/hdd/mpas-model/MPAS-Model/Mediterranean/testux.py", line 13, in uxds["mslp"].plot() File "/home/mpasuser/anaconda3/lib/python3.12/site-packages/uxarray/plot/accessor.py", line 329, in call return self.polygons(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mpasuser/anaconda3/lib/python3.12/site-packages/uxarray/plot/accessor.py", line 416, in polygons gdf = self._uxda.to_geodataframe( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mpasuser/anaconda3/lib/python3.12/site-packages/uxarray/core/dataarray.py", line 197, in to_geodataframe raise ValueError( ValueError: Data Variable must be 1-dimensional, with shape 7912 for face-centered data. (base) mpasuser@stratus:.../MPAS-Model/Mediterranean$

DrCMet avatar Aug 12 '25 18:08 DrCMet