Skip to content

Commit

Permalink
Format with black
Browse files Browse the repository at this point in the history
  • Loading branch information
robintw committed Jun 7, 2021
1 parent acfbcbf commit 6d8f1d7
Show file tree
Hide file tree
Showing 29 changed files with 6,727 additions and 2,339 deletions.
11 changes: 10 additions & 1 deletion Py6S/Params/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,13 @@
from .altitudes import Altitudes
from .geometry import *

__all__ = ["AtmosProfile", "AeroProfile", "AtmosCorr", "GroundReflectance", "Wavelength", "Geometry", "Altitudes", "PredefinedWavelengths"]
__all__ = [
"AtmosProfile",
"AeroProfile",
"AtmosCorr",
"GroundReflectance",
"Wavelength",
"Geometry",
"Altitudes",
"PredefinedWavelengths",
]
70 changes: 50 additions & 20 deletions Py6S/Params/aeroprofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
# along with Py6S. If not, see <http://www.gnu.org/licenses/>.

from collections import defaultdict
#from sixs_exceptions import *

# from sixs_exceptions import *
from Py6S.sixs_exceptions import ParameterError
import sys


class AeroProfile:

"""Class representing options for Aerosol Profiles"""
Expand Down Expand Up @@ -70,13 +72,15 @@ def User(cls, **kwargs):
"""
d = defaultdict(lambda: 0, kwargs)

dust = d['dust']
water = d['water']
oceanic = d['oceanic']
soot = d['soot']
dust = d["dust"]
water = d["water"]
oceanic = d["oceanic"]
soot = d["soot"]

if (((dust + water + oceanic + soot) - 1) > 0.01):
raise ParameterError("Aerosol Profile", "User aerosol components don't sum to 1.0")
if ((dust + water + oceanic + soot) - 1) > 0.01:
raise ParameterError(
"Aerosol Profile", "User aerosol components don't sum to 1.0"
)

return "4 (User's Components)\n%f, %f, %f, %f" % (dust, water, oceanic, soot)

Expand Down Expand Up @@ -177,17 +181,29 @@ def SunPhotometerDistribution(cls, r, dvdlogr, refr_real, refr_imag):
if type(refr_real) is float:
refr_real = [refr_real] * 20
elif len(refr_real) != 20:
raise ParameterError("Aerosol Distribution Real Refractive Index", "You must specify the real part of the Refractive Index at 20 wavelengths.")
raise ParameterError(
"Aerosol Distribution Real Refractive Index",
"You must specify the real part of the Refractive Index at 20 wavelengths.",
)
except TypeError:
raise ParameterError("Aerosol Distribution Imaginary Refractive Index", "You must specify the imaginary part of the Refractive Index at 20 wavelengths.")
raise ParameterError(
"Aerosol Distribution Imaginary Refractive Index",
"You must specify the imaginary part of the Refractive Index at 20 wavelengths.",
)

try:
if type(refr_imag) is float:
refr_imag = [refr_imag] * 20
elif len(refr_imag) != 20:
raise ParameterError("Aerosol Distribution Imaginary Refractive Index", "You must specify the imaginary part of the Refractive Index at 20 wavelengths.")
raise ParameterError(
"Aerosol Distribution Imaginary Refractive Index",
"You must specify the imaginary part of the Refractive Index at 20 wavelengths.",
)
except TypeError:
raise ParameterError("Aerosol Distribution Imaginary Refractive Index", "You must specify the imaginary part of the Refractive Index at 20 wavelengths.")
raise ParameterError(
"Aerosol Distribution Imaginary Refractive Index",
"You must specify the imaginary part of the Refractive Index at 20 wavelengths.",
)

real = map(str, refr_real)
imag = map(str, refr_imag)
Expand All @@ -196,8 +212,8 @@ def SunPhotometerDistribution(cls, r, dvdlogr, refr_real, refr_imag):
real = list(real)
imag = list(imag)

comp += ' '.join(real) + '\n'
comp += ' '.join(imag) + '\n'
comp += " ".join(real) + "\n"
comp += " ".join(imag) + "\n"

return header + num + ds + comp + "0 no results saved"

Expand Down Expand Up @@ -248,13 +264,22 @@ def add_component(self, rmean, sigma, percentage_density, refr_real, refr_imag):
"""
if len(self.values) >= 4:
raise ParameterError("Aerosol Distribution components", "You can only add a maximum of 4 components")
raise ParameterError(
"Aerosol Distribution components",
"You can only add a maximum of 4 components",
)

