From 0b9b3425328046f67851e25224ffa866974e13ec Mon Sep 17 00:00:00 2001 From: Bob Yantosca Date: Thu, 21 Dec 2023 14:15:18 -0500 Subject: [PATCH 1/5] Bug fixes for compare_diags.py example script gcpy/examples/diagnostics/compare_diags.py - Import rename_and_flip_gchp_rst_vars function from gcpy.util gcpy/examples/diagnostics/compare_diags.yml - Added "n_cores: -1" to specify maximum parallelization CHANGELOG.md - Updated accordingly Signed-off-by: Bob Yantosca --- CHANGELOG.md | 5 +++++ gcpy/examples/diagnostics/compare_diags.py | 6 +++--- gcpy/examples/diagnostics/compare_diags.yml | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6258b7e..f47afaae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to GCPy will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] - TBD +### Fixed +- Import error in `gcpy/examples/diagnostics/compare_diags.py` +- Added missing `n_cores` to `gcpy/examples/diagnostics/compare_diags.yml` + ## [1.4.1] - 2023-12-08 ### Fixed - Now use the proper default value for the `--weightsdir` argument to `gcpy/file_regrid.py` diff --git a/gcpy/examples/diagnostics/compare_diags.py b/gcpy/examples/diagnostics/compare_diags.py index c80d2660..e225cca3 100755 --- a/gcpy/examples/diagnostics/compare_diags.py +++ b/gcpy/examples/diagnostics/compare_diags.py @@ -11,7 +11,7 @@ import warnings import numpy as np from gcpy.util import add_missing_variables, compare_varnames, \ - dataset_reader, read_config_file + dataset_reader, read_config_file, rename_and_flip_gchp_rst_vars from gcpy.constants import skip_these_vars from gcpy.plot.compare_single_level import compare_single_level from gcpy.plot.compare_zonal_mean import compare_zonal_mean @@ -109,8 +109,8 @@ def read_data(config): # If the data is from a GCHP restart file, rename variables and # flip levels to match the GEOS-Chem Classic naming and level # conventions. Otherwise no changes will be made. - refdata = util.rename_and_flip_gchp_rst_vars(refdata) - devdata = util.rename_and_flip_gchp_rst_vars(devdata) + refdata = rename_and_flip_gchp_rst_vars(refdata) + devdata = rename_and_flip_gchp_rst_vars(devdata) # Define dictionary for return data = { diff --git a/gcpy/examples/diagnostics/compare_diags.yml b/gcpy/examples/diagnostics/compare_diags.yml index 69db1377..2bb4c626 100644 --- a/gcpy/examples/diagnostics/compare_diags.yml +++ b/gcpy/examples/diagnostics/compare_diags.yml @@ -33,3 +33,4 @@ options: filename: '' skip_small_diffs: True small_diff_threshold: 0.0000 + n_cores: -1 From c83f866d10c8c38f90cca3f1c947af552ed0b301 Mon Sep 17 00:00:00 2001 From: Bob Yantosca Date: Tue, 23 Jan 2024 11:04:02 -0500 Subject: [PATCH 2/5] Now require matplotlib >= 3.8 docs/environment_files/environment.yml - Now request matplotlib 3.8 or later. This will ensure that GCPy will not encounter issues caused by older matplotlib versions. Signed-off-by: Bob Yantosca --- docs/environment_files/environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/environment_files/environment.yml b/docs/environment_files/environment.yml index f5fc704d..adbe2f8a 100644 --- a/docs/environment_files/environment.yml +++ b/docs/environment_files/environment.yml @@ -20,7 +20,7 @@ dependencies: - ipython # Interactive Python (used by Jupyter) - joblib # Parallelize python code - jupyter # Jupyter Notebook - - matplotlib # Creates plots and visualizations + - matplotlib>=3.7 # Creates plots and visualizations - netcdf4 # Python wrapper for netCDF - netcdf-fortran # Python wrapper for netCDF-Fortran - numpy # Optimized mathematical functions From 43c769522fb47599f663dfaa7f119cd412c01e99 Mon Sep 17 00:00:00 2001 From: Bob Yantosca Date: Tue, 23 Jan 2024 11:25:27 -0500 Subject: [PATCH 3/5] Remove obsolete mda8_o3_timeseries.py example script gcpy/examples/timeseries/mda8_o3_timeseries.py - Now removed (as per feature request #282 CHANGELOG.md - Updated accordingly Signed-off-by: Bob Yantosca --- CHANGELOG.md | 7 ++ .../examples/timeseries/mda8_o3_timeseries.py | 84 ------------------- 2 files changed, 7 insertions(+), 84 deletions(-) delete mode 100755 gcpy/examples/timeseries/mda8_o3_timeseries.py diff --git a/CHANGELOG.md b/CHANGELOG.md index f47afaae..76cf41f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,17 @@ All notable changes to GCPy will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] - TBD +### Changed +- Now require `matplotlib>=3.8` in `docs/environment_files/environment.yml` + ### Fixed - Import error in `gcpy/examples/diagnostics/compare_diags.py` - Added missing `n_cores` to `gcpy/examples/diagnostics/compare_diags.yml` +### Removed +- Example script `gcpy/examples/plotting/mda8_o3_timeseries.py` + + ## [1.4.1] - 2023-12-08 ### Fixed - Now use the proper default value for the `--weightsdir` argument to `gcpy/file_regrid.py` diff --git a/gcpy/examples/timeseries/mda8_o3_timeseries.py b/gcpy/examples/timeseries/mda8_o3_timeseries.py deleted file mode 100755 index 078469bd..00000000 --- a/gcpy/examples/timeseries/mda8_o3_timeseries.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env python -""" -MDA8 Timeseries Calculations -======================================== - -A common statistic used when constructing standards for air quality -criteria pollutants is to look at the ranked distribution of the -daily maxima of rolling 8-hour averages of a substance, or MDA8 for -short. -""" -# Author: Daniel Rothenberg -# Version: June 1, 2017 -# -# NOTE: Now placed into a function so that we only execute -# these commands when running as a standalone script. -# (Bob Yantosca, 09 Aug 2023) - -import matplotlib.pyplot as plt -import matplotlib.dates as mdates -import pandas as pd -import xarray as xr -plt.style.use(['seaborn-v0_8-talk', 'seaborn-v0_8-ticks']) - - -def main(): - """ - MDA8 O3 timeseries example - """ - - # Read hourly data ### EDIT THIS IF NECESSARY - InFile = 'GEOSChem.Hourly_SfcO3.2017.nc' - ds = xr.open_dataset(InFile) - o3_data = ds['SpeciesConc_O3'] - - # Compute the 8-hour rolling averages for ozone - avg_8hr_o3 = (o3_data.rolling(time=8, min_periods=6).mean()) - - # By default, this takes the last timestamp in a rolling interval; i.e. the - # timestamps correspond to the preceding 8 hours. We want them to refer to - # the proeding 8 hours, so we can adjust them using datetime arithmetic - times_np = avg_8hr_o3.time.values - times_pd = pd.to_datetime(times_np) - pd.Timedelta('8h') - avg_8hr_o3.time.values[:] = times_pd - - # Finally, aggregate by calendar day and compute the maxima of the set of - # 8-hour averages for each day - mda8_o3 = avg_8hr_o3.resample(time='D').max(dim='time') - mda8_o3.name='mda8_o3' - - # Save output to new netCDF file - mda8_o3.to_netcdf( - 'GEOSChem.MDA8_O3.20170.nc', 'w', - format='NETCDF4', - encoding={'lat': {'_FillValue': None}, - 'lon': {'_FillValue': None}, - 'time': {'_FillValue': None}, - 'mda8_o3': {'_FillValue': None}} - ) - - # Select data for one specific location, near Boston - boston_mda8_o3 = mda8_o3.sel(lon=-71., lat=42., method='nearest') - boston_o3 = o3_data.sel(lon=-71., lat=42., method='nearest') - - # Plot both the original (hourly) and MDA* timeseries on the same plot. - fig = plt.figure(figsize=(9, 3)) - ax = fig.add_subplot(111) - boston_o3.plot(ax=ax, color='k') - ax.stem(boston_mda8_o3.time.values, boston_mda8_o3.data, - ':r', markerfmt='ro') - ax.set_ylim(0) - - ax.xaxis.set_major_formatter(mdates.DateFormatter("%h %d")) - for tick in ax.xaxis.get_majorticklabels(): - tick.set_horizontalalignment('center') - - ax.set_xlabel("") - ax.set_ylabel("(MDA8) O$_3$ [ppb]") - - plt.show() - - -# Only execute when running as a standalone script -if __name__ == '__main__': - main() From 5c53c3e23a352b9e193f1bde1a4c943c6920dea7 Mon Sep 17 00:00:00 2001 From: Bob Yantosca Date: Tue, 23 Jan 2024 11:49:12 -0500 Subject: [PATCH 4/5] Remove Pylint GitHub action; Update stale GitHub Action .github/workflows/pylint.yml - Now removed. The Pylint GitHub action would always fail due to non-conforming code. .github/workflows/stale.yml - Now run the stale action at midnight UTC on the 1st of each month - Now remove stale issues after 30 days of being marked - Now do not remove stale PRs CHANGELOG.md - Updated accordingly Signed-off-by: Bob Yantosca --- .github/workflows/pylint.yml | 23 ----------------------- .github/workflows/stale.yml | 17 +++++++++++------ CHANGELOG.md | 3 ++- 3 files changed, 13 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/pylint.yml diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml deleted file mode 100644 index 0f0e51eb..00000000 --- a/.github/workflows/pylint.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Pylint - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.9", "3.10", "3.11"] - steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pylint - - name: Analysing the code with pylint - run: | - pylint $(git ls-files '*.py') diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index d858af41..7a13f5ea 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -7,11 +7,11 @@ name: Mark stale issues and pull requests on: schedule: - - cron: '32 22 * * *' + # Job will run at midnight on the 1st of each month (POSIX time syntax) + - cron: '0 0 1 * *' jobs: stale: - runs-on: ubuntu-latest permissions: issues: write @@ -21,7 +21,12 @@ jobs: - uses: actions/stale@v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'Stale issue message' - stale-pr-message: 'Stale pull request message' - stale-issue-label: 'no-issue-activity' - stale-pr-label: 'no-pr-activity' + # Stale issue settings + days-before-issue-stale: 30 + days-before-issue-close: 30 + stale-issue-label: 'stale' + stale-issue-message: 'This issue is stale because it has been open for 30 days with no activity.' + close-issue-message: "This issue was closed because it has been inactive for 30 days since being marked as stale." + # Never mark PRs as stale + days-before-pr-stale: -1 + days-before-pr-close: -1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 76cf41f0..9fe73628 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] - TBD ### Changed - Now require `matplotlib>=3.8` in `docs/environment_files/environment.yml` +- Now run the `stale` GitHub action at 00:00 UTC on the 1st of each month ### Fixed - Import error in `gcpy/examples/diagnostics/compare_diags.py` @@ -14,7 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Removed - Example script `gcpy/examples/plotting/mda8_o3_timeseries.py` - +- Removed `Pylint` GitHub action ## [1.4.1] - 2023-12-08 ### Fixed From 57ea703df1deaf1025b0987ddee802cc4c61a82b Mon Sep 17 00:00:00 2001 From: Bob Yantosca Date: Wed, 24 Jan 2024 16:03:32 -0500 Subject: [PATCH 5/5] Remove mda8_o3_timeseries from __init__.py gcpy/examples/timeseries/__init__.py - Removed reference to mda8_o3_timeseries, which was removed in the prior commit. This was causing an import error. Now fixed. Signed-off-by: Bob Yantosca --- gcpy/examples/timeseries/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/gcpy/examples/timeseries/__init__.py b/gcpy/examples/timeseries/__init__.py index 92fd2052..ddc29ae5 100644 --- a/gcpy/examples/timeseries/__init__.py +++ b/gcpy/examples/timeseries/__init__.py @@ -1,6 +1,5 @@ """ GCPy import script """ -from .mda8_o3_timeseries import * from .plot_timeseries import *