barronh / finn2cmaq

Fire emission pre-processor for CMAQ.
8 stars 2 forks source link

a problem when i run txt2daily.py #1

Closed bandaoshutiao closed 2 years ago

bandaoshutiao commented 2 years ago

This is a domain I set up myself (base) [/data2/sunzhixu/CMAQv5.3.2/PREP/finn/finn2cmaq-master/scripts]$ python3 txt2daily.py …/aux/GRIDDESC CN36KM 2018 FINNv1.5_2018.GEOSCHEM.tar.gz /data4/sunzhixu/outdata/emis/finn/mid/FINNv1.5_2018.GEOSCHEM.nc *PNC:/data/home/sunzhixu/.local/lib/python3.8/site-packages/PseudoNetCDF/pncwarn.py:24:UserWarning: SDATE was -635; using 1970001 Traceback (most recent call last): File “txt2daily.py”, line 118, in gf = pnc.pncopen(args.GRIDDESC, format=‘griddesc’, GDNAM=args.GDNAM) File “/data/home/sunzhixu/.local/lib/python3.8/site-packages/PseudoNetCDF/_getreader.py”, line 153, in pncopen outfile = reader(args, **kwds) File “/data/home/sunzhixu/.local/lib/python3.8/site-packages/PseudoNetCDF/cmaqfiles/_griddesc.py”, line 132, in init self.setgrid(withcf=withcf) File “/data/home/sunzhixu/.local/lib/python3.8/site-packages/PseudoNetCDF/cmaqfiles/_griddesc.py”, line 185, in setgrid grd = self._grd[key] KeyError: ‘CN36KM’

When I use domian in example, it also report an error (base) [/data2/sunzhixu/CMAQv5.3.2/PREP/finn/finn2cmaq-master/scripts]$ python3 txt2daily.py …/aux/GRIDDESC 108NHEMI2 2018 /data4/sunzhixu/outdata/emis/finn/FINNv1.5_2018.GEOSCHEM.tar.gz /data4/sunzhixu/outdata/emis/finn/mid/FINNv1.5_2018.GEOSCHEM.nc PNC:/data/home/sunzhixu/.local/lib/python3.8/site-packages/PseudoNetCDF/pncwarn.py:24:UserWarning: SDATE was -635; using 1970001 PNC:/data/home/sunzhixu/.local/lib/python3.8/site-packages/PseudoNetCDF/pncwarn.py:24:UserWarning: IOAPI_ISPH is assumed to be 6370000.; consistent with WRF **PNC:/data/home/sunzhixu/.local/lib/python3.8/site-packages/PseudoNetCDF/pncwarn.py:24:UserWarning: IOAPI_ISPH is assumed to be 6370000.; consistent with WRF Traceback (most recent call last): File “txt2daily.py”, line 119, in outf = process(gf, args) File “txt2daily.py”, line 102, in process outf.updatemeta() File “/data/home/sunzhixu/.local/lib/python3.8/site-packages/PseudoNetCDF/cmaqfiles/_ioapi.py”, line 746, in updatemeta self.getVarlist(update=True) File “/data/home/sunzhixu/.local/lib/python3.8/site-packages/PseudoNetCDF/cmaqfiles/_ioapi.py”, line 593, in getVarlist varliststr_old = getattr(self, ‘VAR-LIST’) AttributeError: ‘griddesc’ object has no attribute ‘VAR-LIST’

I can't find out the cause of this error report,I would appreciate it if you could help me I also asked you on CMAS forum

barronh commented 2 years ago

I didn't see the comment on the CMAS forum, but I can look into this.

When you set up your own domain, you have to put the definition into the GRIDDESC file that is being used by this process. It seems like your first error is due to it being missing.

It will take a little longer for me to know what is happening in the second error.

barronh commented 2 years ago

Try changing line 100 of txt2daily.py from

        delattr(outf, 'VAR-LIST')

to

        setattr(outf, 'VAR-LIST', ''.join([varkey.ljust(16) for varkey in varkeys]))

