function GRtool(arg1,grtool_data) % GRTOOL % Graphical user interface for visualization and % simulation of Gravitational Radiation data. % Intended for use with LIGO or VIRGO data. % Handles frame formated data. % % Read: * Load frame header from user specified % file into memory % % Visualize: * Display time domain and frequency domain data % from user specified file. % % * Play time domain data from the IFO_DMRO % channel as sound. % % Export * Export time domain data from user specified % channel to Matlab workspace % * Export time domain data from user specified % channel as sound file .au format % to user specified file. % % Simulate * Simulate non-spinning compact binary inspirals % up to second-post-Newtonian order. Using the % GRASP function make_filters(). % * Export simulations to Matlab workspace. % * Export simulations to .au sound file. % % NOTE: Currently this program automaticly reads the channel IFO_DMRO only. % %Steve Drasco %Summer 1998 %sdrasco@cacr.caltech.edu % define global varriables (later do the same in workspace - don't worry they get cleared too) global GRTOOL_G_ANAME GRTOOL_G_TNAME GRTOOL_G_ACTION GRTOOL_G_T0 GRTOOL_G_TF GRTOOL_G_DATA % define global handles (in GRtool only) global tx ty tt fx fy ft tline fline if nargin == 0 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % build main window % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % close GRtool figures if they exist close(findobj('Tag','GRtool')); close(findobj('Tag','simulate_main')); close(findobj('Tag','sim_subfig')); close(findobj('Tag','tcontrol')); close(findobj('Tag','url_dialog')); hf_main = figure('Units','normalized', ... 'Color',[0.8 0.8 0.8], ... 'Name','Gravitational Radiation Tool', ... 'NumberTitle','off', ... 'Position',[0.2383 0.2253 0.6299 0.6523], ... 'Tag','GRtool', ... 'CreateFcn','global GRTOOL_G_ANAME GRTOOL_G_TNAME GRTOOL_G_ACTION GRTOOL_G_T0 GRTOOL_G_TF GRTOOL_G_DATA', ... 'DeleteFcn',[... 'clear GRTOOL_G_ANAME GRTOOL_G_TNAME GRTOOL_G_ACTION GRTOOL_G_T0 GRTOOL_G_TF GRTOOL_G_DATA;'... 'clear global']); H_opt = uimenu(hf_main,'Label','&Options'); H_opt1 = uimenu(H_opt,'Label','&Rotate-3D'); H_opt1a = uimenu(H_opt1,'Label','O&n',... 'Callback','rotate3d on '); H_opt1b = uimenu(H_opt1,'Label','O&ff',... 'Callback','rotate3d off'); H_opt3 = uimenu(H_opt,'Label','&Background',... 'Callback','whitebg'); H_opt4 = uimenu(H_opt,'Label','&Grid'); H_opt4a = uimenu(H_opt4,'Label','O&n',... 'Callback','grid on'); H_opt4b = uimenu(H_opt4,'Label','O&ff',... 'Callback','grid off'); H_opt44 = uimenu(H_opt,'Label','&Box'); H_opt44a = uimenu(H_opt44,'Label','O&n',... 'Callback','box on'); H_opt44b = uimenu(H_opt44,'Label','O&ff',... 'Callback','box off'); H_opt5 = uimenu(H_opt,'Label','&Zoom'); H_opt5a = uimenu(H_opt5,'Label','O&n',... 'Callback','zoom on'); H_opt5b = uimenu(H_opt5,'Label','O&ff',... 'Callback','zoom off'); hu_frame = uicontrol('Parent',hf_main, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.4 0.2 0.2], ... 'FontSize',0.02156659765355418, ... 'ListboxTop',0, ... 'Position',[0.8124031007751938 0.029940119760479 0.1596899224806202 0.944111776447106], ... 'Style','frame', ... 'Tag','Frame1'); hu_read = uicontrol('Parent',hf_main, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'Callback','GRtool(''read'',GRTOOL_G_DATA)', ... 'FontSize',0.2604166666666667, ... 'ListboxTop',0, ... 'Position',[0.8341 0.8902 0.1163 0.0599], ... 'String','Read', ... 'Tag','Pushbutton'); hu_simulate = uicontrol('Parent',hf_main, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2604166666666667, ... 'ListboxTop',0, ... 'Position',[0.8341 0.8184 0.1163 0.0599], ... 'String','Simulate', ... 'Tag','Pushbutton', ... 'Callback','GRtool(''simulate_build'',GRTOOL_G_DATA)'); hu_close = uicontrol('Parent',hf_main, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2604166666666667, ... 'ListboxTop',0, ... 'Position',[0.8341 0.0499 0.1163 0.0599], ... 'String','Close', ... 'Tag','Pushbutton', ... 'Callback',[... 'close(findobj(''Tag'',''GRtool''));'... 'close(findobj(''Tag'',''simulate_main''));'... 'close(findobj(''Tag'',''sim_subfig''));'... 'close(findobj(''Tag'',''tcontrol''));'... 'close(findobj(''Tag'',''url_dialog''));'] ); % initialize grtool_data structure grtool_data.currentspace = 'tf'; grtool_data.currentbuttons = 'start'; grtool_data.generatespace = 'tf'; assignin('base','GRTOOL_G_DATA',grtool_data); GRtool('generatespace',grtool_data); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Read % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(arg1,'read') rmethod = questdlg('Where is the data?','Data Source','URL','Local Disk','Local Disk'); if strcmp(rmethod,'Local Disk') [filename,filepath] = uigetfile(''); if isstr(filename) | isstr(filepath) filepath=[filepath filename]; nFrame = CountFrames(filepath); [grtool_data.a,grtool_data.t,grtool_data.f,grtool_data.t0,... grtool_data.t0s,grtool_data.c,grtool_data.u,grtool_data.more] = frextract(filepath,'IFO_DMRO',0,nFrame); % data set length a power of 2 newlength=2^floor( log2(length(grtool_data.a)) ); grtool_data.a=grtool_data.a(1:newlength); grtool_data.t=grtool_data.t(1:newlength); % set remaining fields and reset value in workspace grtool_data.index=1:length(grtool_data.a); grtool_data.samplerate=length(grtool_data.index)/(grtool_data.t(grtool_data.index(end))-grtool_data.t(grtool_data.index(1))); grtool_data.cname='IFO_DMRO'; assignin('base','GRTOOL_G_DATA',grtool_data); end else hf_url = figure('Units','normalized', ... 'Color',[0.8 0.8 0.8], ... 'MenuBar','none', ... 'Name','Enter URL', ... 'NumberTitle','off', ... 'Position',[0.1953125 0.6028645833333333 0.5986328125 0.1380208333333333], ... 'Tag','url_dialog'); hu_st = uicontrol('Parent',hf_url, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.390625, ... 'HorizontalAlignment','right', ... 'ListboxTop',0, ... 'Position',[0.0228 0.4623 0.1011 0.2075], ... 'String','Location:', ... 'Style','text', ... 'Tag','StaticText1'); hu_url= uicontrol('Parent',hf_url, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[1 1 1], ... 'FontSize',0.3360215053763446, ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.1223 0.4906 0.8515 0.1981], ... 'Style','edit', ... 'Tag','url'); hu_st = uicontrol('Parent',hf_url, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3978779840848807, ... 'FontWeight','bold', ... 'ListboxTop',0, ... 'Position',[0.03588907014681893 0.7358490566037735 0.9233278955954324 0.1792452830188679], ... 'String','Enter a URL', ... 'Style','text', ... 'Tag','StaticText2'); hu_frame = uicontrol('Parent',hf_url, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.4 0.2 0.2], ... 'FontSize',0.226785419759195, ... 'ListboxTop',0, ... 'Position',[0.03915171288743883 0.09433962264150943 0.9249592169657423 0.3113207547169811], ... 'Style','frame', ... 'Tag','Frame1'); hu_ok = uicontrol('Parent',hf_url, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.3156565656565657, ... 'ListboxTop',0, ... 'Position',[0.0506 0.1415 0.1028 0.2170], ... 'String','OK', ... 'Callback',[... 'GRTOOL_G_DATA.url = get(findobj(''Tag'',''url_dialog''),''String'');'... 'GRTOOL_G_ACTION = ''ok'';'... 'close(findobj(''Tag'',''url_dialog''));'], ... 'Tag','Pushbutton1'); hu_cancel = uicontrol('Parent',hf_url, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.3156565656565657, ... 'ListboxTop',0, ... 'Position',[0.8515 0.1415 0.1028 0.2170], ... 'String','Cancel', ... 'Callback',[... 'GRTOOL_G_ACTION = ''cancel'';'... 'close(findobj(''Tag'',''url_dialog''));'], ... 'Tag','Pushbutton1'); waitfor(hf_url); if ~strcmp(GRTOOL_G_ACTION,'cancel') [filename,filepath] = uiputfile(''); filepath=[filepath filename]; set(findobj('Tag','GRtool'),'Pointer','watch'); % Web is slooooooooooooooooow % Call Roy's URL program mxUrlopen(GRTOOL_G_DATA.url,filepath); set(findobj('Tag','GRtool'),'Pointer','arrow'); % put the arrow back nFrame = CountFrames(filepath); [grtool_data.a,grtool_data.t,grtool_data.f,grtool_data.t0,... grtool_data.t0s,grtool_data.c,grtool_data.u,grtool_data.more] = frextract(filepath,'IFO_DMRO',0,nFrame); % data set length a power of 2 newlength=2^floor( log2(length(grtool_data.a)) ); grtool_data.a=grtool_data.a(1:newlength); grtool_data.t=grtool_data.t(1:newlength); % set remaining fields and value in workspace grtool_data.index=1:length(grtool_data.a); grtool_data.samplerate=length(grtool_data.index)/(grtool_data.t(grtool_data.index(end))-grtool_data.t(grtool_data.index(1))); grtool_data.cname='IFO_DMRO'; assignin('base','GRTOOL_G_DATA',grtool_data); else filename = 0; end end if isstr(filename) grtool_data.generatespace='tf'; if isfield(grtool_data,'b') grtool_data=rmfield(grtool_data,'b'); end assignin('base','GRTOOL_G_DATA',grtool_data); GRtool('generatespace',grtool_data); grtool_data.currentspace='tf'; grtool_data.generatebuttons = 'tf'; assignin('base','GRTOOL_G_DATA',grtool_data); GRtool('generatebuttons',grtool_data); grtool_data.currentbuttons='tf'; end % this will clear out action assignin('base','GRTOOL_G_ACTION','none'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Generate space % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(arg1,'generatespace') hf_main = findobj('Tag','GRtool'); GRtool('clearspace',grtool_data); grtool_data.currentspace = grtool_data.generatespace; assignin('base','GRTOOL_G_DATA',grtool_data); if strcmp(grtool_data.generatespace,'tf') % make the t/f space axes hx_timedomain = axes('Parent',hf_main, ... 'FontUnits','normalized', ... 'Box','on', ... 'CameraUpVector',[0 1 0], ... 'Color',[1 1 1], ... 'FontSize',0.05260942760942761, ... 'Position',[0.07751937984496124 0.546 0.7116279069767442 0.396], ... 'Tag','timedomain', ... 'XColor',[0 0 0], ... 'YColor',[0 0 0], ... 'ZColor',[0 0 0]); tx = text('Parent',hx_timedomain, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'Color',[0 0 0], ... 'FontSize',0.05260942760942761, ... 'HandleVisibility','callback', ... 'HorizontalAlignment','center', ... 'Position',[0.4945533769063181 -0.09595959595959597 0], ... 'Tag','tx', ... 'VerticalAlignment','cap'); set(get(tx,'Parent'),'XLabel',tx); ty = text('Parent',hx_timedomain, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'Color',[0 0 0], ... 'FontSize',0.05260942760942761, ... 'HandleVisibility','on', ... 'HorizontalAlignment','center', ... 'Position',[-0.06971677559912855 0.4898989898989899 0], ... 'String', 'Time Domain', ... 'Rotation',90, ... 'Tag','ty', ... 'VerticalAlignment','baseline'); set(get(ty,'Parent'),'YLabel',ty); tt = text('Parent',hx_timedomain, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'Color',[0 0 0], ... 'FontSize',0.05260942760942761, ... 'HandleVisibility','on', ... 'HorizontalAlignment','center', ... 'Position',[0.4945533769063181 1 0], ... 'Tag','tt', ... 'VerticalAlignment','bottom'); set(get(tt,'Parent'),'Title',tt); hx_freqdomain = axes('Parent',hf_main, ... 'FontUnits','normalized', ... 'Box','on', ... 'CameraUpVector',[0 1 0], ... 'Color',[1 1 1], ... 'FontSize',0.05260942760942761, ... 'Position',[0.07751937984496124 0.08 0.7116279069767442 0.396], ... 'Tag','freqdomain', ... 'XColor',[0 0 0], ... 'XScale','log', ... 'YColor',[0 0 0], ... 'YScale','log', ... 'ZColor',[0 0 0]); fx = text('Parent',hx_freqdomain, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'ButtonDownFcn','ctlpanel SelectMoveResize', ... 'Color',[0 0 0], ... 'FontSize',0.05260942760942761, ... 'HandleVisibility','on', ... 'HorizontalAlignment','center', ... 'Interruptible','off', ... 'Position',[0.4945533769063181 -0.1313131313131313 0], ... 'Tag','fx', ... 'VerticalAlignment','cap'); set(get(fx,'Parent'),'XLabel',fx); fy = text('Parent',hx_freqdomain, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'ButtonDownFcn','ctlpanel SelectMoveResize', ... 'Color',[0 0 0], ... 'FontSize',0.05260942760942761, ... 'HandleVisibility','on', ... 'HorizontalAlignment','center', ... 'Interruptible','off', ... 'Position',[-0.06971677559912855 0.4898989898989899 0], ... 'String', 'Frequency domain', ... 'Rotation',90, ... 'Tag','fy', ... 'VerticalAlignment','baseline'); set(get(fy,'Parent'),'YLabel',fy); ft = text('Parent',hx_freqdomain, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'ButtonDownFcn','ctlpanel SelectMoveResize', ... 'Color',[0 0 0], ... 'FontSize',0.05260942760942761, ... 'HandleVisibility','on', ... 'HorizontalAlignment','center', ... 'Interruptible','off', ... 'Position',[0.4945533769063181 1.02020202020202 0], ... 'Tag','ft', ... 'VerticalAlignment','bottom'); set(get(ft,'Parent'),'Title',ft); % check to see if we have any recent data - if so plot it if isfield(grtool_data,'b') tline = line('Parent',findobj('Tag','timedomain'), ... 'Color','b', ... 'Tag','tline', ... 'HandleVisibility','callback', ... 'XData',grtool_data.t(grtool_data.index), ... 'YData',grtool_data.a(grtool_data.index)); set(tx,'String','time ( s )'); set(ty,'String',[grtool_data.cname ' ( ' grtool_data.u ' )']); set(tt,'String',grtool_data.t0s); % data.t0s causes anoying TeX error fline = line('Parent',findobj('Tag','freqdomain'), ... 'Color','r', ... 'Tag','fline', ... 'HandleVisibility','callback', ... 'XData',grtool_data.f, ... 'YData',grtool_data.b(1:round(length(grtool_data.b)/2)) ); set(fx,'String','Frequency ( Hz )'); set(fy,'String',''); end % we don't want 2-d graphs to rotate rotate3d off; elseif strcmp(grtool_data.generatespace,'template') % make the template space axes hx_template = axes('Parent',hf_main, ... 'FontUnits','normalized', ... 'Box','on', ... 'CameraUpVector',[0 1 0], ... 'Color',[1 1 1], ... 'FontSize',0.02450980392156863, ... 'Position',[0.07596899224806201 0.08799999999999999 0.7116279069767442 0.85], ... 'Tag','templatespace', ... 'XColor',[0 0 0], ... 'YColor',[0 0 0], ... 'ZColor',[0 0 0]); tempx = text('Parent',hx_template, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'Color',[0 0 0], ... 'FontSize',0.02450980392156863, ... 'HandleVisibility','off', ... 'HorizontalAlignment','center', ... 'Position',[0.4945533769063181 -0.04470588235294117 0], ... 'String','m1', ... 'Tag','Axes1Text4', ... 'VerticalAlignment','cap'); set(get(tempx,'Parent'),'XLabel',tempx); tempy = text('Parent',hx_template, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'Color',[0 0 0], ... 'FontSize',0.02450980392156863, ... 'HandleVisibility','off', ... 'HorizontalAlignment','center', ... 'Position',[-0.05228758169934641 0.4964705882352941 0], ... 'String','m2', ... 'Rotation',90, ... 'Tag','Axes1Text3', ... 'VerticalAlignment','baseline'); set(get(tempy,'Parent'),'YLabel',tempy); tempz = text('Parent',hx_template, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'Color',[0 0 0], ... 'FontSize',0.02450980392156863, ... 'HandleVisibility','off', ... 'HorizontalAlignment','right', ... 'Position',[-0.10893246187364 1.06823529411765 0], ... 'String','max( SNR )', ... 'Tag','Axes1Text2', ... 'Visible','off'); set(get(tempz,'Parent'),'ZLabel',tempz); tempt = text('Parent',hx_template, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'Color',[0 0 0], ... 'FontSize',0.02450980392156863, ... 'HandleVisibility','off', ... 'HorizontalAlignment','center', ... 'Position',[0.4945533769063181 1.009411764705882 0], ... 'String',grtool_data.t0s, ... 'Tag','Axes1Text1', ... 'VerticalAlignment','bottom'); set(get(tempt,'Parent'),'Title',tempt); % make the view 3-d and set rotation on view(3); rotate3d on; % check to see if we have any data - if so plot it if isfield(grtool_data,'snr_max') & isequal(length(grtool_data.snr_max),length(grtool_data.m1)) % for loop to plot points and add stems - and change pointer to watch while doing it % (there must be a better way) set(findobj('Tag','GRtool'),'Pointer','watch'); for i=1:length(grtool_data.m1) % plot data points filter_response = line('Parent',findobj('Tag','templatespace'), ... 'Color',grtool_data.timestart(i)/max(grtool_data.timestart)*[0 0 1] , ... 'Tag','filter_response', ... 'XData',grtool_data.m1(i), ... 'YData',grtool_data.m2(i), ... 'Zdata',grtool_data.snr_max(i), ... 'LineStyle','none', ... 'Marker','o', ... 'MarkerSize',6); % add stems response_stem = line('Parent',findobj('Tag','templatespace'), ... 'Tag','response_stem', ... 'Color',[1 0.932259020342589 0.790464898697889], ... 'XData',[grtool_data.m1(i),grtool_data.m1(i)], ... 'YData',[grtool_data.m2(i),grtool_data.m2(i)], ... 'Zdata',[0,grtool_data.snr_max(i)]); end set(findobj('Tag','GRtool'),'Pointer','arrow'); end % check to see if control panel is up - if not build it if isempty( findobj('Tag','tcontrol') ) hf_tcontrol = figure('Units','normalized', ... 'Color',[0.8 0.8 0.8], ... 'MenuBar','none', ... 'Name','Template Space Control Panel', ... 'NumberTitle','off', ... 'Position',[0.0391 0.0313 0.4150 0.2018], ... 'Tag','tcontrol'); hx = uicontrol('Parent',hf_tcontrol, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.4 0.2 0.2], ... 'FontSize',0.2216312056737589, ... 'ListboxTop',0, ... 'Position',[0.03294117647058823 0.06451612903225806 0.9411764705882353 0.2451612903225806], ... 'Style','frame', ... 'Tag','Frame1'); hx = uicontrol('Parent',hf_tcontrol, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2815315315315314, ... 'ListboxTop',0, ... 'Position',[0.7929411764705881 0.1032258064516129 0.1670588235294118 0.1741935483870968], ... 'String','Close', ... 'Callback','close(findobj(''Tag'',''tcontrol''));', ... 'Tag','Pushbutton1'); hu_filter = uicontrol('Parent',hf_tcontrol, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2815315315315314, ... 'ListboxTop',0, ... 'Position',[0.04705882352941175 0.09999999999999996 0.1670588235294117 0.1741935483870968], ... 'String','Filter Data', ... 'Tag','filterbutton', ... 'Callback',[... 'GRtool(''filterdata'',GRTOOL_G_DATA);']); hx = uicontrol('Parent',hf_tcontrol, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.4458977407847801, ... 'FontWeight','bold', ... 'HorizontalAlignment','right', ... 'ListboxTop',0, ... 'Position',[0.01647058823529412 0.7870967741935483 0.3576470588235294 0.1225806451612903], ... 'String','Calibration data File:', ... 'Style','text', ... 'Tag','StaticText1'); hu_calib = uicontrol('Parent',hf_tcontrol, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[1 0.958116157747262 0.863163697968269], ... 'FontSize',0.4166666666666667, ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.4070588235294117 0.7999999999999999 0.3576470588235294 0.09677419354838709], ... 'String','No calibration file loaded.', ... 'Style','text', ... 'Tag','calib_data'); hx = uicontrol('Parent',hf_tcontrol, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2815315315315314, ... 'ListboxTop',0, ... 'Position',[0.7929411764705881 0.7612903225806452 0.1670588235294118 0.1741935483870968], ... 'String','Update', ... 'Callback',[... 'GRTOOL_G_DATA.taction=''updatecalib'';'... 'GRtool(''taction'',GRTOOL_G_DATA);'], ... 'Tag','calib_button'); hx = uicontrol('Parent',hf_tcontrol, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.4458977407847801, ... 'FontWeight','bold', ... 'HorizontalAlignment','right', ... 'ListboxTop',0, ... 'Position',[0.01647058823529412 0.5806451612903225 0.3576470588235294 0.1225806451612903], ... 'String','Templates file:', ... 'Style','text', ... 'Tag','StaticText1'); hu_tmplt = uicontrol('Parent',hf_tcontrol, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[1 0.958116157747262 0.863163697968269], ... 'FontSize',0.4166666666666667, ... 'Position',[0.4094117647058823 0.5935483870967742 0.3576470588235294 0.09677419354838709], ... 'HorizontalAlignment','left', ... 'String','No templates file loaded.', ... 'Style','text', ... 'Tag','tmplt_file'); hx = uicontrol('Parent',hf_tcontrol, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.4458977407847801, ... 'FontWeight','bold', ... 'HorizontalAlignment','right', ... 'ListboxTop',0, ... 'Position',[0.0188235294117647 0.3806451612903226 0.3576470588235294 0.1225806451612903], ... 'String','Low frequency cutoff:', ... 'Style','text', ... 'Tag','StaticText1'); hu_flo = uicontrol('Parent',hf_tcontrol, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[1 1 1], ... 'FontSize',0.3156565656565657, ... 'ListboxTop',0, ... 'Position',[0.4070588235294117 0.367741935483871 0.3647058823529411 0.1483870967741935], ... 'Style','edit', ... 'Tag','tmplt_flo'); hx = uicontrol('Parent',hf_tcontrol, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2815315315315314, ... 'ListboxTop',0, ... 'Position',[0.7929411764705881 0.5548387096774193 0.1670588235294118 0.1741935483870968], ... 'String','Update', ... 'Callback',[... 'GRTOOL_G_DATA.taction=''updatetfile'';'... 'GRtool(''taction'',GRTOOL_G_DATA);'], ... 'Tag','tfile_button'); hx = uicontrol('Parent',hf_tcontrol, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2815315315315314, ... 'ListboxTop',0, ... 'Position',[0.7929411764705881 0.3548387096774193 0.1670588235294118 0.1741935483870968], ... 'String','Update', ... 'Callback',[... 'GRTOOL_G_DATA.taction=''updateflo'';'... 'GRtool(''taction'',GRTOOL_G_DATA);'], ... 'Tag','flo_button'); % check to see if we have calibration data if isfield(grtool_data,'fri') set(hu_calib,'String',['Using: ' grtool_data.calibfile]); end % check to see if we have (m1,m2) if isfield(grtool_data,'m1') & isfield(grtool_data,'m2') set(hu_tmplt,'String',['Using: ' grtool_data.tmplt_file]); end % check to see if we have flo value if isfield(grtool_data,'tmplt_flo') set(hu_flo,'String',num2str(grtool_data.tmplt_flo)); end end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % tcontrol action % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(arg1,'taction') if strcmp(grtool_data.taction,'updatecalib') % select a file [grtool_data.calibfile,filepath]=uigetfile(''); if isstr(filepath) % check to make sure we won't overwrite existing varriables i=1; while i <= length(grtool_data.calibfile) & ~strcmp(grtool_data.calibfile(i),'.') shortname(i)=grtool_data.calibfile(i); i=i+1; end w=whos; for i=1:length(w) if strcmp(shortname,w(i).name) error(['You must rename your file before it can be loaded.'... 'There is a conflict with existing varriables']); end end % load calib file eval(['load ' filepath grtool_data.calibfile ';']); eval(['grtool_data.fri=' shortname '(:);']); eval(['clear ' shortname ';']); assignin('base','GRTOOL_G_DATA',grtool_data); set(findobj('Tag','calib_data'),'String',['Using: ' grtool_data.calibfile]); end elseif strcmp(grtool_data.taction,'updatetfile') % select a file [grtool_data.tmplt_file,filepath]=uigetfile(''); if isstr(filepath) % check to make sure we won't overwrite existing varriables i=1; while i <= length(grtool_data.tmplt_file) & ~strcmp(grtool_data.tmplt_file(i),'.') shortname(i)=grtool_data.tmplt_file(i); i=i+1; end w=whos; for i=1:length(w) if strcmp(shortname,w(i).name) error(['You must rename your file before it can be loaded.'... 'There is a conflict with existing varriables']); end end % load template file eval(['load ' filepath grtool_data.tmplt_file ';']); eval(['grtool_data.m1=' shortname '(:,1);']); eval(['grtool_data.m2=' shortname '(:,2);']); eval(['clear ' shortname ';']); assignin('base','GRTOOL_G_DATA',grtool_data); set(findobj('Tag','tmplt_file'),'String',['Using: ' grtool_data.tmplt_file]); end elseif strcmp(grtool_data.taction,'updateflo') % check to see if there really is a value then update it if ~isempty(get(findobj('Tag','tmplt_flo'),'String')) grtool_data.tmplt_flo=str2num(get(findobj('Tag','tmplt_flo'),'String')); assignin('base','GRTOOL_G_DATA',grtool_data); else error('You have not entered a value'); end elseif strcmp(grtool_data.taction,'generatecalib') % % Generate Calibration file using getfri('outfile.dat'); % end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Clear space % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(arg1,'clearspace') if strcmp(grtool_data.currentspace,'tf') delete(findobj('Tag','timedomain')); delete(findobj('Tag','freqdomain')); elseif strcmp(grtool_data.currentspace,'template') delete(findobj('Tag','templatespace')); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Generate buttons % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(arg1,'generatebuttons') hf_main = findobj('Tag','GRtool'); GRtool('clearbuttons',grtool_data); grtool_data.currentbuttons = grtool_data.generatebuttons; assignin('base','GRTOOL_G_DATA',grtool_data); if strcmp(grtool_data.generatebuttons,'tf') hu_graph = uicontrol('Parent',hf_main, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2604166666666667, ... 'ListboxTop',0, ... 'Position',[0.8341 0.7466 0.1163 0.0599], ... 'String','Graph', ... 'Tag','graphbutton', ... 'Callback',[... 'GRTOOL_G_ACTION=''graph'';'... 'GRtool(''visualize'',GRTOOL_G_DATA)']); hu_sound = uicontrol('Parent',hf_main, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2604166666666667, ... 'ListboxTop',0, ... 'Position',[0.8341 0.6748 0.1163 0.0599], ... 'String','Play Sound', ... 'Tag','soundbutton', ... 'Callback',[... 'GRTOOL_G_ACTION=''sound'';'... 'GRtool(''visualize'',GRTOOL_G_DATA);']); hu_template = uicontrol('Parent',hf_main, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2604166666666667, ... 'ListboxTop',0, ... 'Position',[0.8341 0.6030 0.1163 0.0599], ... 'String','Template Space', ... 'Tag','templatebutton', ... 'Callback',[... 'GRTOOL_G_DATA.generatespace=''template'';'... 'GRTOOL_G_DATA.generatebuttons=''template'';'... 'GRtool(''generatebuttons'',GRTOOL_G_DATA);'... 'GRtool(''generatespace'',GRTOOL_G_DATA);']); hu_export = uicontrol('Parent',hf_main, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2604166666666667, ... 'ListboxTop',0, ... 'Position',[0.8341 0.5312 0.1163 0.0599], ... 'String','Export', ... 'Tag','exportbutton', ... 'Callback','GRTOOL_G_DATA.source=''read'';GRtool(''export'',GRTOOL_G_DATA)'); elseif strcmp(grtool_data.generatebuttons,'template') hu_raise = uicontrol('Parent',hf_main, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2604166666666667, ... 'ListboxTop',0, ... 'Position',[0.8341 0.7466 0.1163 0.0599], ... 'String','Raise Grid', ... 'Tag','raisebutton', ... 'Callback',[... 'GRtool(''raisegrid'',GRTOOL_G_DATA)']); hu_tf = uicontrol('Parent',hf_main, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2604166666666667, ... 'ListboxTop',0, ... 'Position',[0.8341 0.6030 0.1163 0.0599], ... 'String','t/f Space', ... 'Tag','tfbutton', ... 'Callback',[... 'GRTOOL_G_DATA.generatespace=''tf'';'... 'GRTOOL_G_DATA.generatebuttons=''tf'';'... 'GRtool(''generatebuttons'',GRTOOL_G_DATA);'... 'GRtool(''generatespace'',GRTOOL_G_DATA);']); hu_export = uicontrol('Parent',hf_main, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2604166666666667, ... 'ListboxTop',0, ... 'Position',[0.8341 0.6757 0.1163 0.0599], ... 'String','Export', ... 'Tag','exporttmpltbutton', ... 'Callback',[... 'GRtool(''filterexport'',GRTOOL_G_DATA);']); end % this will clear out action assignin('base','GRTOOL_G_ACTION','none'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Clear buttons % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(arg1,'clearbuttons') if strcmp(grtool_data.currentbuttons,'tf') delete(findobj('Tag','graphbutton')); delete(findobj('Tag','soundbutton')); delete(findobj('Tag','templatebutton')); delete(findobj('Tag','exportbutton')); elseif strcmp(grtool_data.currentbuttons,'template') delete(findobj('Tag','raisebutton')); delete(findobj('Tag','tfbutton')); delete(findobj('Tag','exporttmpltbutton')); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Visualize % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(arg1,'visualize') % Dialog for time span hf_tspan = figure('Color',[0.8 0.8 0.8], ... 'Name','Choose Time Range', ... 'NumberTitle','off', ... 'Position',[594 328 267 196], ... 'Tag','tchoose'); hu_inst1 = uicontrol('Parent',hf_tspan, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.462962962962963, ... 'FontWeight','bold', ... 'ListboxTop',0, ... 'Position',[0.1910112359550562 0.8928571428571428 0.6067415730337079 0.08673469387755102], ... 'String','Select a time range from', ... 'Style','text', ... 'Tag','StaticText1'); hu_inst2 = uicontrol('Parent',hf_tspan, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.4310344827586208, ... 'FontWeight','bold', ... 'ListboxTop',0, ... 'Position',[0.04119850187265918 0.7499999999999999 0.9101123595505618 0.1020408163265306], ... 'String',[num2str(grtool_data.t(1)) ' < t < ' num2str(grtool_data.t(grtool_data.index(end)))], ... 'Style','text', ... 'Tag','StaticText2'); hu_inst3 = uicontrol('Parent',hf_tspan, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.4006410256410257, ... 'ListboxTop',0, ... 'Position',[0.2958801498127341 0.596938775510204 0.400749063670412 0.08163265306122448], ... 'String',['(units are seconds)'], ... 'Style','text', ... 'Tag','StaticText3'); hu_inst4 = uicontrol('Parent',hf_tspan, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.4340277777777778, ... 'ListboxTop',0, ... 'Position',[0.1460674157303371 0.4540816326530612 0.2134831460674157 0.07142857142857142], ... 'String','Initial time', ... 'Style','text', ... 'Tag','StaticText4'); hu_inst5 = uicontrol('Parent',hf_tspan, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.4166666666666667, ... 'ListboxTop',0, ... 'Position',[0.1685393258426966 0.3112244897959184 0.1872659176029963 0.07653061224489796], ... 'String','Final time', ... 'Style','text', ... 'Tag','StaticText5'); hu_t0 = uicontrol('Parent',hf_tspan, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[1 1 1], ... 'FontSize',0.2976190476190476, ... 'ListboxTop',0, ... 'Position',[0.3932584269662922 0.4234693877551021 0.5131086142322098 0.1275510204081633], ... 'Style','edit', ... 'Tag','t0'); hu_tf = uicontrol('Parent',hf_tspan, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[1 1 1], ... 'FontSize',0.2976190476190476, ... 'ListboxTop',0, ... 'Position',[0.3932584269662922 0.2857142857142858 0.5131086142322098 0.1275510204081633], ... 'Style','edit', ... 'Tag','tf'); hu_ok = uicontrol('Parent',hf_tspan, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.3156565656565657, ... 'ListboxTop',0, ... 'Position',[0.1647940074906367 0.05102040816326531 0.2471910112359551 0.1173469387755102], ... 'String','OK', ... 'Callback',[... 'GRTOOL_G_T0=str2num(get(findobj(''Tag'',''t0''),''String''));'... 'GRTOOL_G_TF=str2num(get(findobj(''Tag'',''tf''),''String''));'... 'close(findobj(''Tag'',''tchoose''));'], ... 'Tag','Pushbutton1'); hu_cancel = uicontrol('Parent',hf_tspan, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.3156565656565657, ... 'ListboxTop',0, ... 'Position',[0.5655430711610487 0.05102040816326531 0.2471910112359551 0.1173469387755102], ... 'String','Cancel', ... 'Callback', 'GRTOOL_G_ACTION = ''cancel'';close(findobj(''Tag'',''tchoose'')) ', ... 'Tag','Pushbutton1'); waitfor(hf_tspan); if strcmp(GRTOOL_G_ACTION,'graph') % check to see if there are existing plots - erase them if there are if ~isempty( findobj('Tag','tline') ); delete(tline); end if ~isempty( findobj('Tag','fline') ); delete(fline); end % find data in this time span set(findobj('Tag','GRtool'),'Pointer','watch'); % this may take a bit grtool_data.index=find(grtool_data.t<=GRTOOL_G_TF & grtool_data.t>=GRTOOL_G_T0); newlength=2^floor( log2(length(grtool_data.index)) ); % make data set length a power of 2 grtool_data.index=grtool_data.index(1:newlength); grtool_data.samplerate=length(grtool_data.index)/(grtool_data.t(grtool_data.index(end))-grtool_data.t(grtool_data.index(1))); grtool_data.b=abs( fft(grtool_data.a(grtool_data.index)) ); grtool_data.f=linspace(0,grtool_data.samplerate/2,round(length(grtool_data.b)/2)); assignin('base','GRTOOL_G_DATA',grtool_data); set(findobj('Tag','GRtool'),'Pointer','arrow'); % put the arrow back tline = line('Parent',findobj('Tag','timedomain'), ... 'Color','b', ... 'Tag','tline', ... 'XData',grtool_data.t(grtool_data.index), ... 'YData',grtool_data.a(grtool_data.index)); set(tx,'String','time ( s )'); set(ty,'String',[grtool_data.cname ' ( ' grtool_data.u ' )']); set(tt,'String',grtool_data.t0s); % data.t0s causes anoying TeX error fline = line('Parent',findobj('Tag','freqdomain'), ... 'Color','r', ... 'Tag','fline', ... 'XData',grtool_data.f, ... 'YData',grtool_data.b(1:round(length(grtool_data.b)/2)) ); set(fx,'String','Frequency ( Hz )'); set(fy,'String',''); elseif strcmp(GRTOOL_G_ACTION,'sound') sound(grtool_data.a(grtool_data.index)/max(abs(grtool_data.a(grtool_data.index))),grtool_data.samplerate); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Export % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(arg1,'export') % if this is a simulation - make sure you have all the inputs filled in if strcmp(grtool_data.source,'simulate') & (... isequal(get(findobj('Tag','m1'),'String'),'') ... | isequal(get(findobj('Tag','m2'),'String'),'')... | isequal(get(findobj('Tag','fstart'),'String'),'')... | isequal(get(findobj('Tag','points'),'String'),'')... | isequal(get(findobj('Tag','srate'),'String'),'')... | isequal(get(findobj('Tag','order'),'String'),'')... ); error('You have not filled in all the input fields'); end % if this is from simulation - do simulation if it hasn't been done if strcmp(grtool_data.source,'simulate') & ~isfield(grtool_data,'sima1') set(findobj('Tag','GRtool'),'Pointer','watch') % Just in case it's a big data set npoint=str2num( get(findobj('Tag','points'),'String') ); npoint=2^round( log2(npoint) ); % make npoint power of 2 [grtool_data.sima1,grtool_data.sima2,grtool_data.filled, ... grtool_data.t_coal] = mxMake_filters( str2num( get(findobj('Tag','m1'),'String') ), ... str2num( get(findobj('Tag','m2'),'String') ), ... str2num( get(findobj('Tag','fstart'),'String') ), ... npoint, ... str2num( get(findobj('Tag','srate'),'String') ), ... str2num( get(findobj('Tag','err_cd_sprs'),'String') ), ... str2num( get(findobj('Tag','order'),'String') ) ); grtool_data.simsamplerate = str2num( get(findobj('Tag','srate'),'String') ); grtool_data.simt = 0:1/grtool_data.simsamplerate:(length(grtool_data.sima1)-1)*(1/grtool_data.simsamplerate); grtool_data.simb = abs(fft(grtool_data.sima1)); grtool_data.simf = linspace(0,grtool_data.simsamplerate/2,length(grtool_data.simb)/2); assignin('base','GRTOOL_G_DATA',grtool_data); set(findobj('Tag','GRtool'),'Pointer','arrow') % Put the arrow back end % Dialog box: export as sound file, workspace varriables, both, or cancel opt={'Workspace','Sound File (.au format)','Both'}; reply=questdlg('Where do you want to put the data?','Select Export Destination',opt{1},opt{2},opt{3},opt{1}); if strcmp(reply,'Workspace') % Dialog box: name varriables promptstr={'Name for amplitude:','Name for time:'}; titlestr='Name varriables'; inistr={'a','t'}; simstr={'sima1','simt'}; reply=inputdlg(promptstr,titlestr,1,inistr); if ~isempty(reply) % check that everything was filled in for i=1:2 if isempty(reply{i}) error(['Invalid input for name of ' inistr{i} 'varriable']); end end % assign values in the workspace for i=1:2 if strcmp(grtool_data.source,'read') eval(['assignin(''base'',''' reply{i} ''', grtool_data.' inistr{i} ');']); elseif strcmp(grtool_data.source,'simulate') eval(['assignin(''base'',''' reply{i} ''', grtool_data.' simstr{i} ');']); end end end elseif strcmp(reply,'Sound File (.au format)') % tell me the file - then write to it [putname,putpath] = uiputfile(''); if strcmp(grtool_data.source,'read') & isstr(putname) eval(['auwrite(grtool_data.a/max(abs(grtool_data.a)),grtool_data.samplerate,''' putpath putname ''');' ]); elseif strcmp(grtool_data.source,'simulate') & isstr(putname) eval(['auwrite(grtool_data.sima1/max(abs(grtool_data.sima1)),grtool_data.simsamplerate,''' putpath putname ''');' ]); end elseif strcmp(reply,'Both') % Dialog box: name varriables promptstr={'Name for amplitude:','Name for time:'}; titlestr='Name varriables'; inistr={'a','t'}; simstr={'sima1','simt'}; reply=inputdlg(promptstr,titlestr,1,inistr); if ~isempty(reply) % check that everything was filled in for i=1:2 if isempty(reply{i}) error(['Invalid input for name of ' inistr{i} 'varriable']); end end % assign values in the workspace for i=1:2 if strcmp(grtool_data.source,'read') eval(['assignin(''base'',''' reply{i} ''', grtool_data.' inistr{i} ');']); elseif strcmp(data.source,'simulate') eval(['assignin(''base'',''' reply{i} ''', grtool_data.' simstr{i} ');']); end end % write sound file [putname,putpath] = uiputfile(''); if isstr(putname) & strcmp(grtool_data.source,'read') eval([ 'auwrite(grtool_data.a/max(abs(grtool_data.a)),grtool_data.samplerate,''' putpath putname ''')' ]); elseif isstr(putname) & strcmp(grtool_data.source,'simulate') eval([ 'auwrite(grtool_data.sima1/max(abs(grtool_data.sima1)),grtool_data.simsamplerate,''' putpath putname ''')' ]); end end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Simulate Build % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(arg1,'simulate_build') %[0.244140625 0.33203125 0.6123046875 0.3046875] hf_simulate= figure('Units','normalized', ... 'Color',[0.8 0.8 0.8], ... 'MenuBar','none', ... 'Name','Inspiral Simulator', ... 'NumberTitle','off', ... 'Position',[0.0420 0.0612 0.6123 0.3047], ... 'Tag','simulate_main'); hu_st = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3472222222222222, ... 'HorizontalAlignment','right', ... 'ListboxTop',0, ... 'Position',[0.0255 0.1026 0.1914 0.0855], ... 'String','Error Code Supression', ... 'Style','text'); hu_m1 = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[1 1 1], ... 'FontSize',0.3156565656565657, ... 'ListboxTop',0, ... 'Position',[0.2312599681020734 0.8205128205128205 0.2025518341307815 0.09401709401709403], ... 'Tag','m1', ... 'Style','edit'); hu_m2 = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[1 1 1], ... 'FontSize',0.3156565656565657, ... 'ListboxTop',0, ... 'Position',[0.2312599681020734 0.7008547008547008 0.2025518341307815 0.09829059829059829], ... 'Tag','m2', ... 'Style','edit'); hu_order= uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[1 1 1], ... 'FontSize',0.3156565656565657, ... 'ListboxTop',0, ... 'Position',[0.2312599681020734 0.5641025641025641 0.2025518341307815 0.09829059829059829], ... 'Tag','order', ... 'Style','edit'); hu_points = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[1 1 1], ... 'FontSize',0.3156565656565657, ... 'ListboxTop',0, ... 'Position',[0.2312599681020734 0.4487179487179487 0.2025518341307815 0.09829059829059829], ... 'Tag','points', ... 'Style','edit'); hu_fstart = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[1 1 1], ... 'FontSize',0.3156565656565657, ... 'ListboxTop',0, ... 'Position',[0.2312599681020734 0.3333333333333333 0.2025518341307815 0.09829059829059829], ... 'Tag','fstart', ... 'Style','edit'); hu_srate = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[1 1 1], ... 'FontSize',0.3156565656565657, ... 'ListboxTop',0, ... 'Position',[0.2312599681020734 0.2094017094017094 0.2025518341307815 0.09829059829059829], ... 'Tag', 'srate', ... 'Style','edit'); hu_err = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[1 1 1], ... 'FontSize',0.3156565656565657, ... 'ListboxTop',0, ... 'Position',[0.2312599681020734 0.08547008547008547 0.2025518341307815 0.09829059829059829], ... 'Tag','err_cd_sprs', ... 'Style','edit'); hu_st = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3472222222222222, ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.4385964912280702 0.8205128205128205 0.4338118022328549 0.08547008547008547], ... 'String','(Solar Mass Units)', ... 'Style','text'); hu_st = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3472222222222222, ... 'HorizontalAlignment','right', ... 'ListboxTop',0, ... 'Position',[0.02551834130781499 0.2222222222222222 0.1913875598086125 0.08547008547008547], ... 'String','Sampling Frequency', ... 'Style','text'); hu_st = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3472222222222222, ... 'HorizontalAlignment','right', ... 'ListboxTop',0, ... 'Position',[0.02551834130781499 0.3418803418803419 0.1913875598086125 0.08547008547008547], ... 'String','Lower Frequency Limit', ... 'Style','text'); hu_st = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3472222222222222, ... 'HorizontalAlignment','right', ... 'ListboxTop',0, ... 'Position',[0.02551834130781499 0.452991452991453 0.1913875598086125 0.08547008547008547], ... 'String','Number of Points', ... 'Style','text'); hu_st = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3472222222222222, ... 'HorizontalAlignment','right', ... 'ListboxTop',0, ... 'Position',[0.02551834130781499 0.5726495726495726 0.1913875598086125 0.08547008547008547], ... 'String','Order', ... 'Style','text'); hu_st = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3472222222222222, ... 'HorizontalAlignment','right', ... 'ListboxTop',0, ... 'Position',[0.02392344497607656 0.7094017094017094 0.1913875598086125 0.08547008547008547], ... 'String','Mass 2', ... 'Style','text'); hu_st = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3472222222222222, ... 'HorizontalAlignment','right', ... 'ListboxTop',0, ... 'Position',[0.02551834130781499 0.8205128205128205 0.1913875598086125 0.08547008547008547], ... 'String','Mass 1', ... 'Style','text'); hu_st = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3472222222222222, ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.4385964912280702 0.7094017094017094 0.4338118022328549 0.08547008547008547], ... 'String','(Solar Mass Units)', ... 'Style','text'); hu_st = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3472222222222222, ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.4417862838915471 0.5769230769230769 0.4338118022328549 0.08547008547008547], ... 'String','(Power of v/c Past Quadropole Approximation)', ... 'Style','text'); hu_st = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3472222222222222, ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.4401913875598086 0.4615384615384616 0.4338118022328549 0.08547008547008547], ... 'String','(Will be rounded to nearest power of 2)', ... 'Style','text'); hu_st = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3472222222222222, ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.4417862838915471 0.3418803418803419 0.4338118022328549 0.08547008547008547], ... 'String','(Hz)', ... 'Style','text'); hu_st = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3472222222222222, ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.4417862838915471 0.2222222222222222 0.4338118022328549 0.08547008547008547], ... 'String','(Hz)', ... 'Style','text'); hu_st = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',0.3472222222222222, ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.4418 0.1026 0.4338 0.0855], ... 'String','( Integer from 0 - 4000 )', ... 'Style','text'); hu_frame = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.4 0.2 0.2], ... 'FontSize',0.04822530864197531, ... 'ListboxTop',0, ... 'Position',[0.813397129186603 0.05982905982905982 0.1658692185007975 0.8760683760683762], ... 'Style','frame'); hu_graphbut = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2604166666666667, ... 'ListboxTop',0, ... 'Position',[0.8373205741626795 0.764957264957265 0.1196172248803828 0.1282051282051282], ... 'Callback','GRTOOL_G_DATA.simaction=''graph'';GRtool(''simulate_action'',GRTOOL_G_DATA);', ... 'String','Graph'); hu_playbut = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2604166666666667, ... 'ListboxTop',0, ... 'Position',[0.8373205741626795 0.6025641025641026 0.1196172248803828 0.128205128205128], ... 'Callback','GRTOOL_G_DATA.simaction=''play'';GRtool(''simulate_action'',GRTOOL_G_DATA);', ... 'String','Play Sound'); hu_expbut = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2604166666666667, ... 'ListboxTop',0, ... 'Position',[0.8373205741626795 0.4401 0.1196172248803828 0.1282051282051282], ... 'Callback','GRTOOL_G_DATA.source=''simulate'';GRtool(''export'',GRTOOL_G_DATA);', ... 'String','Export'); hu_closebut = uicontrol('Parent',hf_simulate, ... 'Units','normalized', ... 'FontUnits','normalized', ... 'BackgroundColor',[0.701960784313725 0.701960784313725 0.701960784313725], ... 'FontSize',0.2604166666666667, ... 'ListboxTop',0, ... 'Position',[0.8373205741626795 0.1111111111111111 0.1196172248803828 0.1282051282051282], ... 'String','Close', ... 'Callback','close(findobj(''Tag'',''simulate_main'')); close(findobj(''Tag'',''sim_subfig''))'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Simulate Action % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(arg1,'simulate_action') % Make sure we have inputs if isequal(get(findobj('Tag','m1'),'String'),'') ... | isequal(get(findobj('Tag','m2'),'String'),'')... | isequal(get(findobj('Tag','fstart'),'String'),'')... | isequal(get(findobj('Tag','points'),'String'),'')... | isequal(get(findobj('Tag','srate'),'String'),'')... | isequal(get(findobj('Tag','order'),'String'),''); error('You have not filled in all the input fields'); end % calculate simulated signal set(findobj('Tag','GRtool'),'Pointer','watch') % Just in case it's a big data set npoint=str2num( get(findobj('Tag','points'),'String') ); npoint=2^round( log2(npoint) ); % make npoint power of 2 [grtool_data.sima1,grtool_data.sima2,grtool_data.filled, ... grtool_data.t_coal] = mxMake_filters( str2num( get(findobj('Tag','m1'),'String') ), ... str2num( get(findobj('Tag','m2'),'String') ), ... str2num( get(findobj('Tag','fstart'),'String') ), ... npoint, ... str2num( get(findobj('Tag','srate'),'String') ), ... str2num( get(findobj('Tag','err_cd_sprs'),'String') ), ... str2num( get(findobj('Tag','order'),'String') ) ); grtool_data.simsamplerate = str2num( get(findobj('Tag','srate'),'String') ); grtool_data.simt = 0:1/grtool_data.simsamplerate:(length(grtool_data.sima1)-1)*(1/grtool_data.simsamplerate); grtool_data.simb = abs(fft(grtool_data.sima1)); grtool_data.simf = linspace(0,grtool_data.simsamplerate/2,length(grtool_data.simb)/2); assignin('base','GRTOOL_G_DATA',grtool_data); set(findobj('Tag','GRtool'),'Pointer','arrow') % Put the arrow back if strcmp(grtool_data.simaction,'play') sound(grtool_data.sima1/max(abs(grtool_data.sima1)),grtool_data.simsamplerate); elseif strcmp(grtool_data.simaction,'graph') close(findobj('Tag','sim_subfig')); hf_simgraph = figure('Name','Compact Binary inspiral Simulation', ... 'NumberTitle','off', ... 'Tag','sim_subfig'); H_opt = uimenu(hf_simgraph,'Label','&Options'); H_opt3 = uimenu(H_opt,'Label','&Background',... 'Callback','whitebg'); H_opt4 = uimenu(H_opt,'Label','&Grid'); H_opt4a = uimenu(H_opt4,'Label','O&n',... 'Callback','grid on'); H_opt4b = uimenu(H_opt4,'Label','O&ff',... 'Callback','grid off'); H_opt44 = uimenu(H_opt,'Label','&Box'); H_opt44a = uimenu(H_opt44,'Label','O&n',... 'Callback','box on'); H_opt44b = uimenu(H_opt44,'Label','O&ff',... 'Callback','box off'); H_opt5 = uimenu(H_opt,'Label','&Zoom'); H_opt5a = uimenu(H_opt5,'Label','O&n',... 'Callback','zoom on'); H_opt5b = uimenu(H_opt5,'Label','O&ff',... 'Callback','zoom off'); subplot(2,1,1); plot(grtool_data.simt,grtool_data.sima1,'b',grtool_data.simt,grtool_data.sima2,'r'); xlabel('time ( s )') ylabel(' 0 phase and \pi / 2 phase chirps'); title([... 'm1 = ' get(findobj('Tag','m1'),'String') ... ' m2 = ' get(findobj('Tag','m2'),'String')... ' time to coalescense = ' num2str(grtool_data.t_coal) ]); box on; subplot(2,1,2); loglog(grtool_data.simf,grtool_data.simb(1:length(grtool_data.simb)/2),'Color',[0.7 0.4 0.4]); xlabel('Frequency ( Hz )'); ylabel('') box on; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % filter data % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(arg1,'filterdata') % make sure we have everything we need to do filtering if ~( isfield(grtool_data,'m1') & isfield(grtool_data,'m2') & isfield(grtool_data,'fri') & isfield(grtool_data,'tmplt_flo') ) if ~isfield(grtool_data,'m1') | ~isfield(grtool_data,'m2') error(['There is no data for (m1,m2) in memory. Use the Template Space'... ' Control Panel to load data from a templates file.']); elseif ~isfield(grtool_data,'fri') error('There is no calibration data in memory. Use the Template Space Control Panel to load calibration data.'); elseif ~isfield(grtool_data,'tmplt_flo') error('You have not entered a lower cutoff fequency'); end else % filter the data (and change mouse pointer to watch while doing it) set(findobj('Tag','GRtool'),'Pointer','watch'); [grtool_data.snr_max,grtool_data.timestart]=inspfilt(grtool_data.m1,grtool_data.m2,... grtool_data.a(grtool_data.index),grtool_data.samplerate,... grtool_data.tmplt_flo,grtool_data.fri); set(findobj('Tag','GRtool'),'Pointer','arrow'); assignin('base','GRTOOL_G_DATA',grtool_data); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Raise Grid % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(arg1,'raisegrid') % make sure we have everything we need if ~( isfield(grtool_data,'m1') & isfield(grtool_data,'m2') & isfield(grtool_data,'snr_max') ) if ~isfield(grtool_data,'m1') | ~isfield(grtool_data,'m2') error(['There is no data for (m1,m2) in memory. Use the Template Space'... ' Control Panel to load data from a templates file.']); elseif ~isfield(grtool_data,'snr_max') error('You have not filtered the data yet.'); end else % raise the grid if ~isempty( findobj('Tag','filter_response') ); delete(findobj('Tag','filter_response')); delete(findobj('Tag','response_stem')); end % for loop to plot points and add stems - and change pointer to watch while doing it % (there must be a better way) set(findobj('Tag','GRtool'),'Pointer','watch'); for i=1:length(grtool_data.m1) % plot data points filter_response = line('Parent',findobj('Tag','templatespace'), ... 'Color',grtool_data.timestart(i)/max(grtool_data.timestart)*[0 0 1] , ... 'Tag','filter_response', ... 'XData',grtool_data.m1(i), ... 'YData',grtool_data.m2(i), ... 'Zdata',grtool_data.snr_max(i), ... 'LineStyle','none', ... 'Marker','o', ... 'MarkerSize',6); % add stems response_stem = line('Parent',findobj('Tag','templatespace'), ... 'Tag','response_stem', ... 'Color',[1 0.932259020342589 0.790464898697889], ... 'XData',[grtool_data.m1(i),grtool_data.m1(i)], ... 'YData',[grtool_data.m2(i),grtool_data.m2(i)], ... 'Zdata',[0,grtool_data.snr_max(i)]); end set(findobj('Tag','GRtool'),'Pointer','arrow'); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Filter Export % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(arg1,'filterexport') % make sure there is something to export and that data has not changed if ~isfield(grtool_data,'snr_max') error('Can not export: You have not filtered any data.'); elseif ~isequal(length(grtool_data.snr_max),length(grtool_data.m1)) error('Can not export: (m1,m2) data has changed since the last time data was filtered'); end % input dialog box promptstr={'Name for m1:','Name for m2:','Name for max(SNR):','Name for tstart:'}; titlestr='Name varriables'; inistr={'m1','m2','snr_max','timestart'}; reply=inputdlg(promptstr,titlestr,1,inistr); if ~isempty(reply) % check that everything was filled in for i=1:4 if strcmp(reply{i},'') error(['Invalid input for name of ' inistr{i} 'varriable']); end end % assign values in the workspace for i=1:4 eval(['assignin(''base'',''' reply{i} ''', grtool_data.' inistr{i} ');']); end end %%%%%%%%%%%%%%%%%%%%%% QED %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end