#!/opt/local/bin/wish -f # # Simple control panel to start the SSA toolkit. # Click on the QUIT button to terminate the program. # # # Define the vizualization package to be used, and initialize the viz pointer. # source /opt/local/bin/.spectra set auto_path "$auto_path /opt/local/bin /opt/local/bin" # # Process any user defined initialization commands # if [file exists $env(HOME)/.spectra] {source $env(HOME)/.spectra} if [file exists .spectra] {source .spectra} # # Create the main control panel # pack [frame .f0 -relief raised -borderwidth 3] -fill both pack [label .f0.title -text "Spectral Analysis Toolkit v 2.2"] -side top pack append .f0 [frame .f0.infile -bd 5] {fill pady 10} pack [frame .f0.l -bd 3] [frame .f0.r -bd 3] -side left -fill x -expand 1 label .f0.l.anal -text "Analysis Tools" button .f0.l.fft -text "FFT Spectrum" -command {gui_fft $datadir/$infile} -width 24 button .f0.l.mem -text "Maximum Entropy" -command {gui_mem $datadir/$infile} -width 24 button .f0.l.mtm -text "Multi-Taper Method" -command {gui_mtm $datadir/$infile} -width 24 button .f0.l.ssa -text "Singular Spectrum Analysis" -command {gui_ssa $datadir/$infile} -width 24 mkButton .f0.r.show {Show Log} {ShowLog .f0.r.show} mkButton .f0.r.quit QUIT {close_$viz ; destroy .} label .f0.infile.l -text "Input File" entry .f0.infile.e -relief sunken -width 32 -textvariable infile focus .f0.infile.e bind .f0.infile.e { set newpath [file dirname $infile] case $newpath in { {/*} {set datadir $newpath} . {} default { append datadir /$newpath set p [pwd] ; cd $datadir ; set datadir [pwd] ; cd $p } } set infile [file tail $infile] PlotNewFile $datadir $infile $viz } bind .f0.infile.e { if {[FDOpenFilename -dir $datadir] != ""} { set infile $FDvars(filename) set datadir $FDvars(directory) PlotNewFile $datadir $infile $viz } } set datadir . pack append .f0.infile .f0.infile.l {frame nw} .f0.infile.e bottom pack .f0.l.anal .f0.l.fft .f0.l.mem .f0.l.mtm .f0.l.ssa -side top pack .f0.r.show .f0.r.quit -side top # AUTOLAUNCH. Prepare the array of autolaunching switches for each application foreach app {fft mem mtm ssa} {set ${app}(launch) 0} foreach app $AUTOLAUNCH {set ${app}(launch) 1} # Start the visualization package init_$viz # Create the log file exec echo "\nSpectral Toolkit\n\n[exec date]\n" > spectra.log proc ShowLog {w} { global EDITOR if {![info exists EDITOR]} {set EDITOR emacs} eval exec $EDITOR spectra.log & } proc mkNewLog {infile} { if [file exists $infile] { exec echo "\nProcessing input file $infile" >> spectra.log } } proc PlotNewFile {datadir infile viz} { global wp if [file exists $datadir/$infile] { mkNewLog $infile if {![info exists wp]} {set wp [window_$viz "Input Signal"]} plot_$viz $wp linear "$datadir/$infile xy curve" } else { ErrorBox "I cannot find \"$infile\" in the directory \"$datadir\"." } }