Hi,
I am trying to analyze some data in /glade/campaign/cgd/tss/people/oleson/CLM_LAND_ONLY_RELEASE/CLM5/clm50_r270_1deg_GSWP3V1_iso_newpopd_hist/lnd/proc/tseries/month_1
, and the history variables are indexed by landunit
. I'm not sure how to work with this data using typical xarray plotting. For example, a command that @Will Wieder uses:
cf = ax.pcolormesh(clm_sub.lon, clm_sub.lat,
clm_sub.H2OSNO.isel(time=slice(0,120)).max(dim='time'),
transform=ccrs.PlateCarree());
gives this error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/glade/derecho/scratch/afoster/tmp/ipykernel_31860/3617445073.py in <module>
20 ax.add_patch(poly)
21
---> 22 cf = ax.pcolormesh(clm_sub.lon, clm_sub.lat,
23 clm_sub.H2OSNO.isel(time=slice(0,120)).max(dim='time'),
24 transform=ccrs.PlateCarree());
/glade/work/afoster/miniconda3/envs/analysis/lib/python3.8/site-packages/cartopy/mpl/geoaxes.py in wrapper(self, *args, **kwargs)
316
317 kwargs['transform'] = transform
--> 318 return func(self, *args, **kwargs)
319 return wrapper
320
/glade/work/afoster/miniconda3/envs/analysis/lib/python3.8/site-packages/cartopy/mpl/geoaxes.py in pcolormesh(self, *args, **kwargs)
1794 # Add in an argument checker to handle Matplotlib's potential
1795 # interpolation when coordinate wraps are involved
-> 1796 args, kwargs = self._wrap_args(*args, **kwargs)
1797 result = matplotlib.axes.Axes.pcolormesh(self, *args, **kwargs)
1798 # Wrap the quadrilaterals if necessary
/glade/work/afoster/miniconda3/envs/analysis/lib/python3.8/site-packages/cartopy/mpl/geoaxes.py in _wrap_args(self, *args, **kwargs)
1823 X = np.asanyarray(args[0])
1824 Y = np.asanyarray(args[1])
-> 1825 nrows, ncols = np.asanyarray(args[2]).shape
1826 Nx = X.shape[-1]
1827 Ny = Y.shape[0]
ValueError: not enough values to unpack (expected 2, got 1)
I'm guessing because the function expects the data to be a 2-d array. But for this it's a 1D array indexed by landunit
(n=98467)
Adrianna Foster has marked this topic as resolved.
Hi @Adrianna Foster it looks like you marked this as resolved, but if others are wondering about how to analyze 1D output from CESM there are a few resources I can point to. We have an ESDS blog post on using CAM-SE output which is indexed by ncol
instead of lat/lon. There is another blog post on analyzing CLM output indexed by pft
. I'm not sure we have an example for data indexed by landunit
but I would imagine the remapping would be similar to these other cases. If you do find that the solution or analysis is different, this would be a useful contribution!
Thank you! I ended up using a different dataset that was indexed by lat/lon instead of landunit
but this blog post was helpful!
Last updated: May 16 2025 at 17:14 UTC