barronh / aqmbc

Air Quality Model Boundary Condition Tools
GNU General Public License v3.0
11 stars 3 forks source link

can not read GEOS-Chem output #4

Closed haohe1982 closed 1 year ago

haohe1982 commented 1 year ago

I tried to successfully installed the aqmbc and want to process GEOS-Chem output (v14.01.1, 4x5 full chemistry) for my 12US2 CMAQ simulations, but the aqmbc can not read the netCDF file. Below are my .cfg file and the error. I checked my Python environment, with the PseudoNetCDF and pyproj installed.

########################## cfg ####################### ; GDNAM must exists as a projection in GRIDDESC gdnam=12US2 griddesc=GRIDDESC ; VGTOP is the WRF model top in Pascals and VGLVLS are the ; edges of each level in WRF dry-sigma coordinate top vgtop=5000 vglvls=[ 1.0, 0.9975, 0.995, 0.99, 0.985, 0.98, 0.97, 0.96, 0.95, 0.94, 0.93, 0.92, 0.91, 0.9, 0.88, 0.86, 0.84, 0.82, 0.8, 0.77, 0.74, 0.7, 0.65, 0.6, 0.55, 0.5, 0.45, 0.4, 0.35, 0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0.0 ]

; Use linear or conserve to inteprolate vertically ; Linear simplifies the source coordinate to an approximation ; of sigma and interpolates to centers. Conserve uses layer ; edges of both the input and output to conserve mixing ratios. ; Concentrations are mole-weighted levels. vinterp=linear

; Use expressions to translate input model to CMAQ expressions=[ "${rcpath}/definitions/gc/gcnc_airmolden.expr", "${rcpath}/definitions/gc/gc12_to_cb6r3.expr", "${rcpath}/definitions/gc/gc12_soas_to_ae7.expr" ]

[source] ; Sources currently supported are GEOS-Chem bcph, GEOS-Chem netcdf, and CMAQ ; input is a strftime template that will be evaluated for each day. input=input/GEOSChem.BoundaryConditions.%Y%m%d_0000z.nc4

; Format should have a format keyword and options ; a common option is "nogroup": true for GEOS-Chem bpch format={"format": "gcnc"} ; Dims translates dimension names from the source to CMAQ dims={ "TSTEP": "time", "LAY": "lev", "ROW": "lat", "COL": "lon" }

[ICON] ; Usually, you only want a couple ICON, so you specify the ; date individually ;dates=["2016-01-01"] dates=["2019-07-01"] output=ICON/GEOSChem.SpeciesBC.%Y%m%d_0000z.${GDNAM}.ICON.nc

[BCON] ; BCON are provided for each day, so you specify a range

########################## Error ###################### ozone.umd.edu{hhe}1008: python -m aqmbc gcncv12.cfg [common] overwrite = False verbose = 0 pwd = /data/chemstg67/hhe/geos-chem/cmaq_bc rcpath = /data/chemstg67/hhe/geos-chem/cmaq_bc gdnam = 12US2 griddesc = GRIDDESC vgtop = 5000 vglvls = [ 1.0, 0.9975, 0.995, 0.99, 0.985, 0.98, 0.97, 0.96, 0.95, 0.94, 0.93, 0.92, 0.91, 0.9, 0.88, 0.86, 0.84, 0.82, 0.8, 0.77, 0.74, 0.7, 0.65, 0.6, 0.55, 0.5, 0.45, 0.4, 0.35, 0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0.0 ] vinterp = linear expressions = [ "${rcpath}/definitions/gc/gcnc_airmolden.expr", "${rcpath}/definitions/gc/gc12_to_cb6r3.expr", "${rcpath}/definitions/gc/gc12_soas_to_ae7.expr" ]

[source] input = input/GEOSChem.BoundaryConditions.%Y%m%d_0000z.nc4 format = {"format": "gcnc"} dims = { "TSTEP": "time", "LAY": "lev", "ROW": "lat", "COL": "lon" }

[ICON] dates = ["2019-07-01"] output = ICON/GEOSChem.SpeciesBC.%Y%m%d_0000z.${GDNAM}.ICON.nc

[BCON] start_date = 2019-07-01 end_date = 2019-07-02 freq = d output = BCON/GEOSChem.SpeciesBC.%Y%m%d_0000z.${GDNAM}.BCON.nc

Converting input/GEOSChem.BoundaryConditions.20190701_0000z.nc4 to BCON/GEOSChem.SpeciesBC.20190701_0000z.12US2.BCON.nc open Traceback (most recent call last): File "/data/chemstg67/hhe/python/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/data/chemstg67/hhe/python/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/data/chemstg67/hhe/python/anaconda3/lib/python3.7/site-packages/aqmbc/main.py", line 36, in runcfg(args.config) File "/data/chemstg67/hhe/python/anaconda3/lib/python3.7/site-packages/aqmbc/init.py", line 117, in runcfg bc(opts) File "/data/chemstg67/hhe/python/anaconda3/lib/python3.7/site-packages/aqmbc/bcon.py", line 182, in bc infile = pnc.pncopen(inpath, format_kw) File "/data/chemstg67/hhe/python/anaconda3/lib/python3.7/site-packages/PseudoNetCDF/_getreader.py", line 153, in pncopen outfile = reader(*args, kwds) File "/data/chemstg67/hhe/python/anaconda3/lib/python3.7/site-packages/PseudoNetCDF/geoschemfiles/_gcnc.py", line 213, in init netcdf.init(self, *args, *kwds) File "/data/chemstg67/hhe/python/anaconda3/lib/python3.7/site-packages/PseudoNetCDF/core/_files.py", line 2471, in init NetCDFFile.init(self, args, kwds) File "src/netCDF4/_netCDF4.pyx", line 2463, in netCDF4._netCDF4.Dataset.init File "src/netCDF4/_netCDF4.pyx", line 2026, in netCDF4._netCDF4._ensure_nc_success OSError: [Errno -51] NetCDF: Unknown file format: b'input/GEOSChem.BoundaryConditions.20190701_0000z.nc4'

