Skip to content

Commit

Permalink
fix typeError
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasColombi committed Feb 18, 2025
1 parent 9919d11 commit 0b6a81e
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions climada/hazard/tc_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3029,12 +3029,12 @@ def compute_track_density(

limit_ratio = 1.12 * 1.1 # record tc speed 112km/h -> 1.12°/h + 10% margin

#if tc_track.data[0].time_step[0].item() > res / limit_ratio:
# warnings.warn(
# "The time step is too big for the current resolution. For the desired resolution, \n"
# f"apply a time step of {res/limit_ratio}h."
#)
if res < 0.1:
if tc_track.data[0].time_step[0].values > res / limit_ratio:
warnings.warn(
"The time step is too big for the current resolution. For the desired resolution, \n"
f"apply a time step of {res/limit_ratio}h."
)
elif res < 0.1:
warnings.warn(
"The resolution is too high. The computation might take several minutes \n"
"to hours. Consider using a resolution below 0.1°."
Expand Down Expand Up @@ -3069,7 +3069,31 @@ def compute_track_density(
hist_count += hist_new

if density:
grid_area, _ = u_coord.compute_grid_cell_area(res=res)
hist_count = hist_count / grid_area
hist_count = normalize_density()

Check warning on line 3072 in climada/hazard/tc_tracks.py

View check run for this annotation

Jenkins - WCR / Pylint

assignment-from-no-return

HIGH: Assigning result of a function call, where the function has no return
Raw output
Used when an assignment is done on a function call but the inferred functiondoesn't return anything.

Check warning on line 3072 in climada/hazard/tc_tracks.py

View check run for this annotation

Jenkins - WCR / Pylint

no-value-for-parameter

HIGH: No value for argument 'res' in function call
Raw output
Used when a function call passes too few arguments.

return hist_count, lat_bins, lon_bins


def compute_genesis_index(track, lat_bins, lon_bins):

Check warning on line 3077 in climada/hazard/tc_tracks.py

View check run for this annotation

Jenkins - WCR / Pylint

missing-function-docstring

LOW: Missing function or method docstring
Raw output
no description found

# Extract the first lat and lon from each dataset
first_lats = np.array([ds.lat.values[0] for ds in track])
first_lons = np.array([ds.lon.values[0] for ds in track])

# compute 2D density of genesis points
hist_count, _, _ = np.histogram2d(
first_lats,
first_lons,
bins=[lat_bins, lon_bins],
density=False,
)

return hist_count


def normalize_density(res):

Check warning on line 3094 in climada/hazard/tc_tracks.py

View check run for this annotation

Jenkins - WCR / Pylint

missing-function-docstring

LOW: Missing function or method docstring
Raw output
no description found

grid_area, _ = u_coord.compute_grid_cell_area(res=res)
hist_count = hist_count / grid_area

Check warning on line 3097 in climada/hazard/tc_tracks.py

View check run for this annotation

Jenkins - WCR / Pylint

used-before-assignment

HIGH: Using variable 'hist_count' before assignment
Raw output
Used when a local variable is accessed before it's assignment.

pass

Check warning on line 3099 in climada/hazard/tc_tracks.py

View check run for this annotation

Jenkins - WCR / Pylint

unnecessary-pass

NORMAL: Unnecessary pass statement
Raw output
Used when a "pass" statement that can be avoided is encountered.

0 comments on commit 0b6a81e

Please sign in to comment.