From 8477ecf442abc13373831e4303463cc8b9062522 Mon Sep 17 00:00:00 2001 From: Arjo Segers Date: Fri, 25 Apr 2025 15:16:59 +0200 Subject: [PATCH 1/3] Updated documentation and reformated files. --- Makefile | 2 +- doc/source/conf.py | 4 +++- src/cso/__init__.py | 1 + src/cso/cso_colhub.py | 12 ++++++------ src/cso/cso_file.py | 16 ++++++++-------- src/cso/cso_inquire.py | 4 ++-- src/cso/cso_s5p.py | 4 ++-- src/cso/scripts/cli.py | 1 + src/utopya/__init__.py | 26 ++++++++++---------------- src/utopya/utopya_build.py | 2 +- src/utopya/utopya_index.py | 2 +- 11 files changed, 36 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index 542d685..3071efd 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ help: # re-format python files, # use local maximum line-length convention .. black: - black --line-length=99 py doc/source/conf.py + black --line-length=99 src doc/source/conf.py # generate documentation: docu: diff --git a/doc/source/conf.py b/doc/source/conf.py index 3e6cc4c..0b0c855 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -12,6 +12,7 @@ # import os import sys + # sys.path.insert(0, os.path.abspath(os.path.join(os.pardir, os.pardir, "src"))) sys.path.insert(0, os.path.abspath(os.path.join(os.pardir, os.pardir, "src", "utopya"))) @@ -35,12 +36,13 @@ if not os.path.isfile(ppfile): else: # modules: import toml + # open file: with open(ppfile, "r") as f: config = toml.load(f) # extrract: release = config["project"]["version"] -#endif +# endif # -- General configuration --------------------------------------------------- diff --git a/src/cso/__init__.py b/src/cso/__init__.py index 020d635..401f8b0 100644 --- a/src/cso/__init__.py +++ b/src/cso/__init__.py @@ -109,6 +109,7 @@ and are defined according to the following hierchy: # store version number: from importlib import metadata + __version__ = metadata.version(__package__) # import entities from sub-modules: diff --git a/src/cso/cso_colhub.py b/src/cso/cso_colhub.py index 7d47ff1..1dc8989 100644 --- a/src/cso/cso_colhub.py +++ b/src/cso/cso_colhub.py @@ -422,13 +422,13 @@ class CSO_ColHubMirror_Missing(utopya.UtopyaRc): ) # read: listings_curr = [] - for listfile in listfiles : + for listfile in listfiles: # evaluate time templates if necessary: listfile = filedate.strftime(listfile) listfile = listfile.strip() # read: - listings_curr.append( cso_file.CSO_Listing(listfile) ) - #endfor + listings_curr.append(cso_file.CSO_Listing(listfile)) + # endfor # extract orbits: orbits = listing_all.GetValues("orbit").unique() @@ -467,11 +467,11 @@ class CSO_ColHubMirror_Missing(utopya.UtopyaRc): # set flag: found = False # loop over mirror listings: - for listing_curr in listings_curr : + for listing_curr in listings_curr: # check if already available: found = rec["filename"] in listing_curr # found? - if found : + if found: # info ... logging.info(f"{indent} file already present ...") # leave: @@ -488,7 +488,7 @@ class CSO_ColHubMirror_Missing(utopya.UtopyaRc): # endfor ## TESTING ... - #if len(listing) > 0 : + # if len(listing) > 0 : # logging.warning(f"BREAK!") # break ##endif diff --git a/src/cso/cso_file.py b/src/cso/cso_file.py index ee7024d..09da2bb 100644 --- a/src/cso/cso_file.py +++ b/src/cso/cso_file.py @@ -93,9 +93,9 @@ def CheckDir(filename, dmode=None): # modules: import os - + # set creation mode: - if dmode is None : + if dmode is None: mode = 0o777 else: mode = dmode @@ -1293,10 +1293,10 @@ class CSO_Listing(object): index_col=self.index_label, dtype="str", ) - # convert datetime columns, as the default is "str" + # convert datetime columns, as the default is "str" # the "parse_dates" argument could not be used: - self.df["start_time"] = pandas.to_datetime( self.df["start_time"] ) - self.df["end_time"] = pandas.to_datetime( self.df["end_time"] ) + self.df["start_time"] = pandas.to_datetime(self.df["start_time"]) + self.df["end_time"] = pandas.to_datetime(self.df["end_time"]) else: # new table: @@ -1360,13 +1360,13 @@ class CSO_Listing(object): # * - def GetValue(self, filename, key ): + def GetValue(self, filename, key): """ Return ``key`` value for record of ``filename``. """ # copy: - return self.df.at[filename,key] + return self.df.at[filename, key] # enddef GetValue @@ -1379,7 +1379,7 @@ class CSO_Listing(object): """ # switch .. - if name is None : + if name is None: return self.df.index elif name in self.df.keys(): return self.df[name] diff --git a/src/cso/cso_inquire.py b/src/cso/cso_inquire.py index e3aedee..155cede 100644 --- a/src/cso/cso_inquire.py +++ b/src/cso/cso_inquire.py @@ -225,8 +225,8 @@ class CSO_Inquire_Plot(utopya.UtopyaRc): skip_blank_lines=True, dtype="str", ) - xdf["start_time"] = pandas.to_datetime( xdf["start_time"] ) - xdf["end_time"] = pandas.to_datetime( xdf["end_time"] ) + xdf["start_time"] = pandas.to_datetime(xdf["start_time"]) + xdf["end_time"] = pandas.to_datetime(xdf["end_time"]) # combine: if df is None: df = xdf diff --git a/src/cso/cso_s5p.py b/src/cso/cso_s5p.py index df5e4b4..db73c1a 100644 --- a/src/cso/cso_s5p.py +++ b/src/cso/cso_s5p.py @@ -1392,7 +1392,7 @@ class CSO_S5p_File(cso_file.CSO_File): # endif # base time for units "seconds since ..." as start of year: - t0 = pandas.to_datetime( tref ).to_pydatetime() + t0 = pandas.to_datetime(tref).to_pydatetime() # create variable: da = xarray.DataArray(values, dims=vdims, coords={"pixel": pixel}, attrs=oda.attrs) @@ -2885,7 +2885,7 @@ class CSO_S5p_Convert(utopya.UtopyaRc): # endif # output dir: - cso_file.CheckDir( output_filename, dmode=dmode ) + cso_file.CheckDir(output_filename, dmode=dmode) # split filename at extension: fname, ext = os.path.splitext(output_filename) diff --git a/src/cso/scripts/cli.py b/src/cso/scripts/cli.py index 27e5c13..1b5ddb7 100644 --- a/src/cso/scripts/cli.py +++ b/src/cso/scripts/cli.py @@ -32,6 +32,7 @@ def callback( ): """🛰️ CAMS Satellite Operator (CSO) Command Line Interface""" + @main.command() def run(rc_file: str = typer.Argument(..., help="Provide .rc file")): """Run cso based on settings provided in .rc file (e.g., cso run config/tutorial/tutorial.rc)""" diff --git a/src/utopya/__init__.py b/src/utopya/__init__.py index bfdc256..d09e11a 100644 --- a/src/utopya/__init__.py +++ b/src/utopya/__init__.py @@ -67,21 +67,15 @@ Utopya modules Actual implementations can be found in submodules: -.. The following are names of '.rst' files in the 'doc/sources' directory ; - this ensures that each sub-module is given a seperate page in the documentation. - -.. toctree:: - :maxdepth: 1 - - pymod-utopya_base - pymod-utopya_rc - pymod-utopya_jobscript - pymod-utopya_jobtree - pymod-utopya_runscript - pymod-utopya_tools - pymod-utopya_build - pymod-utopya_post - pymod-utopya_index +* :py:mod:`utopya.utopya_base` +* :py:mod:`utopya.utopya_rc` +* :py:mod:`utopya.utopya_jobscript` +* :py:mod:`utopya.utopya_jobtree` +* :py:mod:`utopya.utopya_runscript` +* :py:mod:`utopya.utopya_tools` +* :py:mod:`utopya.utopya_build` +* :py:mod:`utopya.utopya_post` +* :py:mod:`utopya.utopya_index` .. Label, use :ref:`text