<commit_before>from datetime import timedelta as td
from datetime import datetime as dt
from scipy import interpolate
import pyexiv2 as exiv
import numpy as np
import sqlite3
import csv

db_path = 'data/db/raw_log.db'
dt_testlog = 'test_data/sensus/sensus_test.csv'
gps_testlog = 'test_data/gps/GPS_20120722_194204.log'

def connection_and_cursor(path_to_db):
    """Connect to the db and pass back the connection and cursor"""
    conn = sqlite3.connect(path_to_db, detect_types=sqlite3.PARSE_DECLTYPES)
    cur = conn.cursor()
    return conn,cur

def read_gps_log(filepath):
    """Read in a single gps log and keep it in memory so we can search through
    it and find time stamped positions. We will want this to be additive so
    we can read in multiple log files and be able to search through all the 
    timestamped positions.
    
    To be decided:
    - Read in NMEA and GPX or just one? Other formats?
    - In addition to timestamp and position, should we read anything else? Accuracy?
    
    For reading NMEA, I can use pynmea. My gps logger records: '$GPGSA','$GPRMC',
     '$GPVTG','$GPGGA','$ADVER','$GPGSV'. pynmea will handle all except for $ADVER.
    """
    pass
    
def batch_read_gps_logs(directory):
    """Iteratively use read_gps_log on all files in a directory. Restrict to a 
    range of dates?"""
    pass
    
def depth_from_pressure(mbars):
    """Return a depth (in meters) from a pressure in millibars."""
    return (mbars - 1013.25)/100.52
<commit_msg>I made the pressure to depth conversion a little more accurate.<commit_after>from datetime import timedelta as td
from datetime import datetime as dt
from scipy import interpolate
#import pyexiv2 as exiv
import numpy as np
import sqlite3
import csv

db_path = 'data/db/raw_log.db'
dt_testlog = 'test_data/sensus/sensus_test.csv'
gps_testlog = 'test_data/gps/GPS_20120722_194204.log'

def connection_and_cursor(path_to_db):
    """Connect to the db and pass back the connection and cursor"""
    conn = sqlite3.connect(path_to_db, detect_types=sqlite3.PARSE_DECLTYPES)
    cur = conn.cursor()
    return conn,cur

def read_gps_log(filepath):
    """Read in a single gps log and keep it in memory so we can search through
    it and find time stamped positions. We will want this to be additive so
    we can read in multiple log files and be able to search through all the 
    timestamped positions.
    
    To be decided:
    - Read in NMEA and GPX or just one? Other formats?
    - In addition to timestamp and position, should we read anything else? Accuracy?
    
    For reading NMEA, I can use pynmea. My gps logger records: '$GPGSA','$GPRMC',
     '$GPVTG','$GPGGA','$ADVER','$GPGSV'. pynmea will handle all except for $ADVER.
    """
    pass
    
def batch_read_gps_logs(directory):
    """Iteratively use read_gps_log on all files in a directory. Restrict to a 
    range of dates?"""
    pass
    
def depth_from_pressure(mbars):
    """Return a depth (in meters) from a pressure in millibars. Calculated using
    1 atm = 1013.25 millibar and assuming 1 atm for every 9.9908 meters of sea
    water."""
    return (mbars - 1013.25)/102.02488795116682

{'fraction_non_alphanumeric': 0.07726409119696011, 'fraction_numerical': 0.026282457251424952, 'mean_word_length': 3.6116788321167883, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7102175', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1005, 'n_words': 391}