Skip to content

Commit

Permalink
optimize after profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasColombi committed Feb 8, 2025
1 parent f9cd50d commit 49ebfb2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions climada/hazard/tc_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import matplotlib.cm as cm_mp
import matplotlib.pyplot as plt
import netCDF4 as nc
import numba
import numpy as np
import pandas as pd
import pathos
Expand All @@ -52,6 +51,7 @@
from scipy.sparse import csr_matrix

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

View check run for this annotation

Jenkins - WCR / Pylint

unused-import

NORMAL: Unused csr_matrix imported from scipy.sparse
Raw output
Used when an imported module or variable is not used.
from shapely.geometry import LineString, MultiLineString, Point
from sklearn.metrics import DistanceMetric
from tqdm import tqdm

import climada.hazard.tc_tracks_synth
import climada.util.coordinates as u_coord
Expand Down Expand Up @@ -2924,8 +2924,8 @@ def compute_track_density(
lat_bins = np.linspace(-90, 90, int(180 / res))
lon_bins = np.linspace(-180, 180, int(360 / res))
# compute 2D density
hist_count = csr_matrix((len(lat_bins) - 1, len(lon_bins) - 1))
for track in tc_track.data:
hist_count = np.zeros((len(lat_bins) - 1, len(lon_bins) - 1))
for track in tqdm(tc_track.data, desc="Processing Tracks"):

# select according to wind speed
wind_speed = track.max_sustained_wind.values
Expand All @@ -2945,7 +2945,6 @@ def compute_track_density(
bins=[lat_bins, lon_bins],
density=False,
)
hist_new = csr_matrix(hist_new)
hist_new[hist_new > 1] = 1 if filter_tracks else hist_new
hist_count += hist_new

Expand Down

0 comments on commit 49ebfb2

Please sign in to comment.