-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from efmkoene/master
Added testcase for rlon=0
- Loading branch information
Showing
4 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
import shutil | ||
import subprocess | ||
|
||
import netCDF4 as nc | ||
import amrs.nc | ||
|
||
import zipfile | ||
|
||
import pytest | ||
|
||
def test_performance_at_rlon(): | ||
"""\ | ||
Execute processing case which has rlon==0. Hard-coded (in shell) to save | ||
effort of sending in all correct arguments otherwise... | ||
""" | ||
|
||
# working directory | ||
cwd = os.path.dirname(__file__) | ||
|
||
# remove outputs from previous tests | ||
try: | ||
shutil.rmtree(os.path.join(cwd, 'outputs')) | ||
except FileNotFoundError: | ||
pass | ||
|
||
# run emiproc | ||
subprocess.run(["python", "-m", "emiproc", "grid", "--case-file", | ||
"tno_rlon.py"], shell=False, | ||
cwd=cwd) | ||
|
||
# compare output with reference | ||
out_filename = os.path.join(cwd, "outputs", "online", "outgrid.nc") | ||
out_filename_ref = os.path.join(cwd, "tno_ref.nc") | ||
|
||
# assert that the two datasets are (nearly) identical | ||
with nc.Dataset(out_filename) as own, nc.Dataset(out_filename_ref) as ref: | ||
check1, check2 = amrs.nc.compare.datasets_equal(own, ref, []) | ||
assert check1 and check2 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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 = 'cosmo-ghg' | ||
|
||
# path to input inventory | ||
input_path = "test_emissions.nc" | ||
|
||
# input grid | ||
input_grid = TNOGrid(input_path) | ||
|
||
# input species | ||
species = ['co2_ff'] | ||
|
||
# input categories | ||
categories = [ | ||
"A", | ||
] | ||
|
||
# mapping from input to output species (input is used for missing keys) | ||
in2out_species = { | ||
'co2_ff': '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}_{source_type}' # not providing source_type will add up | ||
# point and area sources | ||
|
||
# COSMO domain | ||
output_grid = COSMOGrid( | ||
nx=26, #900 | ||
ny=26, #600 | ||
dx=0.01, #0.01 | ||
dy=0.01, #0.01 | ||
xmin=-0.13, | ||
ymin=-0.13, | ||
pollon=-169.0, | ||
pollat=43.0, | ||
) | ||
|
||
|
||
# output path and filename | ||
output_path = os.path.join('outputs', '{online}') | ||
output_name = "outgrid.nc" | ||
|
||
# resolution of shape file used for country mask | ||
shpfile_resolution = "110m" | ||
|
||
# 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": "Erik Koene", | ||
"EMAIL": "erik.koene@empa.ch", | ||
"AFFILIATION": "Empa Duebendorf, Switzerland", | ||
"DATE CREATED": time.ctime(time.time()), | ||
} |