barronh commented 1 year ago

Can you post your file somewhere (e.g., ftp or google drive) for me to test?

haohe1982 commented 1 year ago

Sure. Attached is my 1-day GEOS-Che m boundary output file.

GEOSChem.BoundaryConditions.20190701_0000z.nc4 https://drive.google.com/file/d/1ddwuatDPqSlylLK7u5b0BbtDEzU2Vj2K/view?usp=drive_web

On Thu, Nov 17, 2022 at 11:47 AM Barron H. Henderson < @.***> wrote:

Can you post your file somewhere (e.g., ftp or google drive) for me to test?

— Reply to this email directly, view it on GitHub https://github.com/barronh/aqmbc/issues/4#issuecomment-1318916817, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANJ3OSRREDQSYU4YWE5DMCDWIZOSZANCNFSM6AAAAAASC4NWLE . You are receiving this because you authored the thread.Message ID: @.***>

haohe1982 commented 1 year ago

One more thing I forgot to mention. The GEOS-Chem was compiled in the netCDF environment with HDF5 library. No idea if it caused the problem for Python.

barronh commented 1 year ago

It ran just fine for me. It is possible that your netcdf4-python is linked against a version of libnetcdf that doesn't support NetCDF.

I noticed is that your file does not include any met variables. In order to convert PM species to micrograms/m3, you will need a measure of air density. The conversion uses AIRMOLDEN [=] mole/m3, which can be calculated a number of ways. You can use Met_PMIDDRY and MetT to calculate it or calculate it from other variables. However, it is easiest if you add the Met variables (e.g., PMIDDRY and T) to your BoundaryConditions file by modifying HISTORY.rc. That way, they are present in the files natively. You can add them separately, but that is more work.

Lastly, I have usually made an hourly (or 3-hourly) SpeciesBC output that contains SpeciesConc?ADV?. You are using the SpeciesBC?ADV?, which has the same units and species. So, that should be fine... Except, all the variable names in definitions/gc/* are SpeciesConc_. This is no problem; you'll need to do a find and replace to change all SpeciesConc_ to SpeciesBC_ in the definition files that you're using.

Note that depending on the version of GEOS-Chem and how it was run, you may need to comment out or change some of the definitions. There are comments in there to guide you.

haohe1982 commented 1 year ago

Good to know the GEOS-Chem looks right and I will play with the HISTORY.rc to save the correct output. I agree that it should be the problem with my python. I used a Linux-based Anaconda to install Python 3.7.3 on a server. Any suggestions on the Python or Anaconda version? Also, your statement has 'pseudonetCDF' and 'prproj' as prerequisites. Any specific version?

Hao

On Mon, Nov 21, 2022 at 3:41 PM Barron H. Henderson < @.***> wrote:

It ran just fine for me. It is possible that your netcdf4-python is linked against a version of libnetcdf that doesn't support NetCDF.

I noticed is that your file does not include any met variables. In order to convert PM species to micrograms/m3, you will need a measure of air density. The conversion uses AIRMOLDEN [=] mole/m3, which can be calculated a number of ways. You can use Met_PMIDDRY and MetT to calculate it or calculate it from other variables. However, it is easiest if you add the Met variables (e.g., PMIDDRY and T) to your BoundaryConditions file by modifying HISTORY.rc. That way, they are present in the files natively. You can add them separately, but that is more work.

Lastly, I have usually made an hourly (or 3-hourly) SpeciesBC output that contains SpeciesConc?ADV?. You are using the SpeciesBC?ADV?, which has the same units and species. So, that should be fine... Except, all the variable names in definitions/gc/* are SpeciesConc. This is no problem; you'll need to do a find and replace to change all SpeciesConc to SpeciesBC_ in the definition files that you're using.

Note that depending on the version of GEOS-Chem and how it was run, you may need to comment out or change some of the definitions. There are comments in there to guide you.

— Reply to this email directly, view it on GitHub https://github.com/barronh/aqmbc/issues/4#issuecomment-1322615548, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANJ3OSXXMU75SJJHGSYOVMTWJPM7HANCNFSM6AAAAAASC4NWLE . You are receiving this because you authored the thread.Message ID: @.***>

barronh commented 1 year ago

Hao - Versions are always tricky, but any vaguely recent version of pseudonetcdf or pyproj should be fine. The functionality for GEOS-Chem NetCDF in pseudonetcdf hasn't changed in some time, and the pyproj functionality being used is pretty basic.