noaa-oar-arl / monet

The Model and ObservatioN Evaluation Toolkit (MONET)
https://monet-arl.readthedocs.io
Other
44 stars 20 forks source link

Attempted read of CAMx v6.50 (.nc) file gives 'DataArray' object has no attribute 'x' #83

Closed twtesche closed 2 years ago

twtesche commented 4 years ago

I'm trying to open a CAMx v6.50 (.nc) file with a the sample CMAQ script given for the Hawaii Volcano Monet website tutorial.

I try to read in a CAMx (.nc) output file with .... fname = '/home/twt/diskc/hgb/2012/650/output/20120616/20120616.avrg.grd01.nc' c = xr.open_dataset(fname, engine='pseudonetcdf', backend_kwargs={'format': 'ioapi'})

And then plot an ozone image file with.... c.O3[15,:,:,:].monet.quick_map() plt.tight_layout() plt.show()

But, the traceback error is... Traceback (most recent call last): File "mycamx.py", line 15, in c.O3[15,:,:,:].monet.quick_map() File "/home/twt/diskc/monet/monet-2.1.2/monet/monet_accessor.py", line 303, in quick_map figsize = _dynamic_fig_size(self.obj) File "/home/twt/diskc/monet/monet-2.1.2/monet/plots/init.py", line 27, in _dynamic_fig_size nx, ny = len(obj.x), len(obj.y) File "/home/twt/.conda/envs/ncl-py/lib/python3.7/site-packages/xarray/core/common.py", line 228, in getattr "%r object has no attribute %r" % (type(self).name, name) AttributeError: 'DataArray' object has no attribute 'x'

The script I'm using is...... import xarray as xr import monet as m from monet.obs import airnow from monet.models import camx import matplotlib.pyplot as plt from monet.util import tools import pandas as pd

fname = '/home/twt/diskc/hgb/2012/650/output/20120616/20120616.avrg.grd01.nc' c = xr.open_dataset(fname, engine='pseudonetcdf', backend_kwargs={'format': 'ioapi'})

c.O3[15,:,:,:].monet.quick_map() plt.tight_layout() plt.show()

Expected behavior A simple plot of ozone concentrations across the US Conus domain.

bbakernoaa commented 4 years ago

@twtesche I tried downloading the CAMx test case. It doesn't appear that they are in the NetCDF format. Could you try thinning the CAMx output you have and zip the file?

If not could you please try the following?

c = xr.open_dataset(fname)
print(c)

and

c = xr.open_dataset(fname, engine='pseudonetcdf', backend_kwargs={'format': 'ioapi'})
print(c)
bbakernoaa commented 4 years ago

You could also install nco or cdo and extract the variable. You can install these with conda.

conda install nco
ncks -v O3 file.nc O3.nc

https://www.unidata.ucar.edu/support/help/MailArchives/netcdf/msg05538.html

zmoon commented 2 years ago

Closing this as stale