Skip to content

Commit

Permalink
Models: Phonons: better HTML rendering. Display % remaining.
Browse files Browse the repository at this point in the history
  • Loading branch information
farhi committed Mar 21, 2017
1 parent 0d2e1c6 commit 1cd4146
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Scripts/Models/Factory/private/sqw_phon.m
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@
seconds = floor(remaining-hours*3600-minutes*60);
enddate = addtodate(now, ceil(remaining), 'second');

options.status = [ 'ETA ' sprintf('%i:%02i:%02i', hours, minutes, seconds) ', ending on ' datestr(enddate) ];
options.status = [ 'ETA ' sprintf('%i:%02i:%02i', hours, minutes, seconds) ', ending on ' datestr(enddate) ' [' num2str(round(move*100.0/size(displacements,1))) '%]' ];
disp([ mfilename ': ' options.status ]);
sqw_phonons_htmlreport('', 'status', options);
end
Expand Down
7 changes: 6 additions & 1 deletion Scripts/Models/Factory/private/sqw_phonons_get_forces.m
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@
[st, result] = system([ precmd 'python ' fullfile(target,'sqw_phonons_forces_iterate.py') ]);
end
disp(result)
% get how many steps have been computed: name is 'phonon.N[xyz][+-].pckl'
move_update = dir(fullfile(target,'phonon.*.pckl'));
if numel(move_update) > move
move = numel(move_update);
end
if move <= nb_of_steps
% display ETA. There are nb_of_steps steps.
% up to now we have done 'move' and it took etime(clock, t)
Expand All @@ -235,7 +240,7 @@
seconds = floor(remaining-hours*3600-minutes*60);
enddate = addtodate(now, ceil(remaining), 'second');

options.status = [ 'ETA ' sprintf('%i:%02i:%02i', hours, minutes, seconds) ', ending on ' datestr(enddate) '. move ' num2str(move) '/' num2str(nb_of_steps) ];
options.status = [ 'ETA ' sprintf('%i:%02i:%02i', hours, minutes, seconds) ', ending on ' datestr(enddate) '. move ' num2str(move) '/' num2str(nb_of_steps) ' [' num2str(round(move*100.0/nb_of_steps)) '%]'];
disp([ mfilename ': ' options.status ]);
sqw_phonons_htmlreport('', 'status', options);
end
Expand Down
14 changes: 11 additions & 3 deletions Scripts/Models/Factory/private/sqw_phonons_htmlreport.m
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,20 @@ function sqw_phonons_htmlreport_table(fid, options, name)
'.vtk Visualization Toolkit (VTK) file which can be viewed with <a href="http://www.paraview.org/">ParaView</a>, <a href="http://code.enthought.com/projects/mayavi/">Mayavi2</a>, <a href="https://wci.llnl.gov/simulation/computer-codes/visit/executables">VisIt</a>, <a href="https://www.slicer.org/">Slicer4</a>' ...
'.mrc MRC Electron density map, to be visualized with <a href="http://www.pymol.org/">PyMol</a>, <a href="http://www.ks.uiuc.edu/Research/vmd/">VMD</a>, <a href="http://www.cgl.ucsf.edu/chimera/">Chimera</a>, <a href="http://www.yasara.org/">Yasara</a>, <a href="http://mem.ibs.fr/VEDA/">VEDA</a>' ...
'.xhtml Extensible Web page. You can rotate the object (left mouse button), zoom (right mouse button), and pan (middle mouse button).', ...
'.fits Flexible Image Transport System (<a href="https://fits.gsfc.nasa.gov/fits_home.html">FITS</a>) image, which can be viewed with e.g. <a href="http://rsb.info.nih.gov/ij/">ImageJ</a>, <a href="http://www.gimp.org/">GIMP.</a>.', ...
'.tiff <a href="https://en.wikipedia.org/wiki/TIFF">TIFF</a> image file, to be viewed with e.g. <a href="http://rsb.info.nih.gov/ij/">ImageJ</a>, <a href="http://www.gimp.org/">GIMP.</a>.' ...
}

