Skip to content

Commit c2c33aa

Browse files
authored
Merge pull request #11 from chen-0126/master
add processing for CAMS&HTAP
2 parents 3a96f65 + a7f5ef8 commit c2c33aa

96 files changed

Lines changed: 1427 additions & 805 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ email: wencong9801@outlook.com
5151

5252
Chinese Academy of Meteorological Sciences, CMA
5353

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

5561
License
5662
-------

emips/__init__$py.class

-11 Bytes
Binary file not shown.

emips/gui/chemical_panel$py.class

503 Bytes
Binary file not shown.

emips/gui/chemical_panel.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import os
99
from emips.chem_spec import ChemMechEnum
1010
from emips import ge_data_dir
11+
from inspect import getsourcefile
12+
13+
dir_chemical_panel = os.path.dirname(os.path.abspath(getsourcefile(lambda: 0)))
1114

1215

1316
class ChemicalPanel(swing.JPanel):

emips/gui/configure$py.class

1.5 KB
Binary file not shown.

emips/gui/configure.py

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,16 @@ def __init__(self, filename):
7272

7373
self.run_output_dir = None
7474
self.is_run_vertical = None
75-
# self.post_process_file = None
75+
self.post_process_file = None
7676

7777
self.emission_module = None
7878
self.grid_spec_module = None
79-
# self.post_process_module = None
79+
self.post_process_module = None
8080

8181
self.load_configure(filename)
8282
self.load_emission_module()
8383
self.load_grid_spec_module()
84-
# self.load_post_process_module()
84+
self.load_post_process_module()
8585

8686
def load_configure(self, filename):
8787
dom = minidom.parse(filename)
@@ -90,7 +90,7 @@ def load_configure(self, filename):
9090
# Emission
9191
emission = root.getElementsByTagName('Emission')[0]
9292
emission_read = emission.getElementsByTagName('Read')[0]
93-
self.emission_read_file = emission_read.getAttribute('ScriptFile')
93+
self.emission_read_file = os.path.abspath(os.path.join(dir_configure, emission_read.getAttribute('ScriptFile')))
9494
emission_sectors = emission.getElementsByTagName("Sectors")[0]
9595
sector_list = emission_sectors.getElementsByTagName("Sector")
9696
for sector in sector_list:
@@ -140,7 +140,7 @@ def load_configure(self, filename):
140140
use_gsf = grid_spec.getAttribute("Enable")
141141
self.voc_use_grid_spec = True if use_gsf == "True" else False
142142
grid_spec_read = grid_spec.getElementsByTagName("Read")[0]
143-
self.grid_spec_read_file = grid_spec_read.getAttribute("ScriptFile")
143+
self.grid_spec_read_file = os.path.abspath(os.path.join(dir_configure,grid_spec_read.getAttribute("ScriptFile")))
144144
grid_spec_mech = grid_spec.getElementsByTagName("ChemMech")[0]
145145
self.chemical_mechanism = ChemMechEnum[grid_spec_mech.getAttribute("name")]
146146

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

161161
def load_emission_module(self):
162-
if os.path.isfile(self.emission_read_file):
163-
run_path = os.path.dirname(self.emission_read_file)
162+
emission_read_file = os.path.abspath(os.path.join(dir_configure, os.pardir, self.emission_read_file))
163+
if os.path.isfile(emission_read_file):
164+
run_path = os.path.dirname(emission_read_file)
164165
if run_path not in sys.path:
165166
sys.path.append(run_path)
166-
run_module = os.path.basename(self.emission_read_file)
167+
run_module = os.path.basename(emission_read_file)
167168
run_module = os.path.splitext(run_module)[0]
168169
self.emission_module = importlib.import_module(run_module)
169170
else:
170-
print('Read emission script file not exist!\n {}'.format(self.emission_read_file))
171+
print('Read emission script file not exist!\n {}'.format(emission_read_file))
171172

172173
def load_grid_spec_module(self):
173-
if os.path.isfile(self.grid_spec_read_file):
174-
run_path = os.path.dirname(self.grid_spec_read_file)
174+
grid_spec_read_file = os.path.abspath(os.path.join(dir_configure, os.pardir, self.grid_spec_read_file))
175+
if os.path.isfile(grid_spec_read_file):
176+
run_path = os.path.dirname(grid_spec_read_file)
175177
if run_path not in sys.path:
176178
sys.path.append(run_path)
177-
run_module = os.path.basename(self.grid_spec_read_file)
179+
run_module = os.path.basename(grid_spec_read_file)
178180
run_module = os.path.splitext(run_module)[0]
179181
self.grid_spec_module = importlib.import_module(run_module)
180182
else:
181-
print('Read grid speciation script file not exist!\n {}'.format(self.grid_spec_read_file))
182-
183-
# def load_post_process_module(self):
184-
# if os.path.isfile(self.post_process_file):
185-
# run_path = os.path.dirname(self.post_process_file)
186-
# if run_path not in sys.path:
187-
# sys.path.append(run_path)
188-
# run_module = os.path.basename(self.post_process_file)
189-
# run_module = os.path.splitext(run_module)[0]
190-
# self.post_process_module = importlib.import_module(run_module)
191-
# else:
192-
# print('Post process script file not exist!\n {}'.format(self.post_process_file))
183+
print('Read grid speciation script file not exist!\n {}'.format(grid_spec_read_file))
184+
185+
def load_post_process_module(self):
186+
if os.path.isfile(self.post_process_file):
187+
run_path = os.path.dirname(self.post_process_file)
188+
if run_path not in sys.path:
189+
sys.path.append(run_path)
190+
run_module = os.path.basename(self.post_process_file)
191+
run_module = os.path.splitext(run_module)[0]
192+
self.post_process_module = importlib.import_module(run_module)
193+
else:
194+
print('Post process script file not exist!\n {}'.format(self.post_process_file))
193195

