CTM_LOG_001.v532_intel_2020_1_20200110.txt (64.7 KB)
dataset_attrs.log.txt (10.0 KB)
run_cctm.csh (36.5 KB)
I just started using CMAQ not long ago. I am trying to use adapt my emission inventory to CMAQ-5.3.2. The emission files were generated by Python script. And I got this error while running CCTM. I can be sure that no value less than 0 exists in my emissions file. There are my running script, error log, and emission file attributes. Some variables in the running script are defined in another bash script.
Many thanks for your help!
ERROR: Invalid Negative emission rate -Infinity has been
for CMAQ species AECJ.
Please inspect the Emission Control Namelist File.
*** ERROR ABORT in subroutine EMISS_NEG_CHECK on PE 001
Negative Emissions Detected
PM3EXIT: date&time specified as 0
Date&time specified as 0
The dataset_attrs.log.txt suggests that the minimum value for PEC is 0 and the max is 1263.509. On its face, this range seems reasonable. The problem is that it may have been generated in a way that ignores missing values. For example, both netcdf4-python and xarray will automatically mask missing values and ignore them in the min/max calculations.
If any values are missing, CMAQ would likely read them in incorrectly. The script below will help to identify any missing values.
import numpy as np
epath = '/home/chengy/CMAQ/CMAQ-5.3/data/2020_1/emis/ALL_20200110_area.nc'
f = netCDF4.Dataset(epath)
misscount = 
for k in sorted(f.variables):
vals = f.variables[k][:]
cmask = np.ma.getmaskarray(vals).sum()
print(k, cmask, ('<-- has missing values' if cmask > 0 else ''))
print('Problems:', sorted([(c, k) for c, k in misscount if c > 0]))
If any of the variables has more than 0 missing, then the file needs to be fixed.
p.s., the long_name attribute should be only 16 characters long, but is 80 right now.
In addition to the test suggested by @barronh , I also suggest trying to run I/O API tools program m3stat to confirm that the file you generated with python can be successfully read by the I/O API library functions also used in CMAQ and to see what species statistics are being reported by that program.
Along the lines mentioned by @barronh, one thing that stands out to me is that one of your global attributes is ‘_FillValue’ and it’s set to 0.0, so while (I think) I/O API doesn’t explicitly use that attribute, the underlying netCDF layer possibly does and then possibly sets all zero values encountered in the emission fields to some internal very large value. Possibly not, but’s it’s not a standard I/O API attribute.
I agree with everything that @hogrefe.christian said. I’ll note that the _FillValue attribute was shown as a file attribute. This is unusual. Usually, the _FillValue is a property of each variable. Either way, IOAPI and thus CMAQ will not handle _FillValue the same way that netcdf4-python or xarray will.
@hogrefe.christian recommendation to use
m3stat is a great one!
For what it’s worth: from the I/O API point of view, “missing” is either
IMISS3=-9999 (for INTEGER); for reasons of avoiding round-off/processor-platform/compiler issues, the correct “missing” test for
X < AMISS3
_FillValue=0 is not supported by the I/O API.
Sorry for reply late. Great thanks to all of you. I have tried m3stat and it failed. So it’s the problem of my python script. I think @barronh 's suggestion is right, and I will try it in the future. And I also suggest the python-ioapi method in this url netCDF Wrapper Library for Gridded I/O API-like files - PYTHON - CMAS CENTER FORUM, to whom may use python to create the ioapi emission file.
Be aware that this interface (attempting to treat the I/O API as defining a “data format” instead of as a “programming interface” (that’s what the “PI” stands for, after all)) does NOT correctly handle time-independent nor restart files: see https://cjcoats.github.io/ioapi/DATETIME.html or https://www.cmascenter.org/ioapi/documentation/all_versions/html/DATETIME.html.
Nor does it handle distributed-I/O files, File-Set File Lists, COUPLING-MODE Virtual Files, nor Native-Binary Real Files ;-(
Nor who knows what else…
Many thanks for your kind reminder. I am a new user of CMAQ, honestly i have not fully understand of I/O API.
It’s quite well-documented, starting at https://www.cmascenter.org/ioapi/documentation/all_versions/html/AA.html or https://cjcoats.github.io/ioapi/AA.html. Note that there is an extensive Tutorial, as well as sections detailing the underlying conventions and concepts, and manual-pages for all the routines and for the M3Tools related programs.