|
1 | 1 | """ |
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 |
3 | 3 | 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 | | -
|
9 | 4 | """ |
10 | | - |
11 | | -from os.path import abspath, expanduser |
12 | | - |
| 5 | +from earthaccess_data import get_files |
| 6 | +from import_logger import get_logger |
13 | 7 | from snowexsql.db import db_session_with_credentials |
| 8 | + |
14 | 9 | from snowex_db.upload.points import PointDataCSV |
15 | 10 |
|
| 11 | +LOG = get_logger() |
16 | 12 |
|
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 | +} |
20 | 16 |
|
| 17 | +def main(file_list: list, doi: str) -> None: |
| 18 | + # Constant Metadata for the GPR data |
21 | 19 | 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", |
30 | 28 | } |
31 | 29 |
|
32 | | - # Break out the path and make it an absolute path |
33 | | - file = abspath(expanduser(file)) |
34 | | - |
35 | | - # Grab a db connection |
36 | 30 | 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 |
41 | 35 |
|
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() |
44 | 40 |
|
45 | 41 |
|
46 | 42 | 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