194196
def save_configure(self, filename=None):
195197
doc = minidom.Document()
@@ -201,7 +203,7 @@ def save_configure(self, filename=None):
201203
# Emission
202204
emission = doc.createElement('Emission')
203205
emission_read = doc.createElement('Read')
204-
emission_read.setAttribute('ScriptFile', self.emission_read_file)
206+
emission_read.setAttribute('ScriptFile', os.path.relpath(self.emission_read_file, dir_configure))
205207
emission.appendChild(emission_read)
206208

207209
elem_sectors = doc.createElement("Sectors")
@@ -246,21 +248,21 @@ def save_configure(self, filename=None):
246248
# Temporal
247249
temporal = doc.createElement('Temporal')
248250
file_name = doc.createElement('FileName')
249-
file_name.setAttribute('Profile', self.temporal_prof_file)
250-
file_name.setAttribute('Reference', self.temporal_ref_file)
251+
file_name.setAttribute('Profile', os.path.basename(self.temporal_prof_file))
252+
file_name.setAttribute('Reference', os.path.basename(self.temporal_ref_file))
251253
temporal.appendChild(file_name)
252254
root.appendChild(temporal)
253255

254256
# Chemical
255257
chemical = doc.createElement("Chemical")
256258
cfiles = doc.createElement("FileName")
257-
cfiles.setAttribute("Profile", self.chemical_prof_file)
258-
cfiles.setAttribute("Reference", self.chemical_ref_file)
259+
cfiles.setAttribute("Profile", os.path.basename(self.chemical_prof_file))
260+
cfiles.setAttribute("Reference", os.path.basename(self.chemical_ref_file))
259261
chemical.appendChild(cfiles)
260262
grid_spec = doc.createElement("GridSpeciation")
261263
grid_spec.setAttribute("Enable", "True" if self.voc_use_grid_spec else "False")
262264
grid_spec_read = doc.createElement("Read")
263-
grid_spec_read.setAttribute("ScriptFile", self.grid_spec_read_file)
265+
grid_spec_read.setAttribute("ScriptFile", os.path.relpath(self.grid_spec_read_file, dir_configure))
264266
grid_spec.appendChild(grid_spec_read)
265267
grid_spec_mech = doc.createElement("ChemMech")
266268
grid_spec_mech.setAttribute("name", self.chemical_mechanism.name)
@@ -283,9 +285,9 @@ def save_configure(self, filename=None):
283285
steps = doc.createElement("Steps")
284286
steps.setAttribute("RunVertical", "True" if self.is_run_vertical else "False")
285287
run.appendChild(steps)
286-
# post_process = doc.createElement("PostProcess")
287-
# post_process.setAttribute("ScriptFile", self.post_process_file)
288-
# run.appendChild(post_process)
288+
post_process = doc.createElement("PostProcess")
289+
post_process.setAttribute("ScriptFile", os.path.relpath(self.post_process_file, dir_configure))
290+
run.appendChild(post_process)
289291
root.appendChild(run)
290292

291293
# Write config file

emips/gui/emission_panel$py.class

532 Bytes
Binary file not shown.

emips/gui/emission_panel.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
from mipylib import plotlib as plt
1313
from mipylib import numeric as np
1414
from .form import FrmSectors, FrmPollutants
15+
from inspect import getsourcefile
16+
17+
dir_emission_panel = os.path.dirname(os.path.abspath(getsourcefile(lambda: 0)))
1518

1619

1720
class EmissionPanel(swing.JPanel):
@@ -223,7 +226,7 @@ def doInBackground(self):
223226
emission = self.panel.run_config.emission_module
224227
data = emission.read_emis(sector, pollutant, year, month)
225228
print(data)
226-
emis_grid = emission.get_emis_grid()
229+
emis_grid = emission.get_emis_grid(sector)
227230
lon = emis_grid.x_coord
228231
lat = emis_grid.y_coord
229232

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

emips/gui/main_gui$py.class

-11 Bytes
Binary file not shown.

emips/gui/run_panel$py.class

-1.03 KB
Binary file not shown.

0 commit comments

Comments
 (0)