Revisions and Bug Fixes to TTS Sediment Load Procedures
09Aug2005
- Added span and degree arguments to flowsrc for use when type="loess"
- Added loess optimizer to turbsscplot and qsscplot. Specifying span=0 when
type="loess" selects the span producing the lowest corrected AIC
(Akaike's Information Criterion) in a range of spans from 0.5 to 1.0. For
storm events, this seems to always result in span=1 because of the small sample
sizes. Optimization is therefore most useful for annual data sets.
- New option, type = "sqrt" for turbsscplot, qsscplot, turbsrc,
and flowsrc. Does linear regression on the square roots of x and y. Uses Duan's
smearing estimator for bias correction.
- For type = "power" in turbsrc and flowsrc, coefficient of variation
is approximated using the delta method.
- Error checks for missing turbidity and missing discharge in FLO data
- Outputs CV as NA instead of NULL so total() function will display it correctly
12Aug2005
- Fixed bug introduced on 09Aug2005, where turbsrc reported missing turbidity
when the missing values were outside the selected time period.
- Added bias="duan" option for type="logxy".
- Restructured functions so that both turbsrc and flowsrc call the same routines
when type="logxy".
22Aug2005
- Fixed bug introduced 12Aug2005. ttsplot was failing for objects created
using turbsrc(..., type="logxy") because turbidity was not included
on the prediction objects.
- Implemented turbsscplot(..., type="sqrt"). This was supposed to
have been implemented 09Aug2005.
01Sep2005
- Improved display of titles by turbsscplot() and qsscplot(). If computed,
AICc is returned along with the model (instead of being displayed on the plot).
- Changed the default value of span from 2/3 to 1 in turbsscplot(), qsscplot(),
turbsrc(), and flowsrc().
- Fixed bug in head() and tail(). These now work on vectors as well as data
frames and matrixes.
19Sep2005
- Fixed bug in turbsrc(). The "exclude" argument was not functioning
except when type="linear" or type="logx".
- Fixed bug with type="sqrt". where estimated load from turbsrc()
and flowsrc() was always zero.
- For type="sqrt", predictions are now set to zero for any x values
less than the x-intercept. Formerly regressions with a positive x-intercept
resulted in predictions with a local minimum at the x-intercept.
20Apr2006
- Updated ttsplot() to allow proper plotting of objects created with type="sqrt".
Had not been implemented last September.
- Added new routine, mismatches() to identify unmatched bottles in 'sed' and
'flo' objects. Used for diagnostics before running merge.flo().
- Default is adj=F for turbsrc(), flowsrc(), lineartime(), and ttsplot().
May have been so before, but is now documented as such in Rprocedures.pdf.
05May2006
- Modified lineartime() so that it works even when there are no samples contained
in the specified period. In this case you should definitely specify non-default
values for ssc1 and ssc2 arguments. You will get a straight line interpolation
for the period specified.
25May2006
- Minor revision to mismatches() function improves appearance of output when
no mismatches occur.
13Jun2006
- Fixed bug in turbsrc() and flowsrc() for type = "loess". Formerly
failed unless extrapolation was required. This was a simple fix in functions
turbloess() and flowloess().
- Enhanced qsscplot() and turbsscplot(). Both now return r squared and residual
standard error along with the fitted model.
16Jun2006
- Several functions (including turbsscplot, qsscplot, and lineartime) that
attach data frames were enhanced with error-trapping for name conflicts. The
user will now be instructed to remove any objects that conflict with names
in data frames attached by these functions. Name conflicts in the past caused
unexplained errors if objects with such names as turb, ssc, q, or dump existed
in the local workspace.
06Jul2006
- Fixed bad bug in flowsrc. Formerly failed to convert cfs to cumecs when
type="linear" or type="logx", hence predicted SSC and
loads were too high by a factor of 35.315. I'm not sure when this bug crept
in.
18Jul2006
- Minor fix to lineartime. Was failing when exactly one sample fell in estimation
period because R converts one-line data frames to a list. Why R does this
and not S-Plus I don't know. Workaround is to convert it back to a data frame.
- Minor fix to ttsplot. When tts1 object is of type "sqrt", it is
sometimes necessary to display separate lines for turbidity and estimated
SSC, because of Duan's bias correction, which is not a simple multiplicative
factor. If lines are within 0.5% of vertical display, we stick with a single
line, i.e. same implementation as for "logxy".
13Nov2006
- Eliminated error message generated when trying to compute stage tic locations
from discharge: Error in flumecalc(stn, stg) : couldn't find function "hy.default".
The water year is now always used when computing stage or discharge.
- Also fixed oldttsplot so that graphical parameters are always restored on
exit. Formerly when there was an error, graphical parameters were not restored,
so plot titles would not display properly in subsequent use of qsscplot or
turbsscplot.
31Jan2007
- Added cubictime function. Works just like lineartime (and takes same arguments),
but uses natural cubic spline interpolation to fit a smooth curve that passes
through all the sample points. But we still do not have a current .RData on
the website.
- This is a big embarrassment and I apologize if it has caused headaches but
I've just learned that the script that runs daily on the PSW template server
in Albany, CA had an error. After I FTP changes from Arcata to Albany, this
script copies my changes from the template server to the USFS server in Washington
DC, but it has not updated the .RData file (because its name begins with a
period) since August 2005!! The script was corrected today, so .RData is now
current for the first time in 18 months. There is a user responsibility here
too. Folks, if you're using this software and it does not act as advertised,
please let me know (email: jlewis01@fs.fed.us) so that I am aware of the problems
and can take steps to eliminate them.
15May2007
- Argument list of flowsqrt was incorrect, causing errors when evoking flowsrc
with type="sqrt".
- Eliminated warnings about duplicate x values that could occur under flowsrc
or turbsrc with type = "pairs"
- Improved make.chron and ymd2date
- Released new R workspace, tested with R version 2.2.0. Using this version
will avoid the following unavoidable errors in R 1.3.0
- R crashing when command window resized
- error when reading flo file: "Unimplemented feature in duplicate",
followed by R crashing
17Aug2007
- Changed DIS adjustment procedure when extrapolating, only for R version
2.2.0. Requires a column called max in the discoef
data frame, usually set to the highest point SSC represented in the data set
used to develop the regression equation for adjusting point to depth-integrated
SSC. To prevent reckless extrapolation as the regression line diverges y
= x, the regression is now forced to a slope of unity (i.e. parallel
to y = x) above x = max.
22Aug2007
- Added functions format.times and parse.format
to procedures for R 2.2.0. For some reason these are missing from newer versions
of the chron package. These are called by write.ssc.