[index1, index2] = strtok([ name index{1} ]);
if ~isempty(dir(fullfile(options.target,index1)))
% the file exists
if strcmp(index1, [ name '.png' ])
fprintf(fid, '<div style="text-align:center"><a href="%s"><img src="%s" align="middle" title="%s"></a></div><br>\n', index1, index1, index1);
fprintf(fid, '<div style="text-align:center"><a href="%s"><img src="%s" align="middle" title="%s"></a><br>(try the <a href="%s">TIFF file</a> in case the axes are not shown)</div><br>\n', index1, index1, index1, [ name '.tiff' ]);
elseif strcmp(index1, [ name '.html' ])
% embed a frame
fprintf(fid, '<div style="text-align:center"><iframe src="%s" align="middle" width="480" height="480"></iframe><br>%s<br>(<a href="%s" target=_blank>open in external window</a>)<br></div><br>\n', index1, index2, index1);
elseif strcmp(index1, [ name '.xhtml' ])
% embed an x3dom frame
fprintf(fid, [ '<div style="text-align:center"><iframe src="%s" align="middle" width="700" height="850"></iframe><br>\n' ...
'%s<br>(<a href="%s" target=_blank>open in external window</a>)<br>\n' ...
'The <font color="blue">blue</font> axis is the Energy (meV), the <font color="red">red</font> axis is QK (rlu), the <font color="green">green</font> axis is QL (rlu).<br>\n' ...
Expand Down Expand Up @@ -390,7 +394,9 @@ function sqw_phonons_htmlreport_error(fid, options, message)
fprintf(fid, '<h3><a name="kpath"></a>The dispersion along principal directions</h3>\n');
fprintf(fid, 'The dispersion curves along the principal axes is shown in log10 scale.<br>\n');
builtin('save', fullfile(options.target, 'Phonon_kpath.mat'), 'Phonon_kpath');
save(Phonon_kpath, fullfile(options.target, 'Phonon_kpath.png'), 'png', 'view2 tight');
save(Phonon_kpath, fullfile(options.target, 'Phonon_kpath.png'), 'png data');
save(Phonon_kpath, fullfile(options.target, 'Phonon_kpath.fits'), 'fits');
save(Phonon_kpath, fullfile(options.target, 'Phonon_kpath.tiff'), 'tiff');
save(Phonon_kpath, fullfile(options.target, 'Phonon_kpath.dat'), 'dat data');
save(Phonon_kpath, fullfile(options.target, 'Phonon_kpath.svg'), 'svg', 'view2 tight');
save(Phonon_kpath, fullfile(options.target, 'Phonon_kpath.pdf'), 'pdf', 'view2 tight');
Expand Down Expand Up @@ -471,7 +477,9 @@ function sqw_phonons_htmlreport_eval_3D(fid, options, object)
fprintf(fid, 'The powder average S(q,w) is shown below:<br>\n');

builtin('save', fullfile(options.target, 'Phonon_powder.mat'), 'Phonon_powder');
saveas(log_Phonon_powder, fullfile(options.target, 'Phonon_powder.png'),'png','tight view2');
saveas(log_Phonon_powder, fullfile(options.target, 'Phonon_powder.png'),'png data');
saveas(log_Phonon_powder, fullfile(options.target, 'Phonon_powder.fits'),'fits');
saveas(log_Phonon_powder, fullfile(options.target, 'Phonon_powder.tiff'),'tiff');
saveas(log_Phonon_powder, fullfile(options.target, 'Phonon_powder.fig'), 'fig', 'tight');
saveas(Phonon_powder, fullfile(options.target, 'Phonon_powder.dat'), 'dat data');
saveas(log_Phonon_powder, fullfile(options.target, 'Phonon_powder.pdf'), 'pdf', 'tight view2');
Expand Down
1 change: 1 addition & 0 deletions Scripts/Models/Factory/sqw_phonons.m
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
options.duration = 0;
end
Phonon_Model = signal;
if ~isdir(options.target), mkdir(options.target); end
builtin('save', fullfile(options.target, 'Phonon_Model.mat'), 'Phonon_Model');

sqw_phonons_htmlreport('', 'create_atoms', options);
Expand Down

0 comments on commit 1cd4146

Please sign in to comment.