Skip to content

Commit

Permalink
More tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
micah-prime committed Aug 5, 2024
1 parent f79506b commit bd3ccf9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
19 changes: 15 additions & 4 deletions snowex_db/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,14 @@ def _read(self, filename):
str_cols = remap_data_names(str_cols, DataHeader.rename)

dtype = {k: str for k in str_cols}
df = pd.read_csv(filename, header=header_pos, names=str_cols,
usecols=range(n_cols), encoding='latin',
parse_dates=[0], dtype=dtype)
df = pd.read_csv(
filename, header=header_pos, names=str_cols,
usecols=range(n_cols), encoding='latin',
# parse_dates=[0],
dtype=dtype
)
# WHY IS THIS NEEDED?
df["date"] = pd.to_datetime(df["date"])

# Insure all values are 4 digits. Seems like some were not by accident
df['fname_sufix'] = df['fname_sufix'].apply(lambda v: v.zfill(4))
Expand Down Expand Up @@ -286,7 +291,7 @@ class ExtendedSnowExProfileVariables(SnowExProfileVariables):
)
IGNORE = MeasurementDescription(
"ignore", "Ignore this",
["original_index", 'id', 'freq_mhz', 'camera']
["original_index", 'id', 'freq_mhz', 'camera', 'avgvelocity']
)
SAMPLE_SIGNAL = MeasurementDescription(
'sample_signal', "Sample Signal",
Expand All @@ -302,6 +307,12 @@ class ExtendedSnowExProfileVariables(SnowExProfileVariables):
'specific_surface_area', "Specific Surface Area",
['specific_surface_area']
)
DATETIME = MeasurementDescription(
'datetime', "Combined date and time",
["Date/Local Standard Time", "date/local_standard_time", "datetime",
"date&time"],
True
)
DATE = MeasurementDescription(
'date', "Measurement Date (only date column)",
['date_dd_mmm_yy', 'date']
Expand Down
3 changes: 2 additions & 1 deletion snowex_db/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def build_data(self, data_name):

# Assign all meta data to every entry to the data frame
for k, v in self.hdr.info.items():
df[k] = v
if not pd.isna(v):
df[k] = v

df['type'] = data_name
df['date_accessed'] = self.date_accessed
Expand Down
5 changes: 4 additions & 1 deletion tests/test_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ class TestUploadSMPBatch(TableTestBase):
Test whether we can assign meta info from an smp log to 2 profiles
"""
args = [['S19M1013_5S21_20200201.CSV', 'S06M0874_2N12_20200131.CSV']]
kwargs = {'in_timezone': 'UTC', 'smp_log_f': 'smp_log.csv', 'units': 'Newtons'}
kwargs = {
'in_timezone': 'UTC',
'smp_log_f': 'smp_log.csv',
'units': 'Newtons'}
UploaderClass = UploadProfileBatch
TableClass = LayerData
attribute = 'depth'
Expand Down

0 comments on commit bd3ccf9

Please sign in to comment.