From 5b92ce2c8959efbc74770cbbf0952bcbf3918cab Mon Sep 17 00:00:00 2001 From: zmoon Date: Thu, 19 Sep 2024 11:00:06 -0500 Subject: [PATCH 1/3] Update pre-commit hooks --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c99b1a0a..1a1cf822 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: "v4.4.0" + rev: "v4.6.0" hooks: - id: trailing-whitespace exclude: tdump\.[0-9]* @@ -9,23 +9,23 @@ repos: - id: check-yaml - repo: https://github.com/asottile/pyupgrade - rev: "v3.3.1" + rev: "v3.17.0" hooks: - id: pyupgrade args: [--py36-plus] - repo: https://github.com/PyCQA/isort - rev: "5.12.0" + rev: "5.13.2" hooks: - id: isort - repo: https://github.com/psf/black - rev: "23.1.0" + rev: "24.8.0" hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: "6.0.0" + rev: "7.1.1" hooks: - id: flake8 From ef795f3ca48f345110a09a7ac57c9fd95fee7640 Mon Sep 17 00:00:00 2001 From: zmoon Date: Thu, 19 Sep 2024 11:00:58 -0500 Subject: [PATCH 2/3] Format --- monetio/models/_cesm_se_mm.py | 1 + monetio/models/_cmaq_mm.py | 1 + monetio/models/_rrfs_cmaq_mm.py | 1 + monetio/models/_wrfchem_mm.py | 1 + monetio/models/camx.py | 1 + monetio/models/cmaq.py | 1 + monetio/models/hysplit.py | 1 + monetio/models/raqms.py | 1 + monetio/obs/aeronet.py | 1 + monetio/obs/cems_mod.py | 1 + monetio/obs/ish.py | 1 + monetio/obs/ish_lite.py | 1 + monetio/obs/nadp.py | 1 - monetio/obs/openaq.py | 1 + monetio/profile/geoms.py | 1 + monetio/profile/gml_ozonesonde.py | 1 + monetio/sat/_mopitt_l3_mm.py | 1 + monetio/sat/goes.py | 1 + monetio/sat/lpdaac_download.py | 1 + monetio/sat/nesdis_edr_viirs.py | 6 +++--- monetio/sat/nesdis_eps_viirs.py | 6 +++--- monetio/util.py | 30 +++++++++++++++--------------- 22 files changed, 39 insertions(+), 22 deletions(-) diff --git a/monetio/models/_cesm_se_mm.py b/monetio/models/_cesm_se_mm.py index 0473d110..4010a39a 100644 --- a/monetio/models/_cesm_se_mm.py +++ b/monetio/models/_cesm_se_mm.py @@ -1,4 +1,5 @@ """ CESM File Reader """ + import xarray as xr diff --git a/monetio/models/_cmaq_mm.py b/monetio/models/_cmaq_mm.py index b9f0e80e..6db975d3 100644 --- a/monetio/models/_cmaq_mm.py +++ b/monetio/models/_cmaq_mm.py @@ -1,4 +1,5 @@ """ CMAQ File Reader """ + import xarray as xr from numpy import array, concatenate from pandas import Series, to_datetime diff --git a/monetio/models/_rrfs_cmaq_mm.py b/monetio/models/_rrfs_cmaq_mm.py index 3aa9be6c..5b1c5245 100644 --- a/monetio/models/_rrfs_cmaq_mm.py +++ b/monetio/models/_rrfs_cmaq_mm.py @@ -1,4 +1,5 @@ """ RRFS-CMAQ File Reader """ + import numpy as np import xarray as xr from numpy import concatenate diff --git a/monetio/models/_wrfchem_mm.py b/monetio/models/_wrfchem_mm.py index 07989684..5ff5be06 100644 --- a/monetio/models/_wrfchem_mm.py +++ b/monetio/models/_wrfchem_mm.py @@ -1,4 +1,5 @@ """ WRF-Chem File reader """ + import xarray as xr from pandas import Series diff --git a/monetio/models/camx.py b/monetio/models/camx.py index b2821bad..30108fec 100644 --- a/monetio/models/camx.py +++ b/monetio/models/camx.py @@ -1,4 +1,5 @@ """ CAMx File Reader """ + import xarray as xr from numpy import array, concatenate from pandas import Series, to_datetime diff --git a/monetio/models/cmaq.py b/monetio/models/cmaq.py index a811ab47..231e255d 100644 --- a/monetio/models/cmaq.py +++ b/monetio/models/cmaq.py @@ -1,4 +1,5 @@ """ CMAQ File Reader """ + import xarray as xr from numpy import array, concatenate from pandas import Series, to_datetime diff --git a/monetio/models/hysplit.py b/monetio/models/hysplit.py index f2199ac9..6b7f6b76 100644 --- a/monetio/models/hysplit.py +++ b/monetio/models/hysplit.py @@ -40,6 +40,7 @@ """ + import datetime import sys diff --git a/monetio/models/raqms.py b/monetio/models/raqms.py index e19d2a68..72081084 100644 --- a/monetio/models/raqms.py +++ b/monetio/models/raqms.py @@ -5,6 +5,7 @@ More information: http://raqms-ops.ssec.wisc.edu/ """ + import xarray as xr diff --git a/monetio/obs/aeronet.py b/monetio/obs/aeronet.py index ff1a6e02..6bbdf8e4 100644 --- a/monetio/obs/aeronet.py +++ b/monetio/obs/aeronet.py @@ -1,6 +1,7 @@ """ AERONET """ + import warnings from datetime import datetime from functools import lru_cache diff --git a/monetio/obs/cems_mod.py b/monetio/obs/cems_mod.py index 642c5adc..a91d3d9f 100644 --- a/monetio/obs/cems_mod.py +++ b/monetio/obs/cems_mod.py @@ -5,6 +5,7 @@ Python 3 ################################################################# """ + import datetime import os diff --git a/monetio/obs/ish.py b/monetio/obs/ish.py index 6182cf19..cd47ae02 100644 --- a/monetio/obs/ish.py +++ b/monetio/obs/ish.py @@ -2,6 +2,7 @@ https://www.ncei.noaa.gov/products/land-based-station/integrated-surface-database """ + import dask import dask.dataframe as dd import numpy as np diff --git a/monetio/obs/ish_lite.py b/monetio/obs/ish_lite.py index bb51c562..59576ee7 100644 --- a/monetio/obs/ish_lite.py +++ b/monetio/obs/ish_lite.py @@ -8,6 +8,7 @@ --- https://www.ncei.noaa.gov/products/land-based-station/integrated-surface-database """ + import numpy as np import pandas as pd diff --git a/monetio/obs/nadp.py b/monetio/obs/nadp.py index 61019bed..fcee3f59 100644 --- a/monetio/obs/nadp.py +++ b/monetio/obs/nadp.py @@ -1,6 +1,5 @@ """ READS NAPD DATA """ - import pandas as pd from numpy import nan diff --git a/monetio/obs/openaq.py b/monetio/obs/openaq.py index 4b0d384b..acd8b724 100644 --- a/monetio/obs/openaq.py +++ b/monetio/obs/openaq.py @@ -23,6 +23,7 @@ savecols : type Description of attribute `savecols`. """ + import json import pandas as pd diff --git a/monetio/profile/geoms.py b/monetio/profile/geoms.py index 51ca1add..498ce0bb 100644 --- a/monetio/profile/geoms.py +++ b/monetio/profile/geoms.py @@ -9,6 +9,7 @@ For more info, see: https://evdc.esa.int/documentation/geoms/ """ + import warnings import numpy as np diff --git a/monetio/profile/gml_ozonesonde.py b/monetio/profile/gml_ozonesonde.py index d0754126..35901729 100644 --- a/monetio/profile/gml_ozonesonde.py +++ b/monetio/profile/gml_ozonesonde.py @@ -4,6 +4,7 @@ More info: https://gml.noaa.gov/ozwv/ozsondes/ """ + import re import warnings from typing import NamedTuple, Optional, Tuple, Union diff --git a/monetio/sat/_mopitt_l3_mm.py b/monetio/sat/_mopitt_l3_mm.py index a0290bf7..c5b7b1bf 100644 --- a/monetio/sat/_mopitt_l3_mm.py +++ b/monetio/sat/_mopitt_l3_mm.py @@ -11,6 +11,7 @@ * Dataset instead of DataArray - created 2021-12 rrb """ + import glob from pathlib import Path diff --git a/monetio/sat/goes.py b/monetio/sat/goes.py index 13cfa2da..2d698ed2 100644 --- a/monetio/sat/goes.py +++ b/monetio/sat/goes.py @@ -1,4 +1,5 @@ """ this will read the goes_r data""" + import pandas as pd import xarray as xr diff --git a/monetio/sat/lpdaac_download.py b/monetio/sat/lpdaac_download.py index 12979dc4..2d9e72ef 100644 --- a/monetio/sat/lpdaac_download.py +++ b/monetio/sat/lpdaac_download.py @@ -8,6 +8,7 @@ Last Updated: 11/20/2018 --------------------------------------------------------------------------------------------------- """ + import argparse import os import time diff --git a/monetio/sat/nesdis_edr_viirs.py b/monetio/sat/nesdis_edr_viirs.py index 0eb1ee93..19512ea3 100644 --- a/monetio/sat/nesdis_edr_viirs.py +++ b/monetio/sat/nesdis_edr_viirs.py @@ -50,9 +50,9 @@ def read_data(fname, lat, lon, date): da.attrs["units"] = "" da.name = "VIIRS EDR AOD" da.attrs["long_name"] = "Aerosol Optical Depth" - da.attrs[ - "source" - ] = "ftp://ftp.star.nesdis.noaa.gov/pub/smcd/jhuang/npp.viirs.aerosol.data/edraot550" + da.attrs["source"] = ( + "ftp://ftp.star.nesdis.noaa.gov/pub/smcd/jhuang/npp.viirs.aerosol.data/edraot550" + ) return da diff --git a/monetio/sat/nesdis_eps_viirs.py b/monetio/sat/nesdis_eps_viirs.py index c59902c6..71dcd42c 100644 --- a/monetio/sat/nesdis_eps_viirs.py +++ b/monetio/sat/nesdis_eps_viirs.py @@ -95,9 +95,9 @@ def read_data(fname, lat, lon, date): da.attrs["units"] = "" da.name = "VIIRS EPS AOT" da.attrs["long_name"] = "Aerosol Optical Thickness" - da.attrs[ - "source" - ] = "ftp://ftp.star.nesdis.noaa.gov/pub/smcd/VIIRS_Aerosol/npp.viirs.aerosol.data/epsaot550" + da.attrs["source"] = ( + "ftp://ftp.star.nesdis.noaa.gov/pub/smcd/VIIRS_Aerosol/npp.viirs.aerosol.data/epsaot550" + ) return da diff --git a/monetio/util.py b/monetio/util.py index 281901c1..2c6fb2c1 100644 --- a/monetio/util.py +++ b/monetio/util.py @@ -321,30 +321,30 @@ def calc_13_category_usda_soil_type(clay, sand, silt): stype = zeros(clay.shape) stype[where((silt + clay * 1.5 < 15.0) & (clay != 255))] = 1.0 # SAND - stype[ - where((silt + 1.5 * clay >= 15.0) & (silt + 1.5 * clay < 30) & (clay != 255)) - ] = 2.0 # Loamy Sand + stype[where((silt + 1.5 * clay >= 15.0) & (silt + 1.5 * clay < 30) & (clay != 255))] = ( + 2.0 # Loamy Sand + ) stype[ where((clay >= 7.0) & (clay < 20) & (sand > 52) & (silt + 2 * clay >= 30) & (clay != 255)) ] = 3.0 # Sandy Loam (cond 1) - stype[ - where((clay < 7) & (silt < 50) & (silt + 2 * clay >= 30) & (clay != 255)) - ] = 3 # sandy loam (cond 2) - stype[ - where((silt >= 50) & (clay >= 12) & (clay < 27) & (clay != 255)) - ] = 4 # silt loam (cond 1) + stype[where((clay < 7) & (silt < 50) & (silt + 2 * clay >= 30) & (clay != 255))] = ( + 3 # sandy loam (cond 2) + ) + stype[where((silt >= 50) & (clay >= 12) & (clay < 27) & (clay != 255))] = ( + 4 # silt loam (cond 1) + ) stype[where((silt >= 50) & (silt < 80) & (clay < 12) & (clay != 255))] = 4 # silt loam (cond 2) stype[where((silt >= 80) & (clay < 12) & (clay != 255))] = 5 # silt stype[ where((clay >= 7) & (clay < 27) & (silt >= 28) & (silt < 50) & (sand <= 52) & (clay != 255)) ] = 6 # loam - stype[ - where((clay >= 20) & (clay < 35) & (silt < 28) & (sand > 45) & (clay != 255)) - ] = 7 # sandy clay loam + stype[where((clay >= 20) & (clay < 35) & (silt < 28) & (sand > 45) & (clay != 255))] = ( + 7 # sandy clay loam + ) stype[where((clay >= 27) & (clay < 40.0) & (sand > 40) & (clay != 255))] = 8 # silt clay loam - stype[ - where((clay >= 27) & (clay < 40.0) & (sand > 20) & (sand <= 45) & (clay != 255)) - ] = 9 # clay loam + stype[where((clay >= 27) & (clay < 40.0) & (sand > 20) & (sand <= 45) & (clay != 255))] = ( + 9 # clay loam + ) stype[where((clay >= 35) & (sand > 45) & (clay != 255))] = 10 # sandy clay stype[where((clay >= 40) & (silt >= 40) & (clay != 255))] = 11 # silty clay stype[where((clay >= 40) & (sand <= 45) & (silt < 40) & (clay != 255))] = 12 # clay From a0767e94809212e21d76b6bfe2a66445399e12c0 Mon Sep 17 00:00:00 2001 From: zmoon Date: Thu, 19 Sep 2024 11:01:44 -0500 Subject: [PATCH 3/3] No type == --- monetio/obs/ish.py | 2 +- tests/test_ish.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/monetio/obs/ish.py b/monetio/obs/ish.py index cd47ae02..1d37c3e1 100644 --- a/monetio/obs/ish.py +++ b/monetio/obs/ish.py @@ -193,7 +193,7 @@ def _clean(frame): def _decode_bytes(df): if df.empty: return df - bytes_cols = [col for col in df.columns if type(df[col][0]) == bytes] + bytes_cols = [col for col in df.columns if type(df[col][0]) is bytes] with pd.option_context("mode.chained_assignment", None): df.loc[:, bytes_cols] = df[bytes_cols].apply( lambda x: x.str.decode("utf-8"), diff --git a/tests/test_ish.py b/tests/test_ish.py index 42b1dd1c..4461cd82 100644 --- a/tests/test_ish.py +++ b/tests/test_ish.py @@ -149,7 +149,7 @@ def test_ish_read_url_direct(): assert set(df.columns) - set(orig_names) == {"time"} assert set(orig_names) - set(df.columns) == {"date", "htime", "latitude", "longitude"} - assert type(df.t_quality[0]) == str + assert type(df.t_quality[0]) is str def test_ish_small_timeout_fails():