Skip to content

Commit

Permalink
Add mapping for ICON model
Browse files Browse the repository at this point in the history
* Added class for ICON-grid in grids.py
* Added class ICONGrid in grids.py
* Extended the code for mapping to ICON output grid:
 - globally changed "cosmo_grid" to "output_grid" (except for the existing config-files)
 - created a new config file for the tno/ICON-case
 - added 2 new functions in utilities: "prepare_ICON_output_file" and "write_variable_ICON"
 - built in switches in __init__ and utilities where necessary to distinguish between COSMO and ICON grid
 - changed further variables where reasonable, e.g. cosmo_cell_x --> output_cell_x
* Changed all output_grid-variables in the config-files
* Gridding of the pointsources is much more efficient now looping only over cells around the closest vertex 
* central_longitude in Mellweide-projection is now pollon-dependent and Readme is updated with a link to the Readme in cases/
* cases/README.md is now a link
  • Loading branch information
micstein89 authored May 12, 2021
1 parent 7628b63 commit 038a9e5
Show file tree
Hide file tree
Showing 14 changed files with 498 additions and 127 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ be obtained separately.
$ python -m emiproc vp # for vertical profiles
```

Further examples, including the generation of offline files and inventory merging, can be found in [cases/README.md](cases/README.md)

## Gridded annual emissions

Emissions are read from the inventory and projected onto the COSMO grid.
Expand Down
4 changes: 2 additions & 2 deletions cases/config_append.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import time
import os
from emiproc.grids import COSMOGrid, TNOGrid
from emiproc.grids import COSMOGrid, TNOGrid, ICONGrid

inv_1 = os.path.join('outputs', '{online}', 'tno.nc')
inv_name_1 = '_TNO'
Expand All @@ -12,7 +12,7 @@


# COSMO domain
cosmo_grid = COSMOGrid(
output_grid = COSMOGrid(
nx=900,
ny=600,
dx=0.01,
Expand Down
7 changes: 4 additions & 3 deletions cases/config_carbocount.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os
import time

from emiproc.grids import COSMOGrid, SwissGrid
from emiproc.grids import COSMOGrid, SwissGrid, ICONGrid

# inventory
inventory = 'swiss-cc'

# model either "cosmo-art" or "cosmo-ghg" (affects the output units)
# model either "cosmo-art", "cosmo-ghg" or "icon" (affects the
# output units and handling of the output grid)
model = 'cosmo-ghg'

# path to input inventory
Expand Down Expand Up @@ -85,7 +86,7 @@
varname_format = '{species}_{category}'

# COSMO domain
cosmo_grid = COSMOGrid(
output_grid = COSMOGrid(
nx=900,
ny=600,
dx=0.01,
Expand Down
4 changes: 2 additions & 2 deletions cases/config_d1_append.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import time
from emiproc.grids import COSMOGrid, TNOGrid
from emiproc.grids import COSMOGrid, TNOGrid, ICONGrid



Expand All @@ -14,7 +14,7 @@


# Output grid is European domain (rotated pole coordinates)
cosmo_grid = COSMOGrid(
output_grid = COSMOGrid(
nx=192,
ny=164,
dx=0.12,
Expand Down
7 changes: 4 additions & 3 deletions cases/config_d1_swiss_art.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os
import time

from emiproc.grids import COSMOGrid, SwissGrid
from emiproc.grids import COSMOGrid, SwissGrid, ICONGrid

# inventory
inventory = 'swiss-art'

# model is "cosmo-art" or "cosmo-ghg" (affects the output units)
# model either "cosmo-art", "cosmo-ghg" or "icon" (affects the
# output units and handling of the output grid)
model = 'cosmo-art'

# add total emissions (only for swiss inventory)
Expand Down Expand Up @@ -58,7 +59,7 @@
nx = 192
ny = 164

cosmo_grid = COSMOGrid(
output_grid = COSMOGrid(
nx=nx,
ny=ny,
dx=0.12,
Expand Down
7 changes: 4 additions & 3 deletions cases/config_d1_tno_art.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import os
import time

from emiproc.grids import COSMOGrid, TNOGrid
from emiproc.grids import COSMOGrid, TNOGrid, ICONGrid

# inventory
inventory = 'TNO'

# model either "cosmo-art" or "cosmo-ghg" (affects the output units)
# model either "cosmo-art", "cosmo-ghg" or "icon" (affects the
# output units and handling of the output grid)
model = 'cosmo-art'

# input filename
Expand Down Expand Up @@ -53,7 +54,7 @@
output_name = 'tno-art.nc'

# Output grid is European domain (rotated pole coordinates)
cosmo_grid = COSMOGrid(
output_grid = COSMOGrid(
nx=192,
ny=164,
dx=0.12,
Expand Down
7 changes: 4 additions & 3 deletions cases/config_edgar.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from emiproc.grids import COSMOGrid, EDGARGrid
from emiproc.grids import COSMOGrid, EDGARGrid, ICONGrid
import os
import time

# inventory
inventory = 'EDGAR'

# model either "cosmo-art" or "cosmo-ghg" (affect the output units)
# model either "cosmo-art", "cosmo-ghg" or "icon" (affects the
# output units and handling of the output grid)
model = 'cosmo-ghg'

# path to input inventory
Expand Down Expand Up @@ -64,7 +65,7 @@

# Domain
# CHE_Europe domain
cosmo_grid = COSMOGrid(
output_grid = COSMOGrid(
nx=760,
ny=610,
dx=0.05,
Expand Down
79 changes: 79 additions & 0 deletions cases/config_icon_tno.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import os
import time

from emiproc.grids import COSMOGrid, TNOGrid, ICONGrid

# inventory
inventory = 'TNO'

# model either "cosmo-art", "cosmo-ghg" or "icon" (affects the
# output units and handling of the output grid)
model = 'icon'

# path to input inventory
input_path = "/input/TNOMACC/TNO_GHGco/TNO_6x6_GHGco_v1_1/TNO_GHGco_v1_1_year2015.nc"

# input grid
input_grid = TNOGrid(input_path)

# input species
species = ['co2_ff', 'co2_bf']

# input categories
categories = [
"A",
"B",
"C",
"D",
"E",
"F1",
"F2",
"F3",
"G",
"H",
"I",
"J",
"K",
"L",
]

# mapping from input to output species (input is used for missing keys)
in2out_species = {
'co2_ff': 'CO2',
'co2_bf': 'CO2'
}

# mapping from input to output species (input is used for missing keys)
in2out_category = {}

# output variables are written in the following format using species and
# category after applying mapping as well as source_type (AREA or POINT) for
# TNO inventories
varname_format = '{species}_{category}' # not providing source_type will add up
# point and area sources

# path to ICON output grid
icon_path = "/newhome/stem/git/C2SM-RCM/ICON_grids/MCH2km/domain1_DOM01.nc"

# output ICON grid
output_grid = ICONGrid(icon_path)

# output path and filename
output_path = os.path.join('outputs', '{online}')
output_name = "tno.nc"

# resolution of shape file used for country mask
shpfile_resolution = "10m"

# number of processes computing the mapping inventory->COSMO-grid
nprocs = 18

# metadata added as global attributes to netCDF output file
nc_metadata = {
"DESCRIPTION": "Gridded annual emissions",
"DATAORIGIN": "TNO",
"CREATOR": "Jean-Matthieu Haussaire",
"EMAIL": "jean-matthieu.haussaire@empa.ch",
"AFFILIATION": "Empa Duebendorf, Switzerland",
"DATE CREATED": time.ctime(time.time()),
}
15 changes: 8 additions & 7 deletions cases/config_tno.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os
import time

from emiproc.grids import COSMOGrid, TNOGrid
from emiproc.grids import COSMOGrid, TNOGrid, ICONGrid

# inventory
inventory = 'TNO'

# model either "cosmo-art" or "cosmo-ghg" (affect the output units)
# model either "cosmo-art", "cosmo-ghg" or "icon" (affects the
# output units and handling of the output grid)
model = 'cosmo-ghg'

# path to input inventory
Expand Down Expand Up @@ -52,11 +53,11 @@
# point and area sources

# COSMO domain
cosmo_grid = COSMOGrid(
nx=900,
ny=600,
dx=0.01,
dy=0.01,
output_grid = COSMOGrid(
nx=450, #900
ny=300, #600
dx=0.02, #0.01
dy=0.02, #0.01
xmin=-4.92,
ymin=-3.18,
pollon=-170.0,
Expand Down
7 changes: 4 additions & 3 deletions cases/test_swiss_cc.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os
import time

from emiproc.grids import COSMOGrid, SwissGrid
from emiproc.grids import COSMOGrid, SwissGrid, ICONGrid

# inventory
inventory = 'swiss-cc'

# model either "cosmo-art" or "cosmo-ghg" (affects the output units)
# model either "cosmo-art", "cosmo-ghg" or "icon" (affects the
# output units and handling of the output grid)
model = 'cosmo-ghg'

# path to input inventory
Expand Down Expand Up @@ -65,7 +66,7 @@
varname_format = '{species}_{category}'

# COSMO domain
cosmo_grid = COSMOGrid(
output_grid = COSMOGrid(
nx=90,
ny=60,
dx=0.1,
Expand Down
7 changes: 4 additions & 3 deletions cases/test_tno.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os
import time

from emiproc.grids import COSMOGrid, TNOGrid
from emiproc.grids import COSMOGrid, TNOGrid, ICONGrid

# inventory
inventory = 'TNO'

# model either "cosmo-art" or "cosmo-ghg" (affect the output units)
# model either "cosmo-art", "cosmo-ghg" or "icon" (affects the
# output units and handling of the output grid)
model = 'cosmo-ghg'

# path to input inventory
Expand Down Expand Up @@ -49,7 +50,7 @@
varname_format = '{species}_{category}_{source_type}'

# COSMO domain
cosmo_grid = COSMOGrid(
output_grid = COSMOGrid(
nx=90,
ny=60,
dx=0.1,
Expand Down
Loading

0 comments on commit 038a9e5

Please sign in to comment.