From ae3d3b6b41d2fb3ae7f679928de5c0f0345c88e1 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 20 Aug 2024 10:59:34 +1000 Subject: [PATCH 1/2] Code formatting cleanup --- hypercoast/emit.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/hypercoast/emit.py b/hypercoast/emit.py index 265bdf6c..0c1d3820 100644 --- a/hypercoast/emit.py +++ b/hypercoast/emit.py @@ -43,7 +43,7 @@ def read_emit( """ - if ortho == True: + if ortho is True: return emit_xarray( filepath, ortho=True, wavelengths=wavelengths, method=method, **kwargs ) @@ -113,9 +113,9 @@ def plot_emit( hvplot.Plot: The line plot of the reflectance data. """ - import hvplot.xarray + import hvplot.xarray # noqa F401 - if ortho == True: + if ortho is True: if longitude is None or latitude is None: raise ValueError( "Longitude and Latitude must be provided for orthorectified data." @@ -127,10 +127,10 @@ def plot_emit( ) if longitude is not None and latitude is not None: - ortho = True + ortho is True if downtrack is not None and crosstrack is not None: - ortho = False + ortho is False if isinstance(ds, str): ds = read_emit(ds, ortho=ortho) @@ -197,7 +197,7 @@ def viz_emit( Returns: hvplot.Plot: The image plot of the reflectance data at the specified wavelengths. """ - import hvplot.xarray + import hvplot.xarray # noqa F401 if isinstance(ds, str): ds = read_emit(ds, ortho=ortho) @@ -304,12 +304,12 @@ def emit_xarray( xarray.Dataset: An xarray.Dataset constructed based on the parameters provided. """ # Grab granule filename to check product - import s3fs + from s3fs.core import S3File from fsspec.implementations.http import HTTPFile - if type(filepath) == s3fs.core.S3File: + if isinstance(filepath, S3File): granule_id = filepath.info()["name"].split("/", -1)[-1].split(".", -1)[0] - elif type(filepath) == HTTPFile: + elif isinstance(filepath, HTTPFile): granule_id = filepath.path.split("/", -1)[-1].split(".", -1)[0] else: granule_id = os.path.splitext(os.path.basename(filepath))[0] @@ -575,7 +575,7 @@ def quality_mask(filepath: str, quality_bands: list) -> np.ndarray: print(f"Flags used: {flags_used}") # Check for data bands and build mask if any(x in quality_bands for x in [5, 6]): - err_str = f"Selected flags include a data band (5 or 6) not just flag bands" + err_str = "Selected flags include a data band (5 or 6) not just flag bands" raise AttributeError(err_str) else: qmask = np.sum(mask_ds["mask"][:, :, quality_bands].values, axis=-1) @@ -638,7 +638,7 @@ def write_envi( if ( "Orthorectified" in xr_ds.attrs.keys() and xr_ds.attrs["Orthorectified"] == "True" - and glt_file == True + and glt_file is True ): raise Exception("Data is already orthorectified.") @@ -759,7 +759,7 @@ def write_envi( mm[...] = dat # Create GLT Metadata/File - if glt_file == True: + if glt_file is True: # Output Name glt_output_name = os.path.join( output_dir, xr_ds.attrs["granule_id"] + "_" + "glt" @@ -1022,7 +1022,7 @@ def ortho_browse( # Read Data data = io.imread(url) # Orthorectify using GLT and transpose so band is first dimension - if white_background == True: + if white_background is True: fill = 255 else: fill = 0 From fc96549821d8b43a1da9a8d840dfcb7c0b093449 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 20 Aug 2024 11:45:59 +1000 Subject: [PATCH 2/2] Revert issue with vs --- hypercoast/emit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hypercoast/emit.py b/hypercoast/emit.py index 0c1d3820..57cce4c9 100644 --- a/hypercoast/emit.py +++ b/hypercoast/emit.py @@ -127,10 +127,10 @@ def plot_emit( ) if longitude is not None and latitude is not None: - ortho is True + ortho = True if downtrack is not None and crosstrack is not None: - ortho is False + ortho = False if isinstance(ds, str): ds = read_emit(ds, ortho=ortho)