if len(refr_real) != 20:
raise ParameterError("Aerosol Distribution Real Refractive Index", "You must specify the real part of the Refractive Index at 20 wavelengths.")
raise ParameterError(
"Aerosol Distribution Real Refractive Index",
"You must specify the real part of the Refractive Index at 20 wavelengths.",
)

if len(refr_imag) != 20:
raise ParameterError("Aerosol Distribution Imaginary Refractive Index", "You must specify the imaginary part of the Refractive Index at 20 wavelengths.")
raise ParameterError(
"Aerosol Distribution Imaginary Refractive Index",
"You must specify the imaginary part of the Refractive Index at 20 wavelengths.",
)

comp = "%f %f %f\n" % (rmean, sigma, percentage_density)
real = map(str, refr_real)
Expand All @@ -264,14 +289,19 @@ def add_component(self, rmean, sigma, percentage_density, refr_real, refr_imag):
real = list(real)
imag = list(imag)

comp += ' '.join(real) + '\n'
comp += ' '.join(imag) + '\n'
comp += " ".join(real) + "\n"
comp += " ".join(imag) + "\n"

self.values.append(comp)

def __str__(self):
result = "%d\n%f %f %d\n" % (self.numtype, self.rmin, self.rmax, len(self.values))
components = ''.join(self.values)
result = "%d\n%f %f %d\n" % (
self.numtype,
self.rmin,
self.rmax,
len(self.values),
)
components = "".join(self.values)
return result + components + "0 no results saved"

class UserProfile:
Expand Down
10 changes: 8 additions & 2 deletions Py6S/Params/altitudes.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def set_sensor_custom_altitude(self, altitude, aot=-1, water=-1, ozone=-1):
"""
if altitude < 0 or altitude >= 100:
raise ValueError('Sensor altitude must be > 0km and < 100km')
raise ValueError("Sensor altitude must be > 0km and < 100km")
self.sensor_altitude = -1 * altitude
self.aot = aot
self.water = water
Expand All @@ -98,4 +98,10 @@ def __str__(self):
if self.sensor_altitude is None:
return "%f\n%f\n" % (self.target_alt_pres, self.sensor_alt_pres)
else:
return "%f\n%f\n%f %f\n%f\n" % (self.target_alt_pres, self.sensor_altitude, self.water, self.ozone, self.aot)
return "%f\n%f\n%f %f\n%f\n" % (
self.target_alt_pres,
self.sensor_altitude,
self.water,
self.ozone,
self.aot,
)
22 changes: 16 additions & 6 deletions Py6S/Params/atmoscorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ def AtmosCorrLambertianFromRadiance(cls, radiance):
* ``radiance`` -- Radiance of the surface, as measured at the sensor.
"""
return """0 Atm. correction Lambertian
return (
"""0 Atm. correction Lambertian
%f radiance
""" % radiance
"""
% radiance
)

@classmethod
def AtmosCorrLambertianFromReflectance(cls, reflectance):
Expand All @@ -47,7 +50,9 @@ def AtmosCorrLambertianFromReflectance(cls, reflectance):
"""
return """0 Atm. correction Lambertian
%f reflectance
""" % (reflectance * -1)
""" % (
reflectance * -1
)

@classmethod
def AtmosCorrBRDFFromRadiance(cls, radiance):
Expand All @@ -57,9 +62,12 @@ def AtmosCorrBRDFFromRadiance(cls, radiance):
* ``radiance`` -- Radiance of the surface, as measured at the sensor.
"""
return """1 BRDF
return (
"""1 BRDF
%f radiance
""" % radiance
"""
% radiance
)

@classmethod
def AtmosCorrBRDFFromReflectance(cls, reflectance):
Expand All @@ -71,4 +79,6 @@ def AtmosCorrBRDFFromReflectance(cls, reflectance):
"""
return """1 BRDF
%f reflectance
""" % (reflectance * -1)
""" % (
reflectance * -1
)
Loading

0 comments on commit 6d8f1d7

Please sign in to comment.