Skip to content

Instantly share code, notes, and snippets.

@mikshila
Created July 29, 2016 18:40
Show Gist options
  • Save mikshila/f520e96d40a2109d354e0ea5069c9bcf to your computer and use it in GitHub Desktop.
Save mikshila/f520e96d40a2109d354e0ea5069c9bcf to your computer and use it in GitHub Desktop.
Code for managing soil moisture data
from numpy import *
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
matplotlib.style.use('ggplot')
#read in the .dat file
DataIn = np.genfromtxt('CZC\czc13may.dat', delimiter=',', skip_header=1, )
#create column names
my_columns =['Year', 'JulianDay','HRMin', 'TmpC', 'RelHum', 'BattV', 'PPTmm', 'Temp5cm', 'Temp10cm', 'Temp15cm',
'Temp20cm', 'Temp50cm','Temp100cm','SM5cm','SM10cm', 'SM15cm', 'SM20cm', 'SM50cm','SM100cm']
#create data frame with data
df = pd.DataFrame(DataIn)
#assign column names to data frame
df.columns = my_columns
#make Julian Day the index
df.index = df.JulianDay
#plot the soil moisture data
plt.figure()
df.plot(x=df.index, y=['SM5cm','SM10cm', 'SM15cm', 'SM20cm', 'SM50cm','SM100cm'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment