Skip to content

Commit

Permalink
Issue #43 - timeseries 2021 pits should be working
Browse files Browse the repository at this point in the history
  • Loading branch information
micah-prime committed Jan 29, 2025
1 parent d2df92c commit 2583bc6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
24 changes: 11 additions & 13 deletions scripts/upload/add_time_series_pits_2021.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pathlib import Path

from snowex_db.upload.layers import UploadProfileData
from snowex_db.utilities import db_session_with_credentials
from snowexsql.db import db_session_with_credentials

tz_map = {'US/Pacific': ['CA', 'NV', 'WA'],
'US/Mountain': ['CO', 'ID', 'NM', 'UT', 'MT'],
Expand All @@ -35,9 +35,7 @@ def main():
"SNEX21_TS_SP_Summary_SWE_v01_modified.csv"
]

with db_session_with_credentials(
db_name, "./credentials.json"
) as (session, engine):
with db_session_with_credentials("./credentials.json") as (engine, session):
# Upload all the site details files
site_files = list(data_dir.glob('**/*siteDetails*.csv'))
# Upload each site file
Expand All @@ -50,21 +48,21 @@ def main():
u.submit(session)

# find and upload all data files
for data_file in data_dir.glob("**/*_data_.*_v01\csv"):
for data_file in data_dir.glob("**/*_data_*_v01.csv"):
if "_gapFilledDensity_" in data_file.name:
# Use no-gap-filled density for the sole reason that
# Gap filled density for profiles where the scale was broken
# are just an empty file after the headers. We should
# Record that Nan density was collected for the profile
print(f"Not uploading gap filled density {data_file}")

# Instantiate the uploader
u = UploadProfileData(
str(data_file),
doi=doi,
timezone='MST',
)
u.submit(session)
else:
# Instantiate the uploader
u = UploadProfileData(
str(data_file),
doi=doi,
timezone='MST',
)
u.submit(session)


if __name__ == '__main__':
Expand Down
12 changes: 8 additions & 4 deletions snowex_db/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ class ExtendedSnowExMetadataVariables(SnowExMetadataVariables):
[
"profile_id", "timing", # SSA things
"smp_serial_number", "original_total_samples", # SMP things
"data_subsampled_to"
"data_subsampled_to", "wise_serial_no",
"parameter_codes",
"precip_rate" # prefer precip_type
], auto_remap=False
)
FLAGS = MeasurementDescription(
Expand All @@ -312,7 +314,7 @@ class ExtendedSnowExMetadataVariables(SnowExMetadataVariables):
)
COMMENTS = MeasurementDescription(
"comments", "Comments in the header", [
"comments", "pit comments"
"comments", "pit comments", "pit_comments"
], auto_remap=True
)
SLOPE = MeasurementDescription(
Expand Down Expand Up @@ -362,7 +364,8 @@ class ExtendedSnowExMetadataVariables(SnowExMetadataVariables):
], auto_remap=True
)
PRECIP = MeasurementDescription(
"precip", "Site notes on precipitation", ["precip"], auto_remap=True
"precip", "Site notes on precipitation",
["precip", "precip_type"], auto_remap=True
)
WIND = MeasurementDescription(
"wind", "Site notes on wind", ["wind"], auto_remap=True
Expand Down Expand Up @@ -458,7 +461,8 @@ class ExtendedSnowExPrimaryVariables(SnowExPrimaryVariables):
"ignore", "Ignore this",
[
"original_index", 'id', 'freq_mhz', 'camera',
'avgvelocity', 'equipment', 'version_number'
'avgvelocity', 'equipment', 'version_number',
'time_start/end'
]
)
SAMPLE_SIGNAL = MeasurementDescription(
Expand Down

0 comments on commit 2583bc6

Please sign in to comment.