Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code formatting cleanup #115

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions hypercoast/emit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.")

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
Loading