The delattr command was meant to force a refresh, but in the newer version of pnc it seems to break the refresh... I'll have to look into that on the PseudoNetCDF side.

You could also downgrade your PseudoNetCDF to v3.1 and it would work.

bandaoshutiao commented 2 years ago

Thank you very much I have successfully run the test file in example, but there are still errors when I use my own domian This is the domian definition in my GRIDDESC file

'LamCon_40N_97W'
 2 33.000 45.000 -97.000 -97.000 40.000
'POLSTE_HEMI'
 6         1.000        45.000       -98.000       -98.000        90.000
' '
'108NHEMI2'
'POLSTE_HEMI' -10098000.000 -10098000.000    108000.000    108000.000 187 187   1
'12US1'
'LamCon_40N_97W' -2556000.0 -1728000.0 12000.0 12000.0 459 299 1
'12US2'
'LamCon_40N_97W'     -2412000.0 -1620000.0 12000.0 12000.0 396 246 1
'36US3'
'LamCon_40N_97W'  -2952000.000  -2772000.000     36000.000     36000.000 172  148   1
'CN36km'
'LAM_34N110E'  -3114000.000  -2448000.000     36000.000     36000.000 173 136   1
'YRD4km'
'LAM_34N110E'   450000.000   -708000.000      4000.000      4000.000 192 216   1
' '

CN36KM and YRD4km are what I need.

(base) [/data2/sunzhixu/CMAQv5.3.2/PREP/finn/finn2cmaq-master/scripts]$ python3 txt2daily.py ../aux/GRIDDESC CN36km 2018 /data4/sunzhixu/outdata/emis/finn/FINNv1.5_2018.GEOSCHEM.tar.gz /data4/sunzhixu/outdata/emis/finn/mid/FINNv1.5_2018.GEOSCHEM.nc
**PNC:/data/home/sunzhixu/.local/lib/python3.8/site-packages/PseudoNetCDF/pncwarn.py:24:UserWarning:
  SDATE was -635; using 1970001
Traceback (most recent call last):
  File "txt2daily.py", line 120, in <module>
    gf = pnc.pncopen(args.GRIDDESC, format='griddesc', GDNAM=args.GDNAM)
  File "/data/home/sunzhixu/.local/lib/python3.8/site-packages/PseudoNetCDF/_getreader.py", line 153, in pncopen
    outfile = reader(*args, **kwds)
  File "/data/home/sunzhixu/.local/lib/python3.8/site-packages/PseudoNetCDF/cmaqfiles/_griddesc.py", line 132, in __init__
    self.setgrid(withcf=withcf)
  File "/data/home/sunzhixu/.local/lib/python3.8/site-packages/PseudoNetCDF/cmaqfiles/_griddesc.py", line 186, in setgrid
    prj = self._prj[grd['PRJNAME'].strip()]
KeyError: 'LAM_34N110E'

Am I missing something?

bandaoshutiao commented 2 years ago

I found it!! It turns out that I'm missing some content! Thank you again

barronh commented 2 years ago

I'm glad you figured it out. For others who may com across this post and wonder what was missing, see https://www.cmascenter.org/ioapi/documentation/all_versions/html/GRIDDESC.html. Specifically, a grid is made up of a grid definition and a coordinate system.

COORD-NAME COORDTYPE, P_ALP, P_BET, P_GAM, XCENT, YCENT

   and

GRID-NAME COORD-NAME, XORIG, YORIG, XCELL, YCELL NCOLS, NROWS, NTHIK

The grid definition was there, but the new coordinate (Lambert Conic Conformal Projection definition) was missing. From the COORD-NAME (LAM_34N_110E), it is easy to see that the XCENT would be 110 and the YCENT would be 34. Usually, P_GAM = YCENT. P_ALP and P_BET are the standard latitudes where the Lambertian cone intersects the earth's sphere. From the name alone, we cannot guess what they are. From personal experience, I think they are 25 and 40.