<p>You can try the R package <a href="https://atmoschem.github.io/eixport/" rel="nofollow noreferrer">eixport</a>, with <a href="https://atmoschem.github.io/eixport/reference/wrf_put.html" rel="nofollow noreferrer">wrf_put</a></p>

<pre><code># example
# Read the array emissions,
CO &lt;- wrf_get(file = "Path_to_WRFCHEMI", name = "E_CO")
# Change the values, here you should use your data
CO[] = rnorm(length(CO))
# Inyect your emissions into the wrfchemi
wrf_put(file = "Path_to_WRFCHEMI", name = "E_CO", POL = CO)
</code></pre>

<blockquote>
  <p>How to deal with the speciation (my shapefile has only PM10 and
  PM2.5). where exactly do I place this in the new emissions file (the
  edited wrfchemi)I want. There are many pm species there (like pm2.5
  nucleation mode, pm, etc). I am not sure what weights to put on these.</p>
</blockquote>

<p>You need to know the speciation for your local. At my department at Uni. of São Paulo, we use the following speciation of PM 2.5 (g/h/km^2)</p>

<p>e_so4i = 0.0077, e_so4j = 0.0623, e_no3i = 0.00247, e_no3j = 0.01053, e_pm2.5i = 0.1, e_pm2.5j = 0.3, e_orgi = 0.0304, e_orgj = 0.1296, e_eci = 0.056, e_ecj = 0.024, h2o = 0.277</p>

<p>Check <a href="https://atmoschem.github.io/vein/reference/speciate.html" rel="nofollow noreferrer">this</a></p>

<blockquote>
  <p>My emissions are not time dependent, and what do I do when I edit the
  wrfchemi file for this. (the wrfchemi files I have now are also not
  time dependent)</p>
</blockquote>

<p>You need to first edit the namelist.wps and namelist.input to the desired length of time. Then, after running  ./real.exe you will have the wrfinput_d0x. At this stage you can use <a href="https://atmoschem.github.io/eixport/reference/wrf_create.html" rel="nofollow noreferrer">wrf_create</a> which creates a wrfchemi file with 0. Read the manual to see if you want two 0-12z 12-0z files or one file with the length for all hours. Then you can use wrf_put. Just follow the example and read the manual.</p>

<p>You might also try the R package <a href="https://atmoschem.github.io/EmissV/" rel="nofollow noreferrer">EmissV</a></p>

<p><em>References</em>:</p>

<ol>
<li>Ibarra-Espinosa et al., (2018). eixport: An R package to export
emissions to atmospheric models. Journal of Open Source Software,
3(24), 607, <a href="https://doi.org/10.21105/joss.00607" rel="nofollow noreferrer">https://doi.org/10.21105/joss.00607</a> Schuch et al.,
(2018). </li>
<li>EmissV: an R package to create vehicular and other emissions
for air quality models. Journal of Open Source Software, 3(30), 662,
<a href="https://doi.org/10.21105/joss.00662" rel="nofollow noreferrer">https://doi.org/10.21105/joss.00662</a></li>
</ol>

CC BY-SA 4.0
2020-04-20T13:34:39.060Z
Hi, @Sergio, thank you for this. I have a question regarding the input units needed.

My emissions are in a shapefile format in a grid. What units should the user emissions be in?

Also, what should be in the "variables" argument for wrf_create? is this automatically read in with emiss_opt in the namelist? Thank you!
meteo_96
CC BY-SA 4.0
2020-02-05T19:04:45.913Z
2020-02-06T14:32:44.640Z
2020-02-06T14:32:44.640Z
Sergio
<p>As far as working with netCDF files is concerned, you can use <a href="https://unidata.github.io/netcdf4-python/netCDF4/index.html" rel="nofollow noreferrer">this example</a>. What I've done in the past is loop through the dimensions, variables, and file attributes, with if statements to make changes to the parts of the file that I want to edit.</p>

<p>In your case, you can do what you think is best. Perhaps you can just take an average of the emissions to smooth over the subgrid variability between the wrfchemi grid and the shapefile. Just make sure that the units are consistent. Concerning temporal variability, you can do what you think is appropriate, just specify what you do when communicating your methods. So if it is easier for you to just input constant hourly emissions from a daily average emissions, then do that. If you think it is easier to keep the hour-by-hour pattern, then you can do that.</p>

