Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ARGOS_service_data_converter.py #40

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions ARGOS_service_data_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
2018-03-13: Ingest two starter characters that represent time (hour and minute)
and output seconds since midnight.
2018-03-12: Add netcdf output option

2024-12-04: Modify pandas date_parse to be pandas 2.X compliant

Compatibility:
==============
python >=3.6 **tested**
python 2.7 **tested** but may break in the future
python >=3.9 **tested**

"""
import argparse
Expand Down Expand Up @@ -90,7 +90,6 @@ def get_data(fobj=None):
Basic Method to open files. Specific actions can be passes as kwargs for instruments

"""
argo_to_datetime = lambda date: datetime.datetime.strptime(date, "%Y %j %H%M")

header = [
"argosid",
Expand Down Expand Up @@ -120,10 +119,10 @@ def get_data(fobj=None):
"s3": str,
"s4": str,
},
parse_dates=[["year", "doy", "hhmm"]],
date_parser=argo_to_datetime,
)

df["year_doy_hhmm"] = pd.to_datetime(arg=df.pop("year").str.cat(df.pop("doy")).str.cat(df.pop("hhmm")),
format="%Y%j%H%M")
df["longitude"] = df["longitude"] * -1 # convert to +W
df["longitude"] = df.longitude.round(3)
df["latitude"] = df.latitude.round(3)
Expand All @@ -148,7 +147,6 @@ def get_data(fobj=None):
Basic Method to open files. Specific actions can be passes as kwargs for instruments

"""
argo_to_datetime = lambda date: datetime.datetime.strptime(date, "%Y %j %H%M")

header = [
"argosid",
Expand Down Expand Up @@ -186,10 +184,10 @@ def get_data(fobj=None):
"s7": str,
"s8": str,
},
parse_dates=[["year", "doy", "hhmm"]],
date_parser=argo_to_datetime,
)

df["year_doy_hhmm"] = pd.to_datetime(arg=df.pop("year").str.cat(df.pop("doy")).str.cat(df.pop("hhmm")),
format="%Y%j%H%M")
df["longitude"] = df["longitude"] * -1 # convert to +W
df["longitude"] = df.longitude.round(3)
df["latitude"] = df.latitude.round(3)
Expand Down Expand Up @@ -266,7 +264,6 @@ def get_data(fobj=None, time="current"):

Date,AT,RH,WS,WD,BP,QS,AZ,BV
"""
argo_to_datetime = lambda date: datetime.datetime.strptime(date, "%Y %j %H%M")

header = [
"argosid",
Expand Down Expand Up @@ -322,14 +319,13 @@ def get_data(fobj=None, time="current"):
usecols=columns,
on_bad_lines='warn',
dtype=dtype,
parse_dates=[["year", "doy", "hhmm"]],
date_parser=argo_to_datetime,
)

df["year_doy_hhmm"] = pd.to_datetime(arg=df.pop("year").str.cat(df.pop("doy")).str.cat(df.pop("hhmm")),
format="%Y%j%H%M")
df["longitude"] = df["longitude"] * -1 # convert to +W

df.set_index(pd.DatetimeIndex(df["year_doy_hhmm"]), inplace=True)
# df.drop('year_doy_hhmm',axis=1,inplace=True)

return df

Expand Down
Loading