Skip to content

Commit

Permalink
Merge pull request #11 from chen-0126/master
Browse files Browse the repository at this point in the history
add processing for CAMS&HTAP
  • Loading branch information
Yaqiang authored Feb 2, 2023
2 parents 3a96f65 + a7f5ef8 commit c2c33aa
Show file tree
Hide file tree
Showing 96 changed files with 1,427 additions and 805 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ email: wencong9801@outlook.com

Chinese Academy of Meteorological Sciences, CMA

Publication
-----------

- Chen, W.C., Wang, Y.Q., Li, J.W., YI, Z.W., Zhao, Z.C., G, B., Che, H.Z., Zhang, X.Y., 2023.
Description and evaluation of a newly developed emission inventory processing system (EMIPS).
Sci. Total Environ. 870, 161909. https://doi.org/10.1016/j.scitotenv.2023.161909

License
-------
Expand Down
Binary file modified emips/__init__$py.class
Binary file not shown.
Binary file modified emips/gui/chemical_panel$py.class
Binary file not shown.
3 changes: 3 additions & 0 deletions emips/gui/chemical_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import os
from emips.chem_spec import ChemMechEnum
from emips import ge_data_dir
from inspect import getsourcefile

dir_chemical_panel = os.path.dirname(os.path.abspath(getsourcefile(lambda: 0)))


class ChemicalPanel(swing.JPanel):
Expand Down
Binary file modified emips/gui/configure$py.class
Binary file not shown.
72 changes: 37 additions & 35 deletions emips/gui/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ def __init__(self, filename):

self.run_output_dir = None
self.is_run_vertical = None
# self.post_process_file = None
self.post_process_file = None

self.emission_module = None
self.grid_spec_module = None
# self.post_process_module = None
self.post_process_module = None

self.load_configure(filename)
self.load_emission_module()
self.load_grid_spec_module()
# self.load_post_process_module()
self.load_post_process_module()

def load_configure(self, filename):
dom = minidom.parse(filename)
Expand All @@ -90,7 +90,7 @@ def load_configure(self, filename):
# Emission
emission = root.getElementsByTagName('Emission')[0]
emission_read = emission.getElementsByTagName('Read')[0]
self.emission_read_file = emission_read.getAttribute('ScriptFile')
self.emission_read_file = os.path.abspath(os.path.join(dir_configure, emission_read.getAttribute('ScriptFile')))
emission_sectors = emission.getElementsByTagName("Sectors")[0]
sector_list = emission_sectors.getElementsByTagName("Sector")
for sector in sector_list:
Expand Down Expand Up @@ -140,7 +140,7 @@ def load_configure(self, filename):
use_gsf = grid_spec.getAttribute("Enable")
self.voc_use_grid_spec = True if use_gsf == "True" else False
grid_spec_read = grid_spec.getElementsByTagName("Read")[0]
self.grid_spec_read_file = grid_spec_read.getAttribute("ScriptFile")
self.grid_spec_read_file = os.path.abspath(os.path.join(dir_configure,grid_spec_read.getAttribute("ScriptFile")))
grid_spec_mech = grid_spec.getElementsByTagName("ChemMech")[0]
self.chemical_mechanism = ChemMechEnum[grid_spec_mech.getAttribute("name")]

Expand All @@ -155,41 +155,43 @@ def load_configure(self, filename):
self.run_output_dir = output.getAttribute("Directory")
steps = run.getElementsByTagName("Steps")[0]
self.is_run_vertical = True if steps.getAttribute("RunVertical") == "True" else False
# post_process = run.getElementsByTagName("PostProcess")[0]
# self.post_process_file = post_process.getAttribute("ScriptFile")
post_process = run.getElementsByTagName("PostProcess")[0]
self.post_process_file = os.path.abspath(os.path.join(dir_configure, post_process.getAttribute("ScriptFile")))

def load_emission_module(self):
if os.path.isfile(self.emission_read_file):
run_path = os.path.dirname(self.emission_read_file)
emission_read_file = os.path.abspath(os.path.join(dir_configure, os.pardir, self.emission_read_file))
if os.path.isfile(emission_read_file):
run_path = os.path.dirname(emission_read_file)
if run_path not in sys.path:
sys.path.append(run_path)
run_module = os.path.basename(self.emission_read_file)
run_module = os.path.basename(emission_read_file)
run_module = os.path.splitext(run_module)[0]
self.emission_module = importlib.import_module(run_module)
else:
print('Read emission script file not exist!\n {}'.format(self.emission_read_file))
print('Read emission script file not exist!\n {}'.format(emission_read_file))

def load_grid_spec_module(self):
if os.path.isfile(self.grid_spec_read_file):
run_path = os.path.dirname(self.grid_spec_read_file)
grid_spec_read_file = os.path.abspath(os.path.join(dir_configure, os.pardir, self.grid_spec_read_file))
if os.path.isfile(grid_spec_read_file):
run_path = os.path.dirname(grid_spec_read_file)
if run_path not in sys.path:
sys.path.append(run_path)
run_module = os.path.basename(self.grid_spec_read_file)
run_module = os.path.basename(grid_spec_read_file)
run_module = os.path.splitext(run_module)[0]
self.grid_spec_module = importlib.import_module(run_module)
else:
print('Read grid speciation script file not exist!\n {}'.format(self.grid_spec_read_file))

