Skip to content

Commit

Permalink
Remove attribute-style accesses in storm_europe and correct mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
luseverin committed Aug 18, 2024
1 parent 3e990df commit 117257d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions climada/hazard/storm_europe.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,19 @@ def _read_one_nc(cls, file_name, centroids, intensity_thres):

# xarray does not penalise repeated assignments, see
# http://xarray.pydata.org/en/stable/data-structures.html
stacked = ncdf.max_wind_gust.stack(
stacked = ncdf['max_wind_gust'].stack(
intensity=('latitude', 'longitude', 'time')
)
stacked = stacked.where(stacked > intensity_thres)
stacked = stacked.fillna(0)

# fill in values from netCDF
ssi_wisc = np.array([float(ncdf.ssi)])
ssi_wisc = np.array([float(ncdf.attrs['ssi'])])
intensity = sparse.csr_matrix(stacked)
new_haz = cls(ssi_wisc=ssi_wisc,
intensity=intensity,
event_name=[ncdf.storm_name],
date=np.array([datetime64_to_ordinal(ncdf.time.data[0])]),
event_name=[ncdf.attrs['storm_name']],
date=np.array([datetime64_to_ordinal(ncdf['time'].data[0])]),
# fill in default values
centroids=centroids,
event_id=np.array([1]),
Expand Down
2 changes: 1 addition & 1 deletion climada/hazard/tc_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def from_ibtracs_netcdf(cls, provider=None, rescale_windspeeds=True, storm_id=No

# A track that crosses the antimeridian in IBTrACS might be truncated by `t_msk` in
# such a way that the remaining part is not crossing the antimeridian:
if (track_ds['lon'].lon.values > 180).all():
if (track_ds['lon'].values > 180).all():
track_ds['lon'] -= 360

# set time_step in hours
Expand Down

0 comments on commit 117257d

Please sign in to comment.