Skip to content

Commit

Permalink
final run of yapf
Browse files Browse the repository at this point in the history
  • Loading branch information
fnattino committed Nov 20, 2023
1 parent be9e79c commit 063259d
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 49 deletions.
8 changes: 3 additions & 5 deletions dhdt/auxiliary/handler_mgrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@

supported_drivers['KML'] = 'rw'

MGRS_TILING_URL = (
"https://sentinels.copernicus.eu/documents/247904/1955685/"
"S2A_OPER_GIP_TILPAR_MPC__20151209T095117_V20150622T000000"
"_21000101T000000_B00.kml"
)
MGRS_TILING_URL = ("https://sentinels.copernicus.eu/documents/247904/1955685/"
"S2A_OPER_GIP_TILPAR_MPC__20151209T095117_V20150622T000000"
"_21000101T000000_B00.kml")

MGRS_TILING_FILENAME = 'sentinel2_tiles_world.geojson'
MGRS_TILING_DIR_DEFAULT = os.path.join('.', 'data', 'MGRS')
Expand Down
4 changes: 3 additions & 1 deletion dhdt/generic/handler_landsat.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def get_wrs_url(version=2):
""" # noqa: E501
assert isinstance(version, int), 'please provide an integer'
assert 0 < version < 3, 'please provide a correct version, i.e.: {1,2}'
wrs_url = 'https://d9-wret.s3.us-west-2.amazonaws.com/assets/palladium/production/s3fs-public/atoms/files/WRS' + str(version) + '_descending_0.zip' # noqa: E501
wrs_url = (
'https://d9-wret.s3.us-west-2.amazonaws.com/assets/palladium/production/s3fs-public/atoms/files/WRS' # noqa: E501
+ str(version) + '_descending_0.zip')
return wrs_url


Expand Down
13 changes: 3 additions & 10 deletions dhdt/generic/mapping_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,16 +989,9 @@ def get_bbox(geoTransform, rows=None, cols=None):
def get_geoTransform(bbox, dx, dy):
dx = float(dx)
dy = float(dy)
geoTransform = (
bbox[0],
+dx,
0.,
bbox[3],
0.,
-dy,
int(np.floor((bbox[3] - bbox[2]) / dy)),
int(np.floor((bbox[1] - bbox[0]) / dx))
)
geoTransform = (bbox[0], +dx, 0., bbox[3], 0., -dy,
int(np.floor((bbox[3] - bbox[2]) / dy)),
int(np.floor((bbox[1] - bbox[0]) / dx)))
return geoTransform


Expand Down
37 changes: 22 additions & 15 deletions dhdt/generic/orbit_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ def orbital_calculation(ltime, radius, inclination, period, ω_0, λ_0):
return Px


def observation_calculation(ltime, Sat, Gx, radius, inclination,
period, ω_0, λ_0):
def observation_calculation(ltime, Sat, Gx, radius, inclination, period, ω_0,
λ_0):
"""
Parameters
Expand Down Expand Up @@ -679,37 +679,44 @@ def partial_obs(ltime, Sat, Gx, ϕ, λ, radius, inclination, period):
are_two_arrays_equal(Sat, Gx)
P_0 = np.zeros((3, 4, ltime.size))
ω_0, λ_0 = _omega_lon_calculation(ϕ, λ, inclination)
Dx = observation_calculation(ltime, Sat, Gx, radius, inclination,
period, ω_0, λ_0)
Dx = observation_calculation(ltime, Sat, Gx, radius, inclination, period,
ω_0, λ_0)
pert_var = ['lat', 'lon', 'radius', 'inclination']
Pert = np.array([1E-5, 1E-5, 1E+1, 1E-4])
for idx, pert in enumerate(Pert):
(ϕ, λ, radius, inclination) = _pert_param(idx, +pert, ϕ, λ,
radius, inclination)
(ϕ, λ, radius, inclination) = _pert_param(idx, +pert, ϕ, λ, radius,
inclination)

