#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Aug  7 12:30:51 2023

@author: benjaminallen
"""
#Run with pandas v1.3.4, numpy v1.20.3, and matplotlib v3.4.3

import pandas as pd
from datetime import datetime
import numpy as np
import matplotlib.pyplot as plt

h5File = "welldata.h5";

# Pick which well number (1-15)
wellnum=8

welldat = pd.read_hdf(h5File,'data/w'+str(wellnum))

del h5File
## Daily Fluid Elevation

time=[]

for n in welldat['Time']:
    time.append(datetime.strptime(n,'%m/%d/%Y %H:%M:%S'))

time=np.array(time)
#time=datetime.strptime(welldat['Time'],'%m/%d/%Y %H:%M:%S'))

timestep = pd.date_range(start=time[0], end='3/20/2020', freq='2d')
delev=[]
for f in np.arange(1,len(timestep)):
    subdat=welldat[(time>timestep[f-1]) & (time<timestep[f])]
    delev.append(np.nanmean(subdat['FluidElevation']))
timestep=timestep[1:len(timestep)]

plt.figure(figsize=(10,3))
plt.xlabel('Date')
plt.ylabel('Elevation (ft)')
plt.scatter(timestep, delev-delev[0])
plt.show()

## 