Skip to content

Commit

Permalink
handle obs_time through GenFile and to_xarray method
Browse files Browse the repository at this point in the history
  • Loading branch information
JessyBarrette committed Oct 14, 2022
1 parent d6d0767 commit 5083eac
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cioos_data_transform/cioos_data_transform/IosObsFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ def _save_variable(name, units, data_type="float32"):

def get_channel_attributes(self):
def _map_dtype(ios_type):
if ios_type.strip() in (None,""):
if ios_type.strip() in (None, ""):
return str
elif ios_type in ios_dtypes_to_python:
return ios_dtypes_to_python[ios_type]
Expand Down Expand Up @@ -662,6 +662,7 @@ def _format_attributes(attrs, prefix=""):
{chan: attrs["dtype"] for chan, attrs in channel_attributes.items()}
)
ds = df.to_xarray()
ds["observation_time"] = (ds.dims, self.obs_time)

# Generate global attributes
ds.attrs.update(_format_attributes(self.administration))
Expand Down Expand Up @@ -902,6 +903,8 @@ def import_data(self):


class GenFile(ObsFile):
"""General method used to parse the different IOS data types."""

def import_data(self):
self.type = None
self.start_dateobj, self.start_date = self.get_date(opt="start")
Expand Down Expand Up @@ -933,4 +936,7 @@ def import_data(self):
except Exception as e:
return 0

chnList = [i.strip().lower() for i in self.channels["Name"]]
if "date" in chnList and "time" in chnList:
self.get_obs_time()
return 1

0 comments on commit 5083eac

Please sign in to comment.