├── Disclaimer.docx ├── Disclaimer.txt ├── Getting Started.txt ├── LICENSE ├── License.doc ├── License.txt ├── Older_DSI_UserGuides ├── 0A_PSMtools_Description2.doc ├── 0B_DSItools_FunctionalityTableA.doc ├── 1A_PSMtools_UserGuide2.doc ├── 1B_Ringdown_UGuideA.doc ├── 1C_Ringdown_UGuideB.doc ├── 1D_PSMtools_UGuide2_Filtering.doc ├── Contents.txt ├── DSI_InstallNoteD.doc ├── DSI_Tools_FunctionalityTable.pdf ├── DSItools_FunctionalityTableA.doc ├── GUIfeatures062403B.ppt └── PSMlaunchMacro Worknote.doc ├── PSMtools Source ├── PSDScase_Ex2A.mat ├── PSDScase_Ex2AngFrq.mat ├── PSDScase_Ex2MWB.mat ├── PSMPaths1.m ├── PSMlaunch.m ├── PSMlaunchMacro.m ├── PSMpcode.m ├── PSMtools │ ├── AddCom.m │ ├── Alias1.m │ ├── BstringOut.m │ ├── CD2loc.m │ ├── CaseComPlot.m │ ├── CaseTags.m │ ├── Char2Blank.m │ ├── CharTrim.m │ ├── CkTsteps.m │ ├── DSAspec1.m │ ├── DSAspec2.m │ ├── DataTrim.m │ ├── Date2PSM.m │ ├── Detrend1.m │ ├── EScan │ │ ├── Batch_Event_Scan.m │ │ ├── Batch_Event_Scan_config.m │ │ ├── EventScan1_config.m │ │ ├── funESAlarmLog.m │ │ ├── funESFreqBoundary.m │ │ ├── funEventSummary.m │ │ ├── funEventTimeSummary.m │ │ ├── funFindStr.m │ │ ├── funLoadMacro.m │ │ ├── subCheckValid.m │ │ ├── subDispPrompt.m │ │ └── subMacroEdit.m │ ├── EndChecks.m │ ├── EventScan1.m │ ├── IndSift.m │ ├── Multplot.m │ ├── PSM2Date.m │ ├── PSMButr4.m │ ├── PSMSinc.m │ ├── PSMTload.m │ ├── PSM_ButtonsP2.m │ ├── PSMautocov.m │ ├── PSMbox.m │ ├── PSMbrowser.m │ ├── PSMcov1.m │ ├── PSMfilt.m │ ├── PSMhist1.m │ ├── PSMlabl.m │ ├── PSMload.m │ ├── PSMnamesCk.m │ ├── PSMparse.m │ ├── PSMplot2.m │ ├── PSMreload.m │ ├── PSMresamp.m │ ├── PSMring1.m │ ├── PSMsave.m │ ├── PSMscanDirectory.m │ ├── PSMscanFiles.m │ ├── PSMsigCors.m │ ├── PSMspec1.m │ ├── PSMspec1saveA.m │ ├── PSMunwrap.m │ ├── PTIcase_Ex1N.m │ ├── PickList1.m │ ├── PickList2.m │ ├── PickSigsN.m │ ├── SWXdisp.m │ ├── SWXwrite.m │ ├── SetExtPSMT.m │ ├── ShowRange.m │ ├── SigSelect.m │ ├── SincHP.m │ ├── SpecialDisp.m │ ├── StringOut.m │ ├── Tabs2Blanks.m │ ├── TrfCalcS.m │ ├── TrfCalcZ.m │ ├── TrigSync.m │ ├── cparseR.m │ ├── cread.m │ ├── db.m │ ├── ezbutter.m │ ├── funDSIMat2DST02.m │ ├── funMatlab2dst.m │ ├── funMatlab2dst02.m │ ├── glabel.m │ ├── hanning2.m │ ├── hanning2sq.m │ ├── names2chans.m │ ├── patchN.m │ ├── promptnv.m │ ├── promptyn.m │ ├── sinc1.m │ ├── unwrapN.m │ └── vec2mat.m ├── PSMtools_Utilities │ ├── COMTRADE Utilities │ │ ├── CFFload.m │ │ └── funReadCFF.m │ ├── DFR_Utilities │ │ └── DFRread.m │ ├── PDC_Utilities │ │ ├── PDCCSVload.m │ │ ├── PDCcalcA.m │ │ ├── PDCcalcC.m │ │ ├── PDCload0.m │ │ ├── PDCload1.m │ │ ├── PDCload2.m │ │ ├── PDCload3.m │ │ ├── PDCload4.m │ │ ├── PDCloadN.m │ │ ├── PDCmenu.m │ │ ├── PDCpatch1.m │ │ ├── PDCpatch2.m │ │ ├── PDCrefsig.m │ │ ├── PMUosc2.m │ │ ├── PMUosc2N.m │ │ ├── SetExtPDC.m │ │ ├── cparse.m │ │ ├── funSelectRMS.m │ │ ├── inicopy.m │ │ ├── inipars2.m │ │ ├── isdst.m │ │ ├── pdc2mat.m │ │ ├── pdccsvread.m │ │ ├── pdcread1.m │ │ └── pdcread2.m │ ├── PPSM_Utilities │ │ ├── PPSM_splread.m │ │ ├── PPSMload.m │ │ ├── PPSMmenu.m │ │ ├── PPSMread.m │ │ └── SetExtPPSM.m │ ├── PRS_Utilities │ │ ├── CompassPlotsA.m │ │ ├── ModeDisp1.m │ │ ├── PRSdisp1.m │ │ ├── PRSvan1.m │ │ ├── RootSort1.m │ │ └── par2ss.m │ ├── PSAM_Utilities │ │ ├── PSAMload.m │ │ ├── PSAMmenu.m │ │ ├── PSAMread.m │ │ └── SetExtr2.m │ ├── PSMpcode.m │ ├── SQL_Utilities │ │ ├── SQLload.m │ │ ├── funApplySQLJAR.m │ │ └── funReadSQL.m │ └── SWX_Utilities │ │ ├── F08load.m │ │ ├── F08read.m │ │ ├── PSDSnamesFix.m │ │ ├── PTIprntread.m │ │ ├── PTIrawcRead.m │ │ ├── SWXload.m │ │ ├── SWXmenu.m │ │ └── SetExtSWX.m ├── Start_PSM.fig ├── Start_PSM.m └── _PSMtools_AddOns │ ├── DCU_Utilities │ └── DCUload.m │ ├── DXD_Utilities │ ├── ASpecF1.m │ ├── Box2BP1.m │ ├── BuildBF.m │ ├── BuildBox.m │ ├── BuildSinc.m │ ├── CLS1.m │ ├── CLSBP1.m │ ├── DXDcalcs1.m │ ├── DXDcore.m │ ├── DXDmod1.m │ ├── InitialVI.m │ ├── REMEZBP1.m │ ├── RevPol.m │ ├── Sigplot.m │ ├── Specplot.m │ ├── WindowCks3.m │ └── seqTXmats.m │ └── ModeMeter_Utilities │ ├── DTmodemeterC_Source │ ├── ModeMeterC.m │ ├── funFindModes.m │ ├── funMEYWSpectralAmbient.m │ ├── funMEYWambient.m │ ├── funMatchPoles.m │ ├── funMatchPoles3.m │ ├── funModeMeterAmbient.m │ └── funN4SIDambient.m │ ├── JPierreTestCodes │ └── PM8modelpierre.m │ ├── ModeMeterA │ ├── ARMAovr.m │ ├── MMscanA.m │ ├── MMscanPlots2.m │ ├── ModeMeterA.m │ ├── ModeMeterA_Docs │ │ └── ModeMeterA_JPreport090700.doc │ ├── PM8model.m │ ├── PRNYPH3.M │ ├── RHATFUNC.M │ ├── RtrueCt.m │ ├── SORTPOLE.M │ ├── Sortpole1.m │ ├── Start3v2.m │ ├── datacrct.m │ ├── orderener.m │ ├── pltstrt2.m │ ├── preproc.m │ ├── preprocdsn.m │ ├── rvarbound.m │ ├── rvariance.m │ └── startaux.m │ ├── ModeMeterB │ ├── JPmodemeterB_Docs │ │ └── JPmodemeter_UserNote1.doc │ └── JPmodemeterB_Source │ │ ├── ModeMeterB.m │ │ ├── TestSubspace1.m │ │ ├── TestSubspace2.m │ │ ├── funDecimate.m │ │ ├── funFindModes.m │ │ ├── funFindPoles.m │ │ ├── funL1Subspace.m │ │ ├── funNewSamplingRate.m │ │ ├── funSubspace.m │ │ ├── funbodeaux.m │ │ └── funffplot.m │ ├── ModeMeterD_R3LS │ ├── ModeMeterOfflineDemo.fig │ ├── ModeMeterOfflineDemo.m │ ├── ModeMeterOfflineDemoConfig.m │ ├── SubRRLSIni.m │ ├── funConfigParameters.fig │ ├── funConfigParameters.m │ ├── funSub │ │ ├── PSM2Date.p │ │ ├── SubLoadNewData.p │ │ ├── dividenowarn.p │ │ ├── funDominantMode.p │ │ ├── funFindModes.p │ │ ├── funFindPoles.p │ │ ├── funFreqz.p │ │ ├── funMatchPoles.p │ │ ├── funMode2Pole.p │ │ ├── funModeDispSelection.p │ │ ├── funPole2Mode.p │ │ ├── funPolePowerAR.p │ │ ├── funR3LSModesIni.p │ │ ├── funRDetrend.p │ │ ├── funRMedianDetrend.p │ │ ├── funRMedianDetrendNaN.p │ │ ├── funRMedianFilter.p │ │ ├── funRarxRobustExt.p │ │ ├── funRarxRobustExtP.p │ │ ├── funRarxRobustExtP05MIMOoffline.p │ │ ├── funShowPointsAni01.p │ │ ├── funShowPointsAni02.p │ │ ├── funShowPointsAniAxes.p │ │ └── residuez.p │ ├── logo.tif │ └── pnnllogo.gif │ ├── ModeMeterM.m │ └── ModeMeter_Math │ ├── TrueCovS.m │ ├── TrueCovZ.m │ ├── TrueCovZSmath.doc │ └── TrueCovZmath.doc ├── PSMtools_Security ├── PSMPaths1.m └── Security_Utilities │ ├── PDC_Alias.m │ └── dstalias0.m ├── README.md ├── Ringdown130930 ├── Contents.txt ├── Getmodel.m ├── MsgDict.m ├── PSMlabl.m ├── README.TXT ├── cmd_line_ringdown.m ├── private │ ├── PPSMread.m │ ├── PSAMread.m │ ├── combin.m │ ├── create_dict.m │ ├── dpssread.m │ ├── prgv2_5.m │ ├── prspak.m │ ├── ptirread.m │ ├── reorder_modes.m │ ├── rguidt.m │ ├── rguifilt.m │ ├── rguiload.m │ ├── rguimgr.m │ ├── rguipref.mat │ ├── rguipref_back.p │ ├── rguisave.m │ ├── settp.m │ ├── swxload0.m │ ├── tranfrq0.m │ ├── tranfun.m │ └── transimf.m └── ringdown.m ├── SQL_Config.cfg ├── SQL_Database_Interface.txt └── UserFunctions ├── User Function Guidelines.txt ├── funDSI_USR_copychans.m └── funUserFunctionInterface.m /Disclaimer.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/Disclaimer.docx -------------------------------------------------------------------------------- /Disclaimer.txt: -------------------------------------------------------------------------------- 1 | This material was prepared as an account of work sponsored by an agency of the 2 | United States Government. Neither the United States Government nor the United 3 | States Department of Energy, nor Battelle, nor any of their employees, nor any 4 | jurisdiction or organization that has cooperated in the development of these 5 | materials, makes any warranty, express or implied, or assumes any legal 6 | liability or responsibility for the accuracy, completeness, or usefulness or 7 | any information, apparatus, product, software, or process disclosed, or 8 | represents that its use would not infringe privately owned rights. 9 | 10 | Reference herein to any specific commercial product, process, or service by 11 | trade name, trademark, manufacturer, or otherwise does not necessarily 12 | constitute or imply its endorsement, recommendation, or favoring by the United 13 | States Government or any agency thereof, or Battelle Memorial Institute. The 14 | views and opinions of authors expressed herein do not necessarily state or 15 | reflect those of the United States Government or any agency thereof. 16 | 17 | PACIFIC NORTHWEST NATIONAL LABORATORY 18 | operated by 19 | BATTELLE 20 | for the 21 | UNITED STATES DEPARTMENT OF ENERGY 22 | under Contract DE-AC05-76RL01830 -------------------------------------------------------------------------------- /Getting Started.txt: -------------------------------------------------------------------------------- 1 | To begin using the DSI toolbox, first the entire path must be added 2 | to your current MATLAB path. There are two ways to do this in MATLAB. 3 | 4 | 1A. Utilize the MATLAB GUI to add the DSI toolbox to the path. 1A and 1B below depend on 5 | which version of MATLAB you are running (newer versions are 1A, older have 1B). 6 | 1AA. Click the "Set Path" button under the "Home" tab on the top of the MATLAB window. 7 | 1AB. Go to File->"Set Path" menu option on the top of the MATLAB window. 8 | 9 | -- After finding the "Set Path" button/item, click the "Add with Subfolders" button 10 | -- Locate the base folder of the DSI Toolbox (the folder with this file in it) and 11 | hit "Select Folder" 12 | -- After adding the path, you can either "Close" or "Save and Close", depending on if you 13 | want this saved in the MATLAB path for just this session, or forever. 14 | 15 | 1B. Utilize a MATLAB command to add the DSI Toolbox to the working path for the current session. 16 | This can be done with the MATLAB command: 17 | 18 | addpath(genpath('C:\MATLABToolBoxes\DSITools')); 19 | 20 | where "C:\MATLABToolBoxes\DSITools" is the path to the parent folder of the DSI Toolbox. 21 | 22 | 2. After adding the DSI Toolbox to the appropriate path, it can now be launched with the command: 23 | 24 | PSMbrowser 25 | 26 | If you wish to utilize the SQL connection capability, please follow the "SQL_Database_Interface.txt" 27 | instructions before executing PSMbrowser. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Dynamic System Identification Toolbox 2 | Copyright © 2014, Battelle Memorial Institute 3 | 4 | 1. Battelle Memorial Institute (hereinafter Battelle) hereby grants permission 5 | to any person or entity lawfully obtaining a copy of this software and 6 | associated documentation files (hereinafter “the Software”) to redistribute 7 | and use the Software in source and binary forms, with or without modification. 8 | Such person or entity may use, copy, modify, merge, publish, distribute, 9 | sublicense, and/or sell copies of the Software, and may permit others to do 10 | so, subject to the following conditions: 11 | • Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimers. 13 | • Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | • Other than as used herein, neither the name Battelle Memorial Institute 17 | or Battelle may be used in any form whatsoever without the express 18 | written consent of Battelle. 19 | 20 | 2. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | ARE DISCLAIMED. IN NO EVENT SHALL BATTELLE OR CONTRIBUTORS BE LIABLE FOR 24 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 30 | DAMAGE. 31 | -------------------------------------------------------------------------------- /License.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/License.doc -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/License.txt -------------------------------------------------------------------------------- /Older_DSI_UserGuides/0A_PSMtools_Description2.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/Older_DSI_UserGuides/0A_PSMtools_Description2.doc -------------------------------------------------------------------------------- /Older_DSI_UserGuides/0B_DSItools_FunctionalityTableA.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/Older_DSI_UserGuides/0B_DSItools_FunctionalityTableA.doc -------------------------------------------------------------------------------- /Older_DSI_UserGuides/1A_PSMtools_UserGuide2.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/Older_DSI_UserGuides/1A_PSMtools_UserGuide2.doc -------------------------------------------------------------------------------- /Older_DSI_UserGuides/1B_Ringdown_UGuideA.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/Older_DSI_UserGuides/1B_Ringdown_UGuideA.doc -------------------------------------------------------------------------------- /Older_DSI_UserGuides/1C_Ringdown_UGuideB.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/Older_DSI_UserGuides/1C_Ringdown_UGuideB.doc -------------------------------------------------------------------------------- /Older_DSI_UserGuides/1D_PSMtools_UGuide2_Filtering.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/Older_DSI_UserGuides/1D_PSMtools_UGuide2_Filtering.doc -------------------------------------------------------------------------------- /Older_DSI_UserGuides/Contents.txt: -------------------------------------------------------------------------------- 1 | This folder contains older documentation and user guides for the 2 | DSI toolbox. While most of the material should still be relevant and 3 | correct, some of these files are a little old. Please be aware that any 4 | web links and addresses are probably no longer valid. -------------------------------------------------------------------------------- /Older_DSI_UserGuides/DSI_InstallNoteD.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/Older_DSI_UserGuides/DSI_InstallNoteD.doc -------------------------------------------------------------------------------- /Older_DSI_UserGuides/DSI_Tools_FunctionalityTable.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/Older_DSI_UserGuides/DSI_Tools_FunctionalityTable.pdf -------------------------------------------------------------------------------- /Older_DSI_UserGuides/DSItools_FunctionalityTableA.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/Older_DSI_UserGuides/DSItools_FunctionalityTableA.doc -------------------------------------------------------------------------------- /Older_DSI_UserGuides/GUIfeatures062403B.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/Older_DSI_UserGuides/GUIfeatures062403B.ppt -------------------------------------------------------------------------------- /Older_DSI_UserGuides/PSMlaunchMacro Worknote.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/Older_DSI_UserGuides/PSMlaunchMacro Worknote.doc -------------------------------------------------------------------------------- /PSMtools Source/PSDScase_Ex2A.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/PSDScase_Ex2A.mat -------------------------------------------------------------------------------- /PSMtools Source/PSDScase_Ex2AngFrq.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/PSDScase_Ex2AngFrq.mat -------------------------------------------------------------------------------- /PSMtools Source/PSDScase_Ex2MWB.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/PSDScase_Ex2MWB.mat -------------------------------------------------------------------------------- /PSMtools Source/PSMlaunchMacro.m: -------------------------------------------------------------------------------- 1 | PSMlaunch -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/AddCom.m: -------------------------------------------------------------------------------- 1 | function [CaseCom]=AddCom(CaseCom) 2 | % AddCom permits the user to add lines to case comment array CaseCom 3 | % 4 | % function [CaseCom]=AddCom(CaseCom) 5 | % 6 | % [Last modified 12/20/00. jfh] 7 | % [Last modified 03/31/20/06. Zn to add macro] 8 | 9 | global Kprompt ynprompt nvprompt 10 | %---------------------------------------------------- 11 | % Begin: Macro definition ZN 03/31/06 12 | global PSMMacro % Macro Structure 13 | if ~isfield(PSMMacro,'RunMode'), PSMMacro.RunMode=-1; end 14 | % End: Macro definition ZN 03/31/06 15 | %---------------------------------------------------- 16 | 17 | for n=1:20 18 | %---------------------------------------------------- 19 | % Begin: Macro selection ZN 03/31/06 20 | if ~isfield(PSMMacro,'AddCom_lineok') 21 | PSMMacro.AddCom_lineok=NaN; 22 | end 23 | 24 | if (PSMMacro.RunMode<1 || isnan(PSMMacro.AddCom_lineok)) % 'Macro record mode' or 'selection was not defined in a macro' 25 | lineok=promptyn('In AddCom: Add a line of text to Case Comments? ', 'n'); 26 | else 27 | lineok=PSMMacro.AddCom_lineok; 28 | end 29 | 30 | if PSMMacro.RunMode==0 % if in macro definition mode 31 | if PSMMacro.PauseMode==0 % if record mode is not paused 32 | PSMMacro.AddCom_lineok=lineok; 33 | else 34 | PSMMacro.AddCom_lineok=NaN; 35 | end 36 | save(PSMMacro.MacroName,'PSMMacro'); 37 | end 38 | % End: Macro selection ZN 03/31/06 39 | %---------------------------------------------------- 40 | 41 | if ~lineok, return, end 42 | newline=input([ 'Type New Line: '],'s'); 43 | CaseCom=str2mat(CaseCom,newline); 44 | end 45 | 46 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/Alias1.m: -------------------------------------------------------------------------------- 1 | function [FAlias]=Alias1(F,Srate); 2 | %Determine aliased frequency for a sine wave of frequency F, 3 | %when sampled at Srate samples per second 4 | % [FAlias]=Alias1(F,Srate); 5 | % 6 | % Last modified 01/09/04. jfh 7 | 8 | %Srate=50; F=[-1.08;118.92;57.84;177.84;116.76;236.76]; 9 | FN=Srate/2; %Nyquist frequency 10 | FAlias=F*0; 11 | for I=1:length(F) 12 | FA=mod(F(I),Srate); 13 | if FA>FN, FA=FA-Srate; end; 14 | FAlias(I)=FA; 15 | end 16 | 17 | if min(FAlias)<0 18 | disp('In Alias1: Negative frequencies in output') 19 | end 20 | 21 | %end of PSMT function 22 | 23 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/BstringOut.m: -------------------------------------------------------------------------------- 1 | function [ClinesN]=BstringOut(Clines0,OutChar,MinOuts) 2 | % Deletes long strings of undesirable characters that are 3 | % common to the rows of Clines. 4 | % 5 | % [ClinesN]=BstringOut(Clines,OutChar,MinOuts); 6 | % 7 | % Last modified 12/17/02. jfh 8 | 9 | tabchar=' '; 10 | StringN=''; 11 | if nargin<1, disp('In BstringOut: No data - return'), return, end 12 | if nargin<2, OutChar=' '; end 13 | if nargin<3, MinOuts=2; end 14 | if isempty(OutChar), OutChar=' '; end 15 | MinOuts=max(MinOuts,2); 16 | %disp('In BstringOut:') 17 | 18 | Clines=Clines0; 19 | Clines=Char2Blank(Clines0); %Substitute blanks for tabs 20 | Clines=deblank(Clines); 21 | for Ntries=1:10 22 | 23 | ClinesN=Clines; 24 | [nlines nchars]=size(Clines); 25 | Bind=zeros(nlines,nchars); 26 | Bloc1=1; Bloc2=2; 27 | Bstr=''; for n=1:MinOuts, Bstr=[Bstr OutChar]; end 28 | for L=1:nchars 29 | for N=1:nlines 30 | Bind(N,:)=zeros(1,nchars); 31 | Lbstr=findstr(Bstr,ClinesN(N,:)); 32 | Bind(N,Lbstr)=1; 33 | end 34 | LBsum=sum(Bind,1); 35 | if max(LBsum)Bloc1+1 41 | ClinesN=ClinesN(:,[1:Bloc1 Bloc2:nchars]); 42 | Clines =ClinesN; 43 | %disp(['Removing surplus characters of type ' ''' ''' ' from character array']) 44 | %disp([Bloc1 Bloc2]) 45 | %disp( 'Revised character array is') 46 | %disp(ClinesN) 47 | end 48 | 49 | end %Termination of Ntries loop 50 | 51 | return 52 | 53 | %end of PSMT function -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/CD2loc.m: -------------------------------------------------------------------------------- 1 | function [CDpath]=CD2loc(CDfile) 2 | % CD2.m changes the present Matlab directory to that of CDfile 3 | % 4 | % [CDpath]=CD2loc(CDfile) 5 | % 6 | % 7 | % Last modified 04/26/01. jfh 8 | 9 | CDpath=''; 10 | 11 | Nup=0; 12 | if ~isempty(CDfile) 13 | command=['CDloc=which(' '''' CDfile '''' ');']; 14 | eval(command) 15 | if isempty(CDloc) 16 | disp(['File ' CDloc ' not found on Matlab path:']) 17 | disp('Directory not changed') 18 | return 19 | end 20 | ind=find(CDloc=='\'); 21 | last=ind(max(size(ind))-Nup); 22 | CDpath=CDloc(1:last); 23 | end 24 | disp(['Setting path to working directory: CD file = ' CDfile]) 25 | disp('User may want to customize this later') 26 | command=['cd(' '''' CDpath '''' ');']; 27 | eval(command); 28 | str=cd; disp(['In CD2loc: Starting directory = ' str]) 29 | 30 | %End of PSMT utility -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/CaseComPlot.m: -------------------------------------------------------------------------------- 1 | function CaseComPlot(CaseCom,Ptitle,PrintPlot,SavePlot,SaveFileP) 2 | % Plot lines of text 3 | % 4 | % CaseComPlot(CaseCom,Ptitle,PrintPlot,SavePlot,SaveFileP) 5 | % 6 | % Last modified 11/05/02. jfh 7 | % Last Modified 02/17/07. by Ning Zhou to add macro function 8 | % 9 | % By J. F. Hauer, Pacific Northwest National Laboratory. 10 | 11 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 12 | % retains a paid-up nonexclusive, irrevocable worldwide license to 13 | % reproduce, prepare derivative works, perform publicly and display 14 | % publicly by or for the Government, including the right to distribute 15 | % to other Government contractors. 16 | 17 | if ~exist('PrintPlot'),PrintPlot=0; end 18 | if ~exist('SavePlot'), SavePlot=0; end 19 | if ~exist('SaveFileP'),SaveFileP=''; end 20 | 21 | %---------------------------------------------------- 22 | % Begin: Macro definition ZN 03/31/06 23 | global PSMMacro % Macro Structure 24 | % End: Macro definition ZN 03/31/06 25 | %---------------------------------------------------- 26 | %keyboard 27 | 28 | tabchar=' '; 29 | [CaseCom]=Char2Blank(CaseCom,tabchar); %Replace tabs 30 | 31 | %************************************************************************* 32 | %Generate case header plot 33 | lines0=size(CaseCom,1); 34 | lines=lines0; Plines=50; 35 | Hpages=ceil(lines/Plines); HPtrim=0; 36 | if Hpages>4 37 | disp(['Long case header: Pages = ', num2str(Hpages)]) 38 | %---------------------------------------------------- 39 | % Begin: Macro selection ZN 03/31/06 40 | if ~isfield(PSMMacro, 'CaseComPlot_HPtrim'), PSMMacro.CaseComPlot_HPtrim=NaN; end 41 | if (PSMMacro.RunMode<1 || isnan(PSMMacro.CaseComPlot_HPtrim)) % Not in Macro playing mode or selection not defined in a macro 42 | HPtrim=promptyn('Plot first & last pages only? ', 'y'); 43 | else 44 | HPtrim=PSMMacro.CaseComPlot_HPtrim; 45 | end 46 | 47 | if PSMMacro.RunMode==0 % if in macro record mode 48 | if PSMMacro.PauseMode==0 % if record mode is not paused 49 | PSMMacro.CaseComPlot_HPtrim=HPtrim; 50 | else 51 | PSMMacro.CaseComPlot_HPtrim=NaN; 52 | end 53 | save(PSMMacro.MacroName,'PSMMacro'); 54 | end 55 | % End: Macro selection ZN 03/31/06 56 | %---------------------------------------------------- 57 | 58 | 59 | if HPtrim, Hpages=2; end 60 | end 61 | jbase=0; j1=1; j2=min(Plines,lines); 62 | for Hpage=1:Hpages 63 | h=figure; %Case header plot 64 | plotno=sprintf('P%2.0i: ',h); 65 | set(gca,'xlim',[0 120]) 66 | set(gca,'ylim',[-Plines -1]) 67 | axis('off') 68 | Ptitle{1}=['Case Header']; 69 | if Hpage>1, Ptitle{1}=['Case Header (ctd)']; end 70 | Ptitle{1}=[plotno Ptitle{1}]; 71 | title(Ptitle) 72 | %j1,j2,jbase 73 | for j=j1:j2 74 | linej=CaseCom(j,:); 75 | if HPtrim 76 | if Hpage==1&j==j2 77 | linej='START OF DISPLAY TRIMMING'; 78 | end 79 | if Hpage==2&j==j1 80 | linej='END OF DISPLAY TRIMMING'; 81 | end 82 | end 83 | text(0,jbase-(j+1),linej,'FontName','courier new',... 84 | 'FontSize',8) 85 | end 86 | if PrintPlot, print -f, end 87 | if SavePlot 88 | SaveP=[SaveFileP num2str(h)]; 89 | eval(['print -depsc -tiff ' SaveP]) 90 | end 91 | lines=lines-Plines; jbase=jbase+Plines; 92 | j1=j1+Plines; j2=j2+min(Plines,lines); 93 | if HPtrim 94 | j1=lines0-Plines+1; j2=lines0; 95 | jbase=j1-1; 96 | end 97 | end 98 | %************************************************************************* 99 | 100 | %end of PSMT function -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/CaseTags.m: -------------------------------------------------------------------------------- 1 | function [caseID,casetime,CaseCom,Gtags]=CaseTags(caseID) 2 | % CaseTags.m accepts case identification and comments from the user. 3 | % 4 | % [caseID,casetime,CaseCom,Gtags]=CaseTags 5 | % 6 | % a) "caseID" is a one-line case ID tag entered within CaseTags by the user. 7 | % b) "casetime" is the time when case execution starts 8 | % c) "CaseCom" is the initial value for a matrix of comments 9 | % d) "Gtags" is a comment matrix to be pasted onto graphs 10 | % 11 | % Last modified 01/09/01. jfh 12 | % Last modified 03/31/2006 ZN for running macro 13 | 14 | 15 | %Global controls on prompt defaults 16 | global Kprompt ynprompt nvprompt 17 | %---------------------------------------------------- 18 | % Begin: Macro definition ZN 03/31/06 19 | global PSMMacro % Macro Structure 20 | if ~isfield(PSMMacro,'RunMode'), PSMMacro.RunMode=-1; end 21 | % End: Macro definition ZN 03/31/06 22 | %---------------------------------------------------- 23 | 24 | disp('In CaseTags:') 25 | 26 | if ~exist('caseID'),caseID=''; end 27 | 28 | %************************************************************************* 29 | %Obtain name for present case 30 | setok=0; 31 | maxtrys=10; 32 | for i=1:maxtrys 33 | if ~setok 34 | disp(['In CaseTags: caseID = ' caseID]) 35 | %---------------------------------------------------- 36 | % Begin: Macro selection ZN 03/31/06 37 | if ~isfield(PSMMacro,'CaseTags_setok') PSMMacro.CaseTags_setok=NaN; end 38 | if (PSMMacro.RunMode<1 || isnan(PSMMacro.CaseTags_setok)) % Macro definition mode or selection not defined in a macro 39 | setok=promptyn('In CaseTags: Is this ok? ', 'y'); 40 | else 41 | setok=PSMMacro.CaseTags_setok; 42 | end 43 | 44 | if PSMMacro.RunMode==0 % if macro is in record mode 45 | if PSMMacro.PauseMode==0 % if record mode is not paused 46 | PSMMacro.CaseTags_setok=setok; 47 | else % if record mode is paused 48 | PSMMacro.CaseTags_setok=NaN; 49 | end 50 | save(PSMMacro.MacroName,'PSMMacro'); 51 | end 52 | % End: Macro selection ZN 03/31/06 53 | %---------------------------------------------------- 54 | 55 | if setok, break, end 56 | prompt='In CaseTags: Enter name for present case: '; 57 | caseID=input(prompt,'s'); 58 | end 59 | end 60 | if ~setok 61 | disp(['Sorry - ' int2str(maxtrys) ' chances is all you get!']) 62 | disp(['In CaseTags: Using caseID = ' caseID]) 63 | end 64 | %************************************************************************* 65 | 66 | %************************************************************************* 67 | %Set case time tag 68 | tag=fix(clock); tag(1)=tag(1)-fix(tag(1)/100)*100; 69 | casetime=[sprintf('%2.0i',tag(2)) '/' sprintf('%2.0i',tag(3)) '/'... 70 | sprintf('%2.0i',tag(1)) '_']; 71 | casetime=[casetime sprintf('%2.0i',tag(4)) ':' sprintf('%2.0i',... 72 | tag(5)) ':' sprintf('%2.0i',tag(6))]; 73 | nchars=size(casetime,2); 74 | for i=1:nchars 75 | if strcmp(casetime(i),' '), casetime(i)='0'; end 76 | end 77 | disp(['In CaseTags: Case Time = ' casetime]) 78 | %************************************************************************* 79 | 80 | %************************************************************************* 81 | %Initialize case documentation matrix CaseCom 82 | S0=['Case ID = ' caseID]; %defines string S0 83 | S1=['Case Time = ' casetime]; %defines string S1 84 | CaseCom=str2mat(S0,S1); %loads strings into matrix 85 | Gtags=str2mat(caseID,casetime); 86 | %************************************************************************* 87 | 88 | %************************************************************************* 89 | %Permit user to add further comments 90 | [CaseCom]=AddCom(CaseCom); 91 | %************************************************************************* 92 | 93 | return 94 | 95 | %end of PSM script 96 | 97 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/Char2Blank.m: -------------------------------------------------------------------------------- 1 | function [ClinesN]=Char2Blank(Clines,BlankChar) 2 | % Substitute blanks for characters of type BlankChar 3 | % 4 | % [ClinesN]=Char2Blank(Clines,BlankChar); 5 | % 6 | % Last modified 07/22/03. jfh 7 | 8 | tabchar=' '; 9 | StringN=''; 10 | if nargin<1, disp('In Char2Blank: No data - return'), return, end 11 | if nargin<2, BlankChar=tabchar; end 12 | if ~exist('Clines'), Clines=''; end 13 | if isempty(BlankChar), BlankChar=tabchar; end 14 | 15 | ClinesN='(No Comment Lines)'; 16 | if isempty(Clines), disp('In Char2Blank: No data - return'), return, end 17 | nlines=size(Clines,1); 18 | for N=1:nlines %Replace entries of type BlankChar by blanks 19 | %line=deblank(ClinesN(N,:)); 20 | line=Clines(N,:); 21 | LBchar=findstr(line,BlankChar); 22 | if ~isempty(LBchar), line(LBchar)=' '; end 23 | if N==1 24 | ClinesN=line; 25 | else 26 | ClinesN=str2mat(ClinesN,line); 27 | end 28 | end 29 | 30 | return 31 | 32 | %end of PSMT function -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/CharTrim.m: -------------------------------------------------------------------------------- 1 | function [StrN,TrimChar]=CharTrim(Str,TrimChar,StrEnd) 2 | % Trim off leading or trailing characters of type TrimChar 3 | % 4 | % Last modified 03/04/03. jfh 5 | 6 | tab=' '; TrimChar=tab; 7 | StrN=''; 8 | if ~exist('Str'), Str=''; end 9 | if isempty(Str), return, end 10 | 11 | if nargin<1, disp('In CharTrim: No data - return'), return, end 12 | if nargin<2, TrimChar=tab; end 13 | if isempty(TrimChar), TrimChar=tab; end 14 | if nargin<3, StrEnd='trailing'; end 15 | if isempty(StrEnd), StrEnd='trailing'; end 16 | 17 | %Trimming off trailing characters of type TrimChar 18 | StrN=Str; chars=length(Str); 19 | keep=find(Str~=TrimChar); 20 | if isempty(keep), return, end 21 | if ~isempty(findstr('trailing',lower(StrEnd))) 22 | StrN=Str(:,1:max(keep)); 23 | return 24 | end 25 | if ~isempty(findstr('leading',lower(StrEnd))) 26 | StrN=Str(:,min(keep):chars); 27 | return 28 | end 29 | 30 | return 31 | 32 | %end of PSMT utility -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/CkTsteps.m: -------------------------------------------------------------------------------- 1 | function [CaseCom,timeN,tstepN,swlocs,roughlocs,smoothdef]... 2 | =CkTsteps(caseID,casetime,CaseCom,time,tstep,smoothdef); 3 | % CkTsteps.m checks for repeated and irregular time steps 4 | % [CaseCom,timeN,tstepN,swlocs,roughlocs,smoothdef]... 5 | % =CkTsteps(caseID,casetime,CaseCom,time,tstep,smoothdef); 6 | % 7 | % Special functions used: 8 | % (none) 9 | % 10 | % Modified 02/19/04. jfh 11 | 12 | % By J. F. Hauer, Pacific Northwest National Laboratory. 13 | % 14 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 15 | % retains a paid-up nonexclusive, irrevocable worldwide license to 16 | % reproduce, prepare derivative works, perform publicly and display 17 | % publicly by or for the Government, including the right to distribute 18 | % to other Government contractors. 19 | 20 | if ~exist('smoothdef'), smoothdef=[]; end; 21 | if isempty(smoothdef), smoothdef=0.005; end; 22 | 23 | str=['In CkTsteps: Using smoothdef= ' num2str(smoothdef)]; 24 | disp(str); CaseCom=str2mat(CaseCom,str); 25 | 26 | %Initialize outputs 27 | timeN=time; tstepN=tstep; swlocs=[]; roughlocs=[]; 28 | 29 | %************************************************************************* 30 | %Initialize plot headers 31 | Ptitle{1}=' '; 32 | Ptitle{2}=['caseID=' caseID ' casetime=' casetime]; 33 | %************************************************************************* 34 | 35 | SampleRate=1/tstep; 36 | maxpoints=length(time); 37 | tsteps=time(2:maxpoints)-time(1:maxpoints-1); 38 | 39 | %************************************************************************* 40 | %Check for repeated points and irregular time steps 41 | eps=0.001*tstep; 42 | swlocs=find(abs(time(1:maxpoints-1)-time(2:maxpoints))0)); 56 | Lmax=find(tstepsA==max(tstepsA)); Lmax=Lmax(1); 57 | Lmin=find(tstepsA==min(tstepsA)); Lmin=Lmin(1); 58 | maxfrac=tstepsA(Lmax)/tstep; minfrac=tstepsA(Lmin)/tstep; 59 | roughness=max(abs(maxfrac-1),abs(minfrac-1)); 60 | roughtime=roughness>smoothdef; 61 | if roughtime 62 | str1=[' Irregular time steps:']; 63 | str2=[' Maximum time step =' num2str(maxfrac) ' of standard']; 64 | str3=[' at time= ' num2str(time(Lmax)) ' sec. ' num2str(Lmax) ' samples' ]; 65 | str4=[' Minimum time step =' num2str(minfrac) ' of standard']; 66 | str5=[' at time= ' num2str(time(Lmin)) ' sec. ' num2str(Lmin) ' samples' ]; 67 | strs=str2mat(str1,str2,str3,str4,str5); disp(strs) 68 | CaseCom=str2mat(CaseCom,strs); 69 | h=figure; plot(time) 70 | Ptitle{1}='Irregular time steps'; 71 | title(Ptitle) 72 | xlabel('Time in Samples') 73 | ylabel('Time in seconds') 74 | h=figure; plot(tsteps) 75 | Ptitle{1}='Irregular time steps'; 76 | title(Ptitle) 77 | xlabel('Time in Samples') 78 | ylabel('Time Steps') 79 | roughck1=abs(tsteps/tstep-1); %figure; plot(roughck1) 80 | roughlocs=find(roughck1>smoothdef); 81 | str=['Number of rough time steps = ' num2str(length(roughlocs))]; 82 | disp(str); CaseCom=str2mat(CaseCom,str); 83 | end 84 | %************************************************************************* 85 | 86 | disp('Returning from CkTsteps') 87 | disp(' ') 88 | return 89 | 90 | %end of PSMT function 91 | 92 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/DataTrim.m: -------------------------------------------------------------------------------- 1 | function y = DataTrim(data,range) 2 | % 3 | % function y = DataTrim(data,range) 4 | % 5 | % All DATA values are trimmed to lie within RANGE values. 6 | % 7 | % It is useful to examine the details of Matlab plots 8 | % through commands such as 9 | % 10 | % set (gca,'xlim',xrng) 11 | % 12 | % However, clipboard copies of such plots may exhibit 13 | % trace "runovers" when pasted into other applications. 14 | % DataTrim is a simple workaround to this problem. 15 | 16 | y=max(data,range(1)); 17 | y=min(y,range(2)); 18 | 19 | %end of PSM script 20 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/Date2PSM.m: -------------------------------------------------------------------------------- 1 | function [PSMtime]=Date2PSM(DateString); 2 | % Convert Date to PSM time 3 | % 4 | % [PSMtime]=PSM2Date(DateString); 5 | % 6 | % Date string should be in format 10-Aug-1996 15:48:46.133 7 | % PSM time = seconds starting at 1-Jan-1900 8 | % Matlab time = days starting at 1-Jan-0000 9 | % 10 | % See also PSM2Date 11 | % 12 | % See also Matlab built-in functions NOW, DATESTR, DATENUM, DATEVEC 13 | % 14 | % Last modified 03/28/03. jfh 15 | 16 | % By J. F. Hauer, Pacific Northwest National Laboratory. 17 | % 18 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 19 | % retains a paid-up nonexclusive, irrevocable worldwide license to 20 | % reproduce, prepare derivative works, perform publicly and display 21 | % publicly by or for the Government, including the right to distribute 22 | % to other Government contractors. 23 | 24 | daysecs=24*3600; 25 | 26 | %Date string should be in format 10-Aug-1996 15:48:46.133 27 | DateString=deblank(DateString); 28 | PSMtime=(datenum(DateString)-datenum(1900,1,1,0,0,0))*daysecs; 29 | %disp(['Checking date: ' PSM2Date(PSMtime)]) 30 | 31 | return 32 | 33 | %end PSMT utility 34 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/Detrend1.m: -------------------------------------------------------------------------------- 1 | function y = Detrend1(sigs,Mtrend) 2 | % 3 | % function y = Detrend1(sigs,Mtrend) 4 | % 5 | % Mtrend Mode for removing signal trends. Primary options are 6 | % 1 Remove initial value 7 | % 2 Remove average value 8 | % 3 Remove least-squares fitted ramp 9 | % 4 Remove final value 10 | % 11 | % Last modified 01/09/02. jfh 12 | 13 | nsigpts=size(sigs,1); 14 | nsigs=size(sigs,2); 15 | % 16 | if Mtrend<=0 17 | y=sigs; end 18 | 19 | if Mtrend==1 20 | y=sigs-ones(nsigpts,1)*sigs(1,:); end 21 | 22 | if Mtrend==2 23 | y=sigs-ones(nsigpts,1)*sum(sigs)/nsigpts; end 24 | 25 | if Mtrend==3 26 | LSmat = [(1:nsigpts)'/nsigpts ones(nsigpts,1)]; 27 | y=sigs-LSmat*(LSmat\sigs); end 28 | 29 | if Mtrend==4 30 | y=sigs-ones(nsigpts,1)*sigs(nsigpts,:); end 31 | 32 | 33 | 34 | %end of PSM script 35 | 36 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/EScan/Batch_Event_Scan_config.m: -------------------------------------------------------------------------------- 1 | MaxFiles=4; %Maximum number of PSM files to load together 2 | % configuration files for the 'Batch_Event_Scan' 3 | PSMMacro.EventScan1_PathName=''; % use the menu to choose the path for the *.dst files 4 | PSMMacro.EventScan1_CFname=''; % use the menu to choose the *.ini files 5 | %PSMMacro.EventScan1_PathName='C:\ZhouNingDataHugeSize\EventScanData'; % path for the *.dst files 6 | %PSMMacro.EventScan1_CFname='C:\ZhouNingDataHugeSize\EventScanData\BPA2_050215.ini'; % *.ini files with path; the default path is same as the *.dst files 7 | PSMMacro.EventScan1_PSMfilesIndex=0; % the Index the current *.dst file 8 | PSMMacro.EventScan1_ChannelSeq=[]; % The channel selections [] means all the channels 9 | %PSMMacro.EventScan1_ChannelSeq=NaN; % NaN means user selection of channel 10 | %PSMMacro.EventScan1_ChannelSeq=[1,10:90]; 11 | CurDateStr=datestr(now,'yyyymmddHHMM'); 12 | PSMMacro.EventScan1_LogFname=['BatchESLog', CurDateStr,'.xls']; 13 | 14 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/EScan/EventScan1_config.m: -------------------------------------------------------------------------------- 1 | %*************************************** 2 | % Alarm definition 3 | ESPara.Alarm_LevelN=4; % Number of Alarm levels 4 | ESPara.Alarm_Color=['k','g','b','m','r']; 5 | ESPara.Alarm_LevelPlot=2; % the alarm level above which a plot is going to be drawn. 6 | 7 | 8 | % 2.2 Freq Alarm detection parameter definition 9 | ESPara.FreqB_ES=1; % 1, do the event scan for Freq boudary, 0, skip the event scan 10 | Freq_Norm=60; % in Hz ES(EventScan) 11 | ESPara.FreqB_Alarm= [ 12 | 4, Freq_Norm-20, Freq_Norm-0.5; 13 | 3, Freq_Norm-0.5, Freq_Norm-0.2; % alarm level (1~4), lower limit(Hz), upper limit(Hz) 14 | 2, Freq_Norm-0.2, Freq_Norm-0.05; 15 | 1, Freq_Norm+0.05, Freq_Norm+0.2; 16 | 3, Freq_Norm+0.2, Freq_Norm+0.5 17 | 4, Freq_Norm+0.5, Freq_Norm+20]; % frequency to triger the alarm 18 | ESPara.FreqB_MinEventTimeDist=60; % minimum time distance between two events (second). Two events which are close to each other is considered as on events. 19 | 20 | % 2.2 Voltage magnitude alarm detection parameter definition 21 | ESPara.VM_ES=1; % 1, do the event scan for Voltage Magnitude 22 | VM_Norm=1.0; % in pu ES(EventScan) 23 | ESPara.VMB_Alarm= [ 24 | 4, VM_Norm-0.99, VM_Norm-0.5; 25 | 3, VM_Norm-0.5, VM_Norm-0.3; 26 | 2, VM_Norm-0.3, VM_Norm-0.15; % alarm level (1~4), lower limit(p.u.), upper limit(p.u.) 27 | 1, VM_Norm-0.15, VM_Norm-0.08; 28 | 1, VM_Norm+0.10, VM_Norm+0.2; 29 | 2, VM_Norm+0.20, VM_Norm+0.50; 30 | 4, VM_Norm+0.5, VM_Norm+1 31 | 3, VM_Norm+1 , VM_Norm+10 32 | ]; % VM to triger the alarm 33 | ESPara.VMB_MinEventTimeDist=60; % minimum time distance between two events (second). Two events which are close to each other is considered as on events. -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/EScan/funEventSummary.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | function EventTime=funEventSummary(kAlarmSeq,MinEventDist) 4 | % 5 | % Input Parameters: 6 | % kAlarmSeq: A 'ascendly' sorted vector 7 | % MinEventDist: The miminum distance between two neigbor events 8 | % 9 | % Output Parameters: 10 | % EventTime: EventTime(:,1) is the start index of the events 11 | % EventTime(:,2) is the duration of the events (in steps) 12 | % 13 | % 14 | % Create by Ning Zhou, 05/11/2006 15 | % 16 | if nargin<2 17 | MinEventDist=30*60; 18 | end 19 | EventTime=[]; 20 | startRelTime=kAlarmSeq(1); 21 | lastRelTime=kAlarmSeq(1); 22 | for kIndex=1:length(kAlarmSeq) 23 | curRelTime=kAlarmSeq(kIndex); 24 | if curRelTime-lastRelTime < MinEventDist % in events minimum distance (steps) or event resolution 25 | lastRelTime=curRelTime; 26 | else 27 | endRelTime=lastRelTime; 28 | %save the events 29 | EventTime=[EventTime; startRelTime endRelTime-startRelTime+0.5]; 30 | startRelTime=curRelTime; 31 | lastRelTime=curRelTime; 32 | end 33 | end 34 | endRelTime=curRelTime; 35 | % save the events 36 | EventTime=[EventTime; startRelTime endRelTime-startRelTime+0.5]; 37 | return 38 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/EScan/funEventTimeSummary.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | function EventTime=funEventTimeSummary(kAlarmSeq,MinEventTimeDist,timeSeq) 4 | % 5 | % Input Parameters: 6 | % kAlarmSeq: A 'ascendly' sorted vector (steps) 7 | % MinEventTimeDist: The miminum distance between two neigbor events (seconds) 8 | % timeSeq: The time sequency 9 | % Output Parameters: 10 | % EventTime: EventTime(:,1) is the start time of the events (seconds) 11 | % EventTime(:,2) is the duration of the events (in seconds) 12 | % 13 | % 14 | % Create by Ning Zhou, 05/15/2006 15 | % 16 | if nargin<2, MinEventTimeDist=30*60; end 17 | if nargin<3, timeSeq=1:kAlarmSeq(end); end 18 | 19 | EventTime=[]; 20 | startRelTime=timeSeq(kAlarmSeq(1)); 21 | lastRelTime=timeSeq(kAlarmSeq(1)); 22 | for kIndex=1:length(kAlarmSeq) 23 | curRelTime=timeSeq(kAlarmSeq(kIndex)); 24 | if curRelTime-lastRelTime < MinEventTimeDist % in events minimum distance (steps) or event resolution 25 | lastRelTime=curRelTime; 26 | else 27 | endRelTime=lastRelTime; 28 | %save the events 29 | EventTime=[EventTime; startRelTime endRelTime-startRelTime]; 30 | startRelTime=curRelTime; 31 | lastRelTime=curRelTime; 32 | end 33 | end 34 | endRelTime=curRelTime; 35 | % save the events 36 | EventTime=[EventTime; startRelTime endRelTime-startRelTime]; 37 | return 38 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/EScan/funFindStr.m: -------------------------------------------------------------------------------- 1 | function chFreqSeq=funFindStr(namesX, MyStr) 2 | MyStr=lower(MyStr); 3 | nsigsX=size(namesX,1); 4 | chFreqSeq=[]; 5 | for chIndex=1:nsigsX 6 | chName=lower(namesX(chIndex,:)); 7 | if findstr(chName,MyStr) 8 | chFreqSeq=[chFreqSeq; chIndex]; 9 | end 10 | end -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/EScan/subCheckValid.m: -------------------------------------------------------------------------------- 1 | %************************************************ 2 | %2.0 check the definition of the default selections 3 | 4 | %2.1 check the path for the *.dst files (data file) 5 | if isempty(PSMMacro.EventScan1_PathName) 6 | for kIndex=1:3 7 | [n,p]=uigetfile('*.dst','Please choose your dst file directory:'); 8 | if p 9 | PSMMacro.EventScan1_PathName=p; 10 | break; 11 | elseif kIndex==3 12 | disp('Selection is NOT a valid directory. This must be a valid directory.'); 13 | NFiles=0; 14 | %keyboard% 15 | return; 16 | end 17 | end 18 | end 19 | 20 | if PSMMacro.EventScan1_PathName(end)~='/' && PSMMacro.EventScan1_PathName(end)~='\' 21 | PSMMacro.EventScan1_PathName=[PSMMacro.EventScan1_PathName '\']; 22 | end 23 | 24 | if ~isdir(PSMMacro.EventScan1_PathName) 25 | disp('The pathname is NOT a valid directory.'); 26 | [n,p]=uigetfile('*.dst','Default.pathname is NOT valid. Please choose your dst file:'); 27 | if p 28 | PSMMacro.EventScan1_PathName=p; 29 | else 30 | disp('The pathname is NOT a valid directory. This must be a valid directory.'); 31 | NFiles=0; 32 | return; 33 | end 34 | end 35 | 36 | dstFileNames=dir([PSMMacro.EventScan1_PathName '*.dst']); 37 | NFiles=length(dstFileNames); 38 | if NFiles<=0 39 | message='No *.dst files are detected in specified directory. Please check the definition of the PSMMacro.EventScan1_PathName'; 40 | disp(['In subCheckValid : ',message]); 41 | % disp('Press any key to continue...'); pause; 42 | return 43 | end 44 | 45 | %2.2 check the availability for the *.ini file (configuration file) 46 | if isempty(PSMMacro.EventScan1_CFname) 47 | cd(PSMMacro.EventScan1_PathName); 48 | for kIndex=1:3 49 | [n,p]=uigetfile('*.ini','Please select PDC configuration file:'); 50 | if n~=0; 51 | PSMMacro.EventScan1_CFname=[p n]; 52 | break; 53 | end 54 | end 55 | end 56 | 57 | PSMMacro.EventScan1_CFname=deblank(PSMMacro.EventScan1_CFname); 58 | fid=fopen(setstr(PSMMacro.EventScan1_CFname),'r'); 59 | 60 | if fid<0 61 | disp(['The specified ini file can not be found. Launching dialog box for PDC configuration file']) 62 | cd(PSMMacro.EventScan1_PathName); 63 | [n,p]=uigetfile('*.ini','The specified ini file can not be found. Please select PDC configuration file:'); 64 | if n==0; 65 | NFiles=0; 66 | return; 67 | end; 68 | PSMMacro.EventScan1_CFname=[p n]; 69 | [fid,message]=fopen(PSMMacro.EventScan1_CFname,'r'); 70 | if fid<0 71 | NFiles=0; 72 | return 73 | else 74 | fclose(fid); 75 | end 76 | else 77 | fclose(fid); 78 | end 79 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/EScan/subDispPrompt.m: -------------------------------------------------------------------------------- 1 | % subDispPrompt.m 2 | disp('********************************************************************'); 3 | disp('* Directions for the Macro function: *'); 4 | disp('* *'); 5 | disp('* 1) To record a macro, enter "r" or "90"; *'); 6 | disp('* 2) To play a macro (macro go), enter "g","p" or "91"; *'); 7 | disp('* 3) To stop a macro, enter "s" or "92"; *'); 8 | disp('* 4) To view/edit a macro, enter "v" ; *'); 9 | disp('* 5) To wipe macro recording in the recording mode, enter "w"; *'); 10 | disp('* 6) For all the "yes/no" questions, the macro hot keys *'); 11 | disp('* (i.e. "r","w","s","p","v" ) can be used to change *'); 12 | disp('* macro states. *'); 13 | disp('* *'); 14 | disp('*******************************************************************'); 15 | disp(' ') 16 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/EScan/subMacroEdit.m: -------------------------------------------------------------------------------- 1 | % subMacroEdit 2 | % For editing macro. 3 | % It is used in promptyn.m and promptynv.m 4 | % by Ning Zhou 02/14/2007 5 | % 6 | tempFile=[PSMMacro.MacroName(1:length(PSMMacro.MacroName)-3),'m']; 7 | [fid,message] = fopen(tempFile, 'w'); 8 | if fid>0 9 | fwrite(fid,''); 10 | fprintf(fid, ' %% Edit macro function using matlab: \r' ); 11 | fprintf(fid, ' %% --------------------------------------------------------------------------- \r' ); 12 | fprintf(fid, ' %% 1)View/Edit/Save the macro. \r' ); 13 | fprintf(fid, ' %% 2)Close this Edit windows. \r' ); 14 | fprintf(fid, ' %% --------------------------------------------------------------------------- \r' ); 15 | fprintf(fid, 'PSMMacro.PSMload_DataPath=''%s''; %% The path for the *.dst files \r', PSMMacro.PSMload_DataPath); 16 | fprintf(fid, 'PSMMacro.PDCload4_fnameNew=''%s''; %% The file name of the *.ini files \r', PSMMacro.PDCload4_fname); 17 | fprintf(fid, 'PSMMacro.SetExtPDC_chansX=[%s]; %% channel selections \r', num2str(PSMMacro.SetExtPDC_chansX)); 18 | fclose(fid); 19 | open(tempFile); 20 | disp('Invoking Edit macro function.') 21 | disp(['Please view/edit/save: ' tempFile]); 22 | disp('After editing/saving the macro, press any key to continue...') 23 | pause 24 | clear(tempFile); 25 | run(tempFile); 26 | if isfield(PSMMacro, 'PDCload4_fnameNew') 27 | if ~strcmp(PSMMacro.PDCload4_fnameNew, PSMMacro.PDCload4_fname) 28 | PSMMacro.PDCload4_fname=PSMMacro.PDCload4_fnameNew; 29 | PSMMacro.PDCload4_initext=[]; 30 | end 31 | end 32 | save(PSMMacro.MacroName,'PSMMacro'); 33 | disp('-------------------------------------------------------------------------------' ); 34 | fprintf(1, 'PSMMacro.PSMload_DataPath=''%s''; %% The path for the *.dst files \r', PSMMacro.PSMload_DataPath); 35 | fprintf(1, 'PSMMacro.PDCload4_fnameNew=''%s''; %% The file name of the *.ini files \r', PSMMacro.PDCload4_fname); 36 | fprintf(1, 'PSMMacro.SetExtPDC_chansX=[%s]; %% channel selections \r', num2str(PSMMacro.SetExtPDC_chansX)); 37 | disp('-------------------------------------------------------------------------------' ); 38 | end 39 | 40 | prompt=['In subEditMacro: Do you want the keyboard to view/edit macro? Enter y or n [n]: ']; 41 | tempQKbdok1=input(prompt,'s'); if isempty(tempQKbdok1), tempQKbdok1='n'; end 42 | tempQKbdok2=strcmp(lower(tempQKbdok1(1)),'y'); %String comparison 43 | if tempQKbdok2 44 | disp(' '); 45 | disp('Macro definition is stored in "PSMMacro"'); 46 | disp('-------------------------------------------------------------------------------' ); 47 | disp('1) To view all the Macro definition, type in "PSMMacro".' ); 48 | disp('2) To view one Macro definition, type in PSMMacro.fieldname.' ); 49 | disp(' For example: "PSMMacro.PSMload_DataPath"' ); 50 | disp(' For example: "PSMMacro.SetExtPDC_chansX"' ); 51 | disp(' For example: "PSMMacro.PDCload4_fname"' ); 52 | disp('3) To edit a Macro definition, use matlab assignment command' ); 53 | disp(' For example: "PSMMacro.PSMload_DataPath=''c:\DstFilefolder\''; "' ); 54 | disp(' For example: "PSMMacro.SetExtPDC_chansX=[1, 2, 3]; "' ); 55 | disp(' For example: "PSMMacro.PDCload4_fname=''c:\IniFilefolder\BPA2_051220.ini''; PSMMacro.PDCload4_initext=[];"' ); 56 | disp('-------------------------------------------------------------------------------' ); 57 | disp('In subEditMacro: Invoking "keyboard" command - Enter "return" when you are finished') 58 | keyboard 59 | save(PSMMacro.MacroName,'PSMMacro'); 60 | end 61 | disp('Return from editing macro.'); -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/IndSift.m: -------------------------------------------------------------------------------- 1 | function [IndexC,IndexD]=IndSift(IndexA,IndexB) 2 | % IndexC = all integers in IndexA that are not in IndexB 3 | % IndexD = all integers in IndexA that are in IndexB 4 | % 5 | % Last modified 12/31/01. jfh 6 | 7 | % By J. F. Hauer, Pacific Northwest National Laboratory. 8 | % 9 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 10 | % retains a paid-up nonexclusive, irrevocable worldwide license to 11 | % reproduce, prepare derivative works, perform publicly and display 12 | % publicly by or for the Government, including the right to distribute 13 | % to other Government contractors. 14 | 15 | lenA=length(IndexA); 16 | IndexC=[]; IndexD=[]; 17 | for N=1:lenA 18 | test=find(IndexA(N)==IndexB); 19 | if isempty(test) 20 | IndexC=[IndexC IndexA(N)]; 21 | else 22 | IndexD=[IndexD IndexA(N)]; 23 | end 24 | end 25 | 26 | return 27 | 28 | %end of PSMT function -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/PSM2Date.m: -------------------------------------------------------------------------------- 1 | function [DateString,MatlabTime]=PSM2Date(PSMtime); 2 | % Convert PSM time to Matlab time, then to date string 3 | % 4 | % [DateString,MatlabTime]=PSM2Date(PSMtime); 5 | % 6 | % PSM time = seconds starting at 1-Jan-1900 7 | % Matlab time = days starting at 1-Jan-0000 8 | % Date string will be in format 10-Aug-1996 15:48:46.133 9 | % 10 | % See also date2PSM 11 | % 12 | % See also Matlab built-in functions NOW, DATESTR, DATENUM, DATEVEC 13 | % 14 | % Last modified 03/28/03. jfh 15 | 16 | % By J. F. Hauer, Pacific Northwest National Laboratory. 17 | % 18 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 19 | % retains a paid-up nonexclusive, irrevocable worldwide license to 20 | % reproduce, prepare derivative works, perform publicly and display 21 | % publicly by or for the Government, including the right to distribute 22 | % to other Government contractors. 23 | 24 | DateString=''; 25 | lines=max(size(PSMtime)); 26 | daysecs=24*3600; 27 | %keyboard 28 | 29 | MatlabTime=zeros(lines,1); 30 | for N=1:lines 31 | secfrac=PSMtime(N)-fix(PSMtime(N)); 32 | secfrac=round(secfrac*1000)/1000; 33 | PSMtime(N)=floor(PSMtime(N))+secfrac; 34 | secfrac=PSMtime(N)-fix(PSMtime(N)); 35 | MatlabTime(N)=datenum(1900,1,1,0,0,0)+floor(PSMtime(N))/daysecs; 36 | DateStr=datestr(MatlabTime(N),0); 37 | Tag=sprintf('%3.0i',round(secfrac*1000)); 38 | if secfrac==0, Tag='000'; end 39 | locs=findstr(' ',Tag); Tag(locs)='0'; 40 | DateStr=[DateStr '.' Tag]; 41 | if N==1, DateString=DateStr; 42 | else DateString=str2mat(DateString,DateStr); 43 | end 44 | end 45 | 46 | return 47 | 48 | %end PSM file 49 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/PSM_ButtonsP2.m: -------------------------------------------------------------------------------- 1 | %PSI Script PSM_ButtonsP2.m 2 | %Experimental pushbutton logic to select processing operations 3 | % 4 | %Operations supported: 5 | % Batch Plots 6 | % Filter/Decimate 7 | % Backload Filtered Data 8 | % Fourier 9 | % Histograms 10 | % Ringdown GUI 11 | % ModeMeter 12 | % save results 13 | % keyboard 14 | % end case 15 | % 16 | %NOTES: 17 | % a) GUI is figure number FigNo_GUI2 18 | % b) Secected operation is in text string BP2_Op 19 | % 20 | % Last modified 09/20/00. jfh 21 | 22 | 23 | %************************************************************************ 24 | FigNo_GUI2 = figure('Name','PSM Processing','units','normal',... 25 | 'position',[0.7 0.4 0.25 0.5]); 26 | 27 | % Batch Plots pushbutton 28 | pb_BatchPlots=uicontrol(FigNo_GUI2,'style','push','string','Batch Plots',... 29 | 'units','normal','position',[.1,.920,.50,.06],... 30 | 'callback','BP2_Op=''Batch Plots'';'); 31 | 32 | % Filter/Decimate pushbutton 33 | pb_FilterDec=uicontrol(FigNo_GUI2,'style','push','string','Filter/Decimate',... 34 | 'units','normal','position',[.1,.850,.50,.06],... 35 | 'callback','BP2_Op=''Filter/Decimate'';'); 36 | 37 | % Backload Filtered pushbutton 38 | pb_BkldFiltered=uicontrol(FigNo_GUI2,'style','push','string','Backload Filtered Data',... 39 | 'units','normal','position',[.1,.780,.50,.06],... 40 | 'callback','BP2_Op=''Backload Filtered'';'); 41 | 42 | % Fourier pushbutton 43 | pb_Fourier=uicontrol(FigNo_GUI2,'style','push','string','Fourier Analysis',... 44 | 'units','normal','position',[.1,.710,.50,.06],... 45 | 'callback','BP2_Op=''Fourier'';'); 46 | 47 | % Histograms pushbutton 48 | pb_Histograms=uicontrol(FigNo_GUI2,'style','push','string','Histogram Analysis',... 49 | 'units','normal','position',[.1,.640,.50,.06],... 50 | 'callback','BP2_Op=''Histograms'';'); 51 | 52 | % Ringdown GUI pushbutton 53 | pb_RingdownGUI=uicontrol(FigNo_GUI2,'style','push','string','Launch Ringdown GUI',... 54 | 'units','normal','position',[.1,.570,.50,.06],... 55 | 'callback','BP2_Op=''Ringdown GUI'';'); 56 | 57 | % ModeMeter pushbutton 58 | pb_ModeMeter=uicontrol(FigNo_GUI2,'style','push','string','Launch ModeMeter',... 59 | 'units','normal','position',[.1,.500,.50,.06],... 60 | 'callback','BP2_Op=''ModeMeter'';'); 61 | 62 | % Save Results pushbutton 63 | pb_SaveResults=uicontrol(FigNo_GUI2,'style','push','string','save latest results',... 64 | 'units','normal','position',[.1,.400,.50,.06],... 65 | 'callback','BP2_Op=''save results'';'); 66 | 67 | % Keyboard pushbutton 68 | pb_keyboard=uicontrol(FigNo_GUI2,'style','push','string','keyboard',... 69 | 'units','normal','position',[.1,.330,.50,.06],... 70 | 'callback','BP2_Op=''keyboard'';'); 71 | 72 | % End Case pushbutton 73 | pb_EndCase=uicontrol(FigNo_GUI2,'style','push','string','end case',... 74 | 'units','normal','position',[.1,.260,.50,.06],... 75 | 'callback','BP2_Op=''end case'';'); 76 | 77 | %************************************************************************ 78 | 79 | 80 | % End of PSI m-file 81 | 82 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/PSMautocov.m: -------------------------------------------------------------------------------- 1 | function [AutoCov]=PSMautocov(sigs,maxlagN,mode) 2 | % PSMautocov calculates the autocovariance sequence 3 | % for each column of real array sigs. 4 | % 5 | % Default is the unbiased estimate 6 | % (each lag normalized by number of summed points) 7 | % 8 | % [AutoCov]=PSMautocov(sigs,maxlagN,mode); 9 | % 10 | % Inputs: 11 | % 12 | % Outputs: 13 | % 14 | % Special functions called by PSMautocov: 15 | % 16 | % Last change 06/14/01. jfh 17 | 18 | [maxpts nsigs]=size(sigs); 19 | if isempty(maxlagN), maxlagN=maxpts; end 20 | maxlagN=max(maxlagN,0); maxlagN=min(maxlagN,maxpts); 21 | AutoCov=zeros(maxlagN,nsigs); 22 | for N=1:nsigs 23 | sig=sigs(:,N); sig=sig-mean(sig)*ones(maxpts,1); 24 | for lagN=1:maxlagN 25 | npts=maxpts-lagN+1; 26 | AutoCov(lagN,N)=sum(sig(1:npts).*sig(lagN:maxpts))/npts; 27 | end 28 | end 29 | 30 | %end of PSMT function -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/PSMlabl.m: -------------------------------------------------------------------------------- 1 | function PSMlabl(figInfo,subtitleL,subtitleR,PrintPlot) 2 | 3 | % PSMLABL: Annotates Ringdown Analysis Tool plots using PSM tools format 4 | % 5 | % Places PSM tools style titles on plots generated by the BPA/PNNL Ringdown 6 | % Analysis Tool. This function should be called directly by the tool using 7 | % the 'opts' input to the tool. 8 | % 9 | % Usage: 10 | % 11 | % PSMlabl(figInfo,subtitleL,subtitleR,PrintPlot); 12 | % 13 | % where 14 | % 15 | % figInfo = Structure containing information about the generated plot. 16 | % 17 | % subtitleL = Left justified text to be placed below main title. 18 | % 19 | % subtitleR = Right justified text to be placed below main title. 20 | 21 | % By Jeff M. Johnson, Pacific Northwest National Laboratory. 22 | % Date : March 1999 23 | % 24 | % Copyright (c) 1995-2002 Battelle Memorial Institute. The Government 25 | % retains a paid-up nonexclusive, irrevocable worldwide license to 26 | % reproduce, prepare derivative works, perform publicly and display 27 | % publicly by or for the Government, including the right to distribute 28 | % to other Government contractors. 29 | % 30 | % Last Update: January 24, 2002 (JMJ) 31 | 32 | if nargin<4; PrintPlot=0; end 33 | if nargin<3; subtitleR=''; end 34 | if nargin<2; subtitleL=''; end 35 | 36 | % assignin('base','figInfo',figInfo); 37 | % assignin('base','subtitleL',subtitleL); 38 | % assignin('base','subtitleR',subtitleR); 39 | 40 | axesHndls=figInfo.axesHndls; nnaxes=length(axesHndls); 41 | sigtitles=figInfo.titles; nnsigs=length(sigtitles); 42 | 43 | if nnaxes==1 44 | plottype=figInfo.plottypes; 45 | else 46 | plottype=figInfo.plottypes{1}; 47 | end 48 | 49 | % Set axes font properties to MATLAB defaults. 50 | fntname=get(0,'DefaultAxesFontName'); fntsize=get(0,'DefaultAxesFontSize'); 51 | h=get(axesHndls,{'XLabel' 'YLabel'}); set([h{:}],'FontName',fntname,'FontSize',fntsize); 52 | 53 | % Set tick mark direction outward. Remove top and right side tick marks. 54 | if ~strcmp(plottype,'mtbl') 55 | set(axesHndls,'Box','off','TickDir','out'); 56 | for ii=1:nnaxes 57 | axesHndl=axesHndls(ii); axes(axesHndl); 58 | xlim=get(axesHndl,'XLim'); ylim=get(axesHndl,'YLim'); 59 | line([xlim(1); xlim(2); xlim(2)],[ylim(2); ylim(2); ylim(1)], ... 60 | 'Color',get(axesHndl,'XColor'),'LineWidth',get(axesHndl,'LineWidth')); 61 | end 62 | end 63 | 64 | % Add the title and subtitles 65 | if nnsigs==2; if strcmp(sigtitles{2},'Model'); nnsigs=1; end; end 66 | 67 | if nnsigs==1 68 | switch plottype 69 | case 'tr', fstr='%s'; 70 | case {'frm', 'frp'}, fstr='Frequency spectrum of %s'; 71 | case 'mtbl', fstr='Modes identified from %s'; 72 | otherwise, fstr=''; 73 | end 74 | else 75 | fstr=''; 76 | end 77 | 78 | if isempty(fstr) 79 | pagetitle=get(get(axesHndls(1),'Title'),'String'); 80 | else 81 | pagetitle=sprintf(fstr,sigtitles{1}); 82 | end 83 | 84 | titlHndl=get(axesHndls(1),'Title'); 85 | set(titlHndl,'FontSize',fntsize+2,'Units','normalized'); 86 | if isempty(subtitleL) & isempty(subtitleR) 87 | set(titlHndl,'String',pagetitle); 88 | else 89 | set(titlHndl,'String',{pagetitle ' '}); 90 | set(axesHndls(1),'DefaultTextUnits','normalized', ... 91 | 'DefaultTextFontName',fntname, ... 92 | 'DefaultTextFontSize',fntsize, ... 93 | 'DefaultTextVerticalAlignment','baseline'); 94 | 95 | titlExtent=get(titlHndl,'Extent'); axes(axesHndls(1)); 96 | text(0,titlExtent(2),subtitleL,'HorizontalAlignment','left'); 97 | text(1,titlExtent(2),subtitleR,'HorizontalAlignment','right'); 98 | end 99 | 100 | if PrintPlot; print -f; end -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/PSMnamesCk.m: -------------------------------------------------------------------------------- 1 | % Case Script PSMnamesCk.m 2 | % Logic to standardize names of retrieved PSM data 3 | % 4 | % 5 | % PSM Tools called from PSMnamesCk: 6 | % PSMsave, ... 7 | % 8 | % Last modified 05/24/01. jfh 9 | 10 | % By J. F. Hauer, Pacific Northwest National Laboratory. 11 | % 12 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 13 | % retains a paid-up nonexclusive, irrevocable worldwide license to 14 | % reproduce, prepare derivative works, perform publicly and display 15 | % publicly by or for the Government, including the right to distribute 16 | % to other Government contractors. 17 | 18 | disp('In PSMnamesCk:') 19 | 20 | namesCkok=1; 21 | if namesCkok 22 | Varnames=strvcat(varlist); 23 | %Old SaveListB =['PSMtype PSMsigsX tstep namesX chankeyX CaseComR DataNames RefTimesR']; 24 | %Standard SaveList=['PSMtype PSMsigsX tstep namesX chankeyX CaseComR PSMfiles PSMreftimes CFname']; 25 | %Filtered SaveList=['PSMtype PSMsigsF tstepF namesX chankeyX CaseComF PSMfiles PSMreftimes CFname']; 26 | %command=['exist(' '''QQ''' ')'] 27 | PSMTnames=str2mat('PSMtype','PSMsigsX','tstep','namesX','chankeyX'); 28 | PSMTnames=str2mat(PSMTnames,'CaseComR','PSMfiles','PSMreftimes'); 29 | Nvars1=size(Varnames,1); Nvars2=size(PSMTnames,1); 30 | VarFound=zeros(Nvars2,1); NotFound=0; 31 | for N2=1:Nvars2 32 | name2=deblank(PSMTnames(N2,:)); 33 | for N1=1:Nvars1 34 | name1=deblank(Varnames(N1,:)); 35 | if strcmp(name1,name2), VarFound(N2)=N1; end; 36 | if strcmp(name2,'PSMsigsX')&strcmp(name1,'PSMsigsF') 37 | PSMsigsX=PSMsigsF; PSMsigsF=[]; VarFound(N2)=1; 38 | str1='Retrieved signal array is named PSMsigsF -- renamed to PSMsigsX'; 39 | disp(str1); filtered=1; 40 | end 41 | if strcmp(name2,'CaseComR')&strcmp(name1,'CaseCom') 42 | CaseComR=CaseCom; VarFound(N2)=1; 43 | str1='Retrieved Case Processing file is named CaseCom -- renamed to CaseComR'; 44 | disp(str1) 45 | end 46 | if strcmp(name2,'CaseComR')&strcmp(name1,'CaseComF') 47 | CaseComR=CaseComF; VarFound(N2)=1; 48 | str1='Retrieved Case Processing file is named CaseComF -- renamed to CaseComR'; 49 | disp(str1) 50 | end 51 | if strcmp(name2,'tstep')&strcmp(name1,'tstepF') 52 | tstep=tstepF; tstepF=[]; VarFound(N2)=1; 53 | str1='Retrieved time step is named tstepF -- renamed to tstep'; 54 | disp(str1) 55 | end 56 | end 57 | if VarFound(N2) str1=[name2 ' found']; 58 | else str1=[name2 ' not found']; 59 | disp(str1); eval([name1 '=[];']); 60 | NotFound=NotFound+1; 61 | end 62 | end 63 | if NotFound 64 | disp(' ') 65 | disp('Standard stored varibles for PSMtools are'); disp(PSMTnames) 66 | disp('Giving you the keyboard to rename variables - Type "return" when you are done') 67 | disp(' ') 68 | disp('Retrieved variables are'); disp(Varnames) 69 | keyboard 70 | end 71 | end 72 | 73 | disp('Return from PSMnamesCk') 74 | 75 | 76 | %end of PSMT utility 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/PSMparse.m: -------------------------------------------------------------------------------- 1 | function [pathname,filename]=PSMparse(fullpathname); 2 | 3 | % function [pathname,filename]=PSMparse(fullpathname); 4 | % 5 | % Parses a full file path into the individual path and filename 6 | % components. 7 | % 8 | 9 | % Copyright (c) 1996 Battelle Memorial Institute. The Government 10 | % retains a paid-up nonexclusive, irrevocable worldwide license to 11 | % reproduce, prepare derivative works, perform publicly and display 12 | % publicly by or for the Government, including the right to distribute 13 | % to other Government contractors. 14 | % 15 | % $Id$ 16 | 17 | % RCS Identification 18 | rcsid='$Id$'; 19 | 20 | % Platform specific path separator. 21 | c=computer; 22 | if strcmp(c,'MAC2') 23 | pathsep=':'; 24 | elseif (strcmp(c,'PCWIN') || strcmp(c,'PCWIN64')) 25 | pathsep='\'; 26 | elseif isunix 27 | pathsep='/'; 28 | else 29 | error(['Computer platform ' c ' not recognized.']) 30 | end 31 | 32 | pathseploc=find(fullpathname==pathsep); 33 | 34 | if isempty(pathseploc) 35 | filename=fullpathname; 36 | pathname=''; 37 | else 38 | filenameloc=pathseploc(length(pathseploc)); 39 | filename=fullpathname(filenameloc+1:length(fullpathname)); 40 | pathname=fullpathname(1:filenameloc); 41 | end 42 | 43 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/PSMunwrap.m: -------------------------------------------------------------------------------- 1 | function [TxyangD]=PSMunwrap(TxyangDW,UWmode,plusfrac) 2 | % [TxyangD]=PSMunwrap(TxyangDW,UWmode,plusfrac); 3 | % 4 | % jfh phase unwrapping logic 5 | % Angle data is assumed to be in degrees 6 | % UWmode = 0: Unwrapped angle data starts on interval (-360 0] 7 | % UWmode = 1: Unwrapped angle data starts at initial angle 8 | % plusfrac*180 is test level for wrapping jump (default=0.90) 9 | % 10 | % Last modified 09/20/02. jfh 11 | 12 | if ~exist('UWmode'), UWmode=[]; end 13 | if isempty(UWmode), UWmode=0; end 14 | if ~exist('plusfrac'), plusfrac=[]; end 15 | if isempty(plusfrac), plusfrac=0.90; end 16 | plusfrac=max(plusfrac,0.60); plusfrac=min(plusfrac,1.00); 17 | 18 | TxyangD=TxyangDW; 19 | dims=size(TxyangD); 20 | if dims(2)>dims(1) 21 | disp(['In PSMunwrap: WARNING - dimensions = ' num2str(dims)]) 22 | pause 23 | end 24 | 25 | npts=size(TxyangD,1); 26 | if UWmode==0 27 | if TxyangD(1)>0, TxyangD(1)=TxyangD(1)-360; end 28 | if TxyangD(1)<=-360 29 | wraps=fix(TxyangD(1)/360); 30 | TxyangD(1)=TxyangD(1)-wraps*360; 31 | end 32 | end 33 | for i=2:npts, 34 | dth=TxyangD(i)-TxyangD(i-1); 35 | wraps=fix(dth/360); 36 | dth=dth-wraps*360; 37 | if dth>(180*plusfrac), dth=dth-360; end 38 | if dth<-(180/plusfrac), dth=dth+360; end 39 | TxyangD(i)=TxyangD(i-1)+dth; 40 | end 41 | 42 | return 43 | 44 | %end of PSMT utility 45 | 46 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/PickList1.m: -------------------------------------------------------------------------------- 1 | function [PickNo,PickName,pickOK,sequential]=PickList1(OptList,InPick,locbase,maxtrys,Index) 2 | % Pick one choice from displayed options list 3 | % 4 | % 5 | % [Pick,PickName,pickOK,sequential]=PickList 1(OptList,InPick,locbase,maxtrys,Index); 6 | % 7 | % Index indicates special numbering of options. Generally used when displayed 8 | % options are a special subset of some external list. 9 | % 10 | % See also PickList2, names2chans 11 | % 12 | % Last modified 10/15/03. jfh 13 | 14 | % By J. F. Hauer, Pacific Northwest National Laboratory. 15 | % 16 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 17 | % retains a paid-up nonexclusive, irrevocable worldwide license to 18 | % reproduce, prepare derivative works, perform publicly and display 19 | % publicly by or for the Government, including the right to distribute 20 | % to other Government contractors. 21 | 22 | Noptions=size(OptList,1); 23 | if ~exist('locbase'), locbase=[]; end 24 | if isempty(locbase), locbase=1; end 25 | locbase=min(1,max(0,locbase)); 26 | if ~exist('maxtrys'), maxtrys=[]; end 27 | if isempty(maxtrys), maxtrys=5; end 28 | maxtrys=max(maxtrys,1); 29 | if ~exist('Index'), Index=[]; end 30 | if length(Index)~=Noptions, Index=[]; end 31 | if isempty(Index), Index=[locbase:Noptions+locbase-1]; end 32 | IndSteps=Index(2:Noptions)-Index(1:Noptions-1); 33 | sequential=isempty(find(IndSteps~=1)); 34 | if ~exist('InPick'), InPick=[]; end 35 | PickNo=[]; 36 | if ~isempty(InPick) 37 | PickNo=find(Index==InPick); 38 | if ~isempty(PickNo), PickNo=InPick; end 39 | end 40 | 41 | OptListN=names2chans(OptList,locbase,Index); 42 | 43 | %************************************************************************* 44 | %Select option from provided list 45 | default='n'; 46 | if ~isempty(PickNo), default='y'; end 47 | if isempty(InPick), default=''; end 48 | pickOK=0; 49 | for M=0:maxtrys 50 | if ~pickOK 51 | disp('Select desired option from list below: ') 52 | disp(OptListN) 53 | if sequential 54 | prompt=[' Enter ' num2str(Index(1)) ' to ' num2str(Index(Noptions))]; 55 | else 56 | prompt=[' Enter value from index set [' num2str(Index) ']:']; 57 | end 58 | PickNo=promptnv(prompt,PickNo); 59 | if isempty(PickNo), PickNo=1; end 60 | PickNo=max(PickNo,min(Index)); PickNo=min(PickNo,max(Index)); 61 | PickNoD=find(Index==PickNo); 62 | PickName=OptList(PickNoD,:); 63 | disp(['PickNo = ' num2str(PickNo) ': ' PickName]) 64 | pickOK=promptyn('Is this ok?', default); 65 | default='y'; 66 | else 67 | break 68 | end 69 | end 70 | if ~pickOK 71 | str1=sprintf('Sorry -%5i chances is all you get!',maxtrys); 72 | disp([str1,' Returning to invoking Matlab function.']) 73 | PickNo=[]; PickName=''; return 74 | end 75 | %************************************************************************* 76 | 77 | %end of PSMT utility -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/PickList2.m: -------------------------------------------------------------------------------- 1 | function [PickVec,PickNames,pickOK]=PickList2(OptList,InPick,locbase,maxtrys,Index) 2 | % Pick multiple choices from displayed options list 3 | % 4 | % [Pick,PickNames,pickOK]=PickList2(OptList,InPick,locbase,maxtrys,Index); 5 | % 6 | % See also PickList1, names2chans 7 | % 8 | % Last modified 06/27/03. jfh 9 | 10 | % By J. F. Hauer, Pacific Northwest National Laboratory. 11 | % 12 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 13 | % retains a paid-up nonexclusive, irrevocable worldwide license to 14 | % reproduce, prepare derivative works, perform publicly and display 15 | % publicly by or for the Government, including the right to distribute 16 | % to other Government contractors. 17 | 18 | Noptions=size(OptList,1); 19 | if ~exist('locbase'), locbase=[]; end 20 | if isempty(locbase), locbase=1; end 21 | locbase=min(1,max(0,locbase)); 22 | if ~exist('maxtrys'), maxtrys=[]; end 23 | if isempty(maxtrys), maxtrys=10; end 24 | maxtrys=max(maxtrys,1); 25 | if ~exist('Index'), Index=[]; end 26 | if length(Index)~=Noptions, Index=[]; end 27 | if isempty(Index), Index=[locbase:Noptions+locbase-1]; end 28 | IndSteps=Index(2:Noptions)-Index(1:Noptions-1); 29 | sequential=isempty(find(IndSteps~=1)); 30 | if ~exist('InPick'), InPick=[]; end 31 | if isempty(InPick), PickVec=Index(1); 32 | else 33 | PickVec=[]; 34 | for n=1:length(InPick) 35 | if find(InPick(n)==Index), PickVec=[PickVec InPick(n)]; end 36 | end 37 | end 38 | 39 | disp('Select desired options from list below: ') 40 | OptListN=names2chans(OptList,locbase,Index); 41 | disp(OptListN) 42 | 43 | %************************************************************************* 44 | %Select option from provided list 45 | default='n'; 46 | if ~isempty(InPick), default='y'; end 47 | for M=0:maxtrys 48 | PickVecD=[]; 49 | for n=1:length(PickVec) 50 | PickVecD=[PickVecD find(PickVec(n)==Index)]; 51 | end 52 | if isempty(PickVecD) PickVecD=1; end 53 | disp(' ') 54 | disp('Present selections shown below:') 55 | disp(OptListN(PickVecD,:)) 56 | pickOK=promptyn('Is this ok?', default); 57 | default='y'; 58 | if M==maxtrys, break, end 59 | if ~pickOK 60 | disp(' ') 61 | disp('Update selection vector shown below: ') 62 | PickVecS=['val=[' num2str(PickVec) ']']; 63 | disp(PickVecS) 64 | disp('Invoking "keyboard" command - Enter "return" when you are finished') 65 | val=1; %Assure nonempty value 66 | keyboard 67 | PickVec=val; 68 | else 69 | PickNames=OptList(PickVecD,:); break 70 | end 71 | end 72 | if ~pickOK 73 | str1=sprintf('Sorry -%5i chances is all you get!',maxtrys); 74 | disp([str1,' Returning to invoking Matlab function.']) 75 | PickVec=[]; PickNames=''; return 76 | end 77 | %************************************************************************* 78 | 79 | %end of PSMT function -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/SWXdisp.m: -------------------------------------------------------------------------------- 1 | function [CaseCom]=SWXdisp(caseID,casetime,CaseCom,namesX,PSMsigsX); 2 | % Displays/prints powerflow data 3 | % 4 | % Functions provided: 5 | % 6 | % 7 | % PSMT utilities called from PSMload: 8 | % 9 | % Last modified 09/06/01. jfh 10 | 11 | % By J. F. Hauer, Pacific Northwest National Laboratory. 12 | % 13 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 14 | % retains a paid-up nonexclusive, irrevocable worldwide license to 15 | % reproduce, prepare derivative works, perform publicly and display 16 | % publicly by or for the Government, including the right to distribute 17 | % to other Government contractors. 18 | 19 | disp(['In SWXdisp:']) 20 | keyboard 21 | 22 | strs=['Powerflow display for ' caseID]; 23 | strs=str2mat(strs,CaseCom(1:2,:)) 24 | 25 | [maxpoints nsigs]=size(PSMsigsX); 26 | for N=1:nsigs 27 | dline=[' ' num2str(PSMsigsX(1,N))]; 28 | strs=str2mat(strs,namesX(N,:),dline); 29 | end 30 | disp(strs) 31 | 32 | %end of PSMT utility 33 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/SetExtPSMT.m: -------------------------------------------------------------------------------- 1 | function [MenuName,chansX,chansXok]=SetExtPSMT(chansXstr,names,chankey,CFname) 2 | % Determine signals to extract from SWX records 3 | % 4 | % PSM Tools called from SetExtPSMT: 5 | % promptyn 6 | % 7 | % Last modified 03/04/03. jfh 8 | 9 | % By J. F. Hauer, Pacific Northwest National Laboratory. 10 | % 11 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 12 | % retains a paid-up nonexclusive, irrevocable worldwide license to 13 | % reproduce, prepare derivative works, perform publicly and display 14 | % publicly by or for the Government, including the right to distribute 15 | % to other Government contractors. 16 | 17 | MenuName=''; chansX=[]; chansXok=0; 18 | if ~ischar(chansXstr) 19 | chansXstr=['chansX=[' num2str(chansXstr) '];']; 20 | end 21 | eval(chansXstr); 22 | 23 | FNname='SetExtPSMT'; %Internal name of this utility 24 | 25 | %********************************************************************* 26 | nsigs=size(names,1); 27 | TimeOK=~isempty(findstr('time',lower(names(1,1:4)))); 28 | disp(' ') 29 | str=['In ' FNname ': Number of stored signals=' num2str(nsigs)]; 30 | disp(str) 31 | if TimeOK 32 | disp(' Includes time axis inserted at column 1') 33 | else 34 | disp(' WARNING: NO TIME AXIS FOUND AT COLUMN 1') 35 | end 36 | %********************************************************************* 37 | 38 | 39 | %********************************************************************* 40 | %Define PSMT signal types 41 | %PDC signal types 42 | SigTypes=str2mat('Time','Freq','VFrq','VMag','VAng','IMag','IAng','MW ','MVar'); 43 | %PSLF signal types 44 | SigTypes=str2mat(SigTypes,'vbus VMag','abus VAng','fbus Freq'); 45 | SigTypes=str2mat(SigTypes,'pbr MW ','qbr Mvar','pif MW ','qif Mvar'); 46 | SigTypes=str2mat(SigTypes,'pacr MW ','qacr Mvar','paci MW ','qaci Mvar'); 47 | SigTypes=str2mat(SigTypes,'ang Gang','spd Gfrq','pg MW ','qg Mvar'); 48 | %PTI signal types 49 | SigTypes=str2mat(SigTypes,'POWR ','ANGL ','FREQ ','SPD ','VARS '); 50 | SigTypes=str2mat(SigTypes,'PMEC ','VREF ','EFD ','ETRM ','AUX '); 51 | %********************************************************************* 52 | 53 | %********************************************************************* 54 | %Load PSMT custom menus 55 | %keyboard 56 | chansMenuC=''; chansSC=''; 57 | if ~isempty(deblank(which('PSMTmenu'))) 58 | [chansMenuC,chansSC]=PSMTmenu('','',CFname,nsigs); 59 | end 60 | if ~isempty(chansMenuC) 61 | if isempty(deblank(chansMenuC(1,:))) 62 | NmenusC=size(chansMenuC,1); 63 | if NmenusC>1 64 | chansMenuC=chansMenuC(2:NmenusC,:); 65 | chansSC=chansSC(2:NmenusC,:); 66 | else 67 | chansMenuC=''; chansSC=''; 68 | end 69 | end 70 | end 71 | NmenusC=size(chansMenuC,1); 72 | %********************************************************************* 73 | 74 | %********************************************************************* 75 | %Determine signals to extract 76 | ProcessCom='PSMT signal extraction'; 77 | [MenuName,chansX,chansXok]=SigSelect(chansX,names,chankey,...) 78 | CFname,SigTypes,chansMenuC,chansSC,ProcessCom); 79 | %********************************************************************* 80 | 81 | %********************************************************************* 82 | if TimeOK 83 | if chansX(1)~=1, chansX=[1 chansX]; end 84 | end 85 | if ~chansXok 86 | chansX=0; chansXok=0; 87 | MenuName='NONE'; 88 | str1=['In ' FNname ': No signals selected - ']; 89 | disp([str1,'Returning to invoking Matlab function']) 90 | disp(' ') 91 | return 92 | end 93 | %********************************************************************* 94 | 95 | return 96 | 97 | %end of PSMT function -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/ShowRange.m: -------------------------------------------------------------------------------- 1 | function [TRange,nrange,TRangeok]=ShowRange(PSMsigsX,namesX,DispSig,TRange,tstep,maxtrys) 2 | % Interactive graphics to determine processing range 3 | % 4 | % [TRange,nrange,TRangeok]=ShowRange(PSMsigsX,namesX,DispSig,TRange,tstep,maxtrys); 5 | % 6 | % Last modified 08/25/03. jfh 7 | % Modified 07/12/05 by Henry Huang. Changed some defaults & prompts 8 | 9 | % By J. F. Hauer, Pacific Northwest National Laboratory. 10 | % 11 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 12 | % retains a paid-up nonexclusive, irrevocable worldwide license to 13 | % reproduce, prepare derivative works, perform publicly and display 14 | % publicly by or for the Government, including the right to distribute 15 | % to other Government contractors. 16 | 17 | global Kprompt ynprompt nvprompt 18 | 19 | nsigsX=size(PSMsigsX,2); 20 | maxpoints=size(PSMsigsX,1); 21 | if ~exist('DispSig'), DispSig=[]; end 22 | if isempty(DispSig), DispSig=min(nsigsX,3); end 23 | DispSig=min(DispSig,nsigsX); 24 | if ~exist('tstep'), tstep=[]; end 25 | if isempty(tstep), tstep=PSMsigsX(2,1)-PSMsigsX(1,1); end 26 | 27 | tmin=PSMsigsX(1,1); tmax=PSMsigsX(maxpoints,1); 28 | disp(sprintf('In ShowRange: Max TRange = [ %6.2f %6.2f ]', tmin,tmax)) 29 | if ~exist('TRange'), TRange=[]; end 30 | if isempty(TRange), TRange=[tmin tmax]; end 31 | if TRange(2)<=TRange(1),TRange=[tmin tmax]; end 32 | if ~exist('maxtrys'), maxtrys=1; end 33 | if isempty(maxtrys), maxtrys=5; end 34 | maxtrys=max(maxtrys,1); 35 | 36 | %************************************************************************* 37 | TRangeok=0; 38 | %keyboard; 39 | for i=1:maxtrys 40 | if ~TRangeok 41 | if i==1, h=figure; end %Initiate new figure 42 | plot(PSMsigsX(:,1),PSMsigsX(:,DispSig)); figure(h) 43 | Ptitle{1}=namesX(DispSig,:); 44 | Ptitle{2}=sprintf('TRange = [ %6.2f %6.2f ]', TRange); 45 | title(Ptitle); xlabel('Time in Seconds') 46 | set(gca,'TickDir','out') 47 | set(gca,'xlim',TRange) 48 | disp(sprintf('In ShowRange: Indicated TRange = [ %6.2f %6.2f ]', TRange)) 49 | TRangeok=promptyn(' Is this range ok? ', 'y'); % set default to 'y'. Henry 07/12/05 50 | if ~TRangeok 51 | disp('In ShowRange: Select time range for data operations') 52 | str=sprintf('Display signal is DispSig=%3.0i : ',DispSig); 53 | disp([str namesX(DispSig,:)]) 54 | disp('EXAMPLE FOLLOWS:') 55 | disp(sprintf(' TRange=[ %6.2f %6.2f ]',TRange)) 56 | disp('Invoking "keyboard" command - Enter "return" when you are finished') 57 | keyboard 58 | end 59 | TRange(1)=max(TRange(1),tmin); TRange(2)=min(TRange(2),tmax); 60 | end 61 | end 62 | if ~TRangeok 63 | disp(sprintf('Sorry -%5i chances is all you get!',maxtrys)) 64 | disp(' Defaulting to full time range') 65 | disp(' Returning to invoking Matlab function') 66 | TRange=[tmin tmax]; nrange=[1 maxpoints]; return 67 | end 68 | %Determine save range in samples 69 | n1=round((TRange(1)-tmin)/tstep+1); n2=round(min((TRange(2)-tmin)/tstep+1,maxpoints)); 70 | nrange=[n1 n2]; 71 | 72 | 73 | %end of PSMT m-file -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/SpecialDisp.m: -------------------------------------------------------------------------------- 1 | % Custom Script SpecialDisp.m 2 | % 3 | % Users can use this as a link to custom codes 4 | % 5 | % Modified 04/13/04. jfh 6 | % Modified 10/18/2006 Ning Zhou to add macro function 7 | 8 | % By J. F. Hauer, Pacific Northwest National Laboratory. 9 | 10 | if 0 11 | keyboard 12 | save Debug_13 13 | elseif 0 14 | clear all 15 | close all 16 | clc 17 | load Debug_13 18 | funLoadMacro() 19 | PSMMacro.RunMode=1; %run macro 20 | % PSMMacro.RunMode=0; %record macro 21 | % PSMMacro.RunMode=-1; %normal orperation 22 | end 23 | 24 | %Call user-provided custom code 25 | %Robust050902A_PSMT %[CUSTOM EXAMPLE] 26 | %Robust091902A_PSMT %[CUSTOM EXAMPLE] 27 | %Robust091902B_PSMT %[CUSTOM EXAMPLE] 28 | 29 | RobustCode='Robust091902B_PSMT'; %keyboard 30 | 31 | disp(' '); disp('In Custom Utility SpecialDisp:') 32 | disp(['Indicated user utility = ' RobustCode]) 33 | %---------------------------------------------------- 34 | % Begin: Macro selection ZN 03/31/06 35 | if ~isfield(PSMMacro, 'SpecialDisp_launchok'), PSMMacro.SpecialDisp_launchok=NaN;end 36 | if (PSMMacro.RunMode<1 || isnan(PSMMacro.SpecialDisp_launchok)) % Macro definition mode or selection not defined in a macro 37 | launchok=promptyn(['Launch utility ' RobustCode '? '],'y'); 38 | else 39 | launchok=PSMMacro.SpecialDisp_launchok; 40 | end 41 | 42 | if PSMMacro.RunMode==0 % if in macro definition mode 43 | if PSMMacro.PauseMode==0 % if record mode is not paused 44 | PSMMacro.SpecialDisp_launchok=launchok; 45 | else 46 | PSMMacro.SpecialDisp_launchok=NaN; 47 | end 48 | save(PSMMacro.MacroName,'PSMMacro'); 49 | end 50 | %launchok=promptyn(['Launch utility ' RobustCode '? '],'y'); 51 | % End: Macro selection ZN 03/31/06 52 | %---------------------------------------------------- 53 | 54 | 55 | launchck=deblank(which(RobustCode)); %Check presence 56 | if isempty(launchck) 57 | disp(['In SpecialDisp: Cannot find case ' RobustCode]) 58 | launchok=0; 59 | else 60 | if launchok 61 | eval(RobustCode); 62 | end 63 | end 64 | %---------------------------------------------------- 65 | % Begin: Macro selection ZN 03/31/06 66 | if ~isfield(PSMMacro, 'SpecialDisp_keybdok'), PSMMacro.SpecialDisp_keybdok=NaN;end 67 | if (PSMMacro.RunMode<1 || isnan(PSMMacro.SpecialDisp_keybdok)) % Macro definition mode or selection not defined in a macro 68 | keybdok=promptyn(['In SpecialDisp: Do you want the keyboard? '], ''); 69 | else 70 | keybdok=PSMMacro.SpecialDisp_keybdok; 71 | end 72 | 73 | if PSMMacro.RunMode==0 % if in macro definition mode 74 | if PSMMacro.PauseMode==0 % if record mode is not paused 75 | PSMMacro.SpecialDisp_keybdok=keybdok; 76 | else 77 | PSMMacro.SpecialDisp_keybdok=NaN; 78 | end 79 | save(PSMMacro.MacroName,'PSMMacro'); 80 | end 81 | %keybdok=promptyn(['In SpecialDisp: Do you want the keyboard? '], ''); 82 | % End: Macro selection ZN 03/31/06 83 | %---------------------------------------------------- 84 | 85 | 86 | if keybdok 87 | disp(['In SpecialDisp: Invoking "keyboard" command - Enter "return" when you are finished']) 88 | keyboard 89 | end 90 | 91 | disp('Return from SpecialDisp') 92 | disp(' ') 93 | return 94 | 95 | %end of PSMT utility 96 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/StringOut.m: -------------------------------------------------------------------------------- 1 | function [ClinesN]=StringOut(Clines,OutChar) 2 | % Deletes long strings of OutChar characters that are common 3 | % to the rows of Clines 4 | % 5 | % [ClinesN]=StringOut(Clines,OutChar); 6 | % 7 | % Last modified 01/25/02. jfh 8 | 9 | tabchar=' '; 10 | StringN=''; 11 | if nargin<1, disp('In StringOut: No data - return'), return, end 12 | if nargin<2, OutChar=' '; end 13 | if isempty(OutChar), OutChar=' '; end 14 | 15 | ClinesN=Clines; 16 | [nlines nchars]=size(Clines,1); 17 | Bind=zeros(nlines,nchars); 18 | MinBks=5; Bloc1=1; Bloc2=2; 19 | Bstr=''; for n=1:MinBks, Bstr=[Bstr OutChar]; end 20 | for L=1:chars 21 | for N=1:nlines 22 | Bind(N,:)=zeros(1,nchars); 23 | Lbstr=findstr(Bstr,ClinesN(1,:)); 24 | Bind(N,Lbstr)=1; 25 | end 26 | LBsum=sum(Bind,1); 27 | if max(LBsum)Bloc1+1 33 | disp(['Removing surplus characters of type ' ''' ''' ' from character array']) 34 | disp( 'Revised character array is') 35 | ClinesN=ClinesN(:,[1:Bloc1 Bloc2:nchars]); 36 | disp(ClinesN) 37 | end 38 | 39 | return 40 | 41 | %end of PSMT function -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/Tabs2Blanks.m: -------------------------------------------------------------------------------- 1 | %PSMT Utility PSDSnamesFix 2 | 3 | tab=' '; 4 | 5 | [y,comment,fname,names]=cread(''); 6 | nsigs=size(names,1); 7 | namesN=names; 8 | line=''; MaxLen=0; 9 | for N=2:nsigs %Replace tabs by blanks 10 | line=deblank(namesN(N,:)); 11 | Ltabs=findstr(line,tab); 12 | if ~isempty(Ltabs), line(Ltabs)=' '; end 13 | LineLen=length(line); 14 | namesN(N,1:LineLen)=line; 15 | MaxLen=max(MaxLen,LineLen); 16 | end 17 | namesN=namesN(:,1:MaxLen); 18 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/TrfCalcS.m: -------------------------------------------------------------------------------- 1 | function [Trf,frq] = TrfCalcS(BB,AA,arg3,arg4) 2 | % 3 | % Evaluates s-domain transfer function BB/AA, 4 | % under standard Matlab notation for filters. 5 | % 6 | % All frequency parameters are in Hertz. 7 | % 8 | % FORM A: 9 | % function [Trf,frq] = TrfCalcS(BB,AA,nfrq,frqstep) 10 | % 11 | % FORM B: 12 | % function [Trf,frq] = TrfCalcS(BB,AA,frq) 13 | % 14 | % INPUTS (form A): 15 | % nfrq = number of eqi-spaced frequency samples for Trf evaluation 16 | % frqstep = spacing for frequency samples 17 | % 18 | % INPUTS (form B): 19 | % frq = frequency samples for Trf evaluation 20 | % 21 | % OUTPUTS: 22 | % Trf = complex values of transfer function BB/AA 23 | % frq = frequency points (in Hertz) for Trf evaluation 24 | % 25 | % Last modified 05/20/98. jfh 26 | 27 | if max(size(arg3)) == 1 28 | nfrq=arg3; frqstep=arg4; 29 | frq=(0:nfrq-1)'*frqstep; 30 | else 31 | frq=arg3; 32 | end 33 | 34 | imag=sqrt(-1); 35 | fac=imag*2*pi; 36 | Trf=polyval(BB,frq*fac)./polyval(AA,frq*fac); 37 | 38 | %end of jfh m-file 39 | 40 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/TrfCalcZ.m: -------------------------------------------------------------------------------- 1 | function [Trf,frq] = TrfCalcZ(BB,AA,nfrq,samprate) 2 | % 3 | % function [Trf,frq] = TrfCalcZ(BB,AA,nfrq,samprate) 4 | % 5 | % Evaluates digital transfer function BB/AA, 6 | % under standard Matlab notation for filters. 7 | % 8 | % nfrq = number of eqi-spaced samples for evaluation on unit circle 9 | % samprate = sample rate (per second) 10 | % Trf = complex values of transfer function BB/AA 11 | % frq = frequency points (in Hertz) for Trf evaluation 12 | % 13 | % last modified 07/30/97. jfh 14 | 15 | Nyquist=0.5*samprate; imag=sqrt(-1); 16 | frq=(0:nfrq-1)'*Nyquist/nfrq; 17 | fac=imag*pi/Nyquist; 18 | Trf=polyval(BB,exp(frq*fac))./polyval(AA,exp(frq*fac)); 19 | 20 | %end of jfh m-file 21 | 22 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/TrigSync.m: -------------------------------------------------------------------------------- 1 | function[BSincH]=TrigSync(CaseCom,fcorner0,SincFac,tstep,track) 2 | % Constructs Hanned Sinc filter for Trig3.m 3 | % 4 | % [BSincH]=TrigSync(CaseCom,fcorner0,SincFac,tstep); 5 | % 6 | % Last modified 09/05/01. jfh 7 | 8 | %General initialization 9 | global Kprompt ynprompt nvprompt 10 | 11 | %Check input parameters 12 | if isempty(CaseCom), CaseCom='In TrigSync:'; end 13 | if isempty(fcorner0),fcorner0=1; end 14 | if isempty(SincFac), SincFac=1; end 15 | if isempty(tstep), tstep=0.05; end 16 | if tstep<=0, tstep=0.05; end 17 | if isempty(track), track=0; end 18 | 19 | %************************************************************************* 20 | %Construct signal filter 21 | strs='In TrigSync: Constructing Sinc filter SincH'; 22 | disp(strs) 23 | CaseCom=str2mat(CaseCom,strs); 24 | simrate=1/tstep; 25 | Nyquist=0.5*simrate; 26 | strs='NOTES:'; 27 | strs=str2mat(strs,' a) Filter Sinc0 is a basic Sinc filter of "Sincpts" points'); 28 | strs=str2mat(strs,' b) Filter SincH is filter Sinc0 plus a Hamming window'); 29 | strs=str2mat(strs,' c) [Sinc0 SincH] will have -6 dB corners in the general range'); 30 | strs=str2mat(strs,' of [1 2]*fcorner0. Just where depends upon SincFac.'); 31 | strs=str2mat(strs,' d) Use SincFac=[2 1 0.5] for a [low medium high] order filter'); 32 | if track, disp(strs); end 33 | if fcorner0<=0, fcorner0=1; end %lowpass corner frequency in Hertz 34 | if SincFac<=0, SincFac=1.0; end %medium order filter 35 | disp('DEFAULT SETTINGS:') 36 | disp(sprintf('fcorner0=%3.3f',fcorner0)) 37 | disp(sprintf('SincFac= %3.3f',SincFac)) 38 | setok=promptyn('In PSMSinc: Is this ok?', 'y'); 39 | if ~setok 40 | strs='In TrigSync: Invoking "keyboard command for modification of filter values.'; 41 | disp(str2mat(strs,' Type "return" when you are finished.')) 42 | keyboard 43 | end 44 | ncorner=fcorner0/Nyquist; 45 | Sincpts=fix(0.5*simrate/SincFac)*2; %force an even number 46 | SincRange=ncorner*(-Sincpts:Sincpts); 47 | I=find(SincRange); 48 | SincWts=ones(size(SincRange)); 49 | SincWts(I)=sin(pi*SincRange(I))./(pi*SincRange(I)); 50 | HamWts=0.54-0.46*cos(2*pi*(0:2*Sincpts)/(2*Sincpts)); 51 | BSinc0=ncorner*SincWts; 52 | BSincH=BSinc0.*HamWts; 53 | BSinc0=BSinc0/sum(BSinc0); 54 | BSincH=BSincH/sum(BSincH); 55 | SincDat1=sprintf('fcorner0=%5.3f, SincFac= %5.3f',fcorner0,SincFac); 56 | strs=['Sinc1 Parameters: ' SincDat1]; 57 | SincDat2=sprintf('ncorner=%5.3f, Sincpts=%5.3i',ncorner, Sincpts); 58 | strs=str2mat(strs,SincDat2); 59 | disp(strs) 60 | CaseCom=str2mat(CaseCom,strs); 61 | %************************************************************************* 62 | 63 | %************************************************************************* 64 | %Optional plotting of filter characteristics 65 | plotok=promptyn('In TrigSync: Plot filter characteristics?', 'n'); 66 | if plotok 67 | h1=figure; 68 | plot([BSinc0' BSincH']) 69 | Ptitle{1}=['weights for Sinc0,Sinc1: ' SincDat1]; 70 | title(Ptitle) 71 | set(gca,'TickDir','out') 72 | h=figure; 73 | [resp0,f]=TrfCalcZ(BSinc0,1,4096,simrate); 74 | [resp1,f]=TrfCalcZ(BSincH,1,4096,simrate); 75 | plot(f,[db(abs(resp0)) db(abs(resp1))]); 76 | Ptitle{1}=['dB gain for Sinc0, Sinc1: ' SincDat1]; 77 | title(Ptitle) 78 | set(gca,'TickDir','out') 79 | h=figure; 80 | plot(f,[db(abs(resp0)) db(abs(resp1))]); 81 | title(Ptitle) 82 | set(gca,'TickDir','out') 83 | set (gca,'ylim',[-6 6]) 84 | disp('Processing paused - press any key to continue') 85 | pause 86 | end 87 | %************************************************************************* 88 | 89 | return 90 | 91 | %end of jfh m-file 92 | 93 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/cparseR.m: -------------------------------------------------------------------------------- 1 | function [ValMat,count]=cparseR(String,del) 2 | % Parsing delimited text string into numerical value array 3 | % 4 | % Last modified 05/22/00. jfh 5 | 6 | ValMat=0; 7 | tab=' '; 8 | if nargin<1, disp('In CparseR: No data-return'), return, end 9 | if nargin<2, del=tab; end 10 | if isempty(del), del=tab; end 11 | 12 | %String=[String del]; 13 | [ValMat,count]=sscanf(String,'%f'); 14 | 15 | return 16 | 17 | %end of PSM script -------------------------------------------------------------------------------- /PSMtools Source/PSMtools/db.m: -------------------------------------------------------------------------------- 1 | function [y]=db(x); 2 | %Calculate the db gain of x: 3 | % [y]=db(x); 4 | %Calculation equivalent to 5 | % y=20*log10(abs(x)); 6 | %but with protection against log of zero 7 | % 8 | % Last modified 01/19/01. jfh 9 | 10 | % $Id: db.m,v 1.1.1.1 1994/06/02 14:50:56 d3f011 Exp $ 11 | MinLevel=1e-40; 12 | loc=find(abs(x)1 14 | disp('In vec2mat: entry should be a vector, not an array') 15 | disp([' Entry size = ' num2str(size(vec)) ' -- returning']) 16 | return 17 | end 18 | 19 | if size(vec,2)>size(vec,1) 20 | vec=vec'; 21 | end 22 | %disp('In vec2mat:'); keyboard 23 | 24 | if isempty(vecmat) 25 | vecmat=vec; return 26 | end 27 | 28 | nvec=length(vec); 29 | [nrows ncols]=size(vecmat); 30 | 31 | fillvec=ones(max(nrows,nvec),1)*vfill; 32 | fillmat=ones(max(nrows,nvec),ncols)*vfill; 33 | fillvec(1:nvec)=vec; 34 | fillmat(1:nrows,1:ncols)=vecmat; 35 | vecmat=[fillmat fillvec]; 36 | 37 | return 38 | 39 | %end of PSMT utility 40 | 41 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools_Utilities/PDC_Utilities/PDCload0.m: -------------------------------------------------------------------------------- 1 | function [CaseCom,SaveFile,chankeyX,namesX,PSMsigsX,tstep,PDCfiles]... 2 | =PDCload0(caseID,PDCfiles,SigMask,CaseCom,decfacX,loadopt,saveopt,trackX) 3 | 4 | % PDCload0.m is the main driver in the logic that retrieves and 5 | % restructures PDC phasor data saved as .mat files. 6 | % [CaseCom,SaveFile,chankeyX,namesX,PSMsigsX,tstep,PDCfiles]... 7 | % =PDCload0(caseID,PDCfiles,SigMask,CaseCom,decfacX,loadopt,saveopt,trackX) 8 | % 9 | % Last modified 06/29/98. jfh 10 | 11 | % By J. F. Hauer, Pacific Northwest National Laboratory. 12 | % 13 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 14 | % retains a paid-up nonexclusive, irrevocable worldwide license to 15 | % reproduce, prepare derivative works, perform publicly and display 16 | % publicly by or for the Government, including the right to distribute 17 | % to other Government contractors. 18 | 19 | 20 | global Kprompt ynprompt 21 | SaveFile=''; 22 | 23 | if nargin==7 24 | disp('In PDCload0: old input list. Need entry for LOADOPT.') 25 | trackX=saveopt 26 | saveopt=loadopt 27 | loadopt=1 28 | end 29 | 30 | %Determine number of files to load 31 | nXfiles=size(PDCfiles,1); 32 | disp(['In PDCload0: Seeking data from ' sprintf('%2.1i',nXfiles) ' files:']) 33 | disp(PDCfiles) 34 | 35 | %Clear storage 36 | PMUsigs=[]; PMUfreqs=[]; RMSsigs=[]; 37 | chankeyX=''; namesX=''; 38 | PSMsigsX=[]; 39 | 40 | %Save original case comments 41 | CaseCom0=CaseCom; 42 | 43 | %************************************************************************* 44 | %Proceed to extract data 45 | for N=1:nXfiles 46 | PDCfile=PDCfiles(N,:); close all; 47 | CaseCom=CaseCom0; 48 | if (loadopt==1) 49 | [PMUsigs,PMUfreqs,tstep,PMUnames,PhsrNames,Phsrkey,PDCfile,CaseCom]... 50 | =PDCload1(caseID,PDCfile,PMUsigs,PMUfreqs,CaseCom,saveopt,trackX); end 51 | if (loadopt==2) 52 | [PMUsigs,PMUfreqs,tstep,PMUnames,PhsrNames,Phsrkey,PDCfile,CaseCom]... 53 | =PDCload2(caseID,PDCfile,PMUsigs,PMUfreqs,CaseCom,saveopt,trackX); end 54 | end 55 | %************************************************************************* 56 | 57 | CaseCom=CaseCom0; 58 | 59 | return 60 | 61 | %end of PSM script 62 | 63 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools_Utilities/PDC_Utilities/cparse.m: -------------------------------------------------------------------------------- 1 | function [StrMat]=cparse(String,del) 2 | % Parsing tab-delimited text string into text array 3 | % 4 | % Last modified 03/29/00. jfh 5 | 6 | StrMat=0; 7 | tab=' '; 8 | if nargin<1, disp('In Cparse: No data-return'), return, end 9 | if nargin<2, del=tab; end 10 | if isempty(del), del=tab; end 11 | 12 | 13 | String=[String del]; 14 | len=size(String,2); 15 | loc=[0 findstr(String,del)]; 16 | NF=size(loc,2)-1; %number of text fields 17 | for n=1:NF 18 | span=loc(n+1)-loc(n)-1; 19 | text=''; 20 | if span>0, text=String(loc(n)+1:loc(n+1)-1); end 21 | if n==1, StrMat=text; 22 | else StrMat=str2mat(StrMat,text); 23 | end 24 | end 25 | 26 | %end of PSM script -------------------------------------------------------------------------------- /PSMtools Source/PSMtools_Utilities/PDC_Utilities/inicopy.m: -------------------------------------------------------------------------------- 1 | function [initext,fname,CFname]=inicopy(fname,ctag); 2 | % 3 | % Copies PDC configuration data from a PDC ini file. 4 | % 5 | % [initext,fname,CFname]=inicopy(fname,ctag); 6 | % 7 | % Last modified 01/23/03. jfh 8 | 9 | % By J. F. Hauer, Pacific Northwest National Laboratory. 10 | % 11 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 12 | % retains a paid-up nonexclusive, irrevocable worldwide license to 13 | % reproduce, prepare derivative works, perform publicly and display 14 | % publicly by or for the Government, including the right to distribute 15 | % to other Government contractors. 16 | 17 | 18 | if nargin<1, fname=''; ctag=';'; end; 19 | if ~exist('ctag'), ctag=''; end 20 | if isempty(ctag), ctag=';'; end 21 | 22 | initext=''; CFname=''; 23 | 24 | %******************************************************************** 25 | % Open configuration file 26 | if ~isempty(fname) 27 | fname=deblank(fname); 28 | fid=fopen(setstr(fname),'r'); 29 | else 30 | fid=-1; 31 | end 32 | if fid<0 33 | disp(['In inicopy: Launching dialog box for PDC configuration file']) 34 | [n,p]=uigetfile('*.*','Select PDC configuration file:'); 35 | if n==0; return; end; 36 | fname=[p n]; 37 | [fid,message]=fopen(fname,'r'); 38 | if fid<0; error(message); end; 39 | end 40 | Ctype=computer; 41 | D='\'; %Default delimiter 42 | if strcmp(Ctype,'MAC2'), D=':'; end 43 | Ds=findstr(D,fname); 44 | if isempty(Ds) 45 | CFname=fname; 46 | else 47 | last=Ds(size(Ds,2)); 48 | CFname=fname(last+1:size(fname,2)); 49 | end 50 | %******************************************************************** 51 | 52 | if max(size(fname))<60 53 | disp(['In inicopy: configuration file = ' fname]) 54 | else 55 | disp(['In inicopy: configuration file is ']) 56 | disp([' ' fname]) 57 | end 58 | 59 | %******************************************************************** 60 | % Read file as lines of text 61 | initext=''; 62 | for N=1:999 63 | cs=fgetl(fid); 64 | if ~isstr(cs), break, end 65 | if N==1, initext=cs; 66 | else initext=str2mat(initext,cs); end 67 | end 68 | %******************************************************************** 69 | 70 | fclose(fid); 71 | 72 | %end of PSMT m-file 73 | 74 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools_Utilities/PDC_Utilities/isdst.m: -------------------------------------------------------------------------------- 1 | % Function to determine whether a given time is 2 | % Daylight Saving Time or not. 3 | 4 | function f = isdst(datnm,yr,mon,dom,hr) 5 | dow=weekday(datnm)-1; 6 | f = 1; 7 | 8 | if (mon>4 & mon<10), return; end; 9 | if (mon==4 & dom>7), return; end; 10 | if (mon==4 & dom<=7 & dow==0 & hr>=7), return; end; 11 | if (mon==4 & dom<=7 & dow>0 & dom>dow), return; end; 12 | 13 | if (mon==10 & dom<25), return; end; 14 | if (mon==10 & dom>=25 & dow==0 & hr<6), return; end; 15 | if (mon==10 & dom>=25 & dow>0 & dom-24-dow < 1), return; end; 16 | 17 | f = 0; 18 | return -------------------------------------------------------------------------------- /PSMtools Source/PSMtools_Utilities/PRS_Utilities/ModeDisp1.m: -------------------------------------------------------------------------------- 1 | function [CaseCom]=ModeDisp1(caseID,casetime,CaseCom,SigName,... 2 | Poles0,Zeros0,DispType,PoleCats0,PoleCatNames); 3 | %ModeDisp1 displays poles & zeros according to DispType 4 | % 5 | % [CaseCom]=ModeDisp1(caseID,casetime,CaseCom,SigName,... 6 | % Poles,Zeros,DispType,PoleCats); 7 | % 8 | % Last modified 11/13/01. jfh 9 | 10 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 11 | % retains a paid-up nonexclusive, irrevocable worldwide license to 12 | % reproduce, prepare derivative works, perform publicly and display 13 | % publicly by or for the Government, including the right to distribute 14 | % to other Government contractors. 15 | 16 | 17 | %Clear outputs 18 | 19 | %Check inputs 20 | if ~exist('DispType'), DispType=0; end 21 | if ~exist('Zeros'), Zeros=[]; end 22 | if ~exist('PoleCats'), PoleCats=0; end 23 | if ~exist('PoleCatNames'),PoleCatNames=''; end 24 | Npoles0=length(Poles0); 25 | if length(PoleCats0)~=Npoles0 26 | PoleCats0=zeros(Npoles0,1); 27 | end 28 | 29 | disp(' ') 30 | disp(['In ModeDisp1:']) 31 | if ~DispType, return, end 32 | 33 | %keyboard 34 | 35 | Poles=Poles0; Zeros=Zeros0; PoleCats=PoleCats0; 36 | Npoles=length(Poles); 37 | Nzeros=length(Zeros); 38 | if Npoles==0&Nzeros==0 39 | disp('Nothing to display') 40 | disp('Return from ModeDisp1') 41 | return 42 | end 43 | 44 | %Display mode table (by pole number) 45 | strs=['Sorted Mode Table for ' SigName ':']; 46 | strs=str2mat(strs,' Pole Sigma Omega Freq in Hz Damp Ratio (pu)'); 47 | CaseCom=str2mat(CaseCom,strs); disp(strs) 48 | for N=1:Npoles 49 | CatN=PoleCats(N); CatName=''; 50 | if CatN>0, CatName=PoleCatNames(CatN,:); end 51 | sigma=real(Poles(N)); omd=imag(Poles(N)); 52 | zeta=sigma/sqrt(sigma*sigma+omd*omd); 53 | if omd>0 %complex pole pair 54 | dampPU=-zeta; 55 | frqHz=omd/(2*pi); sigHz=sigma/(2*pi); 56 | str=sprintf('%4.0i %14.8f %14.8f %14.8f %14.8f',[N sigma omd frqHz dampPU]); 57 | str=[str ' ' CatName]; 58 | CaseCom=str2mat(CaseCom,str); disp(str) 59 | end 60 | if omd==0 %real pole 61 | sigHz=-sigma/(2*pi); 62 | str=sprintf('%4.0i %14.8f %14.8f %14.8f',[N sigma omd sigHz]); 63 | str=[str ' N/A ' CatName]; 64 | CaseCom=str2mat(CaseCom,str); disp(str) 65 | end 66 | end 67 | 68 | if Nzeros==0 69 | disp('Return from ModeDisp1') 70 | return 71 | end 72 | 73 | %Display zeros table 74 | strs=['Sorted Zeros Table for ' SigName ':']; 75 | strs=str2mat(strs,' zero Sigma Omega Freq in Hz Sigma/(2*pi)'); 76 | CaseCom=str2mat(CaseCom,strs); disp(strs) 77 | for N=1:Nzeros 78 | sigma=real(Zeros(N)); omd=imag(Zeros(N)); 79 | zeta=sigma/sqrt(sigma*sigma+omd*omd); 80 | if omd>0 %complex zero pair 81 | sigHz=sigma/(2*pi); 82 | frqHz=omd/(2*pi); sigHz=sigma/(2*pi); 83 | str=sprintf('%4.0i %14.8f %14.8f %14.8f %14.8f',[N sigma omd frqHz sigHz]); 84 | CaseCom=str2mat(CaseCom,str); disp(str) 85 | end 86 | if omd==0 %real zero 87 | sigHz=-sigma/(2*pi); 88 | str=sprintf('%4.0i %14.8f %14.8f %14.8f %14.8f',[N sigma omd sigHz sigHz]); 89 | CaseCom=str2mat(CaseCom,str); disp(str) 90 | end 91 | end 92 | 93 | 94 | disp('Return from ModeDisp1') 95 | return 96 | 97 | %end of PSMT function 98 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools_Utilities/PRS_Utilities/PRSvan1.m: -------------------------------------------------------------------------------- 1 | function [CaseCom,PRSmodel]=... 2 | PRSvan1(caseID,casetime,CaseCom); 3 | %PRSvan1 solves the Vandermonde equations for multiple signals, 4 | % given a collection of poles upon which to project 5 | % 6 | % [CaseCom,PRSmodel]=... 7 | % PRSvan1(caseID,casetime,CaseCom); 8 | % 9 | % Last modified 02/13/02. jfh 10 | 11 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 12 | % retains a paid-up nonexclusive, irrevocable worldwide license to 13 | % reproduce, prepare derivative works, perform publicly and display 14 | % publicly by or for the Government, including the right to distribute 15 | % to other Government contractors. 16 | 17 | 18 | persistent FigDef 19 | if isempty(FigDef), FigDef=1; end 20 | 21 | %Clear outputs 22 | PRSmodel=[]; 23 | 24 | %Check inputs 25 | 26 | Ptitle{1}=' '; 27 | Ptitle{2}=['caseID=' caseID ' casetime=' casetime]; 28 | disp(' ') 29 | str='In PRSvan1: EXPERIMENTAL CODE FOR EXTENDING A PRONY SOLUTION '; 30 | str=[str ' TO MULTIPLE SIGNALS']; %Temporary warning 31 | disp(str) 32 | disp(['In PRSvan1: ' Ptitle{2}]); 33 | format short %May need diagnostic displays 34 | %format short %May need diagnostic displays 35 | %keyboard 36 | 37 | %************************************************************************ 38 | prompt=['In PRSvan1: Indicate figure number for Prony solution ']; 39 | PRSfig=promptnv(prompt,FigDef); 40 | PRSfig=max(PRSfig,1); 41 | disp(['In PRSvan1: PRSfig = ' num2str(PRSfig)]) 42 | setok=promptyn(' Is this value ok?', 'y'); 43 | if ~setok 44 | disp(' Invoking "keyboard" command - Enter "return" when you are finished') 45 | keyboard 46 | end 47 | FigDef=PRSfig; 48 | %************************************************************************ 49 | 50 | %************************************************************************ 51 | %Get PRS parameters, place them in basic order 52 | idmodel=Getmodel(PRSfig,0,1); 53 | [AllPoles nfits]=size(idmodel.res); 54 | Poles0 =idmodel.pol; 55 | Bres0 =idmodel.bres; 56 | Tres0 =idmodel.res; 57 | RelEn0 =idmodel.releng; 58 | Afpe0 =idmodel.afpe; 59 | Select0=idmodel.select; 60 | SigNames0=char(idmodel.titles); 61 | thru=idmodel.thru; if isnan(thru), thru=zeros(nfits,1); end 62 | %Order all Poles by ascending frequency, with real Poles first 63 | disp(['In PRSvan1: Full signal names are']) 64 | disp(names2chans(SigNames0)) 65 | SigNames=SigNames0; %Sometimes need to shorten these 66 | [SigNames]=BstringOut(SigNames0,' ',3); 67 | locsS0=zeros(AllPoles,nfits); 68 | for N=1:nfits 69 | SortType=1; SortTrack=(N==1); 70 | [PolesP,SortType,PoleCats,PoleCatNames,locsS0(:,N)]=... 71 | RootSort1(Poles0(:,N),SortType,SortTrack); 72 | Poles0(:,N) =Poles0(locsS0(:,N),N); 73 | Bres0(:,N) =Bres0(locsS0(:,N),N); 74 | Tres0(:,N) =Tres0(locsS0(:,N),N); 75 | RelEn0(:,N) =RelEn0(locsS0(:,N),N); 76 | Afpe0(:,N) =Afpe0(locsS0(:,N),N); 77 | Select0(:,N)=Select0(locsS0(:,N),N); 78 | end 79 | %PRS is now in basic order 80 | %Later versions of Ringdown GUI should do this internally 81 | %************************************************************************ 82 | 83 | 84 | 85 | setok=promptyn('In PRSvan1: Do you want the keyboard?', 'n'); 86 | if setok 87 | disp(' Invoking "keyboard" command - Enter "return" when you are finished') 88 | keyboard 89 | end 90 | 91 | 92 | return 93 | %end of PSMT utility 94 | 95 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools_Utilities/PRS_Utilities/par2ss.m: -------------------------------------------------------------------------------- 1 | function [a,b,c,d]=par2ss(res,pol,k); 2 | % 3 | %RES2SS [a,b,c,d]=par2ss(res,pol,k); 4 | % Converts a parallel SISO Transfer function to 5 | % state-space form. 6 | % 7 | % res = residues, (arranged as complexc conjugates) 8 | % pol = poles of residues. 9 | % k = feedforward gain. 10 | % a,b,c,d = state-space matrices. 11 | % 12 | 13 | % Modified by Jeff Johnson. 5/10/93 14 | % Modified to account for when the k matrix is empty. 15 | 16 | res=res(:);pol=pol(:);n=length(res); 17 | if n==0;stop;end; 18 | if isempty(k) 19 | k=0; 20 | end 21 | [a,b,c,d]=tf2ss(k,1); 22 | j=1; 23 | while j <= n; 24 | if abs(imag(pol(j)))<100*eps; 25 | [a2,b2,c2,d2]=tf2ss([0 res(j)],[1 -pol(j)]); 26 | [a,b,c,d]=parallel(a,b,c,d,a2,b2,c2,d2); 27 | j=j+1; 28 | else 29 | num=[0 2*real(res(j)) real(-res(j)*pol(j+1)-res(j+1)*pol(j))]; 30 | den=[1 -2*real(pol(j)) abs(pol(j))^2]; 31 | [a2,b2,c2,d2]=tf2ss(num,den); 32 | [a,b,c,d]=parallel(a,b,c,d,a2,b2,c2,d2); 33 | j=j+2; 34 | end; 35 | end; 36 | 37 | 38 | %end of PSM script -------------------------------------------------------------------------------- /PSMtools Source/PSMtools_Utilities/SQL_Utilities/funApplySQLJAR.m: -------------------------------------------------------------------------------- 1 | function funApplySQLJAR 2 | % function funApplySQLJAR 3 | % 4 | % Function to read in SQL database information and load the .jar file to run it. 5 | % Has to be done early because altering the Java dynamic path clears global variables, 6 | % which messes up most other DSI toolbox functions. 7 | % 8 | % Requires the SQL_Config.cfg file to be present in the DSI Toolbox parent folder 9 | % 10 | % Functionalized March 3, 2014 by Frank Tuffner 11 | 12 | %% Read in the configuration file for the SQL linkage 13 | 14 | %Find the configuration file 15 | FileLocation = which('SQL_Config.cfg'); 16 | 17 | if (isempty(FileLocation)) 18 | disp('In funApplySQLJAR: Failure to find SQL_Config.cfg file -- exiting'); 19 | return 20 | end 21 | 22 | %Read in configuration file - defaults to PSMfiles Source, one folder in 23 | fHandle=fopen(FileLocation,'rt'); 24 | 25 | %Make sure it was found 26 | if (fHandle==-1) 27 | disp('In funApplySQLJAR: Failure to find SQL_Config.cfg file -- exiting'); 28 | return; 29 | end 30 | 31 | %Read in the data 32 | ConfigDataRaw=textscan(fHandle,'%s %s','Delimiter',{':='},'CommentStyle','#','CollectOutput',1); 33 | 34 | %close file handle 35 | fclose(fHandle); 36 | 37 | %Extract it out one layer so double cells are being used 38 | ConfigData=ConfigDataRaw{1}; 39 | 40 | %% Configure connection string 41 | 42 | %Get the number of entries read 43 | NumEntriesRead=size(ConfigData,1); 44 | 45 | %Find the JARFile entry 46 | JARFile=''; 47 | for sVals=1:NumEntriesRead 48 | 49 | if (strcmpi(ConfigData{sVals,1},'JARFile')~=0) 50 | JARFile=ConfigData{sVals,2}; 51 | break; 52 | end 53 | end 54 | 55 | %Make sure it was found 56 | if isempty(JARFile) 57 | disp('In funApplySQLJAR: JARFile entry in SQL_Config.cfg was either empty or missing'); 58 | return; 59 | end 60 | 61 | %% Java commands 62 | 63 | %Output message 64 | disp('Adding JAR file for SQL support -- if this gives a warning and you wish to use'); 65 | disp('the SQL functionality, please insure your SQL_Config.cfg file is set properly'); 66 | disp(' '); 67 | 68 | %Add JARFile to the Java path 69 | javaclasspath(strrep(JARFile,'''','')); 70 | -------------------------------------------------------------------------------- /PSMtools Source/PSMtools_Utilities/SWX_Utilities/PSDSnamesFix.m: -------------------------------------------------------------------------------- 1 | %PSMT Utility PSDSnamesFix 2 | 3 | tab=' '; 4 | 5 | [y,comment,fname,names]=cread(''); 6 | nsigs=size(names,1); 7 | namesN=names; 8 | line=''; MaxLen=0; 9 | for N=2:nsigs %Replace tabs by blanks 10 | line=deblank(namesN(N,:)); 11 | Ltabs=findstr(line,tab); 12 | if ~isempty(Ltabs), line(Ltabs)=' '; end 13 | LineLen=length(line); 14 | namesN(N,1:LineLen)=line; 15 | MaxLen=max(MaxLen,LineLen); 16 | end 17 | namesN=namesN(:,1:MaxLen); 18 | -------------------------------------------------------------------------------- /PSMtools Source/Start_PSM.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/Start_PSM.fig -------------------------------------------------------------------------------- /PSMtools Source/Start_PSM.m: -------------------------------------------------------------------------------- 1 | function varargout = Start_PSM(varargin) 2 | % START_PSM M-file for Start_PSM.fig 3 | % START_PSM, by itself, creates a new START_PSM or raises the existing 4 | % singleton*. 5 | % 6 | % H = START_PSM returns the handle to a new START_PSM or the handle to 7 | % the existing singleton*. 8 | % 9 | % START_PSM('CALLBACK',hObject,eventData,handles,...) calls the local 10 | % function named CALLBACK in START_PSM.M with the given input arguments. 11 | % 12 | % START_PSM('Property','Value',...) creates a new START_PSM or raises the 13 | % existing singleton*. Starting from the left, property value pairs are 14 | % applied to the GUI before Start_PSM_OpeningFunction gets called. An 15 | % unrecognized property name or invalid value makes property application 16 | % stop. All inputs are passed to Start_PSM_OpeningFcn via varargin. 17 | % 18 | % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 19 | % instance to run (singleton)". 20 | % 21 | % See also: GUIDE, GUIDATA, GUIHANDLES 22 | 23 | % Edit the above text to modify the response to help Start_PSM 24 | 25 | % Last Modified by GUIDE v2.5 28-Aug-2003 14:12:21 26 | 27 | % Begin initialization code - DO NOT EDIT 28 | gui_Singleton = 1; 29 | gui_State = struct('gui_Name', mfilename, ... 30 | 'gui_Singleton', gui_Singleton, ... 31 | 'gui_OpeningFcn', @Start_PSM_OpeningFcn, ... 32 | 'gui_OutputFcn', @Start_PSM_OutputFcn, ... 33 | 'gui_LayoutFcn', [] , ... 34 | 'gui_Callback', []); 35 | if nargin & isstr(varargin{1}) 36 | gui_State.gui_Callback = str2func(varargin{1}); 37 | end 38 | 39 | if nargout 40 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 41 | else 42 | gui_mainfcn(gui_State, varargin{:}); 43 | end 44 | % End initialization code - DO NOT EDIT 45 | 46 | disp('Click the button in the popup window to launch DSI Toolbox.') 47 | 48 | 49 | % --- Executes just before Start_PSM is made visible. 50 | function Start_PSM_OpeningFcn(hObject, eventdata, handles, varargin) 51 | % This function has no output args, see OutputFcn. 52 | % hObject handle to figure 53 | % eventdata reserved - to be defined in a future version of MATLAB 54 | % handles structure with handles and user data (see GUIDATA) 55 | % varargin command line arguments to Start_PSM (see VARARGIN) 56 | 57 | % Choose default command line output for Start_PSM 58 | handles.output = hObject; 59 | 60 | % Update handles structure 61 | guidata(hObject, handles); 62 | 63 | % UIWAIT makes Start_PSM wait for user response (see UIRESUME) 64 | % uiwait(handles.figure1); 65 | 66 | 67 | % --- Outputs from this function are returned to the command line. 68 | function varargout = Start_PSM_OutputFcn(hObject, eventdata, handles) 69 | % varargout cell array for returning output args (see VARARGOUT); 70 | % hObject handle to figure 71 | % eventdata reserved - to be defined in a future version of MATLAB 72 | % handles structure with handles and user data (see GUIDATA) 73 | 74 | % Get default command line output from handles structure 75 | varargout{1} = handles.output; 76 | 77 | 78 | % --- Executes on button press in pushbutton1. 79 | function pushbutton1_Callback(hObject, eventdata, handles) 80 | % hObject handle to pushbutton1 (see GCBO) 81 | % eventdata reserved - to be defined in a future version of MATLAB 82 | % handles structure with handles and user data (see GUIDATA) 83 | PSMLaunch 84 | 85 | % --- If Enable == 'on', executes on mouse press in 5 pixel border. 86 | % --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton1. 87 | function pushbutton1_ButtonDownFcn(hObject, eventdata, handles) 88 | % hObject handle to pushbutton1 (see GCBO) 89 | % eventdata reserved - to be defined in a future version of MATLAB 90 | % handles structure with handles and user data (see GUIDATA) 91 | 92 | 93 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/DXD_Utilities/ASpecF1.m: -------------------------------------------------------------------------------- 1 | function [sigfft,nfft] = ASpecF1(fftsigs,Snames,Xrange,Yrange,samplerate,Gtags) 2 | % 3 | % [sigfft,nfft] = ASpecF1(fftsigs,Snames,Xrange,Yrange,samplerate,Gtags) 4 | % 5 | % Displays voltage & current autospectra for input "fftsigs". 6 | % 7 | % THIS FUNCTION HAS A LOT OF OPTIONS--READ THE CODE!! 8 | % 9 | % Last modified 03/13/02. jfh 10 | 11 | % By J. F. Hauer, Pacific Northwest National Laboratory. 12 | % 13 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 14 | % retains a paid-up nonexclusive, irrevocable worldwide license to 15 | % reproduce, prepare derivative works, perform publicly and display 16 | % publicly by or for the Government, including the right to distribute 17 | % to other Government contractors. 18 | 19 | %disp('In ASpecF1:') 20 | 21 | %Genesamplerate case/time stamp for plots 22 | Ptitle{1}=' '; 23 | Ptitle{2}=['caseID=' Gtags(1,:) ' casetime=' Gtags(2,:)]; 24 | 25 | npoints=size(fftsigs,1); 26 | nfft=2^fix(log2(npoints)); 27 | tstep=1/samplerate; 28 | tbar=tstep*nfft; 29 | frqstep=1/tbar; 30 | fftfrq=[0:nfft/2-1]'*frqstep; 31 | start=max(1,npoints-nfft+1); %Allowance for filter startup 32 | sigfft=fft(fftsigs(start:npoints,:),nfft)/nfft; 33 | sigfft=sigfft(1:nfft,:); 34 | Nnames=size(Snames,1); 35 | Nplots=size(Xrange,1); 36 | for j=1:Nnames 37 | for n=1:Nplots 38 | h=figure; 39 | plotno=sprintf('P%2.0i: ',h); 40 | n1=1; n2=nfft/2; 41 | if ~isempty(Xrange) 42 | n1=fix(Xrange(n,1)/frqstep+1); n2=min(fix(Xrange(n,2)/frqstep),nfft/2); 43 | end 44 | plot(fftfrq(n1:n2),[db(sigfft(n1:n2,j))]) 45 | Ptitle{1}=[plotno ' ' Snames(j,:)]; 46 | title(Ptitle) 47 | if ~isempty(Xrange), set(gca,'xlim',Xrange(n,:)); end 48 | if ~isempty(Yrange), set(gca,'Ylim',Yrange); end 49 | xlabel('Frequency in Hertz'); 50 | Ylabel('Autospectrum in dB'); 51 | set(gca,'TickDir','out') 52 | end 53 | end 54 | 55 | %end PSMT utility 56 | 57 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/DXD_Utilities/Box2BP1.m: -------------------------------------------------------------------------------- 1 | function [ND,DD]=Box2BP1(FLP,F1,F2,simrate) 2 | % 3 | % Last modified 07/08/02. jfh 4 | 5 | % By J. F. Hauer, Pacific Northwest National Laboratory. 6 | % 7 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 8 | % retains a paid-up nonexclusive, irrevocable worldwide license to 9 | % reproduce, prepare derivative works, perform publicly and display 10 | % publicly by or for the Government, including the right to distribute 11 | % to other Government contractors. 12 | 13 | %Filter transformation equations: (Proakis, p. 649) 14 | % wp = cutoff frequency of given LP filter 15 | % [w1 w2] = desired passband for BP filter 16 | % alph = cos((w2+w1)/2)/cos((w2-w1)/2) 17 | % kfac = cot((w2-w1)/2)*tan(wp/2) 18 | % a1 = -2*alph*kfac/(kfac+1) 19 | % a2 = (kfac-1)/(kfac+1) 20 | % 21 | % Substitution: 22 | % -2 -1 23 | % -1 z -a1*z + a2 24 | % Z = - ------------------------------ 25 | % -2 -1 26 | % a2*z -a1*z + 1 27 | 28 | %[ND,DD]=Box2BP1(60,250,320,720); 29 | %[ND,DD]=Box2BP1(100,300,490,1000); 30 | 31 | %help conv; help filter; 32 | 33 | %simrate=720; 34 | %FLP=60; F1=100; F2=40; 35 | 36 | Nyquist=simrate/2; 37 | fac=pi/Nyquist; 38 | wp=FLP*fac; w1=F1*fac; w2=F2*fac; 39 | 40 | alph=cos((w2+w1)/2)/cos((w2-w1)/2); 41 | kfac=cot((w2-w1)/2)*tan(wp/2); 42 | a1 =-2*alph*kfac/(kfac+1); 43 | a2 =(kfac-1)/(kfac+1); 44 | num=-[a2 -a1 1]; den=[1 -a1 a2]; 45 | 46 | %Build LP boxcar 47 | Nbox=round(simrate/FLP); 48 | Bbox=ones(Nbox,1); 49 | Ptitle{1}=['IN Box2BP1:']; 50 | Ptitle{2}=['LP Boxcar: wp=[' num2str(wp) ']']; 51 | [resp2,W]=freqz(Bbox,1,256,simrate); 52 | figure; plot(W,abs(resp2)); title(Ptitle) 53 | 54 | %Transform LP boxcar 55 | ND=zeros(1,Nbox*2+1); 56 | DD=1; 57 | for M=1:Nbox 58 | NDT=1; 59 | for M1=1:M 60 | NDT=conv(NDT,num); 61 | end 62 | for M2=M+1:Nbox 63 | NDT=conv(NDT,den); 64 | end 65 | ND=ND+NDT; 66 | DD=conv(DD,den); 67 | end 68 | Ptitle{1}=['IN Box2BP1:']; 69 | Ptitle{2}=['BP Boxcar: wp=[' num2str(wp) ']']; 70 | [resp2,W]=freqz(ND,DD,256,simrate); 71 | figure; plot(W,abs(resp2)); title(Ptitle) 72 | 73 | %end of PSMT utility Box2BP1 74 | 75 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/DXD_Utilities/CLS1.m: -------------------------------------------------------------------------------- 1 | % PSMtools Utility CLSBP1 2 | % 3 | % Last modified 07/03/02. jfh 4 | 5 | % By J. F. Hauer, Pacific Northwest National Laboratory. 6 | % 7 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 8 | % retains a paid-up nonexclusive, irrevocable worldwide license to 9 | % reproduce, prepare derivative works, perform publicly and display 10 | % publicly by or for the Government, including the right to distribute 11 | % to other Government contractors. 12 | 13 | %help REMEZ 14 | simrate=720; Nyquist=simrate/2; 15 | 16 | N=40; %Filter order 17 | BL=[1 1 0 0]; %Band levels 18 | BE=[45 110 210 360]; %Band edges 19 | Wts=[60 1]; %Band weights 20 | 21 | N=40; BE=[45 110 210 360]; Wts=[60 1]; 22 | N=38; BE=[45 125 220 360]; Wts=[80 1]; 23 | BREM=REMEZ(20,[0 0.4 0.5 1],[1 1 0 0]); %LP filter 24 | BREM=REMEZ(20,[0 0.4 0.5 1],[1 1 0 0],[50 1]); %LP filter 25 | BREM=REMEZ(N,BE/Nyquist,BL,Wts,'h'); %BP filter 26 | Ptitle{1}=['BE =[' num2str(BE) ']']; 27 | Ptitle{2}=['N=' num2str(N) ' Wts=[' num2str(Wts) ']']; 28 | %figure; plot(BREM); title(Ptitle) 29 | [resp2,W]=freqz(BREM,1,256,simrate); 30 | figure; plot(W,abs(resp2)); title(Ptitle) 31 | 32 | 33 | 34 | %end of PSMT utility CLSBP1 35 | 36 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/DXD_Utilities/CLSBP1.m: -------------------------------------------------------------------------------- 1 | % PSMtools Utility CLSBP1 2 | % 3 | % Last modified 07/21/02. jfh 4 | 5 | % By J. F. Hauer, Pacific Northwest National Laboratory. 6 | % 7 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 8 | % retains a paid-up nonexclusive, irrevocable worldwide license to 9 | % reproduce, prepare derivative works, perform publicly and display 10 | % publicly by or for the Government, including the right to distribute 11 | % to other Government contractors. 12 | 13 | %help fircls 14 | % From Matlab example: 15 | n = 30; 16 | f = [0 0.40 0.8 1]; 17 | f = [0 0.04 0.3 1]; 18 | a = [0 1 0]; 19 | up = [ 0.01 1.001 0.2]; 20 | lo = [-0.01 0.999 -0.2]; 21 | b = fircls(n,f,a,up,lo); 22 | [resp2,W]=freqz(b,1,256,2); 23 | figure; plot(W,abs(resp2)); 24 | %help firls 25 | 26 | 27 | 28 | simrate=720; Nyquist=simrate/2; 29 | 30 | N=40; %Filter order 31 | BL=[0 1 0]; %Band levels 32 | BE=[45 110 210 360]; %Band edges 33 | 34 | N=20; BE=[0 18 180 360]; 35 | UL=[ 0.01 1.0001 0.8]; 36 | LL=[-0.01 0.9999 -0.8]; 37 | BCLS=fircls(N,BE/Nyquist,BL,UL,LL); %BP filter 38 | Ptitle{1}=['IN CLSBP1: N=' num2str(N) ' BE=[' num2str(BE) ']']; 39 | Ptitle{2}=['UL=[' num2str(UL) '] LL=[' num2str(LL) ']']; 40 | %figure; plot(BCLS); title(Ptitle) 41 | [resp2,W]=freqz(BCLS,1,256,simrate); 42 | figure; plot(W,abs(resp2)); title(Ptitle) 43 | 44 | 45 | 46 | %end of PSMT utility CLSBP1 47 | 48 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/DXD_Utilities/REMEZBP1.m: -------------------------------------------------------------------------------- 1 | % PSMtools Utility REMEZBP1 2 | % 3 | % Last modified 07/03/02. jfh 4 | 5 | % By J. F. Hauer, Pacific Northwest National Laboratory. 6 | % 7 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 8 | % retains a paid-up nonexclusive, irrevocable worldwide license to 9 | % reproduce, prepare derivative works, perform publicly and display 10 | % publicly by or for the Government, including the right to distribute 11 | % to other Government contractors. 12 | 13 | %help REMEZ 14 | 15 | simrate=720; Nyquist=simrate/2; 16 | 17 | N=40; %Filter order 18 | BL=[1 1 0 0]; %Band levels 19 | BE=[45 110 210 360]; %Band edges 20 | Wts=[60 1]; %Band weights 21 | 22 | N=50; BE=[42 140 235 360]; Wts=[10 1]; %Closest 23 | %N=40; BE=[45 110 210 360]; Wts=[60 1]; 24 | %N=38; BE=[45 125 220 360]; Wts=[80 1]; 25 | BREM=REMEZ(20,[0 0.4 0.5 1],[1 1 0 0]); %LP filter 26 | BREM=REMEZ(20,[0 0.4 0.5 1],[1 1 0 0],[50 1]); %LP filter 27 | BREM=REMEZ(N,BE/Nyquist,BL,Wts,'h'); %BP filter 28 | Ptitle{1}=['IN REMEZBP1: N=' num2str(N) ' BE=[' num2str(BE) ']']; 29 | Ptitle{2}=['Wts=[' num2str(Wts) ']']; 30 | %figure; plot(BREM); title(Ptitle) 31 | [resp2,W]=freqz(BREM,1,256,simrate); 32 | figure; plot(W,abs(resp2)); title(Ptitle) 33 | 34 | 35 | 36 | %end of PSMT utility REMEZBP1 37 | 38 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/DXD_Utilities/RevPol.m: -------------------------------------------------------------------------------- 1 | function [AvecRev]=RevPol(Avec) 2 | % 3 | % Last modified 07/08/02. jfh 4 | 5 | locs=length(Avec):-1:1; 6 | AvecRev=Avec(locs); 7 | 8 | 9 | %end of PSMT utility RevPol 10 | 11 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/DXD_Utilities/Sigplot.m: -------------------------------------------------------------------------------- 1 | function [h]=Sigplot (time,signal,Ptitle,Pscale,Gtags) 2 | % 3 | % jfh m-file Sigplot: 4 | % [h]=Sigplot (time,signal,Ptitle,Pscale,Gtags) 5 | % 6 | % Displays time and signal data. 7 | % 8 | % THIS FUNCTION HAS A LOT OF OPTIONS--READ THE CODE!! 9 | % 10 | % Last modified 09/01/99. jfh 11 | 12 | % By J. F. Hauer, Pacific Northwest National Laboratory. 13 | % 14 | % Copyright (c) 1995-1998 Battelle Memorial Institute. The Government 15 | % retains a paid-up nonexclusive, irrevocable worldwide license to 16 | % reproduce, prepare derivative works, perform publicly and display 17 | % publicly by or for the Government, including the right to distribute 18 | % to other Government contractors. 19 | 20 | Nplots=size(Ptitle,1); 21 | Nscales=size(Pscale,1); %number of rows 22 | Ntraces=size(signal,2); 23 | 24 | h=figure; 25 | for n=1:Nplots 26 | T1=1+(n-1)*Ntraces/Nplots; 27 | Tf=n*Ntraces/Nplots; 28 | subplot(Nplots,1,n) 29 | plot(time,signal(:,T1:Tf)) 30 | title(Ptitle(n,:)) 31 | set(gca,'TickDir','out') 32 | end 33 | pause 34 | for m=1:Nscales 35 | for n=1:Nplots 36 | subplot(Nplots,1,n) 37 | set(gca,'xlim',Pscale(m,:)) 38 | end 39 | pause 40 | end 41 | 42 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/DXD_Utilities/Specplot.m: -------------------------------------------------------------------------------- 1 | function Specplot (freq,spectrum,Ptitle,Pscale) 2 | 3 | Nplots=size(Ptitle,1); 4 | Nscales=size(Pscale,1); %number of rows 5 | Ntraces=size(spectrum,2); 6 | 7 | h=figure; 8 | figure(h) 9 | for n=1:Nplots 10 | F1=1+(n-1)*Ntraces/Nplots; 11 | Ff=n*Ntraces/Nplots; 12 | subplot(Nplots,1,n) 13 | plot(time,spectrum(:,F1:Ff)) 14 | title(Ptitle(n,:)) 15 | end 16 | pause 17 | for m=1:Nscales 18 | for n=1:Nplots 19 | subplot(Nplots,1,n) 20 | set(gca,'xlim',Pscale(m,:)) 21 | end 22 | pause 23 | end 24 | 25 | %end of PSM script 26 | 27 | 28 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/DXD_Utilities/WindowCks3.m: -------------------------------------------------------------------------------- 1 | %Window Checks #3 2 | % 3 | % Last modified 09/02/99. jfh 4 | 5 | AngStep=1; %Angle step in degrees 6 | Asteps=fix(180/AngStep); 7 | angles=[0:Asteps]'; 8 | Win1=sin(angles*2*pi/360); 9 | Window=[Win1 Win1.^2 Win1.^4]; 10 | %set(gca,'xlim',[0 180]) 11 | h=figure; 12 | plot(angles,Window) 13 | title('Window Response Amplitude') 14 | xlabel('Angle in Degrees'); Ylabel('Window Response Amplitude') 15 | h=figure; 16 | plot(angles,db(Window)) 17 | title('Window Response in dB') 18 | xlabel('Angle in Degrees'); Ylabel('Window Response in dB') 19 | set(gca,'ylim',[-100 20]) 20 | h=figure; 21 | plot(angles,db(Window)) 22 | title('-3 dB Bandwidths') 23 | xlabel('Angle in Degrees'); Ylabel('Window Response in dB') 24 | set(gca,'ylim',[-3 2]) 25 | 26 | %end of jfh m-file 27 | 28 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/DXD_Utilities/seqTXmats.m: -------------------------------------------------------------------------------- 1 | function [TX,TXI]=seqTXmats 2 | % Transformation Matrices for symmetrical components 3 | % [J. F. Hauer - Pacific NW Laboratory] 4 | % 5 | % [symmetrical componsents]=[TX][observed quantities] 6 | % 7 | %set conversions 8 | global PI DPI DEG DEGI; 9 | 10 | % construct reference phasors for symmetrical components 11 | refrot=2*PI/3; 12 | AOP=exp(j*refrot); 13 | AOP2=AOP*AOP; 14 | TX=ones(3,3); 15 | TX(1:2,2:3)=[AOP,AOP2;AOP2,AOP]; 16 | TX=TX/3; 17 | TXI=ones(3,3); 18 | TXI(2:3,1:2)=[AOP2,AOP;AOP,AOP2]; 19 | 20 | %end of PSM script 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/DTmodemeterC_Source/funFindModes.m: -------------------------------------------------------------------------------- 1 | function [Freq, DR]=funFindModes(sPoles); 2 | % JPierre utility for mode display 3 | % function [Freq, DR]=funFindModes(sPoles); 4 | % 5 | % Modified 05/18/04. jfh Longer fields for numerical display 6 | 7 | [Y,I]=sort(imag(sPoles)); 8 | sPoles=sPoles(I); 9 | Freq=imag(sPoles)./(2*pi); 10 | DR=-100*real(sPoles)./abs(sPoles); 11 | 12 | %*********************************************************************************** 13 | if nargout == 0, % do plots 14 | Np=length(sPoles); 15 | disp(' ') 16 | disp('Major Modes:'); 17 | disp('Frequency(Hz) Damping Ratio(%)'); 18 | disp('----------------------------------'); 19 | for nIndex=1:Np 20 | disp(sprintf('freq=%14.8f DR=%14.8f ', Freq(nIndex),DR(nIndex))); 21 | end 22 | disp('----------------------------------'); 23 | end 24 | %*********************************************************************************** 25 | 26 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/DTmodemeterC_Source/funMatchPoles.m: -------------------------------------------------------------------------------- 1 | function [MajorPoles,Err2,Degrade]=funMatchPoles(TruePoles,EstPoles,EmphasisFactor) 2 | % find the estimation error square for estimation poles 3 | % 4 | % TruePoles: True possition of poles 5 | % EstPoles: Estimation of position of poles 6 | % EmphasisFactor: How much do we want to emphasis the image part 7 | % 8 | % Err2: squares of estimation errors (inf if can not be found) 9 | % MajorPoles: Major poles close to TruePoles; (0 if can not be found) 10 | if (nargin < 2);error('Pole match analysis needs at least 3 arguments');end 11 | if (nargin < 4);EmphasisFactor=[];end 12 | if (length(EmphasisFactor)==0); EmphasisFactor=1;end 13 | 14 | Nt=length(TruePoles); 15 | Ne=length(EstPoles); 16 | 17 | %************************************* 18 | % 1.0 establish distance matrix 19 | Dist=zeros(Nt,Ne); % distance matrix 20 | MSErr=zeros(Nt,Ne); 21 | for tIndex=1:Nt 22 | for eIndex=1:Ne 23 | dTemp=TruePoles(tIndex)-EstPoles(eIndex); 24 | MSErr(tIndex,eIndex)=abs(dTemp).^2; 25 | rTemp=real(dTemp); 26 | iTemp=imag(dTemp); 27 | Dist(tIndex,eIndex)=rTemp*rTemp/EmphasisFactor+iTemp*iTemp; % distance between two poles; 2.5 used to reduce influene of distance on real direction 28 | end 29 | end 30 | 31 | %************************************* 32 | % 2.0 establish pole matches 33 | Err2=zeros(Nt,1); 34 | MajorPoles=zeros(Nt,1); 35 | PoleDegrade=zeros(Nt,1); 36 | tempDist=Dist; 37 | for tIndex=1:Nt 38 | [minRowsValue,minColIndex]=min(tempDist,[],2); % find minmum distance for each true modes 39 | [minMatrixValue,minRowIndex]=min(minRowsValue); % find minmum distance for whole disctance matrix. 40 | MajorPoles(minRowIndex)=EstPoles(minColIndex(minRowIndex)); % locate the correponding estimation poles for true modes. 41 | Err2(minRowIndex)=MSErr(minRowIndex,minColIndex(minRowIndex)); % find the error. 42 | 43 | for rIndex=1:Nt 44 | if rIndex~=minRowIndex 45 | if minColIndex(minRowIndex)==minColIndex(rIndex) 46 | if minRowsValue(rIndex)1; error('Dimension error on TruePoles.'); end 14 | if size(EstPoles,2)>1; error('Dimension error on EstPoles.'); end 15 | if min(size(Energy)~=size(EstPoles)); error('Energy must be same size as EstPoles.'); end 16 | 17 | %Get rid of poles with more than Dmax % damping 18 | x = abs(real(EstPoles))./abs(EstPoles); 19 | Energy = Energy(xM 17 | %no repeat roots of a 18 | %********************* 19 | % 20 | %Modified version of John Pierre Matlab utility 21 | %Last modified 09/29/03 jfh 22 | 23 | N=length(a)-1; %system order 24 | M=length(b)-1; %numerator order 25 | Ts=1/fs; %sampling period 26 | [gamma,p,k]=residue(b,a); %partial fracton of innovation filter 27 | alpha=zeros(size(gamma)); 28 | for i=1:N, %find alpha's from gamma's and poles 29 | q=-p(i); 30 | qbvect=q.^(M:-1:-0).'; 31 | qavect=q.^(N:-1:0).'; 32 | alpha(i)=gamma(i)*(b*qbvect)/(a*qavect); 33 | end 34 | L 35 | keyboard 36 | if 0 37 | %[A,B,C,D]=par2ss(resN,polN,thru); 38 | NUM=b; DEN=a; 39 | fstep=0.01; Fmax=4*25.6; 40 | wHz=[0:fstep:Fmax]'; %frequency in Hz 41 | FrespI=TrfCalcS(NUM,DEN,wHz); 42 | figure; plot(wHz,db(FrespI)); 43 | set(gca,'xlim',[0 2]) 44 | set(gca,'ylim',[-40 10]) 45 | xlabel('Frequency in Hertz') 46 | title('Frequency Response for System Model') 47 | disp('ERROR IN CODE TO FOLLOW:'); pause 48 | NUM=poly(alpha); 49 | DEN1=a; DEN2=-poly(-p); 50 | Fresp1=TrfCalcS(NUM,DEN1,wHz); 51 | Fresp2=TrfCalcS(NUM,DEN2,wHz); 52 | figure; plot(wHz,db(Fresp1+Fresp2)); 53 | set(gca,'xlim',[0 2]) 54 | %set(gca,'ylim',[-40 10]) 55 | xlabel('Frequency in Hertz') 56 | title('Frequency Response for Ideal AutoCovariance') 57 | end 58 | for k=0:L 59 | r(k+1)=alpha.'*exp(p*Ts*k); 60 | end 61 | r=real(r); 62 | if size(r,2)>size(r,1), r=r'; end 63 | 64 | %End of John Pierre Matlab utility 65 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterA/SORTPOLE.M: -------------------------------------------------------------------------------- 1 | function [ur,cr,sr,Y]=SORTPOLE(zpoles,rhat,spoles,F1,F2) 2 | %Sort poles to place critical modes at top of list 3 | % [ur,cr,sr,Y]=SORTPOLE(zpoles,rhat,spoles) 4 | % inputs: zpoles=zplane poles 5 | % rhat=correlation function of appropriate length 6 | % spoles=splane poles 7 | % F1=approximate mode frequency for sorting purposes 8 | % F2=approximate mode frequency for sorting purposes 9 | % Outputs: 10 | % ur=ordered z-plane poles 11 | % cr=residues 12 | % sr=s-plane poles 13 | % Y=energies 14 | % 15 | % Note: This program should be modified to be more appropriate for ARMA 16 | % problem in general. 17 | % Updated 12/3/99 (JWP) 18 | % 19 | % 20 | % Last modified 10/20/00. jfh 21 | %************************************************************************* 22 | 23 | %************************************************************************* 24 | K=length(rhat); 25 | N=length(spoles); 26 | c=PRNYPH3(zpoles,rhat); % find the residues 27 | %presort to get only positive frequencies 28 | [junk,I]=sort(imag(spoles)); 29 | spoles=spoles(I); 30 | zpoles=zpoles(I); 31 | c=c(I); 32 | jnk=(imag(spoles)<0); 33 | cmplxnu=sum(jnk); %number of complex pole pairs 34 | spoles=spoles(cmplxnu+1:N); %this spoles contains real poles and positive freq. poles of complex pole pairs 35 | zpoles=zpoles(cmplxnu+1:N); 36 | c=c(cmplxnu+1:N); 37 | %end of presort 38 | %************************************************************************* 39 | 40 | %************************************************************************* 41 | [ur,cr,sr,Y]=orderener(zpoles,c,spoles,K); 42 | %below is an additional sort to make sure the intertie mode is first 43 | Q=5; %number of high energy terms for additional sort 44 | %%[junk,I]=sort((abs(abs(imag(sr(1:Q))/(2*pi))-0.26))); 45 | [junk,I]=sort((abs(abs(imag(sr(1:Q))/(2*pi))-F1))); 46 | %[junk,I]=sort(-real(sr(1:Q))); 47 | sr(1:Q)=sr(I); 48 | ur(1:Q)=ur(I); 49 | cr(1:Q)=cr(I); 50 | Y(1:Q)=Y(I); 51 | %************************************************************************* 52 | 53 | %************************************************************************* 54 | %sort to make 0.43 Hz mode second in list 55 | %%[junk,I]=sort((abs(abs(imag(sr(2:Q))/(2*pi))-0.45))); 56 | [junk,I]=sort((abs(abs(imag(sr(2:Q))/(2*pi))-F2))); 57 | sr(2:Q)=sr(I+1); 58 | ur(2:Q)=ur(I+1); 59 | cr(2:Q)=cr(I+1); 60 | Y(2:Q)=Y(I+1); 61 | %end of additional sort 62 | %************************************************************************* 63 | 64 | %end of ModeMeter utility -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterA/Sortpole1.m: -------------------------------------------------------------------------------- 1 | function [ur,cr,sr,Y]=sortpole1(zpoles,rhat,spoles,TrackFrqs) 2 | %Sort poles to place critical modes at top of list 3 | % [ur,cr,sr,Y]=sortpole1(zpoles,rhat,spoles) 4 | % 5 | % inputs: zpoles=zplane poles 6 | % rhat=correlation function of appropriate length 7 | % spoles=splane poles 8 | % F1=approximate mode frequency for sorting purposes 9 | % F2=approximate mode frequency for sorting purposes 10 | % Outputs: 11 | % ur=ordered z-plane poles 12 | % cr=residues 13 | % sr=s-plane poles 14 | % Y=energies 15 | % 16 | % Note: This program should be modified to be more appropriate for ARMA 17 | % problem in general. 18 | % 19 | % Developed by J. W. Pierre at U. Wyoming 20 | % Updated 12/3/99 (JWP) 21 | % 22 | % Functions called by Sortpole1: 23 | % prnyph3 24 | % orderener 25 | % 26 | % 27 | % Last modified 10/23/00. jfh 28 | %************************************************************************* 29 | 30 | F1=TrackFrqs(1); %Temporary 31 | F2=TrackFrqs(2); %Temporary 32 | 33 | %************************************************************************* 34 | K=length(rhat); 35 | N=length(spoles); 36 | c=PRNYPH3(zpoles,rhat); % find the residues 37 | %presort to get only positive frequencies 38 | [junk,I]=sort(imag(spoles)); 39 | spoles=spoles(I); 40 | zpoles=zpoles(I); 41 | c=c(I); 42 | jnk=(imag(spoles)<0); 43 | cmplxnu=sum(jnk); %number of complex pole pairs 44 | spoles=spoles(cmplxnu+1:N); %this spoles contains real poles and positive freq. poles of complex pole pairs 45 | zpoles=zpoles(cmplxnu+1:N); 46 | c=c(cmplxnu+1:N); 47 | %end of presort 48 | %************************************************************************* 49 | 50 | %************************************************************************* 51 | [ur,cr,sr,Y]=orderener(zpoles,c,spoles,K); 52 | %below is an additional sort to make sure the intertie mode is first 53 | Q=5; %number of high energy terms for additional sort 54 | %%[junk,I]=sort((abs(abs(imag(sr(1:Q))/(2*pi))-0.26))); 55 | [junk,I]=sort((abs(abs(imag(sr(1:Q))/(2*pi))-F1))); 56 | %[junk,I]=sort(-real(sr(1:Q))); 57 | sr(1:Q)=sr(I); 58 | ur(1:Q)=ur(I); 59 | cr(1:Q)=cr(I); 60 | Y(1:Q)=Y(I); 61 | %************************************************************************* 62 | 63 | %************************************************************************* 64 | %sort to make 0.43 Hz mode second in list 65 | %%[junk,I]=sort((abs(abs(imag(sr(2:Q))/(2*pi))-0.45))); 66 | [junk,I]=sort((abs(abs(imag(sr(2:Q))/(2*pi))-F2))); 67 | sr(2:Q)=sr(I+1); 68 | ur(2:Q)=ur(I+1); 69 | cr(2:Q)=cr(I+1); 70 | Y(2:Q)=Y(I+1); 71 | %end of additional sort 72 | %************************************************************************* 73 | 74 | %end of ModeMeter script -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterA/datacrct.m: -------------------------------------------------------------------------------- 1 | function z=datacrct(x,thresh) 2 | %**************************** 3 | %data correction for missing data 4 | %usage: z=datacrct(x,thresh) 5 | %inputs: 6 | % x=input data 7 | % thresh=magnitude considered out of range indicating in correct data 8 | %output 9 | % y=corrected data by linearly interpolating to correct for missing data 10 | %**************************** 11 | z=x; %Initialize output as input 12 | N=length(x); %total length of data 13 | %locate the start and stop indexes of poor data 14 | Istart=[]; 15 | Istop=[]; 16 | u=(abs(x)>thresh); %vector of ones (bad data) and zeros(good data) 17 | %special case for first sample 18 | if u(1)==1 19 | Istart=[Istart 1]; 20 | end 21 | if (u(1)==1)&(u(2)==0) 22 | Istop=[Istop 1]; 23 | end 24 | %samples 2 through N-1 25 | for n=2:(N-1) 26 | if (u(n)==1)&(u(n-1)==0) 27 | Istart=[Istart n]; 28 | end 29 | if (u(n)==1)&(u(n+1)==0) 30 | Istop=[Istop n]; 31 | end 32 | end 33 | %special case for last sample 34 | if u(N)==1 35 | Istop=[Istop N]; 36 | end 37 | if (u(N)==1)&(u(N-1)==0) 38 | Istart=[Istart N]; 39 | end 40 | %now that the starting and stopping points of poor strings 41 | %of data are stored in Istart and Istop 42 | %we correct the data by linear interpolation 43 | if length(Istart)>0 44 | for m=1:length(Istart) 45 | if Istart(m)==1 %special case if first data point is poor 46 | z(1:Istop(1))=x(Istop(1)+1); 47 | elseif Istop(m)==N %special case if last data point is poor 48 | z(Istart(m):N)=x(Istart(m)-1); 49 | else 50 | slope=(x(Istop(m)+1)-x(Istart(m)-1))/(Istop(m)-Istart(m)+2); 51 | for j=Istart(m):Istop(m) 52 | z(j)=z(j-1)+slope; 53 | end 54 | end 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterA/orderener.m: -------------------------------------------------------------------------------- 1 | function [ur,cr,sr,Y]=orderener(u,c,s,K) 2 | %*************************** 3 | %usage: [ur,cr,sr,Y]=orderener(u,c,s,K) 4 | %inputs: 5 | % u=z-plane poles 6 | % c=residues 7 | % s=s-plane poles 8 | % K=length 9 | %Outputs: 10 | % ur=ordered z-plane poles 11 | % cr=residues 12 | % sr=s-plane poles 13 | % Y=energies 14 | % see also reduce.m 15 | %*************************** 16 | N=length(u); 17 | k=(0:N-1)'; 18 | Matr=(diag(c)*((u*ones(1,K)).^(ones(size(u))*(0:K-1)))); 19 | Ener=sum((Matr.*conj(Matr))'); 20 | [Y,I]=sort(Ener); 21 | Y=Y(N:-1:1)'; 22 | I=I(N:-1:1); 23 | ur=u(I); 24 | cr=c(I); 25 | sr=s(I); 26 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterA/pltstrt2.m: -------------------------------------------------------------------------------- 1 | % Script pltstrt2.m 2 | % 3 | % Last modified 09/06/00. jfh 4 | % 5 | % Integration into PSM_Tools by J. F. Hauer, 6 | % Pacific Northwest National Laboratory. 7 | 8 | disp('In pltstrt2:') 9 | 10 | %plotting results 11 | %display all the modes in the s-plane for all the trials 12 | h=figure; 13 | plot(real(S1),imag(S1)/(2*pi),'x') 14 | title('s-plane') 15 | xlabel('real part of pole') 16 | ylabel('imag part of pole / (2pi)') 17 | axis([-0.5 0 0 1]) 18 | 19 | %display intertie mode 20 | mode=1; 21 | strt=T/2; 22 | t1=(strt:Tu:(strt+(Dblocks-1)*Tu)); 23 | h=figure; 24 | subplot(3,1,1) 25 | plot(time(1:decfac:maxpoints),MMsig(1:decfac:maxpoints),'-') 26 | ylabel('Signal Amplitude') 27 | title('Intertie Mode') 28 | subplot(3,1,2) 29 | plot(t1/60,abs(imag(S1(mode,:)))/(2*pi),'+') %plot freq vs t 30 | ylabel('Frequency in Hertz') 31 | %axis([t(1)/60 t(length(t))/60 0.25 0.35]); 32 | %axis([t(1)/60 t(length(t))/60 0.24 0.32]); 33 | if autoaxis~=1 %if autoaxis not equal to one 34 | axis([t(1)/60 t(length(t))/60 0.2 0.35]); 35 | end 36 | subplot(3,1,3) 37 | plot(t1/60,-real(S1(mode,:))./abs(S1(mode,:)),'+') %plot damp rat vs t 38 | ylabel('Damping Ratio') 39 | if autoaxis~=1 %if autoaxis not equal to one 40 | axis([t(1)/60 t(length(t))/60 0.0 0.15]); 41 | end 42 | xlabel('Time in Minutes') 43 | 44 | %Alberta 0.4 Hz mode 45 | mode=2; 46 | h=figure; 47 | subplot(3,1,1) 48 | plot(time(1:decfac:maxpoints),MMsig(1:decfac:maxpoints),'-') 49 | ylabel('Signal Amplitude') 50 | title('Alberta Mode') 51 | subplot(3,1,2) 52 | plot(t1/60,abs(imag(S1(mode,:)))/(2*pi),'+') %plot freq vs t 53 | ylabel('Frequency in Hertz') 54 | if autoaxis~=1 %if autoaxis not equal to one 55 | axis([t(1)/60 t(length(t))/60 0.3 0.45]); 56 | end 57 | subplot(3,1,3) 58 | plot(t1/60,-real(S1(mode,:))./abs(S1(mode,:)),'+') %plot damp rat vs t 59 | ylabel('Damping Ratio') 60 | if autoaxis~=1 %if autoaxis not equal to one 61 | axis([t(1)/60 t(length(t))/60 0.0 0.15]); 62 | end 63 | xlabel('Time in Minutes') 64 | 65 | %end of m-file 66 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterA/preproc.m: -------------------------------------------------------------------------------- 1 | function y=preproc(x,D,blp,bhp,ahp); 2 | %********************************* 3 | %Usage y=preproc(x,D,blp,bhp,ahp); 4 | % Inputs: 5 | % x: signal to be preprocessed 6 | % D: Decimation factor 7 | % blp: Lowpass FIR filter coefficients 8 | % bhp: Highpass numerator filter coefficients 9 | % ahp: Highpass denominator filter coefficients 10 | % Outputs: 11 | % y: signal after preprocessing 12 | %********************************** 13 | y=filter(blp,1,x); %lowpass filtered data 14 | y=y(1:D:length(y)); %decimated data 15 | y=filter(bhp,ahp,y); %highpassed filtered data 16 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterA/preprocdsn.m: -------------------------------------------------------------------------------- 1 | function [D,blp,bhp,ahp]=preprocdsn(Finitial,Fs) 2 | %****************************** 3 | %preprocessing design: i.e. lowpass filter and decimate, 4 | %usage [D,blp,bhp,ahp]=preprocdsn(Finitial,Fs) 5 | %designed and tested for Finitial=30 and Fs=5; 6 | %input 7 | % Finitial=initial sampling rate 8 | % Fs=new sampling rate after decimation 9 | % Note: the ratio of Finitial to Fs should be an integer 10 | %outputs 11 | % D=decimation factor 12 | % blp=coef. for low-pass FIR filter 13 | % bhp=numerator coef. for high pass filter 14 | % ahp=denominator coef. for high pass filter 15 | %note: 16 | % length of lowpass filter is 91 samples 17 | % Low pass cutt-off frequency is 2 Hz 18 | % Low pass stop frequency is 3 Hz 19 | % high pass filter is first order with a zero at z=0 20 | % and a pole at z=0.95 21 | %******************************** 22 | %First, lowpass filter for decimation 23 | Finitial=30; %initial sampling rate 24 | Fs=5; %decimated sampling rate 25 | D=Finitial/Fs; %decimation factor 26 | F=[0 2 3 Finitial/2]; %specs for filter frequencies 27 | f=F/Finitial; %normalized digital frequency filter specs 28 | m=90; %order of lowpass FIR filter, approx. 3 seconds of data 29 | blp=remez(m,2*f,[1 1 0 0]); %lowpass digital antialias filter used before dec. 30 | %[Hlp,w]=freqz(blp,1,512); 31 | %%figure(1) 32 | %%plot(w*Finitial/(2*pi),20*log10(abs(Hlp))) 33 | %second, highpass filter to remove very low frequency trends, high freq. gain=1 34 | %to be applied after lowpass filtering and decimating 35 | bhp=(1.95/2)*[1 -1]; %numerator with z-plane zero at z=1 36 | ahp=[1 -0.95]; %denominator with z-plane pole at z=0.95 37 | %[Hhp,w]=freqz(bhp,ahp,512); 38 | %%figure(2) 39 | %plot(w*Fs/(2*pi),20*log10(abs(Hhp))); 40 | %%plot(w*Fs/(2*pi),abs(Hhp)); 41 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterA/rvarbound.m: -------------------------------------------------------------------------------- 1 | function [rvarbnd,rvarlimit]=rvarbound(rtrue,N) 2 | %***************************** 3 | %Usage 4 | %Input 5 | % rtrue=true correlation function 6 | % N=sample size for estimated r 7 | %Output 8 | %***************************** 9 | L=length(rtrue); 10 | r=[rtrue(L:-1:2) rtrue]; 11 | %for i=-(L-1-k):(L-1-k), 12 | rvarsum=0; 13 | for i=-(L-1):1:(L-1) 14 | m=i+L; %convert the i index to a matlab index 15 | rvarsum=rvarsum+(r(m)^2); 16 | end 17 | rvarbnd=2*rvarsum/N; 18 | rvarlimit=1*rvarsum/N; -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterA/rvariance.m: -------------------------------------------------------------------------------- 1 | function rvar=rvariance(rtrue,N) 2 | %***************************** 3 | %Usage 4 | %Input 5 | % rtrue=true correlation function 6 | % N=sample size for estimated r 7 | %Output 8 | %***************************** 9 | L=length(rtrue); 10 | r=[rtrue(L:-1:2) rtrue]; 11 | for k=0:L-1, 12 | rvar(k+1)=0; 13 | for i=-(L-1-k):(L-1-k), 14 | m=i+L; %convert the i index to a matlab index 15 | %rvar(k+1)=rvar(k+1)+(1-(k+abs(i))/L)*(r(m)^2+r(m+k)*r(m-k)); 16 | rvar(k+1)=rvar(k+1)+(N-k-abs(i))*(r(m)^2+r(m+k)*r(m-k)); 17 | end 18 | end 19 | rvar=rvar/(N^2); 20 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterB/JPmodemeterB_Docs/JPmodemeter_UserNote1.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterB/JPmodemeterB_Docs/JPmodemeter_UserNote1.doc -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterB/JPmodemeterB_Source/funDecimate.m: -------------------------------------------------------------------------------- 1 | function MyDataOut=funDecimate(MyDataIn,DeciFactor) 2 | 3 | if DeciFactor> 1 4 | Ts=MyDataIn.Ts; 5 | Fs=1/Ts; 6 | DeciFactor=round(DeciFactor); 7 | TsFinal=Ts*DeciFactor; 8 | FsFinal=1/TsFinal; 9 | if length(MyDataIn.u)==0 % if ambient data is used 10 | % Anti-Alias low pass linear-phase FIR filter design using the Parks-McClellan algorithm 11 | n=90; % order of the FIR filter 12 | %F=[0 0.01 0.02 FsFinal/2-0.5 FsFinal/2+0.5 Fs/2]; % Frequency in Hz 13 | F=[0 FsFinal/2-0.5 FsFinal/2+0.5 Fs/2]; % Frequency in Hz 14 | f=F/(Fs/2); % f is a vector of pairs of normalized frequency points, specified in the range between 0 and 1, 15 | m=[1 1 0 0]; % m is a vector containing the desired amplitudes at the points specified in f. 16 | w=[1 3]; 17 | %m=[0 0 1 1 0 0]; % m is a vector containing the desired amplitudes at the points specified in f. 18 | %w=[0.5 1 3]; 19 | b=remez(n,f,m,w); 20 | FilteredOutput=filter(b,1,MyDataIn.y); 21 | %Decimation 22 | y=FilteredOutput(length(b)+1:DeciFactor:end,:); 23 | MyDataOut=iddata(y,[],TsFinal); 24 | else % if injection data is used 25 | % Anti-Alias low pass linear-phase FIR filter design using the Parks-McClellan algorithm 26 | FilterOrder=5; 27 | FilterWn=(FsFinal/2)/(Fs/2); 28 | MyData = idfilt(MyDataIn,FilterOrder,FilterWn,'noncausal'); 29 | MyDataOut = idresamp(MyData,DeciFactor); 30 | end 31 | 32 | % disp(' '); 33 | % disp('Decimation has been performed on your data set'); 34 | % disp(' '); 35 | else 36 | MyDataOut=MyDataIn; 37 | end -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterB/JPmodemeterB_Source/funFindModes.m: -------------------------------------------------------------------------------- 1 | function [Freq, DR]=funFindModes(sPoles); 2 | % JPierre utility for mode display 3 | % function [Freq, DR]=funFindModes(sPoles); 4 | % 5 | % Modified 05/18/04. jfh Longer fields for numerical display 6 | 7 | [Y,I]=sort(imag(sPoles)); 8 | sPoles=sPoles(I); 9 | Freq=imag(sPoles)./(2*pi); 10 | DR=-100*real(sPoles)./abs(sPoles); 11 | 12 | %*********************************************************************************** 13 | if nargout == 0, % do plots 14 | Np=length(sPoles); 15 | disp(' ') 16 | disp('Major Modes:'); 17 | disp('Frequency(Hz) Damping Ratio(%)'); 18 | disp('----------------------------------'); 19 | for nIndex=1:Np 20 | disp(sprintf('freq=%14.8f DR=%14.8f ', Freq(nIndex),DR(nIndex))); 21 | end 22 | disp('----------------------------------'); 23 | end 24 | %*********************************************************************************** 25 | 26 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterB/JPmodemeterB_Source/funFindPoles.m: -------------------------------------------------------------------------------- 1 | function [sPoles,sMajorPoles,MRED]=funFindPoles(MyModel,NumMajorPoles); 2 | % 3 | % function [sPoles,sMajorPoles,MRED]=funFindPoles(MyModel,NumMajorPoles); 4 | % 5 | %*********************************************************************************** 6 | % Input parameters 7 | % MyModel: The state space model 8 | % NumMajorPoles: # of the major modes of state space model 9 | % 10 | % Output parameters 11 | % Poles: All the continuous poles found from State Space model. 12 | % MajorPoles: Major continuous poles from State Space model. 13 | % 14 | % Modified 05/26/04. jfh (Displays to track processing) 15 | 16 | FNname='funFindPoles'; %name for this function 17 | 18 | disp(' ') 19 | disp(['In JPmodeMeter function ' FNname ':']) 20 | disp(' ') 21 | 22 | %*********************************************************************************** 23 | % 1 Check the arguments 24 | if (nargin < 1); error('SubspaceAmbient needs at least one argument'); end 25 | if (nargin < 2); NumMajorPoles=[]; end 26 | Fs=1/MyModel.Ts; 27 | % end of 1.0 Check the arguments 28 | %*********************************************************************************** 29 | 30 | %*********************************************************************************** 31 | % 2.3 find all identified Poles 32 | A=MyModel.a; 33 | Order=length(A); 34 | zPoles=eig(A); % discrete modes 35 | sPoles=log(zPoles).*Fs; % continuous modes in radian/s 36 | % end of 2 37 | %*********************************************************************************** 38 | 39 | %*********************************************************************************** 40 | % 3. find the main poles for state space model 41 | NRawPoles=length(sPoles); 42 | if length(NumMajorPoles)<2 43 | if length(NumMajorPoles)==0 % number of major modes is not given 44 | MainOrder=min([max([round(Order/2),13]),Order]); % Order of state space model 45 | elseif length(NumMajorPoles)==1 %number of major modes is given 46 | MainOrder=NumMajorPoles*2; 47 | end 48 | MRED = idmodred(MyModel,MainOrder); %do model reduction 49 | MainOrder =length(MRED.a); 50 | zMainPoles=eig(MRED.a); %find the major discrete poles 51 | sMainPoles=log(zMainPoles).*Fs; %convert to continuous poles 52 | NMainPoles=length(sMainPoles); NpolesE=NRawPoles-NMainPoles; 53 | disp(['In ' FNname ': Model reduction has eliminated ' num2str(NpolesE) ' poles']) 54 | else % frequency matrix is given 55 | sMainPoles=2*pi*NumMajorPoles*i; 56 | end 57 | %*********************************************************************************** 58 | 59 | %*********************************************************************************** 60 | NMainPoles=length(sMainPoles); % number of main freq 61 | sMajorPoles=zeros(NMainPoles,1); 62 | for pIndex=1:NMainPoles 63 | tempDist=100000; 64 | for ywIndex=1:Order 65 | dTemp=sMainPoles(pIndex)-sPoles(ywIndex); 66 | rTemp=real(dTemp); 67 | iTemp=imag(dTemp); 68 | %Distance between two poles; 2.5 is used to reduce influence of distance on real direction 69 | dTemp=rTemp*rTemp/1.5+iTemp*iTemp; 70 | if dTemp 6) 5 | disp(sprintf('Your sample Freq is %5.2f Hz,which might be too high for identification purpose.',Fs)); 6 | Response=input('Do you want to do decimation (decrease the sampling freq)? Enter y or n [y]:','s'); 7 | if isempty(Response) %Test for empty string 8 | setok=1; 9 | else 10 | setok=~strcmp(lower(Response(1)),'n'); %String comparison 11 | end 12 | 13 | if setok 14 | disp(' '); 15 | disp(sprintf('New sample freq = %5.2f/decimation factor',Fs)); 16 | DeciFactor=input(sprintf('Input your decimation factor (which should be a positive integer)[%d]:', floor(Fs/5))); 17 | if isempty(DeciFactor) 18 | DeciFactor=floor(Fs/5); 19 | else 20 | DeciFactor=round(DeciFactor); 21 | end 22 | disp(' '); 23 | disp(sprintf('New sampling rate= %5.2f Hz',Fs/DeciFactor)); 24 | disp(' '); 25 | else 26 | DeciFactor=1; 27 | disp('........'); 28 | disp('Decimation is not performed'); 29 | disp(' '); disp(' '); 30 | end 31 | else 32 | DeciFactor=1 33 | disp('........'); 34 | disp('Decimation is not performed'); 35 | disp(' '); disp(' '); 36 | end 37 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterB/JPmodemeterB_Source/funffplot.m: -------------------------------------------------------------------------------- 1 | function [amp,phas,w,sdamp,sdphas] = funffplot(varargin) 2 | %FFPLOT Plots a diagram of a frequency function or spectrum with linear 3 | % frequency scales and Hz as the frequency unit. 4 | % 5 | % FFPLOT(M) or FFPLOT(M,'SD',SD) or FFPLOT(M,W) or FFPLOT(M,SD,W) 6 | % 7 | % where M is an IDMODEL or IDFRD object, like IDPOLY, IDSS, IDARX or 8 | % IDGREY, obtained by any of the estimation routines, including 9 | % ETFE and SPA. The frequencies in W are specified in Hz. 10 | % 11 | % The syntax is the same as for BODE. See also IDMODEL/BODE for all 12 | % details. When used with output arguments, 13 | % [Mag,Phase,W,SDMAG,SDPHASE] = FFPLOT(M,W) 14 | % the frequency unit of W is Hz. 15 | 16 | % Copyright 1986-2001 The MathWorks, Inc. 17 | % $Revision: 1.9 $ $Date: 2001/04/06 14:22:30 $ 18 | 19 | try 20 | if nargout == 0 21 | funbodeaux(0,varargin{:}); 22 | elseif nargout <= 3 23 | [amp,phas,w] = funbodeaux(0,varargin{:}); 24 | w=w/2/pi; 25 | else 26 | [amp,phas,w,sdamp,sdphas] = funbodeaux(0,varargin{:}); 27 | w=w/2/pi; 28 | end 29 | catch 30 | error(lasterr) 31 | end 32 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/ModeMeterOfflineDemo.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/ModeMeterOfflineDemo.fig -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/ModeMeterOfflineDemo.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/ModeMeterOfflineDemo.m -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/ModeMeterOfflineDemoConfig.m: -------------------------------------------------------------------------------- 1 | % 2 | % Copyright Battelle Memorial Institute. All Rights Reserved." 3 | % 4 | % PDCDataReaderDemo Configuration File 5 | % Created on 17-Feb-2006 16:15:23 6 | % keyboard; 7 | % PDC .INI file and UDP port 8 | % PDCConfigFile = 'C:\d3p045\DSTini\BPA2_060508.ini'; 9 | % PDCMatFile = 'C:\d3p045\DSTini\BPA2_060508.ini'; 10 | % PDCUDPPort = 3050; 11 | % PDCConfigFile = 'C:\d3p045\TVA_PDC.INI'; 12 | % PDCUDPPort = 3077; 13 | % 14 | % Time series plot parameters 15 | % 16 | PlotWindowSec = 15; 17 | % Fourier analysis parameters 18 | DFTWindowLength = 1024; 19 | DFTWindowOverlap = 768; 20 | xNote=[]; 21 | sNote=[]; 22 | DRBorder=[0, 5, 10, 20]; 23 | TopSpeed=10; 24 | 25 | ModelType =1; % 0 for AR model 26 | % 1 for ARMA model 27 | 28 | SaveModeFileName='SavedMode.txt'; 29 | SaveMode=1; 30 | 31 | % AR Model parameters 32 | %aOrder=45; 33 | %ForgTimeConst=120; % memory time constant (sec) see page 378 eq(11.65a) 34 | WindowLength=5*60; % Limited window size in (sec) =0 means infinite window length 35 | %ForgTimeConst=10*60; % memory time constant (sec) see page 378 eq(11.65a) 36 | 37 | % ARMA Model parameters 38 | aOrder2=30; %30 order of AR 39 | bOrder2=25; %25 order of X 40 | cOrder2=5; %5 order of MA 41 | kOrder2=1; 42 | NumMajorPoles=5; 43 | if NumMajorPoles>(aOrder2/2) 44 | NumMajorPoles=floor(aOrder2/2); 45 | end 46 | 47 | %lModel=1; % number of data channels 48 | delta2=4; 49 | 50 | %------------------------------------ 51 | % start: Parameter for mode initialization 52 | IniModeFreq=[0.26; 0.455]; 53 | IniModeDR=[5.; 10]; 54 | IniModeWeight=[0; 0]; 55 | 56 | %handles.IniModeWeight 57 | % temp=IniModeFreq*2*pi; 58 | % Poles=temp.*cot(acos(-IniModeDR/100))+j*temp; 59 | % funPole2mode(Poles); 60 | % end: Parameter for mode initialization 61 | %-------------------------------------- 62 | 63 | %keyboard; 64 | ForgTimeConst02=2*60; % Limited window size in (sec) =0 means infinite window length 65 | PDCMatPath=[pwd, '\']; 66 | PDCMatFile='Current.mat'; 67 | sigIndxInput=0; % Input channel index 0 means no injection 68 | sigIndx=2; % output channel index 69 | 70 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funConfigParameters.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funConfigParameters.fig -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/PSM2Date.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/PSM2Date.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/SubLoadNewData.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/SubLoadNewData.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/dividenowarn.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/dividenowarn.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funDominantMode.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funDominantMode.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funFindModes.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funFindModes.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funFindPoles.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funFindPoles.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funFreqz.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funFreqz.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funMatchPoles.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funMatchPoles.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funMode2Pole.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funMode2Pole.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funModeDispSelection.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funModeDispSelection.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funPole2Mode.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funPole2Mode.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funPolePowerAR.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funPolePowerAR.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funR3LSModesIni.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funR3LSModesIni.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funRDetrend.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funRDetrend.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funRMedianDetrend.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funRMedianDetrend.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funRMedianDetrendNaN.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funRMedianDetrendNaN.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funRMedianFilter.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funRMedianFilter.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funRarxRobustExt.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funRarxRobustExt.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funRarxRobustExtP.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funRarxRobustExtP.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funRarxRobustExtP05MIMOoffline.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funRarxRobustExtP05MIMOoffline.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funShowPointsAni01.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funShowPointsAni01.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funShowPointsAni02.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funShowPointsAni02.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funShowPointsAniAxes.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/funShowPointsAniAxes.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/residuez.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/funSub/residuez.p -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/logo.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/logo.tif -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/pnnllogo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeterD_R3LS/pnnllogo.gif -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeter_Math/TrueCovS.m: -------------------------------------------------------------------------------- 1 | function [r,alpha,Poles]=TrueCovS(b,a,L,fs) 2 | %********************* 3 | %John Pierre Matlab utility 4 | %Usage: [r,alpha,p]=TrueCovS(b,a,L,fs) 5 | %true correlation function for continuous time system 6 | %Inputs: 7 | % b=[b0 b1 ... bM] %numerator in the s-domain 8 | % a=[1 a1 ... aN] %denominator in the s-domain 9 | % L=max lag to be calculated 10 | % fs=sampling rate 11 | %Outputs: 12 | % r=true autocorrelation function of length L 13 | % alpha=true residues of the autocorrelation function 14 | % Poles=true poles of the autocorrelation function 15 | %where N>M 16 | %no repeat roots of a 17 | %********************* 18 | % 19 | %Last modified 01/29/02 jfh 20 | 21 | disp('In TrueCovS:') 22 | disp('WARNING--THERE IS SOMETHING WRONG WITH THIS CODE!!!') 23 | disp('Use RtrueCt instead') 24 | pause 25 | 26 | N=length(a)-1; %system order 27 | M=length(b)-1; %numerator order 28 | Ts=1/fs; %sampling period 29 | [gamma,Poles,K]=residue(b,a); %partial fracton of innovation filter 30 | alpha=zeros(size(gamma)); 31 | 32 | %Find alpha's from gamma's and poles 33 | for i=1:N 34 | q=-Poles(i); 35 | qbvect=q.^(M:-1:0).'; 36 | qavect=q.^(N:-1:0).'; 37 | alpha(i)=gamma(i)*(b*qbvect)/(a*qavect); 38 | end 39 | 40 | for k=0:L 41 | r(k+1)=alpha.'*exp(Poles*Ts*k); 42 | end 43 | if size(r,2)>size(r,1), r=r'; end 44 | 45 | if 1 %Diagnostics with alternate logic: 46 | disp('In TrueCovS'); keyboard; %disp(gamma) 47 | bconj=b.*((-1).^(M:-1:0)); 48 | aconj=a.*((-1).^(N:-1:0)); 49 | disp('[b'' bconj''] = ') 50 | disp([b' bconj']) 51 | disp('[a'' aconj''] = ') 52 | disp([a' aconj']) 53 | disp('A'' = '); A=conv(a,aconj); disp(A') 54 | disp('B'' = '); B=conv(b,bconj); disp(B') 55 | disp('roots(B) = '); disp(roots(B)), 56 | disp('roots(A) = '); disp(roots(A)) 57 | disp('residue(b,a) = '); disp(residue(b,a)) 58 | disp('alpha = '); disp(alpha) 59 | disp('residue(B,A) = '); disp(residue(B,A)) 60 | figure; plot([real(r) imag(r)]) 61 | Time=[0:L]*Ts; thru=0; 62 | [A,B,C,D]=par2ss(alpha,Poles,thru); 63 | AcovCk=impulse(A,B,C,D,1,Time); 64 | figure; plot([real(r) AcovCk]) 65 | end 66 | 67 | %Return r as real column vector 68 | r=real(r); if r(1)<0; r=-r; end %Should we do this??? 69 | 70 | %End of John Pierre Matlab utility 71 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeter_Math/TrueCovZ.m: -------------------------------------------------------------------------------- 1 | function [r,alpha,p]=TrueCovZ(b,a,L) 2 | %********************* 3 | %Usage: [r,alpha,p]=TrueCovZ(b,a,L) 4 | %Inputs: 5 | % b=[b0 b1 ... bM] %numerator in the z-domain 6 | % a=[1 a1 ... aN] %denominator in the z-domain 7 | % L=max lag to be calculated 8 | %Outputs: 9 | % r=true autocorrelation function of length L 10 | % alpha=true residues of the autocorrelation function 11 | % p=true poles of the auto correlation function 12 | %where N>M 13 | %no repeat roots of a 14 | %see Papoulis, 3rd ed. pg. 410 15 | %********************* 16 | % 17 | %Last modified 10/30/01 jfh 18 | 19 | N=length(a)-1; %system order 20 | M=length(b)-1; %numerator order 21 | [gamma,p,k]=residuez(b,a); %partial fracton of innovation filter 22 | alpha=zeros(size(gamma)); 23 | for i=1:N, %find alpha's from gamma's and poles 24 | q=conj(1/p(i)); 25 | qbvect=q.^(0:-1:-M)'; 26 | qavect=q.^(0:-1:-N)'; 27 | alpha(i)=gamma(i)*(b*qbvect)/(a*qavect); 28 | end 29 | for k=0:L 30 | r(k+1)=alpha.'*(p.^k); 31 | end 32 | 33 | %End of John Pierre Matlab utility 34 | 35 | -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeter_Math/TrueCovZSmath.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeter_Math/TrueCovZSmath.doc -------------------------------------------------------------------------------- /PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeter_Math/TrueCovZmath.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/PSMtools Source/_PSMtools_AddOns/ModeMeter_Utilities/ModeMeter_Math/TrueCovZmath.doc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DSIToolbox 2 | Dynamic System Identification Toolbox 3 | Developed at the Pacific Northwest National Laboratory with contributions 4 | from other government entities and universities. 5 | 6 | The DSI Toolbox provides unique capabilities in the analysis and control of 7 | large dynamic systems. It is designed to run with MATLAB, providing flexibility 8 | in using, tailoring, and integrating the functionality in combination with 9 | other tools. Its functions include data format conversion, data merging, data 10 | filtering, data batch plotting, Fourier analysis, Prony analysis, and ModeMeter. 11 | 12 | The DSI Toolbox is primarily oriented toward the analysis of phasor measurement 13 | unit-based information. Please visit the website for the North American 14 | SynchroPhasor Initiative (NASPI - http://www.naspi.org) for more details on 15 | phasor measurement unit analysis and other tools. -------------------------------------------------------------------------------- /Ringdown130930/Contents.txt: -------------------------------------------------------------------------------- 1 | % BPA/PNNL Dynamic Systems Identification Toolbox 2 | % 3 | % Ringdown Analysis Tool, Version 3.1.8, 30-Sep-2013. 4 | % 5 | % The Ringdown Analysis Tool is a MATLAB graphical user interface based 6 | % environment for analyzing dynamic system ringdown data using Prony and 7 | % Fourier based techniques. It is a component of the Dynamic Systems 8 | % Identification Toolbox. 9 | % 10 | % For usage instructions, type 11 | % 12 | % help ringdown 13 | % 14 | % at the MATLAB command prompt. 15 | % 16 | % Files in this directory: 17 | % 18 | % ringdown.m - Opens the Ringdown Analysis Tool. 19 | % getmodel.m - Returns identified model to MATLAB workspace. 20 | % 21 | % Files in the private subdirectory: 22 | % 23 | % combin.m, create_dict.m, create_inpulse_matrix.m, dpssread.m, 24 | % MsgDict.m, ppsmread.m, prgv2_5.m, prspak.m, PSAMread.m, ptirread.m, 25 | % reorder_modes.m, rguidt.m, rguifilt.m, rguiload.m, rguimgr.m, 26 | % rguipref.p, rguisave.m, settp.m, swxload0.m, tranfrq0.m, tranfun.m, 27 | % transimf.m 28 | % 29 | % These are Ringdown Analysis Tool utility functions. 30 | 31 | % Copyright (c) 1995-2014 Battelle Memorial Institute. The Government 32 | % retains a paid-up nonexclusive, irrevocable worldwide license to 33 | % reproduce, prepare derivative works, perform publicly and display 34 | % publicly by or for the Government, including the right to distribute 35 | % to other Government contractors. 36 | % 37 | % $Id$ -------------------------------------------------------------------------------- /Ringdown130930/MsgDict.m: -------------------------------------------------------------------------------- 1 | % This is the error/warning flag class 2 | classdef MsgDict < handle 3 | 4 | properties 5 | type = {}; 6 | num_key = []; 7 | err_msg = {}; 8 | end 9 | 10 | methods 11 | function this = MsgDict(type, key, msg), 12 | if nargin == 0, 13 | this = this; 14 | elseif nargin == 3, 15 | this.type = type; 16 | this.num_key = key; 17 | this.err_msg = msg; 18 | end 19 | end 20 | 21 | function add_elem(this, type, key, msg), 22 | this.type = [this.type; type]; 23 | this.num_key = [this.num_key; key]; 24 | this.err_msg = [this.err_msg; msg]; 25 | end 26 | 27 | function item_key = get_key(this, key), 28 | if nargin == 1, 29 | fprintf('An error code is required to make a decision!\n'); 30 | else, 31 | item_key = this.num_key(find(this.num_key == key)); 32 | end 33 | end 34 | 35 | function print_msg(this, key), 36 | if nargin == 1, 37 | fprintf('Really? Give me a code error if you want something!\n'); 38 | else, 39 | msg = [this.type{find(this.num_key == key)}, ': ', this.err_msg{find(this.num_key == key)}]; 40 | fprintf(2, '%s\n', msg); 41 | end 42 | end 43 | end 44 | 45 | end -------------------------------------------------------------------------------- /Ringdown130930/PSMlabl.m: -------------------------------------------------------------------------------- 1 | function PSMlabl(figInfo,subtitleL,subtitleR,PrintPlot) 2 | 3 | % PSMLABL: Annotates Ringdown Analysis Tool plots using PSM tools format 4 | % 5 | % Places PSM tools style titles on plots generated by the BPA/PNNL Ringdown 6 | % Analysis Tool. This function should be called directly by the tool using 7 | % the 'opts' input to the tool. 8 | % 9 | % Usage: 10 | % 11 | % PSMlabl(figInfo,subtitleL,subtitleR,PrintPlot); 12 | % 13 | % where 14 | % 15 | % figInfo = Structure containing information about the generated plot. 16 | % 17 | % subtitleL = Left justified text to be placed below main title. 18 | % 19 | % subtitleR = Right justified text to be placed below main title. 20 | 21 | % By Jeff M. Johnson, Pacific Northwest National Laboratory. 22 | % Date : March 1999 23 | % 24 | % Copyright (c) 1995-2002 Battelle Memorial Institute. The Government 25 | % retains a paid-up nonexclusive, irrevocable worldwide license to 26 | % reproduce, prepare derivative works, perform publicly and display 27 | % publicly by or for the Government, including the right to distribute 28 | % to other Government contractors. 29 | % 30 | % Last Update: January 24, 2002 (JMJ) 31 | 32 | if nargin<4; PrintPlot=0; end 33 | if nargin<3; subtitleR=''; end 34 | if nargin<2; subtitleL=''; end 35 | 36 | % assignin('base','figInfo',figInfo); 37 | % assignin('base','subtitleL',subtitleL); 38 | % assignin('base','subtitleR',subtitleR); 39 | 40 | axesHndls=figInfo.axesHndls; nnaxes=length(axesHndls); 41 | sigtitles=figInfo.titles; nnsigs=length(sigtitles); 42 | 43 | if nnaxes==1 44 | plottype=figInfo.plottypes; 45 | else 46 | plottype=figInfo.plottypes{1}; 47 | end 48 | 49 | % Set axes font properties to MATLAB defaults. 50 | fntname=get(0,'DefaultAxesFontName'); fntsize=get(0,'DefaultAxesFontSize'); 51 | h=get(axesHndls,{'XLabel' 'YLabel'}); set([h{:}],'FontName',fntname,'FontSize',fntsize); 52 | 53 | % Set tick mark direction outward. Remove top and right side tick marks. 54 | if ~strcmp(plottype,'mtbl') 55 | set(axesHndls,'Box','off','TickDir','out'); 56 | for ii=1:nnaxes 57 | axesHndl=axesHndls(ii); axes(axesHndl); 58 | xlim=get(axesHndl,'XLim'); ylim=get(axesHndl,'YLim'); 59 | line([xlim(1); xlim(2); xlim(2)],[ylim(2); ylim(2); ylim(1)], ... 60 | 'Color',get(axesHndl,'XColor'),'LineWidth',get(axesHndl,'LineWidth')); 61 | end 62 | end 63 | 64 | % Add the title and subtitles 65 | if nnsigs==2; if strcmp(sigtitles{2},'Model'); nnsigs=1; end; end 66 | 67 | if nnsigs==1 68 | switch plottype 69 | case 'tr', fstr='%s'; 70 | case {'frm', 'frp'}, fstr='Frequency spectrum of %s'; 71 | case 'mtbl', fstr='Modes identified from %s'; 72 | otherwise, fstr=''; 73 | end 74 | else 75 | fstr=''; 76 | end 77 | 78 | if isempty(fstr) 79 | pagetitle=get(get(axesHndls(1),'Title'),'String'); 80 | else 81 | pagetitle=sprintf(fstr,sigtitles{1}); 82 | end 83 | 84 | titlHndl=get(axesHndls(1),'Title'); 85 | set(titlHndl,'FontSize',fntsize+2,'Units','normalized'); 86 | if isempty(subtitleL) & isempty(subtitleR) 87 | set(titlHndl,'String',pagetitle); 88 | else 89 | set(titlHndl,'String',{pagetitle ' '}); 90 | set(axesHndls(1),'DefaultTextUnits','normalized', ... 91 | 'DefaultTextFontName',fntname, ... 92 | 'DefaultTextFontSize',fntsize, ... 93 | 'DefaultTextVerticalAlignment','baseline'); 94 | 95 | titlExtent=get(titlHndl,'Extent'); axes(axesHndls(1)); 96 | text(0,titlExtent(2),subtitleL,'HorizontalAlignment','left'); 97 | text(1,titlExtent(2),subtitleR,'HorizontalAlignment','right'); 98 | end 99 | 100 | if PrintPlot; print -f; end -------------------------------------------------------------------------------- /Ringdown130930/README.TXT: -------------------------------------------------------------------------------- 1 | BPA/PNNL Dynamic Systems Identification (DSI) Toolbox 2 | 3 | This disk contains Version 3.1.8 of the Ringdown 4 | Analysis Tool component of the BPA/PNNL DSI toolbox. 5 | This is a beta version that is current as of 6 | September 30, 2013. The tool runs under MATLAB 2012a, 7 | which is available from The MathWorks, Inc. 8 | 9 | To install the tool: 10 | 11 | 1. Install MATLAB as described in the MATLAB 12 | Installation Guide for PC and Macintosh. 13 | 14 | 2. Copy the folder titled 'dsitools' to the toolbox 15 | folder that is part of the MATLAB installation. 16 | 17 | 3. Launch MATLAB. Using the 'Set Path' item that is 18 | under the 'File' menu, append the newly installed 19 | 'dsitools' folder to the MATLAB search path. 20 | 21 | 4. Type 'help ringdown' at the MATLAB command prompt. 22 | Several lines of text describing the Ringdown 23 | Analysis Tool calling sequence should now be 24 | displayed. -------------------------------------------------------------------------------- /Ringdown130930/cmd_line_ringdown.m: -------------------------------------------------------------------------------- 1 | function [identmodel, xcon, plhs_3, plhs_4] =cmd_line_ringdown(sigdat, tstep, shftnnft, inpulses, known_modes, xcon) 2 | %Just exposes the "private" Prony function so MATLAB can call it in a script. 3 | 4 | [identmodel, xcon, plhs_3, plhs_4]=prgv2_5(sigdat, tstep, shftnnft, inpulses, known_modes, xcon); -------------------------------------------------------------------------------- /Ringdown130930/private/combin.m: -------------------------------------------------------------------------------- 1 | % Function that generates combinations of 1's and 0's 2 | % ************************************************************************** 3 | % 4 | % The following represents the MATLAB translation of the original FORTRAN 5 | % code for the COMBIN function 6 | % Author of the MATLAB code: Laurentiu Dan Marinovici 7 | % Date: August - September 2013 8 | % 9 | % ************************************************************************** 10 | function new_ic = combin(n, m, ic) 11 | global ntaille nsize nwork nsigs nflgs inpmax mincon 12 | new_ic = ic; 13 | if m >= n | m == 0, 14 | % This message is for testing only 15 | % fprintf('Nothing to do in COMBIN function.\n'); 16 | else, 17 | %n1 = n -1; 18 | j_ind = 1; 19 | nj = n - j_ind; 20 | while ic(n) == ic(nj) & j_ind < n, 21 | j_ind = j_ind + 1; 22 | nj = n - j_ind; 23 | end 24 | if mod(m, 2) == 0, % if m is even 25 | if ic(n) ~= 1, 26 | k1 = n - j_ind; 27 | k2 = k1 + 1; 28 | elseif ic(n) == 1, 29 | if mod(j_ind, 2) == 0, % j_ind is even 30 | k1 = n - j_ind; 31 | k2 = min(k1 + 2, n); 32 | elseif mod(j_ind, 2) == 1, % j_ind is odd 33 | % scan form right to left 34 | jp = (n - j_ind) - 1; 35 | i_ind = 1; 36 | i1 = jp + 2 - i_ind; 37 | while ic(i1) == 0 & i_ind < jp, 38 | i_ind = i_ind + 1; 39 | i1 = jp + 2 - i_ind; 40 | end 41 | if ic(i1 - 1) == 1, 42 | k1 = i1 - 1; 43 | k2 = n - j_ind; 44 | else, 45 | k1 = i1 - 1; 46 | k2 = (n + 1) - j_ind; 47 | end 48 | end 49 | end 50 | elseif mod(m, 2) == 1, % if m is odd 51 | if ic(n) == 1, 52 | if mod(j_ind, 2) == 1, 53 | k1 = n - j_ind; 54 | k2 = min(k1 + 2, n); 55 | else, 56 | % scan form right to left 57 | jp = (n - j_ind) - 1; 58 | i_ind = 1; 59 | i1 = jp + 2 - i_ind; 60 | while ic(i1) == 0 & i_ind < jp, 61 | i_ind = i_ind + 1; 62 | i1 = jp + 2 - i_ind; 63 | end 64 | if ic(i1 - 1) == 1, 65 | k1 = i1 - 1; 66 | k2 = n - j_ind; 67 | else, 68 | k1 = i1 - 1; 69 | k2 = (n + 1) - j_ind; 70 | end 71 | end 72 | else, 73 | k2 = (n - j_ind) - 1; 74 | if k2 == 0, 75 | k1 = 1; 76 | k2 = (n + 1) - m; 77 | else, 78 | if ic(k2 + 1) == 1 & ic(k2) == 1, 79 | k1 = n; 80 | else, 81 | k1 = k2 + 1; 82 | end 83 | end 84 | end 85 | end 86 | new_ic(k1) = 1 - ic(k1); 87 | new_ic(k2) = 1 - ic(k2); 88 | end 89 | end -------------------------------------------------------------------------------- /Ringdown130930/private/ptirread.m: -------------------------------------------------------------------------------- 1 | function [y,names,ptirname]=ptirread(ptirname); 2 | 3 | % PTIRREAD: pti, randypak 4 | % Reads data from a PTI file converted for RandyPak. 5 | % 6 | % Usage: 7 | % 8 | % [y,names,ptirname]=ptirread(ptirname); 9 | % 10 | % where 11 | % 12 | % ptirname = Name of PTIR file. If this is empty or invalid, user is prompted to 13 | % select a file. 14 | % 15 | % y = Data matrix. First column is time. 16 | % 17 | % names = Titles for data columns. 18 | 19 | % By Jeff M. Johnson, Pacific Northwest National Laboratory. 20 | % Date: January 2, 1996 21 | % 22 | % Copyright (c) 1995-2013 Battelle Memorial Institute. The Government 23 | % retains a paid-up nonexclusive, irrevocable worldwide license to 24 | % reproduce, prepare derivative works, perform publicly and display 25 | % publicly by or for the Government, including the right to distribute 26 | % to other Government contractors. 27 | % 28 | % $Id$ 29 | 30 | % Initialize output arguments 31 | if nargout; y=[]; names=''; end 32 | 33 | % Print RCSID stamp and copyright 34 | if nargin==1 & ischar(ptirname) & strcmp(ptirname,'rcsid') 35 | fprintf(1,['\n$Id$\n\n' ... 36 | 'Copyright (c) 1995-2013 Battelle Memorial Institute. The Government\n' ... 37 | 'retains a paid-up nonexclusive, irrevocable worldwide license to\n' ... 38 | 'reproduce, prepare derivative works, perform publicly and display\n' ... 39 | 'publicly by or for the Government, including the right to distribute\n' ... 40 | 'to other Government contractors.\n\n' ... 41 | 'Date of last source code modification: 03/24/1999 (JMJ)\n\n']); 42 | return 43 | end 44 | 45 | if nargin<1; ptirname=[]; end 46 | 47 | % Try to open the file. 48 | if ~isempty(ptirname) 49 | ptirfid=fopen(setstr(ptirname),'rt'); 50 | else 51 | ptirfid=-1; 52 | end 53 | 54 | if ptirfid<0 55 | [n,p]=uigetfile('*','Select a PTIR file'); 56 | if n==0; return; end 57 | ptirname=[p n]; 58 | [ptirfid,message]=fopen(ptirname,'rt'); 59 | if ptirfid<0; error(['Error opening file: ' message]); end 60 | end 61 | 62 | % Read the entire file. 63 | [ptirstr,count]=fread(ptirfid,inf,'uchar'); 64 | ptirstr=setstr(ptirstr'); 65 | 66 | % Close the file 67 | fclose(ptirfid); 68 | 69 | if count==0; error('Error reading file.'); end 70 | 71 | % End of line character 72 | c=computer; 73 | if strcmp(c(1:2),'MA') 74 | newline=13; 75 | else 76 | newline=10; 77 | end 78 | 79 | % Find the signal titles. 80 | qtloc=find(ptirstr==34); 81 | nncols=length(qtloc)/2; 82 | names=''; 83 | 84 | if nncols-floor(nncols)>0; error('File does not have correct format.'); end 85 | 86 | for ii=1:nncols 87 | name=ptirstr(qtloc(2*(ii-1)+1)+1:qtloc(2*(ii-1)+2)-1); 88 | eolloc=name>=9 & name<=13; 89 | name(eolloc)=[]; % Strip out end of line characters in name string. 90 | names=str2mat(names,name); 91 | end 92 | names=str2mat('Time',names); 93 | 94 | % Read the data 95 | dataloc=qtloc(length(qtloc))+1; 96 | 97 | y1=sscanf(ptirstr(dataloc:length(ptirstr)),'%f',[nncols+1,inf]); 98 | 99 | y=y1'; 100 | -------------------------------------------------------------------------------- /Ringdown130930/private/rguipref.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/Ringdown130930/private/rguipref.mat -------------------------------------------------------------------------------- /Ringdown130930/private/rguipref_back.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftuffner/DSIToolbox/2ef27486551346d60b8995eb60f94cc373c9c496/Ringdown130930/private/rguipref_back.p -------------------------------------------------------------------------------- /Ringdown130930/private/settp.m: -------------------------------------------------------------------------------- 1 | % Function that sets the Toeplitz matrix, to form least squares Toeplitz 2 | % system for denominator coefficients. Related to the step when 3 | % forward/backward linear prediction is done. 4 | % ************************************************************************** 5 | % 6 | % The following represents the MATLAB translation of the original FORTRAN 7 | % code for the SETTP function 8 | % Author of the MATLAB code: Laurentiu Dan Marinovici 9 | % Date: August - September 2013 10 | % 11 | % ************************************************************************** 12 | function [mat, c, n1] = settp(x, sigcon, n, p, fb, flag), 13 | 14 | global ntaille nsize nwork nsigs nflgs inpmax mincon 15 | 16 | % the total number of equations (rows in mat matrix) is n1 17 | n1 = 0; 18 | 19 | % begin loop to process all the signals in x given by column; total 20 | % number is sigcon 21 | for sig = 1 : sigcon, 22 | l = n(sig) - 1 + p; m = 0; 23 | if flag == 2 | flag == 3, 24 | l = n(sig) - 1; 25 | m = p; 26 | end 27 | k = 0; q = n(sig) - 1 + p; 28 | if flag >= 3 29 | k = p; 30 | q = n(sig) - 1; 31 | end 32 | % case where FORWARD equations are used 33 | if fb <= 2, 34 | if l - k + 1 >= 1, 35 | for i_ind = 1 : l - k + 1, 36 | index = k + i_ind - 1; 37 | if i_ind + n1 >= 1, 38 | if index < 0 | index >= n(sig), 39 | c(i_ind + n1, 1) = 0; 40 | else, 41 | c(i_ind + n1, 1) = - x(index + 1, sig); 42 | end 43 | for j_ind = 1 : p, 44 | index = k - j_ind + i_ind - 1; 45 | if index < 0 | index >= n(sig), 46 | mat(i_ind + n1, j_ind) = 0; 47 | else, 48 | mat(i_ind + n1, j_ind) = x(index + 1, sig); 49 | end 50 | end 51 | end 52 | end 53 | end 54 | end 55 | 56 | % case where BACKWARD equations are used 57 | if fb >= 2, 58 | n2 = q - m + 1; 59 | n3 = 1; 60 | if fb == 2, 61 | n3 = n2 + 1; 62 | end 63 | if n3 >= 1 & n3 + n2 >= 1, 64 | for i_ind = n3 : n3 + n2, 65 | index = m - p + i_ind - n3; 66 | if i_ind + n1 >= 1, 67 | if index < 0 | index >= n(sig), 68 | c(i_ind + n1, 1) = 0; 69 | else, 70 | c(i_ind + n1, 1) = - x(index + 1, sig); 71 | end 72 | for j_ind = 1 : p, 73 | index = i_ind + j_ind - p - n3 + m; 74 | if index < 0 | index >= n(sig), 75 | mat(i_ind + n1, j_ind) = 0; 76 | else, 77 | mat(i_ind + n1, j_ind) = x(index + 1, sig); 78 | end 79 | end 80 | end 81 | end 82 | end 83 | end 84 | n1 = n1 + l - k + 1; 85 | if fb == 2, 86 | n1 = n1 + n2; 87 | end 88 | end 89 | end -------------------------------------------------------------------------------- /SQL_Config.cfg: -------------------------------------------------------------------------------- 1 | # Configuration file for SQL interface capability within DSI Toolbox 2 | # 3 | # Note that all field data should be enclosed in MATLAB-compatible single quotes (') 4 | # Pound signs (#) denote comments, but only at the beginning of the line 5 | # Assignments are dictated by ':=' 6 | # Note that single quotes (') are reserved to determine the overall data fields. Use double quotes (") for strings 7 | # 8 | # Also note the interfacing method utilized by the SQL connection may only work within Microsoft Windows environments 9 | # 10 | # Examples provided are using the MariaDB 1.1.6 Java client 11 | # 12 | # For password prompts, it is highly recommended that Jesse Lai's passwordEntryDialog routine 13 | # be downloaded from the MathWork's File Exchange. This uses Java routines to help mask typed passwords. 14 | # (http://www.mathworks.com/matlabcentral/fileexchange/19729-passwordentrydialog) 15 | 16 | # Interfacing JAR file name - example below is for MariaDB 17 | # Include the full path to this if it is not in the MATLAB working path 18 | JARFile:='C:\Downloads\mariadb-java-client-1.1.6.jar' 19 | 20 | # Driver name for the SQL interface 21 | JARDriverName:='org.mariadb.jdbc.Driver' 22 | 23 | # Connection string for the database 24 | # Note that curly brace bracketed items (e.g., {port}) will look for the appropriate "JARxx" field in this file. 25 | # e.g., {HOST} will look for JARHOST inside this .CFG file for the information - case is important here! 26 | JARConnectString:='jdbc:mariadb://{host}:{port}/{database}' 27 | 28 | # Hostname 29 | JARhost:='127.0.0.1' 30 | 31 | # Port 32 | JARport:='3306' 33 | 34 | # Database/schema 35 | JARdatabase:='mysql' 36 | 37 | # Quantities below here are set as properties to the specific SQL connection 38 | # Anything specified as JARPROPxxx will be filled into a property field for the connection. 39 | # i.e., JARPROPuser:='test' will put 'test' as the value for the 'user' property. 40 | 41 | # Username for the SQL database connection 42 | JARPROPuser:='root' 43 | 44 | # Password - leave this '' to have MATLAB prompt you at connect 45 | # If you store a password here, it is highly recommended you encrypt this file 46 | JARPROPpassword:='' 47 | 48 | # Define SQL Query as a single line -- substitute curly braces for fields to prompt during MATLAB runtime 49 | # e.g., SELECT {range} FROM {databasename} would prompt the user for the value of "range" and "databasename" and 50 | # substitute those values into the query. 51 | # It is highly recommended that a specific VIEW be created on the SQL server for the specific types of information requested 52 | # Note that the first column returned is always expected to be time, preferably in yyyy-mm-dd HH:MM:SS.FFF-type format 53 | # JARSQLQuery:='SELECT {range} FROM {view}' 54 | JARSQLQuery:='SELECT * FROM TEST_VALS' 55 | 56 | # Below are some sample queries - note that the "tag" field is often how SQL interfaces with PI 57 | # Historians can determine channel names 58 | # JARSQLQuery:='SELECT * FROM TEST_VALS_VIEW {where}' 59 | # JARSQLQuery:='SELECT * FROM TEST_VALS_VIEW WHERE Time >= "2014-02-28 13:41:30" AND Time <= "2014-02-28 13:42:05"' 60 | # JARSQLQuery:='SELECT * FROM datatable WHERE Time >= "2014-02-28 13:41:30" AND Time <= "2014-02-28 13:42:05" and tag="other"' 61 | # JARSQLQuery:='SELECT * FROM datatable WHERE tag="freq"' 62 | -------------------------------------------------------------------------------- /SQL_Database_Interface.txt: -------------------------------------------------------------------------------- 1 | In order to get SQL support to work properly, the appropriate Java interface for the SQL database type 2 | is required. Below are the steps for setting up the SQL database JAR interface. 3 | 4 | 1. Download the appropriate interfacing .jar file from the database provider. 5 | 2. Place the .jar file somewhere accessible and note the path. 6 | 3. Obtain the table names, field names, and relevant information from the database of interest. 7 | 4. Edit the "SQL_Config.cfg" file under the main DSI Toolbox folder with the appropriate values. 8 | 5. Run the DSI toolbox -------------------------------------------------------------------------------- /UserFunctions/User Function Guidelines.txt: -------------------------------------------------------------------------------- 1 | User defined functions and reading routines can be placed into this folder. 2 | 3 | Five major "constraints" govern the use of user defined functions in this folder. 4 | The functions must meet all five criteria to be executed properly, otherwise errors may 5 | occur. A sample function, "funDSI_USR_copychans.m" is provided as an example. 6 | 7 | Requirements: 8 | 1. Files to run must be in functional form (unless they are completely self-contained) and 9 | follow the naming convention of "funDSI_USR_.m" where the portion can be 10 | the name of the user-defined call, but without any spaces. For example, "funDSI_USR_median.m" 11 | could be a user-defined function to compute the median inside the DSI toolbox. 12 | 13 | 2. To properly execute, the first line of the "help" statement (e.g., what appears when "help funDSI_USR_median" 14 | is run) must contain the functional syntax and appropriate variables to pass for the function to work. e.g., 15 | for the funDSI_USR_median.m above, a "help funDSI_USR_median" would return: 16 | "[PSMsigsX,namesX,chankeyX]=funDSI_USR_median(PSMsigsX,namesX,chankeyX)" 17 | 18 | 3. A "user friendly" description of the file is expected to be on the second line of the "help" statement. This will 19 | be used for populating the menu of available choices, so it should be sufficient for a user to understand what this 20 | file does. If a second line is not detected, the file name will simply be used. 21 | 22 | 4. The functions primarily have access to the data inside the DSI Toolbox. Calls to other functions and larger 23 | toolbox globals (such as the macro functionality) are not supported directly. The user can attempt to use these, 24 | but their functionality is not guaranteed. Variables available to the functions are: 25 | CFname - Configuration file name for any data load operations. If a user loading function is incorporated, 26 | it is recommended that it populate this variable. 27 | CaseComR - Log of actions done to this particular data set. Could include data loads, any post-processing actions, 28 | or generic information on model parameters. This field is used to help reconstruct the process from which 29 | the final result was produced. 30 | PSMreftimes - Reference times for files loaded, in seconds since January 1, 1900. 31 | PSMtype - Fundamental type of data loaded 32 | PSMfiles - Tracking variable for any files loaded to create PSMsigsX. If a user loading function is incorporated, 33 | it is recommended that it populate this variable. 34 | PSMsigsX - Data with individual channels being columns. Column 1 is assumed to be time in seconds from PSMreftimes entry 35 | number 1, which is encoded as seconds since January 1, 1900. 36 | chankeyX - column numbers and channel names for various columns of PSMsigsX 37 | namesX - channel names for various columns of PSMsigsX 38 | tstep - Sampling timestep for data in PSMsigsX 39 | 40 | 5. Only 98 user functions are supported. Item 99 is reserved as the "quit back to the main PSMbrowser menu" call 41 | -------------------------------------------------------------------------------- /UserFunctions/funDSI_USR_copychans.m: -------------------------------------------------------------------------------- 1 | function [PSMsigsXout,namesXout,chankeyXout,CaseComRout]=funDSI_USR_copychans(PSMsigsX,namesX,chankeyX,CaseComR) 2 | % [PSMsigsX,namesX,chankeyX,CaseComR]=funDSI_USR_copychans(PSMsigsX,namesX,chankeyX,CaseComR) 3 | % Sample user-defined function that duplicates the channels of PSMsigsX 4 | % 5 | % 6 | % This function is a simple example of how a user-defined DSI function may work 7 | % This function merely takes the input data, and duplicates the data to a new set 8 | % of channels. 9 | % 10 | % Usage: 11 | % [PSMsigsXout,namesXout,chankeyXout,CaseComRout]=... 12 | % funDSI_USR_copychans(PSMsigsX,namesX,chankeyX,CaseComR) 13 | % 14 | % where: 15 | % PSMsigsXout is the output data matrix 16 | % namesXout is the output, unnumbered channel information variable 17 | % chankeyXout is the output, numbered channel information variable 18 | % CaseComRout is the output, system log for the actions taken on this data 19 | % 20 | % PSMsigsX is the input data matrix 21 | % namesX is the input, unnumbered channel information variable 22 | % chankeyX is the input, numbered channel information variable 23 | % CaseComR is the input, system log for the actions taken on this data 24 | % 25 | % Created March 4, 2014 by Frank Tuffner 26 | 27 | %Error checks 28 | if ((nargin~=4) || (nargout~=4)) 29 | error('In funDSI_USR_copychans: Failed to provide all necessary input variables!'); 30 | end 31 | 32 | %Get initial size information 33 | [DataLength,NumChansIn]=size(PSMsigsX); 34 | FinalChansSize=(1+(NumChansIn-1)*2); 35 | 36 | %Create a new output variable 37 | PSMsigsXout=zeros(DataLength,FinalChansSize); 38 | PSMsigsXout(:,(1:NumChansIn))=PSMsigsX; 39 | PSMsigsXout(:,((NumChansIn+1):FinalChansSize))=PSMsigsX(:,(2:NumChansIn)); 40 | 41 | %Create the new namesX variable 42 | namesXout=[namesX; namesX((2:NumChansIn),:)]; 43 | 44 | %Create new chankeyX - do this from namesX since it is easier that way 45 | chankeyXout=[repmat('% ',FinalChansSize,1) num2str((1:FinalChansSize).','%d') repmat(' ',FinalChansSize,1) namesXout]; 46 | 47 | %Append the CaseComR with what we did 48 | CaseComRout=str2mat(CaseComR,'funDSI_USR_copychans - duplicated channel listing'); --------------------------------------------------------------------------------