From 2f347c7aee959fa6ab1e1eaf3d40a475bbc2b0af Mon Sep 17 00:00:00 2001 From: David Hoese <david.hoese@ssec.wisc.edu> Date: Thu, 25 Jul 2024 14:58:33 -0500 Subject: [PATCH] Cleanup round 3 --- aossceilo/CONFIG.py | 37 +++++++++++++++++++------------------ aossceilo/__init__.py | 18 +++++++----------- pyproject.toml | 2 ++ 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/aossceilo/CONFIG.py b/aossceilo/CONFIG.py index 5b33602..82d3f35 100644 --- a/aossceilo/CONFIG.py +++ b/aossceilo/CONFIG.py @@ -1,5 +1,6 @@ -"""This module holds all directory/path/URL information for metobs.ceilo -packages. This file should be the only place that holds this static information. +"""All directory/path/URL information for metobs.ceilo packages. + +This file should be the only place that holds this static information. This file should not do any file manipulation at all, only return strings or pass other static information such as what plot number goes with what data. @@ -13,7 +14,6 @@ import re from datetime import datetime, timedelta from metobscommon.util import CONFIG as c -from metobscommon.util import RODict CEILO_INCOMING_DIR = os.environ.get( "CEILO_INCOMING_DIR", "/beach/incoming/Instrument_Data/METOBS/RIG/Ceilo/raw" @@ -32,18 +32,18 @@ RE_DIGITS = re.compile(r"\d+") def get_incoming_dir(): - """Return incoming directory for specified date""" + """Return incoming directory for specified date.""" return os.path.join(CEILO_INCOMING_DIR) def get_praw_dir(when=None): - """Return raw directory for specified date and data_type""" + """Return raw directory for specified date and data_type.""" when = when or datetime.now() return os.path.join(CEILO_PRAW_DIR, when.strftime(CEILO_DIR_FORMAT)) def get_sraw_dir(when=None): - """Return raw directory for specified date and data_type""" + """Return raw directory for specified date and data_type.""" raise NotImplementedError( "This function is not used anymore, there should only be one primary storage location" ) @@ -52,24 +52,24 @@ def get_sraw_dir(when=None): def get_cache_dir(data_type, when=None): - """Return cache directory for specified date and data_type""" + """Return cache directory for specified date and data_type.""" when = when or datetime.now() return os.path.join(CEILO_CACHE_DIR, data_type, when.strftime(CEILO_DIR_FORMAT)) def get_latest_dir(): - """Return latest directory""" + """Return latest directory.""" return os.path.join(CEILO_LATEST_DIR) def get_ascii_filename(when=None, site="rig", description=""): - """Return the standard filename of the ascii file for the specified date""" + """Return the standard filename of the ascii file for the specified date.""" when = when or datetime.now() return c.get_filename(site, inst, when, ext="ascii", description=description) def get_ascii_url(when=None, site="rig", description=""): - """Return the standard url of the ascii file for the specified date""" + """Return the standard url of the ascii file for the specified date.""" when = when or datetime.now() return os.path.join( CEILO_ASCII_LOC, @@ -80,13 +80,13 @@ def get_ascii_url(when=None, site="rig", description=""): def get_nc_filename(when=None, site="rig", description=""): - """Return the standard filename of the netCDF file for the specified date""" + """Return the standard filename of the netCDF file for the specified date.""" when = when or datetime.now() return c.get_filename(site, inst, when, ext="nc", description=description) def get_nc_url(when=None, site="rig", description=""): - """Return the standard url of the netCDF file for the specified date""" + """Return the standard url of the netCDF file for the specified date.""" when = when or datetime.now() return os.path.join( CEILO_NC_LOC, @@ -97,7 +97,7 @@ def get_nc_url(when=None, site="rig", description=""): def get_img_filename(begin, end, ptype=1, tag="", site="rig", description=""): - """Return the standard filename of the image that goes from begin to end""" + """Return the standard filename of the image that goes from begin to end.""" pname = _handle_plot_type(ptype) return c.get_filename( site, @@ -112,19 +112,21 @@ def get_img_filename(begin, end, ptype=1, tag="", site="rig", description=""): def get_quicklook_filename(begin, end, ptype=1, site="rig", description=""): + """Generate filename for a quicklook.""" return get_img_filename( begin, end, ptype, tag="", site=site, description=description ) def get_thumbnail_filename(begin, end, ptype=1, site="rig", description=""): + """Generate filename for a quicklook thumbnail.""" return get_img_filename( begin, end, ptype, tag="tn", site=site, description=description ) def get_img_url(begin, end, ptype=1, tag="", site="rig", description=""): - """Return the standard url of the image that goes from begin to end""" + """Return the standard url of the image that goes from begin to end.""" return os.path.join( CEILO_IMG_LOC, "img", @@ -136,14 +138,17 @@ def get_img_url(begin, end, ptype=1, tag="", site="rig", description=""): def get_quicklook_url(begin, end, ptype=1, site="rig", description=""): + """Generate URL for a quicklook.""" return get_img_url(begin, end, ptype, tag="", site=site, description=description) def get_thumbnail_url(begin, end, ptype=1, site="rig", description=""): + """Generate URL for a quicklook thumbnail.""" return get_img_url(begin, end, ptype, tag="tn", site=site, description=description) def rename_incoming(incoming_file, site="rig", description=""): + """Generate filenames for various parts of the archive for the provided incoming file.""" file_date = datetime(*tuple([int(x) for x in RE_DIGITS.findall(incoming_file)])) present_date = datetime.now() praw = get_praw_dir(when=file_date) @@ -153,10 +158,6 @@ def rename_incoming(incoming_file, site="rig", description=""): return praw, cache, rn, remove -def get_type_name(): - return RODict({1: "Backscatter", 2: "Cloud Base Height", 3: "Vertical Visibility"}) - - def _handle_plot_type(plottype=1): if plottype == 1: return "" diff --git a/aossceilo/__init__.py b/aossceilo/__init__.py index 50b612f..2212fb4 100644 --- a/aossceilo/__init__.py +++ b/aossceilo/__init__.py @@ -1,3 +1,4 @@ +"""Processing and archive management code for the AOSS Ceilometer instrument.""" from aossceilo import CONFIG as c from aossceilo.version import __version__ # noqa @@ -5,8 +6,7 @@ instrument_name = "ceilo" def get_ascii_name(dt, site="rig"): - """ - Make a standard filename for a tower ascii file. + """Make a standard filename for a tower ascii file. @type dt: datetime @param dt: datetime of the url to generate. @@ -17,8 +17,7 @@ def get_ascii_name(dt, site="rig"): def get_nc_name(dt, site="rig"): - """ - Make a standard filename for a ceilometer netcdf file. + """Make a standard filename for a ceilometer netcdf file. @type dt: datetime @param dt: datetime of the url to generate. @@ -34,8 +33,7 @@ def get_thumbnail_name(begin, end=None, site="rig", plottype=1): def get_nc_url(dt, site="rig", host=None): - """ - Get a URL to a ceilometer NetCDF file. + """Get a URL to a ceilometer NetCDF file. @type dt: datetime @param dt: datetime of the url to generate. @@ -49,7 +47,7 @@ def get_nc_url(dt, site="rig", host=None): def get_ascii_url(dt, site="rig", host=None): - """Get a URL to a ceilometer ASCII file on the opendap server + """Get a URL to a ceilometer ASCII file on the opendap server. @type dt: datetime @param dt: datetime of the url to generate. @@ -63,16 +61,14 @@ def get_ascii_url(dt, site="rig", host=None): def get_thumbnail_url(begin, end=None, site="rig", host=None, plottype=1): + """Get URL for a quicklook thumbnail file.""" return c.get_image_url(begin, end, ptype=plottype, tag="tn") def get_image_url(begin, end=None, site="rig", host=None, plottype=1): + """Get URL for a quicklook file.""" return c.get_image_url(begin, end, ptype=plottype, tag="") -def get_type_name(): - return c.get_type_name() - - def _handle_plottype(plottype=1): return c._handle_plot_type(plottype) diff --git a/pyproject.toml b/pyproject.toml index 1b002a2..1d497b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,6 +57,8 @@ select = ["A", "D", "E", "W", "F", "I", "PT", "TID", "C90", "Q", "T10", "T20", " [tool.ruff.lint.per-file-ignores] "aossceilo/tests/*" = ["S101", "D100", "D103"] # assert allowed in tests +"aossceilo/level_b1/nc.py" = ["D"] # old module, no time for adding docstrings +"aossceilo/level_b1/message.py" = ["D"] # old module, no time for adding docstrings [tool.ruff.lint.pydocstyle] convention = "numpy" -- GitLab