Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyWRFChemEmiss output, convert_emiss.exe of WRF_CHEM-3.4.1 reads , but wrongly #4

Open
nishadhka opened this issue Nov 11, 2014 · 2 comments

Comments

@nishadhka
Copy link

This issue is continuation of issue mention in #1 related with successful generation of FORTRAN unformatted bin file by pyWRFChemEmiss and grid interpolation of it by convert_emiss.exe. But wrong or nil data entry in the emission fields generated in the file wrfchemi_d01 by convert_emiss.exe.

MIX Asian emission inventory in NETCDF formate was converted into csv then xlsx and fed into the program pyWRFChemEmiss, it gives files wrfem_00to12z_d01 and wrfem_12to24z_d01 with size of 49 MB for model domain specified in namelist.wps. These generated files are used by convert_emiss.exe (as per log entry) but data is nil in the netcdf file wrfchemi_d01
(a size of 1.1MB) output by convert_emiss.exe. Check this csv file generated from the wrfchemi_d01 by a python script for most of nil value in variables. Contrary to this for a comparison check this csv file from wrfchemi_d01 of PREP_CHEM_SRC ouptut emissopt3_d01 converted by convert_emiss.exe program having all variables populated.

The data in MIX Asian emission inventory is 28 km2 and with unit of Mg/month. This was then converted into mol/hour for chemical species and g/hour for PM2.5 and PM10. Since the data is available only for 28 KM2 no further conversion was made into per KM2 as required by pyWRFChemEmiss.

As above problem can be of with domain size, a new attempt was made with enlarged domain size. This is the csv file from emission inventory. The csv file from output of convert_emiss.exe is this with same above problem but with wrong variables which is not available in the emission inventory itself.

From all the csv file it is evident that the unformatted file given by pyWRFCHEMEMISS is plotted correctly. Row size (ploted grid for WRF CHEM) domain is same for all netcdf files from Convert_Emiss.exe irrespective of PREP_CHEM_SRC or pyWRFChemEmiss used. But problem is with wrong or mismatched variable values in pyWRFChemEmiss.

So my doubts are

  1. Is the emission inventory has to be converted into per km2 from 28km2, the problem of mismatched variable values is due to this?
  2. How can the unformatted Fortran bin file can be viewed in python, I tried with fortranfile library in python to view pyWRFChemEmiss, but ends in error such as this IOError: Could not read enough data. Wanted 67108864 bytes, got 1110720. by the code
    import fortranfile;f = fortranfile.FortranFile('wrfem_00to12z_d01');x = f.readReals()

Kindly help me to resolve this issue.

@arifwn
Copy link
Owner

arifwn commented Nov 19, 2014

I'm getting in touch with my professor and we'll review this tool again, but it's been a couple years so it might take a while for me to review this.

Looks like your use case is quite different with ours. This tool was designed to process 1km x 1km grid data into wrf chem, and performing averaging and transformation to fit wrf grid size. We'll review your use case too.

As for reading the fortran file, the file is actually a collection of multi-dimentional numeric arrays (some are integer, some are float). You'll need to know the array types and dimensions in order to read them. Simply reading them with x = f.readReals() won't work. Check out payload.py line 309 to see the array structure of the fortran file.

@nishadhka
Copy link
Author

Ok this clears, Thanks. The problem is major with 28 km2 grid I am using, otherwise all the necessary steps are taken care by PyWRFChemEmiss and it works perfectly with as similar plotting of pollutant as of PREP_CHEM_SRC in domain extent. The problem is shuffling of variables values that would be due to larger grid used.

In that case can you please point me the code actually taking care of this 1km grid, tweaking this to care larger grid would solve the problem. Native language commenting of the code makes harder to know much about the code.

As far as the application is concern, I think PyWRFChemEmiss is one of kind written in python and important application in this regard. I could find other than PREP_CHEM_SRC, only one application written in GO that would do emission processor job for WRF CHEM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants