%!PS % Split 0-0.5 REG-BBE-BBE-REG analyzer % ============================= % by Don Lancaster % ========= % attempts to verify third party sine and cosine components over one full cycle % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is required for this program. % After obvious location mods, uncomment ONE of the following two lines: % (C:\\Documents and Settings\\Bee\\Desktop\\Gonzo\\gonzo.ps) run % use internal gonzo (C:\\gonzo2\\gonzo.ps)run % (A:\\gonzo.ps) run % use external gonzo % NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES. % GONZO20A Guru Gonzo PostScript power tools (Interim release) % Includes gonzo justification and layout utilities. % Copyright c 1990, 1996, 2001 by Don Lancaster and Synergetics, Box 809, % Thatcher Arizona, 5552 (928) 428-4073 don@tinaja.com support % via http://www.tinaja.com All commercial rights and all electronic % media rights **FULLY** reserved. Reposting is expressly forbidden. /ps.util.1 {gutil} def % substitute old name /gutility {gutil} def % substitute old name /guru { gonzo begin ps.util.1 begin printerror nuisance begin} def % jumpstart 200 dict /gutil exch def gutil begin %%% REPORTING IMPROVER % /realto8dstring is the high level code for the reporting conversion. It % determines the sign and then tests for values too large or too small. % It then goes to processgoodreal for actual report conversions. % A final deferencing is done to provide a unique output string. /realto8dstring {dup 0 lt % test and flag negatives /isneg exch store abs /val exch store % save real as absolute value val 100000000 ge { % report and error trap values (real is too big! )== % that are too large to process real_is_too_big! } if val 0.00000001 le % truncate small numbers to zero {(0.0000000)} {processgoodreal} ifelse % process numbers versus zeros isneg {(-)}{( )} ifelse % create leading space or minus exch mergestr % add leading space or minus 20 string cvs % dereference string to avoid % any possible rude surprises } store % /processgoodreal continues the realto8string processing after numbers too % large and too small have been dealt with. Subprocs are called for tenmillions, % unitsormore, and fractions. Note that log floor cvi tells you the decade % size and position of any positive number. /processgoodreal { val log floor cvi % evaluate decimal location /posn exch store % posn 7 eq {tenmillions} % treat ten millions special {posn 0 ge {unitsormore} % handle >1 as a class {fractions} % handle fractions as a class ifelse } ifelse } store % /tenmillions handles ten millions as a special case needing no reformatting. /tenmillions { val round cvi % use ten millions val as is. 20 string cvs } store % /unitsormore handles units through millions... /unitsormore { /workstring val % scale val as needed to 10-99 megs 1 7 posn sub {10 mul} % this may give more accuracy repeat mul round cvi 20 string cvs store % and convert to string workstring 0 posn 1 add % stuff decimal point getinterval (.) mergestr workstring % post remainder of string posn 1 add workstring length 1 sub posn sub getinterval mergestr 20 string cvs % dereference } store % /fractions handles fractional values /fractions {/workstring val % scale workstring 1 7 posn sub {10 mul} repeat % this may give more accuracy mul round cvi 20 string cvs store % and convert to string (0.) % prepend leading zero and dp posn neg 1 sub % add intermediate zeros {(0) mergestr} repeat workstring mergestr % postpend value 20 string cvs % dereference } store % Demo 2 sqrt 100000 mul realto8dstring == % PostScript results only approximate because of 32 bit math. %%% PRIMARY ANALYZER FOR GGMS MAGIC SINEWAVES AMPLITUDES 0 to 0.5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% ENTER THE DOUBLE PPQ BBE HERE... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /angs94 [ % angle-position pairs 5.2287842493 % p1s 5.7186838614 % p1e 10.4615598451 % p2s 11.4377387539 % p2e 15.7023460345 % p3s 17.1575850449 % p3e 20.9552232196 % p4s 22.8787512242 % p4e 26.2243782872 % p5s 28.6019538991 % p5e 31.5141718655 % p6s 34.3282160077 % p6e 36.8292431513 % p7s 40.0590498503 % p7e 42.1746780285 % p8s 45.7967476992 % p8e 47.5562831097 % p9s 51.5448478383 % p9e 52.9810349743 % p10s 57.3088752014 % p10e 58.4578086518 % p11s 63.0974609244 % p11e 63.9985019092 % p12s 68.9237599842 % p12e 69.6195004845 % p13s 74.8060635147 % p13e 75.3424212678 % p14s 80.7628879713 % p14e 81.1894103694 % p15s 86.7919445988 % p15e 87.1620685268 % p16s 90 % p16e ] store /reportdbl {/inname exch store (\n\nGenerating GGMS magic sinewaves of amplitudes 0 to 0.5\n) print flush (Target amplitude is ) curfund 20 string cvs mergestr (.\n) mergestr print flush (Input double amplitude file is /) inname 20 string cvs mergestr (.\n) mergestr print flush (\nWARNING: Slight errors present due to 32 bit math!\n) print flush } store %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% (A) SPLIT INTO BBE AND REG %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /splitBBE {/curdbl exch store mark 2 4 curdbl length 1 sub {/curpos exch store curdbl curpos get curdbl curpos 1 add get } for ] /BBE1 exch store (\nBBE1 is now... \n) print BBE1 {( ) print flush realto8dstring == } forall (\n) print flush } store /splitREG {/curdbl exch store mark 0 4 curdbl length 1 sub {/curpos exch store curdbl curpos get curdbl curpos 1 add get } for ] /REG1 exch store (\nREG1 is now... \n) print REG1 {( ) print flush realto8dstring == } forall (\n) print flush } store %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% (B) ANALYZE BBE AND REG %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /showsonesinpectrum { /curspectname exch store curspectname cvx /curspect exch store mark 1 1 maxharms {/curharm exch store % (\n\n starting next harmonic\n) print flush 0 0 2 curspect length 1 sub {/curpulses exch store curspect curpulses 0 add get curharm mul cos % 0 to 90 curspect curpulses 1 add get curharm mul cos sub add % dup == 180 curspect curpulses get sub curharm mul cos % 90 to 180 180 curspect curpulses 1 add get sub curharm mul cos exch sub add % dup == 180 curspect curpulses get add curharm mul cos % 180 to 270 180 curspect curpulses 1 add get add curharm mul cos sub -1 mul add % dup == 360 curspect curpulses get sub curharm mul cos % 270 to 360 360 curspect curpulses 1 add get sub curharm mul cos exch sub -1 mul add % dup == } for % for each pulse pair % (\n) print flush curharm div pi div curfund div } for % for each harmonic ] /curspectresult exch store (\n) print curspectname 10 string cvs ( sine spectrum is...\n\n) mergestr print flush curspectresult {dup abs roundoff lt { pop (0.0\n) print flush} {realto8dstring ==} ifelse } forall } store /showsonecospectrum { /curspectname exch store curspectname cvx /curspect exch store mark 1 1 maxharms {/curharm exch store % (\n\n starting next harmonic\n) print flush 0 0 2 curspect length 1 sub {/curpulses exch store curspect curpulses 0 add get curharm mul sin % 0 to 90 curspect curpulses 1 add get curharm mul sin sub add % dup == 180 curspect curpulses get sub curharm mul sin % 90 to 180 180 curspect curpulses 1 add get sub curharm mul sin exch sub add % dup == 180 curspect curpulses get add curharm mul sin % 180 to 270 180 curspect curpulses 1 add get add curharm mul sin sub -1 mul add % dup == 360 curspect curpulses get sub curharm mul sin % 270 to 360 360 curspect curpulses 1 add get sub curharm mul sin exch sub -1 mul add % dup == } for % for each pulse pair % (\n) print flush curharm div pi div curfund div } for % for each harmonic ] /curspectresult exch store (\n) print curspectname 10 string cvs ( cosine spectrum is...\n\n) mergestr print flush curspectresult {dup abs roundoff lt {pop (0.0\n) print flush} {realto8dstring ==} ifelse } forall } store %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% (C) ANALYZE GGMS OF REG-BBE-BBE-REG %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % this routine assummes quarter wave symmetry /showggmssinspectrum { /insidecurspectname exch store /inspect insidecurspectname cvx store /outsidecurspectname exch store /outspect outsidecurspectname cvx store mark 1 1 maxharms {/curharm exch store 0 0 2 outspect length 1 sub {/curpulses exch store outspect curpulses 0 add get curharm mul cos % outside first 0-90 degrees outspect curpulses 1 add get curharm mul cos sub 1 mul add % positive polarity % dup == 180 outspect curpulses 0 add get sub curharm mul cos % outside first 90-180 degrees 180 outspect curpulses 1 add get sub curharm mul cos exch sub 1 mul add % positive polarity % dup == 180 inspect curpulses 0 add get add curharm mul cos % inside 180-270 degrees 180 inspect curpulses 1 add get add curharm mul cos sub -1 mul add % negative polarity % dup == 360 inspect curpulses 0 add get sub curharm mul cos % inside 270-360 degrees 360 inspect curpulses 1 add get sub curharm mul cos exch sub -1 mul add % negative polarity % dup == inspect curpulses 0 add get curharm mul cos % inside first 0-90 degrees inspect curpulses 1 add get curharm mul cos sub 1 mul add % positive polarity % dup == 180 inspect curpulses 0 add get sub curharm mul cos % inside first 90-180 degrees 180 inspect curpulses 1 add get sub curharm mul cos exch sub 1 mul add % positive polarity % dup == 180 outspect curpulses 0 add get add curharm mul cos % outside 180-270 degrees 180 outspect curpulses 1 add get add curharm mul cos sub -1 mul add % negative polarity % dup == 360 outspect curpulses 0 add get sub curharm mul cos % outside 270-360 degrees 360 outspect curpulses 1 add get sub curharm mul cos exch sub -1 mul add % negative polarity % dup == } for % for grouped pulses curharm div pi div curfund div 2 div % because integrating over two cycles } for % for each harmonic ] /curspectresult exch store (\n\n) print outsidecurspectname 20 string cvs ( + ) mergestr insidecurspectname 20 string cvs mergestr ( GGMS spectrum is...\n\n) mergestr print flush curspectresult {dup abs roundoff lt {(0.0\n) print flush} {realto8dstring ==} ifelse } forall (\n\n) print flush } store % define showggmssinspectrum %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% (D) PLOT SPECTRUM GRAPH %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /graphit { /graphtitle exch store 50 50 10 setgrid 50 21 showgrid 1 0 0 setrgbcolor 0 2 curspectresult length 1 sub {/curharm exch store curharm 2 div 10 mt curspectresult curharm get 10 mul dup pu 0.5 pr pd closepath fill } for black 0 10 mt line1 50 r /cstretch 0.01 store /sstretch 0.01 store /font1 /StoneSerif-Bold 1.60 gonzofont % boxed subseries /font2 /StoneSerif-Bold 1 gonzofont % bold body /yinc 2 store black font1 25 25 graphtitle cc font2 0 -2 (1) cc 25 -2 (50) cc 50 -2 (100) cc 25 -4 (HARMONIC NUMBER) cc showpage } store %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% (E) HIGH LEVEL ROUTINES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /maxharms 100 store % maximum number of harmonics analyzed /curfund 0.47 store % current fundamental amplitude /roundoff 0.001 store % roundoff for PostScript math /pulsesperquadrant 8 store % pulses per quadrant /angs94 reportdbl % report input file angs94 splitREG % split out REG factor angs94 splitBBE % split out BBE factor /REG1 showsonesinpectrum % show standalone REG spectrum /BBE1 showsonesinpectrum % show standalone BBE spectrum /REG1 showsonecospectrum % show standalone REG spectrum (should be zero) /BBE1 showsonecospectrum % show standalone BBE spectrum (should be zero) /REG1 /BBE1 showggmssinspectrum % show cancelled alternating spectrum (/REG1 + /BBE1 + /BBE1 + REG1 Spectrum\nfor ) curfund 20 string cvs mergestr ( Amplitude and ) mergestr pulsesperquadrant 20 string cvs mergestr ( pulses per quadrant.\n\n) mergestr graphit % EOF