ω_0, λ_0 = _omega_lon_calculation(ϕ, λ, inclination)
Dp = observation_calculation(ltime, Sat, Gx, radius,
inclination, period, ω_0, λ_0)
Dp = observation_calculation(ltime, Sat, Gx, radius, inclination,
period, ω_0, λ_0)
P_0[0, idx, :] = np.divide(Dp[:, 0] - Dx[:, 0], pert)
P_0[1, idx, :] = np.divide(Dp[:, 1] - Dx[:, 1], pert)
P_0[2, idx, :] = np.divide(Dp[:, 2] - Dx[:, 2], pert)
(ϕ, λ, radius, inclination) = _pert_param(idx, -pert, ϕ, λ,
radius, inclination)
(ϕ, λ, radius, inclination) = _pert_param(idx, -pert, ϕ, λ, radius,
inclination)
return P_0


def partial_tim(ltime, Sat, Gx, ϕ, λ, radius, inclination, period,
def partial_tim(ltime,
Sat,
Gx,
ϕ,
λ,
radius,
inclination,
period,
pertubation=.1):
are_two_arrays_equal(Sat, Gx)
P_1 = np.zeros((3, 1, ltime.size))
ω_0, λ_0 = _omega_lon_calculation(ϕ, λ, inclination)
Dx = observation_calculation(ltime, Sat, Gx, radius, inclination,
period, ω_0, λ_0)
Dx = observation_calculation(ltime, Sat, Gx, radius, inclination, period,
ω_0, λ_0)

# pertubation in the time domain
ltime += pertubation
Dp = observation_calculation(ltime, Sat, Gx, radius, inclination,
period, ω_0, λ_0)
Dp = observation_calculation(ltime, Sat, Gx, radius, inclination, period,
ω_0, λ_0)
ltime -= pertubation

P_1[0, 0, ...] = np.divide(Dp[..., 0] - Dx[..., 0], pertubation)
Expand Down
34 changes: 25 additions & 9 deletions dhdt/processing/coupling_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,20 @@ def match_pair(I1,
return X2_grd, Y2_grd, match_metric


def match_image(Z, M, D, geoTransform, id_1, id_2, X_grd, Y_grd,
temp_radius=2**3, search_radius=2**4,
correlator='robu_corr', subpix='moment',
metric='peak_abs', **kwargs):
def match_image(Z,
M,
D,
geoTransform,
id_1,
id_2,
X_grd,
Y_grd,
temp_radius=2**3,
search_radius=2**4,
correlator='robu_corr',
subpix='moment',
metric='peak_abs',
**kwargs):
# combating import loops
from .matching_tools_organization import (list_differential_correlators,
list_frequency_correlators,
Expand All @@ -334,17 +344,23 @@ def match_image(Z, M, D, geoTransform, id_1, id_2, X_grd, Y_grd,
I_grd, J_grd = map2pix(geoTransform, X_grd, Y_grd)

# inside selection and padding
IN = np.logical_and.reduce((I_grd >= 0, I_grd < (Z.shape[0] - 1),
J_grd >= 0, J_grd < (Z.shape[1] - 1)))
IN = np.logical_and.reduce((I_grd >= 0, I_grd < (Z.shape[0] - 1), J_grd
>= 0, J_grd < (Z.shape[1] - 1)))

M2_new = pad_radius(M2, ds2)
i2 += ds2
j2 += ds2

I1, I2, i1, j1, i2, j2, IN = pad_images_and_filter_coord_list(
I1, I2, geoTransform1, geoTransform2, X_grd, Y_grd,
temp_radius, search_radius, same=True
)
I1,
I2,
geoTransform1,
geoTransform2,
X_grd,
Y_grd,
temp_radius,
search_radius,
same=True)

return

Expand Down
14 changes: 5 additions & 9 deletions dhdt/processing/matching_tools_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@
get_correlation_metric,
hessian_spread,
list_matching_metrics)
from .matching_tools_spatial_subpixel import (get_top_2d_gaussian,
get_top_birchfield,
get_top_blais, get_top_centroid,
get_top_equiangular,
get_top_esinc, get_top_gaussian,
get_top_mass, get_top_moment,
get_top_parabolic,
get_top_paraboloid, get_top_ren,
get_top_triangular)
from .matching_tools_spatial_subpixel import (
get_top_2d_gaussian, get_top_birchfield, get_top_blais, get_top_centroid,
get_top_equiangular, get_top_esinc, get_top_gaussian, get_top_mass,
get_top_moment, get_top_parabolic, get_top_paraboloid, get_top_ren,
get_top_triangular)


# admin
Expand Down

0 comments on commit 063259d

Please sign in to comment.