Skip to content

Commit 9f1df7d

Browse files
authored
Merge pull request #95 from SnowEx/bsu_gpr
Uploads - Update BSU GPR to new script pattern
2 parents 282102d + c9c6d73 commit 9f1df7d

1 file changed

Lines changed: 29 additions & 31 deletions

File tree

scripts/upload/add_bsu_gpr.py

100644100755
Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,45 @@
11
"""
2-
Read in the SnowEx 2020 Decimated GPR data. Uploaded SWE, Two Way Travel, Depth, to
2+
Read in the SnowEx 2020 BSU GPR data. Uploaded SWE, Two Way Travel, Depth, to
33
the database.
4-
5-
1. Data must be downloaded via sh ../download/download_nsidc.sh
6-
2A. python run.py # To run all together all at once
7-
2B. python add_gpr.py # To run individually
8-
94
"""
10-
11-
from os.path import abspath, expanduser
12-
5+
from earthaccess_data import get_files
6+
from import_logger import get_logger
137
from snowexsql.db import db_session_with_credentials
8+
149
from snowex_db.upload.points import PointDataCSV
1510

11+
LOG = get_logger()
1612

17-
def main():
18-
file = ('../download/data/SNOWEX/SNEX20_BSU_GPR.001/'
19-
'2020.01.28/SNEX20_BSU_GPR_pE_01282020_01292020_02042020.csv')
13+
GPR_BSU_MAP = {
14+
"SNEX20_BSU_GPR": "10.5067/Q2LFK0QSVGS2"
15+
}
2016

17+
def main(file_list: list, doi: str) -> None:
18+
# Constant Metadata for the GPR data
2119
kwargs = {
22-
# Constant Metadata for the GPR data
23-
'campaign_name': 'Grand Mesa',
24-
'observer': 'Tate Meehan',
25-
'instrument': 'gpr',
26-
'instrument_model': 'pulse EKKO Pro multi-polarization 1 GHz GPR',
27-
'timezone': 'UTC',
28-
'doi': 'https://doi.org/10.5067/Q2LFK0QSVGS2',
29-
'name': 'BSU GPR Data',
20+
"campaign_name": "Grand Mesa",
21+
"site": "Grand Mesa",
22+
"observer": "Tate Meehan",
23+
"instrument": "gpr",
24+
"instrument_model": "1 GHz GPR",
25+
"timezone": "UTC",
26+
"doi": doi,
27+
"name": "BSU GPR Data",
3028
}
3129

32-
# Break out the path and make it an absolute path
33-
file = abspath(expanduser(file))
34-
35-
# Grab a db connection
3630
with db_session_with_credentials() as (_engine, session):
37-
# Instantiate the point uploader
38-
csv = PointDataCSV(file, **kwargs)
39-
# Push it to the database
40-
csv.submit(session)
31+
for file in file_list:
32+
# Skip the downsampled version
33+
if "downsampled" in file:
34+
continue
4135

42-
# return the number of errors for run.py can report it
43-
# return len(csv.errors)
36+
LOG.info(f"Uploading {file} file.")
37+
uploader = PointDataCSV(session, file, **kwargs)
38+
# Push it to the database
39+
uploader.submit()
4440

4541

4642
if __name__ == '__main__':
47-
main()
43+
for data_set_id, doi in GPR_BSU_MAP.items():
44+
with get_files(data_set_id, doi) as files:
45+
main(files, doi)

0 commit comments

Comments
 (0)