# def load_post_process_module(self):
# if os.path.isfile(self.post_process_file):
# run_path = os.path.dirname(self.post_process_file)
# if run_path not in sys.path:
# sys.path.append(run_path)
# run_module = os.path.basename(self.post_process_file)
# run_module = os.path.splitext(run_module)[0]
# self.post_process_module = importlib.import_module(run_module)
# else:
# print('Post process script file not exist!\n {}'.format(self.post_process_file))
print('Read grid speciation script file not exist!\n {}'.format(grid_spec_read_file))

def load_post_process_module(self):
if os.path.isfile(self.post_process_file):
run_path = os.path.dirname(self.post_process_file)
if run_path not in sys.path:
sys.path.append(run_path)
run_module = os.path.basename(self.post_process_file)
run_module = os.path.splitext(run_module)[0]
self.post_process_module = importlib.import_module(run_module)
else:
print('Post process script file not exist!\n {}'.format(self.post_process_file))

def save_configure(self, filename=None):
doc = minidom.Document()
Expand All @@ -201,7 +203,7 @@ def save_configure(self, filename=None):
# Emission
emission = doc.createElement('Emission')
emission_read = doc.createElement('Read')
emission_read.setAttribute('ScriptFile', self.emission_read_file)
emission_read.setAttribute('ScriptFile', os.path.relpath(self.emission_read_file, dir_configure))
emission.appendChild(emission_read)

elem_sectors = doc.createElement("Sectors")
Expand Down Expand Up @@ -246,21 +248,21 @@ def save_configure(self, filename=None):
# Temporal
temporal = doc.createElement('Temporal')
file_name = doc.createElement('FileName')
file_name.setAttribute('Profile', self.temporal_prof_file)
file_name.setAttribute('Reference', self.temporal_ref_file)
file_name.setAttribute('Profile', os.path.basename(self.temporal_prof_file))
file_name.setAttribute('Reference', os.path.basename(self.temporal_ref_file))
temporal.appendChild(file_name)
root.appendChild(temporal)

# Chemical
chemical = doc.createElement("Chemical")
cfiles = doc.createElement("FileName")
cfiles.setAttribute("Profile", self.chemical_prof_file)
cfiles.setAttribute("Reference", self.chemical_ref_file)
cfiles.setAttribute("Profile", os.path.basename(self.chemical_prof_file))
cfiles.setAttribute("Reference", os.path.basename(self.chemical_ref_file))
chemical.appendChild(cfiles)
grid_spec = doc.createElement("GridSpeciation")
grid_spec.setAttribute("Enable", "True" if self.voc_use_grid_spec else "False")
grid_spec_read = doc.createElement("Read")
grid_spec_read.setAttribute("ScriptFile", self.grid_spec_read_file)
grid_spec_read.setAttribute("ScriptFile", os.path.relpath(self.grid_spec_read_file, dir_configure))
grid_spec.appendChild(grid_spec_read)
grid_spec_mech = doc.createElement("ChemMech")
grid_spec_mech.setAttribute("name", self.chemical_mechanism.name)
Expand All @@ -283,9 +285,9 @@ def save_configure(self, filename=None):
steps = doc.createElement("Steps")
steps.setAttribute("RunVertical", "True" if self.is_run_vertical else "False")
run.appendChild(steps)
# post_process = doc.createElement("PostProcess")
# post_process.setAttribute("ScriptFile", self.post_process_file)
# run.appendChild(post_process)
post_process = doc.createElement("PostProcess")
post_process.setAttribute("ScriptFile", os.path.relpath(self.post_process_file, dir_configure))
run.appendChild(post_process)
root.appendChild(run)

# Write config file
Expand Down
Binary file modified emips/gui/emission_panel$py.class
Binary file not shown.
7 changes: 5 additions & 2 deletions emips/gui/emission_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
from mipylib import plotlib as plt
from mipylib import numeric as np
from .form import FrmSectors, FrmPollutants
from inspect import getsourcefile

dir_emission_panel = os.path.dirname(os.path.abspath(getsourcefile(lambda: 0)))


class EmissionPanel(swing.JPanel):
Expand Down Expand Up @@ -223,7 +226,7 @@ def doInBackground(self):
emission = self.panel.run_config.emission_module
data = emission.read_emis(sector, pollutant, year, month)
print(data)
emis_grid = emission.get_emis_grid()
emis_grid = emission.get_emis_grid(sector)
lon = emis_grid.x_coord
lat = emis_grid.y_coord

Expand All @@ -232,7 +235,7 @@ def doInBackground(self):
plt.axesm()
plt.geoshow('country', edgecolor='k')
levs = np.logspace(-10, 2, num=13)
layer = plt.imshow(lon, lat, data, levs)
layer = plt.imshow(lon, lat, data*1e6, levs)
plt.colorbar(layer, shrink=0.8)
plt.title('Emission - {} - {} - ({}-{})'.format(sector.name, pollutant.name, year, month))

Expand Down
Binary file modified emips/gui/main_gui$py.class
Binary file not shown.
Binary file modified emips/gui/run_panel$py.class
Binary file not shown.
Loading

0 comments on commit c2c33aa

Please sign in to comment.