# Linear interp data table.ndf This is a simple linear interpolation setup to generate data at "standard" points from a table Bill Howell 01Sep07 lf IS loaddefs 'C:\Documents and Settings\William Neil Howell\My Documents\Qnial\MY_NDFS\Linear interp data table.ndf' # Glaciation data from: Digitized, cleaned, augmented graph of glaciation, -6 to -3 My BP Felix M. Gradstein, editor "A Geologic Time Scale 2004" Cambridge University Press, March 2005, Poster accompaniement available from Geologic Survey of Canada http://www.stratigraphy.org/gts.htm http://www.stratigraphy.org/GTS04.pdf Engage Digitizer, http://digitizer.sourceforge.net/ # Quirks - currently only for single x and y variables the "x_std" must lie within the given data table x's!! x must INCREASE during the series!! data_columns, titles data_rows data_cols - provided by a data file via loaddefs for multi-independent pproblems - will have to modify this to identify & use nearest neighbors!! linear_interp IS OP dir_name fin_name fot_name x_ints { NONLOCAL data_columns data_cols data_rows titles ; % ; loaddefs (link dir_name fin_name) ; x y := data_columns ; IF (AND (last x > last x_ints) (first x < first x_ints)) THEN % ; fot := open (link dir_name fot_name) "w ; writefile fot (link '# ' fot_name) ; writefile fot ' ' ; writefile fot titles ; % ; i_last := 0 ; % ; FOR x_int WITH x_ints DO i_next := i_last ; REPEAT i_next := i_next + 1 ; UNTIL x@i_next > x_int ENDREPEAT ; i_last := i_next - 1 ; y_int := y@i_last + ( (x_int - x@i_last) / (x@i_next - x@i_last) * (y@i_next - y@i_last) ) ; writefile fot (link (string x_int) ', ' (string y_int)) ; ENDFOR ; % ; close fot ; ELSE writescreen 'Values of x for which interpolations are desired lie outside of given x-y dataset x-range' ; ENDIF ; } # Examples dir_name := 'C:\Documents and Settings\William Neil Howell\My Documents\Climate\delta 18O graph 6 My\' ; fin_name := 'Gradstein - digitized, cleaned, aumented data, -6 to 0 My.ndf' ; % this defines glacier_raw glacier_ky glacier_vol ; fot_name := 'Gradstein - linear interpolation each ky, -6 to 0 My.txt' ; x_ints := ((reverse tell (6001 - 9)) + 9) * -1 ; linear_interp dir_name fin_name fot_name x_ints # enddoc