<p>As far as the speciation is concerned (see <a href="https://ruc.noaa.gov/wrf/wrf-chem/Emission_guide.pdf" rel="nofollow noreferrer">pages 14-15</a>), you can put PM10 in the e_pm10 variable. The PM2.5 emissions is up to you, though keep in mind what the difference between these two are (see <a href="https://www.narsto.org/sites/narsto-dev.ornl.gov/files/Ch3813KB.pdF" rel="nofollow noreferrer">this</a> and <a href="https://aerosol.ees.ufl.edu/atmos_aerosol/section04-2.html" rel="nofollow noreferrer">this</a>).</p>

CC BY-SA 4.0
2019-10-04T19:02:03.590Z
2019-10-04T19:02:03.590Z
BarocliniCplusplus
<p>Does anybody here have any experience with editing wrfchemi outputs from the prep_chem utility so that I overwrite the file with my own emissions?</p>

<p>I am knowledgeable in python, but I am not that well oriented with the manipulation of NetCDF files. </p>

<p>What I want to do, basically, is to use my own emissions inside the WRF/Chem model</p>

<ol>
<li>I have a shapefile of emissions (gridded) with each grid having a value for the emissions.</li>
<li>I want to convert this to a readable format for the WRF/Chem; however, I think editing the wrfchemi files by prep_chem would be easier? (Tell me if not)</li>
</ol>

<p>I have read the emissions guide of the WRF/Chem, but it does not really expound on details about this especially about the following</p>

<ul>
<li>How to deal with the speciation (my shapefile has only PM10 and PM2.5). where exactly do I place this in the new emissions file (the edited wrfchemi)I want. There are many pm species there (like pm2.5 nucleation mode, pm, etc). I am not sure what weights to put on these.</li>
<li>My emissions are not time dependent, and what do I do when I edit the wrfchemi file for this. (the wrfchemi files I have now are also not time dependent)</li>
</ul>

<p>Hoping someone could help out with this.</p>

<p>Thanks!</p>

CC BY-SA 4.0
2019-09-25T19:59:06.933Z
If I understand your question correctly: Do you just want to replace values of some variables in your NetCDF file? Are your emission (the ones in the shape file) already on the same grid as present in the WRF/Chem emission file? The python netCDF4 interface is described here: https://unidata.github.io/netcdf4-python/netCDF4/index.html . Also a tutorial is present there. In order to get familiar with your NetCDF file you might have a look into it with `ncdump` (command line tool). `ncdump -h FILENAME` prints the header of the file containing all variables, dimensions etc.
daniel.heydebreck
CC BY-SA 4.0
2019-09-25T20:00:29.870Z
If your original gridded emission data are not on the same grid as your WRF/Chem setup you could convert the Shape file into NetCDF with NCL and then interpolate it onto your appropriate grid via cdo. Here you find a hint on how to do it: https://code.mpimet.mpg.de/boards/2/topics/6693
daniel.heydebreck
<weather-forecasting><wrf><netcdf><wrf-chem><emissions>
WRF/Chem: Editing NetCDF (wrfchemi files) for own emissions
meteo_96
# WRF/Chem: Editing NetCDF (wrfchemi files) for own emissions

(Asked by: username_0 on 2019-09-24)

Does anybody here have any experience with editing wrfchemi outputs from the prep\_chem utility so that I overwrite the file with my own emissions?

I am knowledgeable in python, but I am not that well oriented with the manipulation of NetCDF files.

What I want to do, basically, is to use my own emissions inside the WRF/Chem model

1. I have a shapefile of emissions (gridded) with each grid having a value for the emissions.
2. I want to convert this to a readable format for the WRF/Chem; however, I think editing the wrfchemi files by prep\_chem would be easier? (Tell me if not)

I have read the emissions guide of the WRF/Chem, but it does not really expound on details about this especially about the following

* How to deal with the speciation (my shapefile has only PM10 and PM2.5). where exactly do I place this in the new emissions file (the edited wrfchemi)I want. There are many pm species there (like pm2.5 nucleation mode, pm, etc). I am not sure what weights to put on these.
* My emissions are not time dependent, and what do I do when I edit the wrfchemi file for this. (the wrfchemi files I have now are also not time dependent)

Hoping someone could help out with this.

Thanks!

**Tags:** weather-forecasting, wrf, netcdf, wrf-chem, emissions

