Skip to content

Commit

Permalink
Reduce warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
SorooshMani-NOAA committed Aug 13, 2024
1 parent 61c03f6 commit 16792fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
14 changes: 6 additions & 8 deletions stormevents/nhc/storms.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,9 @@ def nhc_storms(year: int = None) -> pandas.DataFrame:
url,
header=0,
names=columns,
parse_dates=["start_date", "end_date"],
date_parser=lambda x: (
pandas.to_datetime(x.strip(), format="%Y%m%d%H")
if x.strip() != "9999999999"
else numpy.nan
),
)
for i in ['start_date', 'end_date']:
storms[i] = pandas.to_datetime(storms[i], errors='coerce', format='%Y%m%d%H')

storms = storms.astype(
{"start_date": "datetime64[s]", "end_date": "datetime64[s]"},
Expand Down Expand Up @@ -107,7 +103,9 @@ def nhc_storms(year: int = None) -> pandas.DataFrame:
)
if len(gis_archive_storms) > 0:
gis_archive_storms[["start_date", "end_date"]] = pandas.to_datetime(numpy.nan)
storms = pandas.concat([storms, gis_archive_storms[storms.columns]])
storms = pandas.concat(
[storms, gis_archive_storms[storms.columns].astype(storms.dtypes.to_dict())]
)

for string_column in ["name", "class", "source"]:
storms.loc[storms[string_column].str.len() == 0, string_column] = pandas.NA
Expand Down Expand Up @@ -211,7 +209,7 @@ def nhc_storms_gis_archive(year: int = None) -> pandas.DataFrame:
year = list(range(NHC_GIS_ARCHIVE_START_YEAR, datetime.today().year + 1))

if isinstance(year, Iterable) and not isinstance(year, str):
years = sorted(pandas.unique(year))
years = sorted(pandas.unique(numpy.array(year)))
return pandas.concat(
[
nhc_storms_gis_archive(year)
Expand Down
5 changes: 2 additions & 3 deletions stormevents/nhc/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,7 @@ def atcf(self, advisory: ATCF_Advisory = None) -> DataFrame:
atcf["isotach_radius_for_NWQ"].astype("string").str.pad(5)
)

atcf["background_pressure"].fillna(method="ffill", inplace=True)
atcf["background_pressure"] = atcf["background_pressure"].astype(int)
atcf["background_pressure"] = atcf["background_pressure"].ffill().astype(int)
atcf["central_pressure"] = atcf["central_pressure"].astype(int)

press_cond_nobg = ~atcf["central_pressure"].isna() & (
Expand Down Expand Up @@ -1362,7 +1361,7 @@ def clamp(n, minn, maxn):
data={"forecast_hours": fcsthrs_12hr, "radius_of_maximum_winds": rmw_12hr},
index=dt_12hr,
)
rmw_rolling = df_temp.rolling(window="24.01 H", center=True, min_periods=1)[
rmw_rolling = df_temp.rolling(window="24.01 h", center=True, min_periods=1)[
"radius_of_maximum_winds"
].mean()
for valid_time, rmw in rmw_rolling.items():
Expand Down

0 comments on commit 16792fc

Please sign in to comment.