Skip to content

Commit

Permalink
Updated script to work locally on server
Browse files Browse the repository at this point in the history
  • Loading branch information
micahjohnson150 committed Aug 18, 2024
1 parent c6ce183 commit f71c095
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions scripts/remove_data/remove_bad_utm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
A set of data got uploaded with a bad EPSG value. This script removes them
"""
from snowexsql.data import LayerData, PointData
from snowexsql.api import DB_NAME, db_session
from snowexsql.db import get_db


def delete_data(session, qry):
ans = input(f"You are about to delete {qry.count()}, Continue? (Y/n)")
Expand All @@ -14,26 +15,31 @@ def delete_data(session, qry):


def main():
credentials = ''

print('Querying DB for GPR with bad EPSG...')
# Remove GPR data with bad EPSG in AK
with (db_session(DB_NAME) as (session, engine)):
# Filter to alaska
qry = session.query(PointData).filter(PointData.utm_zone==6)
# Filter to GPR by Randall
qry = qry.filter(PointData.observers=='Randall Bonnell')
qry = qry.filter(PointData.instrument == 'pulseEkko pro 1 GHz GPR')
delete_data(session, qry)

# Delete the AK pits with bad EPSG.
qry = session.query(LayerData).filter(LayerData.utm_zone==6)
types_pit = ['sample_signal', 'grain_size', 'density',
'reflectance', 'permittivity', 'lwc_vol',
'manual_wetness', 'equivalent_diameter',
'specific_surface_area', 'grain_type','temperature',
'hand_hardness'
]
qry = qry.filter(PointData.types.in_(types_pit))
delete_data(session, qry)
engine, session = get_db("localhost/snowex", credentials=credentials)
# Filter to AK
qry = session.query(PointData).filter(PointData.utm_zone==6)
# Filter to GPR used in AK by CSU
qry = qry.filter(PointData.observers=='Randall Bonnell')
qry = qry.filter(PointData.instrument == 'pulseEkko pro 1 GHz GPR')
delete_data(session, qry)

print('Querying DB for Pits with bad EPSG...')
# Delete the AK pits with bad EPSG.
qry = session.query(LayerData).filter(LayerData.utm_zone==6)
types_pit = ['sample_signal', 'grain_size', 'density',
'reflectance', 'permittivity', 'lwc_vol',
'manual_wetness', 'equivalent_diameter',
'specific_surface_area', 'grain_type','temperature',
'hand_hardness'
]
qry = qry.filter(LayerData.types.in_(types_pit))
delete_data(session, qry)

session.close()

if __name__ == '__main__':
main()

0 comments on commit f71c095

Please sign in to comment.