> **Comments:**
> **username_1**: If I understand your question correctly: Do you just want to replace values of some variables in your NetCDF file? Are your emission (the ones in the shape file) already on the same grid as present in the WRF/Chem emission file? The python netCDF4 interface is described here: https://unidata.github.io/netcdf4-python/netCDF4/index.html . Also a tutorial is present there. In order to get familiar with your NetCDF file you might have a look into it with `ncdump` (command line tool). `ncdump -h FILENAME` prints the header of the file containing all variables, dimensions etc.  
> **username_1**: If your original gridded emission data are not on the same grid as your WRF/Chem setup you could convert the Shape file into NetCDF with NCL and then interpolate it onto your appropriate grid via cdo. Here you find a hint on how to do it: https://code.mpimet.mpg.de/boards/2/topics/6693  

---

## 2 answers

### Answer by username_2 on 2020-02-05. Score: 2 | Accepted answer

You can try the R package [eixport](https://atmoschem.github.io/eixport/), with [wrf\_put](https://atmoschem.github.io/eixport/reference/wrf_put.html)

```
# example
# Read the array emissions,
CO <- wrf_get(file = "Path_to_WRFCHEMI", name = "E_CO")
# Change the values, here you should use your data
CO[] = rnorm(length(CO))
# Inyect your emissions into the wrfchemi
wrf_put(file = "Path_to_WRFCHEMI", name = "E_CO", POL = CO)

```

> How to deal with the speciation (my shapefile has only PM10 and
> PM2.5). where exactly do I place this in the new emissions file (the
> edited wrfchemi)I want. There are many pm species there (like pm2.5
> nucleation mode, pm, etc). I am not sure what weights to put on these.

You need to know the speciation for your local. At my department at Uni. of São Paulo, we use the following speciation of PM 2.5 (g/h/km^2)

e\_so4i = 0.0077, e\_so4j = 0.0623, e\_no3i = 0.00247, e\_no3j = 0.01053, e\_pm2.5i = 0.1, e\_pm2.5j = 0.3, e\_orgi = 0.0304, e\_orgj = 0.1296, e\_eci = 0.056, e\_ecj = 0.024, h2o = 0.277

Check [this](https://atmoschem.github.io/vein/reference/speciate.html)

> My emissions are not time dependent, and what do I do when I edit the
> wrfchemi file for this. (the wrfchemi files I have now are also not
> time dependent)

You need to first edit the namelist.wps and namelist.input to the desired length of time. Then, after running ./real.exe you will have the wrfinput\_d0x. At this stage you can use [wrf\_create](https://atmoschem.github.io/eixport/reference/wrf_create.html) which creates a wrfchemi file with 0. Read the manual to see if you want two 0-12z 12-0z files or one file with the length for all hours. Then you can use wrf\_put. Just follow the example and read the manual.

You might also try the R package [EmissV](https://atmoschem.github.io/EmissV/)

*References*:

1. Ibarra-Espinosa et al., (2018). eixport: An R package to export
   emissions to atmospheric models. Journal of Open Source Software,
   3(24), 607, <https://doi.org/10.21105/joss.00607> Schuch et al.,
   (2018).
2. EmissV: an R package to create vehicular and other emissions
   for air quality models. Journal of Open Source Software, 3(30), 662,
   <https://doi.org/10.21105/joss.00662>

> **Comments:**
> **username_0**: Hi, @username_2, thank you for this. I have a question regarding the input units needed.  My emissions are in a shapefile format in a grid. What units should the user emissions be in?  Also, what should be in the "variables" argument for wrf_create? is this automatically read in with emiss_opt in the namelist? Thank you!  

---

### Answer by username_3 on 2019-10-04. Score: 0

As far as working with netCDF files is concerned, you can use [this example](https://unidata.github.io/netcdf4-python/netCDF4/index.html). What I've done in the past is loop through the dimensions, variables, and file attributes, with if statements to make changes to the parts of the file that I want to edit.

In your case, you can do what you think is best. Perhaps you can just take an average of the emissions to smooth over the subgrid variability between the wrfchemi grid and the shapefile. Just make sure that the units are consistent. Concerning temporal variability, you can do what you think is appropriate, just specify what you do when communicating your methods. So if it is easier for you to just input constant hourly emissions from a daily average emissions, then do that. If you think it is easier to keep the hour-by-hour pattern, then you can do that.

As far as the speciation is concerned (see [pages 14-15](https://ruc.noaa.gov/wrf/wrf-chem/Emission_guide.pdf)), you can put PM10 in the e\_pm10 variable. The PM2.5 emissions is up to you, though keep in mind what the difference between these two are (see [this](https://www.narsto.org/sites/narsto-dev.ornl.gov/files/Ch3813KB.pdF) and [this](https://aerosol.ees.ufl.edu/atmos_aerosol/section04-2.html)).


---

