-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from SnowEx/add_more_gpr_datasets_#2
Added CSU and UNM gpr datasets, fixed #2
- Loading branch information
Showing
10 changed files
with
202 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
""" | ||
Read in the SnowEx 2020 Colorado State GPR data. Uploaded SWE, Two Way Travel, Depth, to | ||
the database. | ||
1. Data must be downloaded via sh ../download/download_nsidc.sh | ||
2A. python run.py # To run all together all at once | ||
2B. python add_gpr.py # To run individually | ||
""" | ||
|
||
import time | ||
from os.path import abspath, expanduser, join | ||
|
||
import pandas as pd | ||
|
||
from snowexsql.db import get_db | ||
from snowex_db.upload import * | ||
|
||
|
||
def main(): | ||
file = '../download/data/SNOWEX/SNEX20_GM_CSU_GPR.001/2020.02.06/SNEX20_GM_CSU_GPR_1GHz_v01.csv' | ||
|
||
kwargs = { | ||
# Keyword argument to upload depth measurements | ||
'depth_is_metadata': False, | ||
|
||
# Constant Metadata for the GPR data | ||
'site_name': 'Grand Mesa', | ||
'observers': 'Randall Bonnell', | ||
'instrument': 'pulse EKKO Pro multi-polarization 1 GHz GPR', | ||
'in_timezone': 'UTC', | ||
'out_timezone': 'UTC', | ||
'doi': 'https://doi.org/10.5067/S5EGFLCIAB18', | ||
'epsg': 26912 | ||
} | ||
|
||
# Break out the path and make it an absolute path | ||
file = abspath(expanduser(file)) | ||
|
||
# Grab a db connection to a local db named snowex | ||
db_name = 'localhost/snowex' | ||
engine, session = get_db(db_name, credentials='./credentials.json') | ||
|
||
# Instantiate the point uploader | ||
csv = PointDataCSV(file, **kwargs) | ||
# Push it to the database | ||
csv.submit(session) | ||
|
||
# Close out the session with the DB | ||
session.close() | ||
|
||
# return the number of errors for run.py can report it | ||
return len(csv.errors) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
""" | ||
Read in the SnowEx 2020 UNM GPR. Upload SWE, Two Way Travel, Depth, to | ||
the database. | ||
1. Data must be downloaded via sh ../download/download_nsidc.sh | ||
2A. python run.py # To run all together all at once | ||
2B. python add_gpr.py # To run individually | ||
""" | ||
|
||
import time | ||
from os.path import abspath, expanduser, join | ||
|
||
import pandas as pd | ||
|
||
from snowexsql.db import get_db | ||
from snowex_db.upload import * | ||
|
||
|
||
def main(): | ||
filename = '../download/data/SNOWEX/SNEX20_UNM_GPR.001/2020.01.28/SNEX20_UNM_GPR.csv' | ||
|
||
kwargs = { | ||
# Keyword argument to upload depth measurements | ||
'depth_is_metadata': False, | ||
|
||
# Constant Metadata for the GPR data | ||
'site_name': 'Grand Mesa', | ||
'observers': 'Ryan Webb', | ||
'instrument': None, # See loop below | ||
'in_timezone': 'UTC', | ||
'out_timezone': 'UTC', | ||
'doi': 'https://doi.org/10.5067/WE9GI1GVMQF6', | ||
'epsg': 26912 | ||
} | ||
|
||
# Break out the path and make it an absolute path | ||
filename = abspath(expanduser(filename)) | ||
|
||
# Grab a db connection to a local db named snowex | ||
db_name = 'localhost/snowex' | ||
engine, session = get_db(db_name, credentials='./credentials.json') | ||
|
||
# Read in for management of instruments | ||
df_raw = pd.read_csv(filename) | ||
low_freq = df_raw['FREQ_MHz'] == 800 | ||
hi_freq = df_raw['FREQ_MHz'] == 1600 | ||
|
||
# Instantiate the point uploader | ||
csv = PointDataCSV(filename, **kwargs) | ||
|
||
# Convert depth to centimeters | ||
csv.log.info('Converting depth to centimeters...') | ||
csv.df['depth'] = csv.df['depth'].mul(100) | ||
df_original = csv.df.copy() | ||
|
||
# Loop over the two insturments in the file and separate them for two submissions | ||
for hz, ind in [(800, low_freq), (1600, hi_freq)]: | ||
instrument = f'Mala {hz} MHz GPR' | ||
csv.log.info(f'Isolating {instrument} data for upload.') | ||
csv.df = df_original[ind].copy() | ||
# Change the instrument. | ||
csv.df['instrument'] = instrument | ||
# Push it to the database | ||
csv.submit(session) | ||
|
||
# Close out the session with the DB | ||
session.close() | ||
|
||
# return the number of errors for run.py can report it | ||
return len(csv.errors) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
DATE_dd_mmm_yy,TIME_GMT,FREQ_MHz,LONG,LAT,ELEV_m,NORTHING,EASTING,UTMzone,TWT_ns,DEPTH_m,SWE_mm | ||
28-Jan-20,16:43,800,-108.1340183,39.0296597,3157.1,4323978.711,748088.3947,12,8.97,1.09,299 | ||
29-Jan-20,20:35,800,-108.139506,39.014194,3106.94,4322247.041,747667.2868,12,7.34,0.9,244 | ||
30-Jan-20,22:20,800,-108.1622217,39.03095167,3110.8,4324045.489,745642.1231,12,9.55,1.17,318 | ||
31-Jan-20,20:04,800,-108.1762593,39.02676284,3090.19,4323542.671,744441.2436,12,8.73,1.07,291 | ||
4-Feb-20,16:00,1600,-108.1391578,39.03117433,3141.17,4324132.814,747638.1351,12,7.27,0.89,242 | ||
5-Feb-20,19:04,1600,-108.1715773,39.02401467,3103.3,4323250.231,744856.1064,12,6.15,0.75,205 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters