Skip to content

Commit

Permalink
Merge pull request #45 from zmoon/ci
Browse files Browse the repository at this point in the history
CI: Python-focused automatic linting/formatting
  • Loading branch information
zmoon authored Apr 4, 2024
2 parents 40346b6 + 1046037 commit a3649a7
Show file tree
Hide file tree
Showing 31 changed files with 455 additions and 345 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 100
ignore = E203,E402,E501,W503,E226
18 changes: 18 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lint

on:
push:
branches: [develop]
pull_request:
workflow_dispatch:

jobs:
lint:
name: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: pre-commit/[email protected]
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml

- repo: https://github.com/asottile/pyupgrade
rev: "v3.15.2"
hooks:
- id: pyupgrade
args: [--py37-plus]

- repo: https://github.com/PyCQA/isort
rev: "5.13.2"
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: "24.3.0"
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: "7.0.0"
hooks:
- id: flake8

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: codespell
additional_dependencies:
- tomli
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ git clone -b develop --recurse-submodules [email protected]:noaa-oar-arl/NEXUS.git
```
(Replace `noaa-oar-arl` with your fork if desired.)

To install the pre-commit hooks, first [install `pre-commit`](https://pre-commit.com/#install),
e.g. to your Conda environment.
Then, run
```
pre-commit install --install-hooks
```

### Setup

Expand Down
2 changes: 1 addition & 1 deletion cmake/FindNetCDF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# does it submit to any jurisdiction.
#
# Try to find NetCDF includes and library.
# Supports static and shared libaries and allows each component to be found in sepearte prefixes.
# Supports static and shared libraries and allows each component to be found in separate prefixes.
#
# This module defines
#
Expand Down
2 changes: 1 addition & 1 deletion config/cmaq/HEMCO_sa_Diagn.rc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file defines the diagnostics to be written
# out by the HEMCO standalone model
#
# Name Spec ExtNr Cat Hier Dim Unit
# Name Spec ExtNr Cat Hier Dim Unit
CO_ant CO 0 -1 -1 2 kg/m2/s
SO2_ant SO2 0 -1 -1 2 kg/m2/s
NO2_ant NO2 0 -1 -1 2 kg/m2/s
Expand Down
4 changes: 2 additions & 2 deletions config/cmaq/HEMCO_sa_Spec.rc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# List species below. For each species, the following entries must be given:
# ID : species ID
# NAME : species name
# MW : molecular weight (g/mol)
# MW : molecular weight (g/mol)
# K0 : Henry constant at 298 K (M/atm, liquid over gas)
# CR : Henry temperature dependency (-d ln(KH)/d(1/T)
# pKA : acid dissociation constant
Expand All @@ -23,7 +23,7 @@
14 IOLE 56.1 12.0 4.0 0.0 0.0 0.0
15 OLE 42.1 12.0 2.0 0.0 0.0 0.0
16 ETH 28.1 12.0 2.0 0.0 0.0 0.0
17 ETHA 30.1 12.0 2.0 0.0 0.0 0.0
17 ETHA 30.1 12.0 2.0 0.0 0.0 0.0
18 ETOH 46.1 12.0 2.0 0.0 0.0 0.0
19 MEOH 32.0 12.0 1.0 0.0 0.0 0.0
20 BENZ 78.1 12.0 6.0 0.0 0.0 0.0
Expand Down
2 changes: 1 addition & 1 deletion config/cmaq/HEMCO_sa_Time.rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# List here simulation start, end, and emission time step (seconds).
# List here simulation start, end, and emission time step (seconds).
# Dates must have format YYYY-MM-DD HH:MM:SS
START: 2016-01-05 00:00:00
END: 2016-01-05 23:00:00
Expand Down
76 changes: 38 additions & 38 deletions config/cmaq/NEXUS_Config.rc
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@
# !MODULE: HEMCO_Config.rc
#
# !DESCRIPTION: Contains configuration information for HEMCO. Define the
# emissions inventories and corresponding file paths here. Entire
# emissions inventories and corresponding file paths here. Entire
# configuration files can be inserted into this configuration file with
# an '>>>include' statement, e.g. '>>>include HEMCO\_Config\_test.rc'
# an '>>>include' statement, e.g. '>>>include HEMCO\_Config\_test.rc'
# The settings of include-files will be ignored.
#\\
#\\
# !REMARKS:
# The following tokens will be replaced:
# (1) ROOT : Filepath to HEMCO root directory
# (2) CFDIR : Filepath to directory of this configuration file.
# (2) CFDIR : Filepath to directory of this configuration file.
# (3) MET : Met field type (from G-C compilation command)
# (4) GRID : Horizontal grid type (from G-C compilation command)
# (5) SIM : Simulation type (from G-C compilation command)
# (6) NEST : Nested-grid type (CH, EU, NA, SE)
# (7) LNOX : String for OTD/LIS lightning NOx files:
# (a) For GEOS-5 this is either "geos5.1.0" or "geos5.2.0".
# (a) For GEOS-5 this is either "geos5.1.0" or "geos5.2.0".
# (b) For other met fields, this is the same as MET.
# (8) LEVRED : String w/ the # of levels in the reduced GEOS-Chem grid
# as used in some filenames (e.g. "23L", "30L", "47L")
# (9) LEVFULL : String w/ the # of levels in the full GEOS-Chem grid
# as used in some filenames (e.g. "55L", "72L")
#
# !REVISION HISTORY:
# 09 Mar 2021 - P. Campbell - Initial UFS-CMAQ HEMCO Configuration File for
#
# !REVISION HISTORY:
# 09 Mar 2021 - P. Campbell - Initial UFS-CMAQ HEMCO Configuration File for
# CEDS2019-NEI2016v1-OMI-HTAP2019-EDGAR-HTAP2010
# 15 Jun 2022 - P. Campbell - Added MEGANv2.1 sa extension calcultaions
# 04 Oct 2022 - B. Baker - Remove point sources
# 04 Oct 2022 - B. Baker - Remove point sources

#------------------------------------------------------------------------------
#BOC
Expand Down Expand Up @@ -66,11 +66,11 @@ Cap time shift : true
### BEGIN SECTION EXTENSION SWITCHES
###############################################################################
###
### This section lists all emission extensions available to HEMCO and whether
### they shall be used or not. Extension 'base' must have extension number
### zero, all other extension numbers can be freely chosen. Data fields in
### section 'base emissions' will only be read if the corresponding extension
### (identified by ExtNr) is enabled. Similarly, fields grouped into data
### This section lists all emission extensions available to HEMCO and whether
### they shall be used or not. Extension 'base' must have extension number
### zero, all other extension numbers can be freely chosen. Data fields in
### section 'base emissions' will only be read if the corresponding extension
### (identified by ExtNr) is enabled. Similarly, fields grouped into data
### collections ('(((CollectionName', ')))CollectionName') are only considered
### if the corresponding data collection is enabled in this section. Data
### listed within a disabled extension are always ignored, even if they are
Expand All @@ -81,22 +81,22 @@ Cap time shift : true
### collection name is *not* enabled. This is achieved by leading the
### collection name with '.not.', e.g. '(((.not.FINN_daily' ...
### '))).not.FINN_daily' for FINN monthly data (only used if daily data is
### not being used).
### not being used).
###
### The ExtNr provided in this section must match with the ExtNr assigned to
### the data listed in the base emissions sections. Otherwise, the listed
### the data listed in the base emissions sections. Otherwise, the listed
### files won't be read!
###
### NOTES:
### --> You can only select one biomass burning option (GFED, QFED, FINN).
###
### --> BOND_BIOMASS must be set to false if GFED, QFED, or FINN is enabled.
###
### --> The biomass burning POA scale factor is the same as for the biofuel
### and anthro sources.
### --> The biomass burning POA scale factor is the same as for the biofuel
### and anthro sources.
###
### --> The NAP scale factor is determined as in the original simulation:
### Obtain NAP emissions using scale factor from Hays 2002 ES&T
### Obtain NAP emissions using scale factor from Hays 2002 ES&T
### (0.0253 g NAP/kg DM) and Andreae and Merlet 2001 GBC (92 g CO/kg DM)
###############################################################################
# ExtNr ExtName on/off Species
Expand All @@ -110,7 +110,7 @@ Cap time shift : true
--> C2H6 : false
--> EDGAR : false
--> HTAP : on true
--> EMEP : false
--> EMEP : false
--> GEIA : false
--> LIANG_BROMOCARB : false
--> NEI2005 : false
Expand All @@ -122,7 +122,7 @@ Cap time shift : true
--> MIX : false
--> STREETS : false
--> VOLCANO : false
--> RCP_3PD : false
--> RCP_3PD : false
--> RCP_45 : false
--> RCP_60 : false
--> RCP_85 : false
Expand All @@ -136,25 +136,25 @@ Cap time shift : true
--> MODIS_XLAI : false
--> OFFLINE_SOILNOX : on true
# -----------------------------------------------------------------------------
100 Custom : off -
100 Custom : off -
101 SeaFlux : off DMS/ACET
102 ParaNOx : off NO/NO2/O3/HNO3
--> LUT data format : nc
--> LUT source dir : $ROOT/PARANOX/v2015-02
103 LightNOx : off NO
--> OTD-LIS factors : true
--> CDF table : $ROOT/LIGHTNOX/v2014-07/light_dist.ott2010.dat
104 SoilNOx : off NO
104 SoilNOx : off NO
--> Use fertilizer NOx: true
105 DustDead : off DST1/DST2/DST3/DST4
105 DustDead : off DST1/DST2/DST3/DST4
106 DustGinoux : off DST1/DST2/DST3/DST4
107 SeaSalt : off SALA/SALC/Br2
--> SALA lower radius : 0.01
--> SALA lower radius : 0.01
--> SALA upper radius : 0.5
--> SALC lower radius : 0.5
--> SALC upper radius : 8.0
--> Emit Br2 : true
--> Br2 scaling : 1.0
--> Emit Br2 : true
--> Br2 scaling : 1.0
108 MEGAN : on ISOP/ACET/PRPE/C2H4/ALD2/EOH/MOH/MTPA/MTPO/LIMO/SESQ
--> Isoprene scaling : 1.0
--> CO2 inhibition : true
Expand All @@ -163,7 +163,7 @@ Cap time shift : true
--> Isoprene to SOAS : 0.015
110 MEGAN_SOA : off MTPA/MTPO/LIMO/SESQ
111 GFED : off NO/CO/ALK4/ACET/MEK/ALD2/PRPE/C3H8/CH2O/C2H6/SO2/NH3/BCPO/BCPI/OCPO/OCPI/POA1/NAP
--> GFED3 : false
--> GFED3 : false
--> GFED4 : true
--> GFED_daily : false
--> GFED_3hourly : false
Expand All @@ -181,7 +181,7 @@ Cap time shift : true
### END SECTION EXTENSION SWITCHES ###

###############################################################################
### BEGIN SECTION BASE EMISSIONS
### BEGIN SECTION BASE EMISSIONS
###############################################################################

# ExtNr Name sourceFile sourceVar sourceTime C/R/E SrcDim SrcUnit Species ScalIDs Cat Hier
Expand Down Expand Up @@ -565,7 +565,7 @@ Cap time shift : true
# %%% NOTE: This is an optional inventory. You may select either EDGAR or HTAP
# for the global base emissions %%%
# SHP (ships) and AIR_LTO (aircraft landing & take off < 1 km) sectors are included here.
#==============================================================================
#==============================================================================
(((HTAP
0 HTAP_PMC_AIR $ROOT/HTAP/v2015-03/PMC/EDGAR_HTAP_PMC_AIR_LTO.generic.01x01.nc emi_pmc 2008-2010/1-12/1/0 C xy kg/m2/s PMC 1/27/25 1/2 1
0 HTAP_PMC_SHP $ROOT/HTAP/v2015-03/PMC/EDGAR_HTAP_PMC_SHIPS.generic.01x01.nc emi_pmc 2008-2010/1-12/1/0 C xy kg/m2/s PMC 1/27/25 1/2 1
Expand Down Expand Up @@ -1362,7 +1362,7 @@ Cap time shift : true
0 NEI2016v1_NPOILGAS_PSO4 $ROOT/NEI2016v1/v2022-07/$MM/NEI2016v1_0.1x0.1_2016$MM$DD_np_oilgas.nc PSO4 2016/1-12/1-31/$HH C xyz kg/m2/s PSO4 1007 1 50
)))NEI2016v1_AR

#### MEGAN EMISSION
#### MEGAN EMISSION
108 MEGAN_AEF_ISOP $ROOT/MEGAN/v2020-02/MEGAN2.1_EF.geos.025x03125.nc AEF_ISOPRENE 1985/1/1/0 C xy kgC/m2/s * 61 1 1
108 MEGAN_AEF_MBOX $ROOT/MEGAN/v2020-02/MEGAN2.1_EF.geos.025x03125.nc AEF_MBO 1985/1/1/0 C xy kgC/m2/s * 64 1 1
#108 MEGAN_AEF_APIN $ROOT/MEGAN/v2020-02/MEGAN2.1_EF.geos.025x03125.nc AEF_ALPHA_PINENE 1985/1/1/0 C xy kgC/m2/s * 62 1 1
Expand Down Expand Up @@ -1664,10 +1664,10 @@ Cap time shift : true
###############################################################################
### NON-EMISSIONS DATA (subsection of BASE EMISSIONS SECTION)
###
### Non-emissions data. The following fields are read through HEMCO but do
### not contain emissions data. The extension number is set to wildcard
### character denoting that these fields will not be considered for emission
### calculation. A given entry is only read if the assigned species name is
### Non-emissions data. The following fields are read through HEMCO but do
### not contain emissions data. The extension number is set to wildcard
### character denoting that these fields will not be considered for emission
### calculation. A given entry is only read if the assigned species name is
### an HEMCO species.
###############################################################################

Expand All @@ -1679,7 +1679,7 @@ Cap time shift : true
### END SECTION BASE EMISSIONS ###

###############################################################################
### BEGIN SECTION SCALE FACTORS
### BEGIN SECTION SCALE FACTORS
###############################################################################

# ScalID Name sourceFile sourceVar sourceTime C/R/E SrcDim SrcUnit Oper
Expand All @@ -1697,7 +1697,7 @@ Cap time shift : true
27 TOTFUEL_2008_2010 $ROOT/AnnualScalar/v2014-07/AnnualScalar.geos.1x1.nc NOxscalar 2008-2010/1/1/0 C xy 1 -1

#==============================================================================
# --- diurnal scale factors ---
# --- diurnal scale factors ---
#==============================================================================
25 EDGAR_TODNOX $ROOT/EDGARv42/v2015-02/NO/EDGAR_hourly_NOxScal.nc NOXscale 2000/1/1/HH C xy unitless 1

Expand All @@ -1723,7 +1723,7 @@ Cap time shift : true
999 NOx_to_NO 0.9 - - - xy unitless 1
998 NOx_to_NO2 0.1 - - - xy unitless 1
997 VOC_to_ACET_ag 0.0575823632326 - - - xy unitless 1
996 VOC_to_ACET_ene 0.00957147100992 - - - xy unitless 1
996 VOC_to_ACET_ene 0.00957147100992 - - - xy unitless 1
995 VOC_to_ACET_ind 0.0440082728517 - - - xy unitless 1
994 VOC_to_ACET_res 0.039774498589 - - - xy unitless 1
993 VOC_to_ACET_road 0.0 - - - xy unitless 1
Expand Down Expand Up @@ -1966,7 +1966,7 @@ Cap time shift : true
### END SECTION SCALE FACTORS ###

###############################################################################
### BEGIN SECTION MASKS
### BEGIN SECTION MASKS
###############################################################################

# ScalID Name sourceFile sourceVar sourceTime C/R/E SrcDim SrcUnit Oper Lon1/Lat1/Lon2/Lat2
Expand Down
2 changes: 1 addition & 1 deletion config/cmaq_gfs_megan/HEMCO_sa_Diagn.rc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file defines the diagnostics to be written
# out by the HEMCO standalone model
#
# Name Spec ExtNr Cat Hier Dim Unit
# Name Spec ExtNr Cat Hier Dim Unit
CO_ant CO 0 -1 -1 2 kg/m2/s
SO2_ant SO2 0 -1 -1 2 kg/m2/s
NO2_ant NO2 0 -1 -1 2 kg/m2/s
Expand Down
4 changes: 2 additions & 2 deletions config/cmaq_gfs_megan/HEMCO_sa_Spec.rc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# List species below. For each species, the following entries must be given:
# ID : species ID
# NAME : species name
# MW : molecular weight (g/mol)
# MW : molecular weight (g/mol)
# K0 : Henry constant at 298 K (M/atm, liquid over gas)
# CR : Henry temperature dependency (-d ln(KH)/d(1/T)
# pKA : acid dissociation constant
Expand All @@ -23,7 +23,7 @@
14 IOLE 56.1 12.0 4.0 0.0 0.0 0.0
15 OLE 42.1 12.0 2.0 0.0 0.0 0.0
16 ETH 28.1 12.0 2.0 0.0 0.0 0.0
17 ETHA 30.1 12.0 2.0 0.0 0.0 0.0
17 ETHA 30.1 12.0 2.0 0.0 0.0 0.0
18 ETOH 46.1 12.0 2.0 0.0 0.0 0.0
19 MEOH 32.0 12.0 1.0 0.0 0.0 0.0
20 BENZ 78.1 12.0 6.0 0.0 0.0 0.0
Expand Down
2 changes: 1 addition & 1 deletion config/cmaq_gfs_megan/HEMCO_sa_Time.rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# List here simulation start, end, and emission time step (seconds).
# List here simulation start, end, and emission time step (seconds).
# Dates must have format YYYY-MM-DD HH:MM:SS
START: 2016-01-05 00:00:00
END: 2016-01-05 23:00:00
Expand Down
Loading

0 comments on commit a3649a7

Please sign in to comment.