def pixelfit(obs, i, times, series, timeslice=slice(None,None,None)) : 
    """Fits a series object to the time series of data contained within
    a single pixel, optionally extracting the specified time period. 
    Coefficients of the fit have been stored in the 
    series. The rsquared of the fit is returned."""
    # extract the domain over which the fit applies
    t_extract    = times[timeslice]
    obs_extract  = obs[timeslice,i]
    return series.fit(t_extract, obs_extract)