Loading src/cso/__init__.py +7 −4 Original line number Diff line number Diff line Loading @@ -120,11 +120,14 @@ and are defined according to the following hierchy: # store version number: try: from importlib import metadata __version__ = metadata.version(__package__) except: import os if "CSO_PREFIX" in os.environ.keys(): import tomllib with open(os.path.join(os.environ["CSO_PREFIX"], "pyproject.toml"), "rb") as f: pp = tomllib.load(f) __version__ = pp["project"]["version"] Loading src/cso/cso_earthaccess.py +15 −16 Original line number Diff line number Diff line Loading @@ -799,7 +799,6 @@ class CSO_EarthAccess_Download_Listing(utopya.UtopyaRc): for root, dirs, files in os.walk(bdir): # loop over files: for fname in files: # subdir relative to listing file: subdir = os.path.relpath(root, start=bdir) # info ... Loading @@ -818,12 +817,10 @@ class CSO_EarthAccess_Download_Listing(utopya.UtopyaRc): # data file? if fnmatch.fnmatch(fname, fpattern): # expected filenames: # AERDB_L2_VIIRS_SNPP.A2022001.0342.002.2023076013614.nc parts = fname.split(".") if len(parts) == 6: # second is year-julday, strip the "A" of acquisition: try: t1 = datetime.datetime.strptime(parts[1][1:], "%Y%j") Loading Loading @@ -854,7 +851,9 @@ class CSO_EarthAccess_Download_Listing(utopya.UtopyaRc): data["orbit"] = orbit # update record: listing.UpdateRecord( os.path.join(subdir,fname), data, indent=f"{indent} ") listing.UpdateRecord( os.path.join(subdir, fname), data, indent=f"{indent} " ) # endfor # filename match Loading src/cso/cso_file.py +17 −15 Original line number Diff line number Diff line Loading @@ -636,7 +636,9 @@ class CSO_File(object): for vname in self.ds.keys(): # only numerical values: dtype = self.ds[vname].dtype if numpy.issubdtype(dtype,numpy.integer) or numpy.issubdtype(dtype,numpy.floating): if numpy.issubdtype(dtype, numpy.integer) or numpy.issubdtype( dtype, numpy.floating ): # enable zlib compression and set level: self.ds[vname].encoding["zlib"] = True self.ds[vname].encoding["complevel"] = complevel Loading Loading @@ -1313,7 +1315,6 @@ class CSO_Listing(object): # directory name: if self.filename is not None: # check .. if not os.path.isfile(filename): logging.error("listing file not found: %s" % filename) Loading Loading @@ -1342,7 +1343,6 @@ class CSO_Listing(object): self.df["end_time"] = pandas.to_datetime(self.df["end_time"]) else: # not defined yet, assume current location: self.dirname = os.curdir Loading Loading @@ -1564,7 +1564,9 @@ class CSO_Listing(object): # * def Select(self, tr=None, method="overlap", expr=None, blacklist=[], verbose=True, indent="", **kwargs): def Select( self, tr=None, method="overlap", expr=None, blacklist=[], verbose=True, indent="", **kwargs ): """ Return :py:class:`CSO_Listing` object with selection of records. Loading src/cso/cso_plot.py +104 −90 Original line number Diff line number Diff line Loading @@ -664,7 +664,17 @@ class ColorbarFigure(Figure): # # black-white-magenta: elif colors == "kwm": colors = ["black","blue","cyan","lightgreen","white","yellow","orange","red","magenta"] colors = [ "black", "blue", "cyan", "lightgreen", "white", "yellow", "orange", "red", "magenta", ] # # blue-green-white-yellow-red elif colors == "bgwyr": Loading Loading @@ -755,6 +765,7 @@ class ColorbarFigure(Figure): # get predefined colormap: if colors.startswith("cmcrameri.cm"): import cmcrameri self.cmap = getattr(cmcrameri.cm, colors.lstrip("cmcrameri.cm.")) else: self.cmap = matplotlib.pyplot.get_cmap(colors) Loading Loading @@ -812,12 +823,12 @@ class ColorbarFigure(Figure): if vbounds is None: # set value range if not explicitly done: if self.vmin is None: if hasattr(values,'values') : if hasattr(values, "values"): self.vmin = numpy.nanmin(values.values) else: self.vmin = numpy.nanmin(values) if self.vmax is None: if hasattr(values,'values') : if hasattr(values, "values"): self.vmax = numpy.nanmax(values.values) else: self.vmax = numpy.nanmax(values) Loading Loading @@ -1056,7 +1067,9 @@ class ColorbarFigure(Figure): # reset: cc2[jj, ii] = 1.0 # add mask: self.ax.pcolormesh(xx, yy, cc2, cmap=matplotlib.colors.ListedColormap([self.cmap__color_bad]) ) self.ax.pcolormesh( xx, yy, cc2, cmap=matplotlib.colors.ListedColormap([self.cmap__color_bad]) ) # endif # endif Loading Loading @@ -1197,7 +1210,8 @@ class ColorbarFigure(Figure): vmin=vmin, vmax=vmax, vbounds=vbounds, marker=".", markersize=0, marker=".", markersize=0, linewidths=0, ) Loading Loading @@ -1489,7 +1503,6 @@ def GetColorMap(colors=None, color_under=None, color_over=None, color_bad=None, def MapFigure(domain=None): """ Draw map. Loading @@ -1507,6 +1520,7 @@ def MapFigure( domain=None ): # add ax: fig.AddAxes(domain=domain, bmp=dict(countries=True)) # enddef MapFigure Loading Loading @@ -1576,7 +1590,7 @@ def QuickPat( from . import cso_tools # extract known coordinates: if hasattr(cc,'coords') : if hasattr(cc, "coords"): # longitudes: if x is None: for key in ["lon", "longitude"]: Loading Loading @@ -1634,17 +1648,17 @@ def QuickPat( vmin = -dmax vmax = dmax # colors: if 'cmap' in kwargs.keys() : if 'colors' not in kwargs['cmap'].keys() : kwargs['cmap']['colors'] = 'pwb' if "cmap" in kwargs.keys(): if "colors" not in kwargs["cmap"].keys(): kwargs["cmap"]["colors"] = "pwb" # endif else: kwargs['cmap'] = { 'colors' : 'pwb' } kwargs["cmap"] = {"colors": "pwb"} # endif # endif # value range: if hasattr(cc,'values') : if hasattr(cc, "values"): cmin = numpy.nanmin(cc.values) cmax = numpy.nanmax(cc.values) else: Loading src/cso/cso_tools.py +84 −82 Original line number Diff line number Diff line Loading @@ -211,6 +211,7 @@ def GetCornerGridX( shp, x=None, domain=None, bounds=False ): return xx # endif # enddef GetCornerGridX # * Loading Loading @@ -312,6 +313,7 @@ def GetCornerGridY( shp, y=None, domain=None, bounds=False ): return yy # endif # enddef GetCornerGridY Loading Loading
src/cso/__init__.py +7 −4 Original line number Diff line number Diff line Loading @@ -120,11 +120,14 @@ and are defined according to the following hierchy: # store version number: try: from importlib import metadata __version__ = metadata.version(__package__) except: import os if "CSO_PREFIX" in os.environ.keys(): import tomllib with open(os.path.join(os.environ["CSO_PREFIX"], "pyproject.toml"), "rb") as f: pp = tomllib.load(f) __version__ = pp["project"]["version"] Loading
src/cso/cso_earthaccess.py +15 −16 Original line number Diff line number Diff line Loading @@ -799,7 +799,6 @@ class CSO_EarthAccess_Download_Listing(utopya.UtopyaRc): for root, dirs, files in os.walk(bdir): # loop over files: for fname in files: # subdir relative to listing file: subdir = os.path.relpath(root, start=bdir) # info ... Loading @@ -818,12 +817,10 @@ class CSO_EarthAccess_Download_Listing(utopya.UtopyaRc): # data file? if fnmatch.fnmatch(fname, fpattern): # expected filenames: # AERDB_L2_VIIRS_SNPP.A2022001.0342.002.2023076013614.nc parts = fname.split(".") if len(parts) == 6: # second is year-julday, strip the "A" of acquisition: try: t1 = datetime.datetime.strptime(parts[1][1:], "%Y%j") Loading Loading @@ -854,7 +851,9 @@ class CSO_EarthAccess_Download_Listing(utopya.UtopyaRc): data["orbit"] = orbit # update record: listing.UpdateRecord( os.path.join(subdir,fname), data, indent=f"{indent} ") listing.UpdateRecord( os.path.join(subdir, fname), data, indent=f"{indent} " ) # endfor # filename match Loading
src/cso/cso_file.py +17 −15 Original line number Diff line number Diff line Loading @@ -636,7 +636,9 @@ class CSO_File(object): for vname in self.ds.keys(): # only numerical values: dtype = self.ds[vname].dtype if numpy.issubdtype(dtype,numpy.integer) or numpy.issubdtype(dtype,numpy.floating): if numpy.issubdtype(dtype, numpy.integer) or numpy.issubdtype( dtype, numpy.floating ): # enable zlib compression and set level: self.ds[vname].encoding["zlib"] = True self.ds[vname].encoding["complevel"] = complevel Loading Loading @@ -1313,7 +1315,6 @@ class CSO_Listing(object): # directory name: if self.filename is not None: # check .. if not os.path.isfile(filename): logging.error("listing file not found: %s" % filename) Loading Loading @@ -1342,7 +1343,6 @@ class CSO_Listing(object): self.df["end_time"] = pandas.to_datetime(self.df["end_time"]) else: # not defined yet, assume current location: self.dirname = os.curdir Loading Loading @@ -1564,7 +1564,9 @@ class CSO_Listing(object): # * def Select(self, tr=None, method="overlap", expr=None, blacklist=[], verbose=True, indent="", **kwargs): def Select( self, tr=None, method="overlap", expr=None, blacklist=[], verbose=True, indent="", **kwargs ): """ Return :py:class:`CSO_Listing` object with selection of records. Loading
src/cso/cso_plot.py +104 −90 Original line number Diff line number Diff line Loading @@ -664,7 +664,17 @@ class ColorbarFigure(Figure): # # black-white-magenta: elif colors == "kwm": colors = ["black","blue","cyan","lightgreen","white","yellow","orange","red","magenta"] colors = [ "black", "blue", "cyan", "lightgreen", "white", "yellow", "orange", "red", "magenta", ] # # blue-green-white-yellow-red elif colors == "bgwyr": Loading Loading @@ -755,6 +765,7 @@ class ColorbarFigure(Figure): # get predefined colormap: if colors.startswith("cmcrameri.cm"): import cmcrameri self.cmap = getattr(cmcrameri.cm, colors.lstrip("cmcrameri.cm.")) else: self.cmap = matplotlib.pyplot.get_cmap(colors) Loading Loading @@ -812,12 +823,12 @@ class ColorbarFigure(Figure): if vbounds is None: # set value range if not explicitly done: if self.vmin is None: if hasattr(values,'values') : if hasattr(values, "values"): self.vmin = numpy.nanmin(values.values) else: self.vmin = numpy.nanmin(values) if self.vmax is None: if hasattr(values,'values') : if hasattr(values, "values"): self.vmax = numpy.nanmax(values.values) else: self.vmax = numpy.nanmax(values) Loading Loading @@ -1056,7 +1067,9 @@ class ColorbarFigure(Figure): # reset: cc2[jj, ii] = 1.0 # add mask: self.ax.pcolormesh(xx, yy, cc2, cmap=matplotlib.colors.ListedColormap([self.cmap__color_bad]) ) self.ax.pcolormesh( xx, yy, cc2, cmap=matplotlib.colors.ListedColormap([self.cmap__color_bad]) ) # endif # endif Loading Loading @@ -1197,7 +1210,8 @@ class ColorbarFigure(Figure): vmin=vmin, vmax=vmax, vbounds=vbounds, marker=".", markersize=0, marker=".", markersize=0, linewidths=0, ) Loading Loading @@ -1489,7 +1503,6 @@ def GetColorMap(colors=None, color_under=None, color_over=None, color_bad=None, def MapFigure(domain=None): """ Draw map. Loading @@ -1507,6 +1520,7 @@ def MapFigure( domain=None ): # add ax: fig.AddAxes(domain=domain, bmp=dict(countries=True)) # enddef MapFigure Loading Loading @@ -1576,7 +1590,7 @@ def QuickPat( from . import cso_tools # extract known coordinates: if hasattr(cc,'coords') : if hasattr(cc, "coords"): # longitudes: if x is None: for key in ["lon", "longitude"]: Loading Loading @@ -1634,17 +1648,17 @@ def QuickPat( vmin = -dmax vmax = dmax # colors: if 'cmap' in kwargs.keys() : if 'colors' not in kwargs['cmap'].keys() : kwargs['cmap']['colors'] = 'pwb' if "cmap" in kwargs.keys(): if "colors" not in kwargs["cmap"].keys(): kwargs["cmap"]["colors"] = "pwb" # endif else: kwargs['cmap'] = { 'colors' : 'pwb' } kwargs["cmap"] = {"colors": "pwb"} # endif # endif # value range: if hasattr(cc,'values') : if hasattr(cc, "values"): cmin = numpy.nanmin(cc.values) cmax = numpy.nanmax(cc.values) else: Loading
src/cso/cso_tools.py +84 −82 Original line number Diff line number Diff line Loading @@ -211,6 +211,7 @@ def GetCornerGridX( shp, x=None, domain=None, bounds=False ): return xx # endif # enddef GetCornerGridX # * Loading Loading @@ -312,6 +313,7 @@ def GetCornerGridY( shp, y=None, domain=None, bounds=False ): return yy # endif # enddef GetCornerGridY Loading