<filename>floodsystem/analysis.py
import matplotlib
import numpy as np

def polyfit (dates, levels, p):

    # dates = matplotlib.dates.date2num(dates)
    p_coeff = np.polyfit(dates,levels,p)
    # p_coeff = np.polyfit(dates-dates[0],levels,p)

    poly = np.poly1d(p_coeff)

    return poly, dates[0]
<filename>floodsystem/analysis.py
import matplotlib
import numpy as np

def polyfit (dates, levels, p):

    # dates = matplotlib.dates.date2num(dates)
    p_coeff = np.polyfit(dates,levels,p)
    # p_coeff = np.polyfit(dates-dates[0],levels,p)

    poly = np.poly1d(p_coeff)

    return poly, dates[0]
# dates = matplotlib.dates.date2num(dates) # p_coeff = np.polyfit(dates-dates[0],levels,p)