(part of the AQMEII-NA_N2O family of projects)
table of contents
- sum various EDGAR-4.2 N2O emission inventories (in netCDF format). These inventories cover sectors/processes of N2O production other than those involving biomass burning, oceans, and soils.
- "reunit": convert from (per-gridcell) flux rate (
kg/m^2/s) to molar-mass rate (
moles/sec, which CMAQ wants).
- 2D-regrid from global/unprojected to a projected subdomain (AQMEII-NA).
- "retemporalize" from annual timestep to hourly (and tweak metadata)
- check that mass is (more or less) conserved in all of the above
creating CMAQ-style emissions files (e.g., this, when
gunziped) containing hourly emissions usable for any day in the year. Currently does not provide a clean or general-purpose (much less packaged) solution! but merely shows how to do these tasks using
- bash (tested with version=3.2.25)
- NCL (tested with version=6.1.2)
- R (tested with version=3.0.0) and packages including
To run this code,
git clonethis repo. (See commandlines on the project homepage, where you probably are now.)
cdto its working directory (where you cloned it to).
- Setup your applications and paths.
- Download a copy of these bash utilities to the working directory.
- Open the file in in an editor! You will probably need to edit its functions
setup_appsto make it work on your platform. Notably you will want to point it to your PDF viewer and NCL and R executables.
- You may also want to open the driver (bash) script in an editor and take a look. It should run Out Of The Box, but you might need to tweak something there. In the worst case, you could hardcode your paths and apps in the driver.
- Once you've got it working, you may want to fork it. If so, you can automate running your changes with uber_driver.sh (changing that as needed, too).
- Run the driver:
- This will download input, then run
- an R script to sum the raw inputs, convert that intermediate product from mass flux to molar-mass rate, and plot it. The driver should display a global plot if properly configured.
- an R script to regrid the previous product, and plot the output. The driver should display an AQMEII plot if properly configured.
- an NCL script to generate hourly output suitable for input to CMAQ.
an NCL script to check conservation of mass from input to output. Given that the output domain (AQMEII-NA) is significantly smaller than the input domain (global), it merely reports the fraction of mass (as
kg) in output vs input, and compares that to an estimate of the land area of the output domain relative to the input domain (since these emissions seem overwhelmingly land-based). Current output includes
Compare annual emissions reported by EDGAR to our calculated annual emissions: raw input sum EDGAR annual sum calculated sector (kgN2O) from output EDGAR/calc -------- ---------- ----------- ---------- combust 3.24e+08 3.23e+08 1.00e+00 nonroad 7.79e+07 7.76e+07 1.00e+00 road 2.23e+08 2.23e+08 1.00e+00 resid 2.85e+08 2.84e+08 1.00e+00 petro 6.52e+06 6.52e+06 1.00e+00 ind 1.33e+09 1.33e+09 1.00e+00 manure 3.36e+08 3.35e+08 1.00e+00 runoff 8.94e+08 8.92e+08 1.00e+00 waste 3.75e+08 3.74e+08 1.00e+00 fff 7.53e+05 7.53e+05 1.00e+00 tropo 7.11e+08 6.99e+08 1.02e+00 Is N2O conserved from input to output? units=kg N2O (note (US land area)/(earth land area) ~= 6.15e-02) input input output output global NAs AQMEII-NA NAs out/in 4.55e+09 0 4.38e+08 0 9.64e-02
- Retest with newest
repo_diff.shshows the following local
- refactor more of the common NCL IOAPI-writing code to local
- Move all these TODOs to issue tracker.
*.sh: use bash booleans à la
- Create common project for
regrid_resourcesà la regrid_utils, so I don't hafta hunt down which resource is in which project.
- All regrids: how to nudge off/onshore as required? e.g., soil or burning emissions should never be offshore, marine emissions should never be onshore.
- All regrid maps: add Caribbean islands (esp Bahamas! for offshore burning), Canadian provinces, Mexican states.
- Complain to ncl-talk about NCL "unsupported extensions," e.g.,
<null/>(e.g., MCIP output).
- Determine why
<-assignment is occasionally required in calls to
- Fully document platform versions (e.g., linux, compilers, bash, NCL, R).
- Test on
- tlrPanP5 (which now has R package=ncdf4, but readAsciiTable of input .txt's is very slow compared to terrae)
- HPCC (once problem with ncdf4 on amad1 is debugged: in process with JOB and KMF)