Debian Codegraph @

artemis_parts/log.pl

raw
1 # -*- cperl -*-
2 ## This file is part of Artemis, copyright (c) 2002-2006 Bruce Ravel
3 ##
4
5 ###===================================================================
6 ### log file subsystem
7 ###===================================================================
8
9
10 sub log_file_display {
11 my $which = $_[0] || 'results';
12 $which = 'results' unless (($which eq 'results') or ($which eq 'files'));
13 my $is_busy = grep (/Busy/, $top->bindtags);
14 $top -> Busy unless $is_busy;
15
16 $notes{$which} -> delete('1.0', 'end');
17 my $log = $_[1] || File::Spec->catfile($project_folder, "fits",
18 sprintf("fit%4.4d", $fit{count}), "log");
19 ##print join("!", @_), $/;
20 ##print join("|", $log, @log_type), $/;
21 Echo("Could not read log file \"$log\""), return unless (-e $log);
22 SWITCH:{
23
24 ## raw log file
25 ($log_type[1] eq 'raw') and do {
26 open F, $log;
27 while (<F>) {
28 $_ =~ s{\r}{} if not $is_windows;
29 if ($_ =~ /^!!/) {
30 $notes{$which} -> insert('end', $_, 'warning');
31 } elsif ($_ =~ /\.\.$/) {
32 $notes{$which} -> insert('end', $_, 'pathid');
33 } else {
34 $notes{$which} -> insert('end', $_);
35 };
36 }
37 $notes{$which} -> yviewMoveto(0);
38 close F;
39 last SWITCH;
40 };
41
42 ## quick view
43 ($log_type[1] eq 'quick') and do {
44 my $data = Ifeffit::ArtemisLog -> new($log);
45 my $was_sum = grep {/Fitting was not performed./} ($data->get('warnings'));
46 ## header
47 $notes{$which} -> insert('end', "Project title : " . $data -> get('Project title') . "\n");
48 $notes{$which} -> insert('end', "Comment : " . $data -> get('Comment') . "\n");
49 $notes{$which} -> insert('end', "Figure of merit : " . $data -> get('Figure of merit') . "\n");
50 ## statistics
51 $notes{$which} -> insert('end', $data->stats) unless $was_sum;
52 ## guesses
53 $notes{$which} -> insert('end', $data->guess);
54 ## restraints
55 $notes{$which} -> insert('end', $data->restraint);
56 ## afters
57 $notes{$which} -> insert('end', $data->after);
58 undef $data;
59 last SWITCH;
60 };
61
62 ## columnar view
63 ($log_type[1] eq 'column') and do {
64 my $data = Ifeffit::ArtemisLog -> new($log);
65 #print Data::Dumper->Dump([$data], [qw(*data)]);
66 #$top -> Unbusy unless $is_busy;
67 #return;
68 my $was_sum = grep {/Fitting was not performed./} ($data->get('warnings'));
69 $notes{$which} -> insert('end', $data->header);
70 $notes{$which} -> insert('end', $data->stats) unless $was_sum;
71 $notes{$which} -> insert('end', $data->guess);
72 if ($data->list('def')) {
73 my $wsp = &which_set_path;
74 ($wsp)?
75 $notes{$which} -> insert('end', $data->def($paths{$wsp}->descriptor())) :
76 $notes{$which} -> insert('end', $data->def);
77 };
78 $notes{$which} -> insert('end', $data->restraint) if $data->list('restraint');
79 $notes{$which} -> insert('end', $data->set) if $data->list('set');
80 $notes{$which} -> insert('end', $data->after) if $data->list('after');
81 $notes{$which} -> insert('end', $data->correlations) unless $was_sum;
82 ## restraints data_header columns
83 foreach my $d ($data->list('data')) {
84 my $l = 0;
85 foreach my $p ($data->get($d, 'paths')) {
86 ($l = length($p)) if (length($p) > $l);
87 };
88 my $spacer = " " x $l;
89 $l+=3;
90 my $labels = " path" . $spacer . "degen amp sigma^2 e0 reff delta_R R\n";
91 $notes{$which} -> insert('end', $data->dataparams($d,0));
92 ## tables of path param values
93 $notes{$which} -> insert('end', $labels);
94 $notes{$which} -> insert('end', " " . "-" x length($labels) . "--\n");
95 my $pattern = ' %-' . $l . join(" ", qw(s %9.5f %9.3f %9.5f %9.5f %9.5f %9.5f %9.5f %s));
96 foreach my $p ($data->get($d, 'paths')) {
97 $notes{$which} -> insert('end', sprintf($pattern,
98 "\"".$p."\"",
99 $data->get($d, $p, 'degen'),
100 $data->get($d, $p, 's02'),
101 $data->get($d, $p, 'ss2'),
102 $data->get($d, $p, 'e0'),
103 $data->get($d, $p, 'r')-$data->get($d, $p, 'dr'),
104 $data->get($d, $p, 'dr'),
105 $data->get($d, $p, 'r'),
106 "\n"
107 ));
108 };
109 $notes{$which} -> insert('end', "\n");
110 my $write_second_table = 0;
111 my $epsilon = 0.000001;
112 foreach my $p ($data->get($d, 'paths')) {
113 foreach my $param (qw(ei 3rd 4th dphase)) {
114 ++$write_second_table if (abs($data->get($d, $p, $param)) > $epsilon);
115 };
116 };
117 if ($write_second_table) {
118 $pattern = ' %-' . $l . join(" ", qw(s %9.5f %9.5f %9.5f %9.5f %s));
119 $labels = " path" . $spacer . "ei 3rd 4th dphase\n";
120 $notes{$which} -> insert('end', $labels);
121 $notes{$which} -> insert('end', " " . "-" x length($labels) . "--\n");
122 foreach my $p ($data->get($d, 'paths')) {
123 $notes{$which} -> insert('end', sprintf($pattern,
124 "\"".$p."\"",
125 $data->get($d, $p, 'ei'),
126 $data->get($d, $p, '3rd'),
127 $data->get($d, $p, '4th'),
128 $data->get($d, $p, 'dphase'),
129 "\n"
130 ));
131 };
132 };
133 $notes{$which} -> insert('end', "\n");
134 $notes{$which} -> insert('end', "\n");
135 };
136 last SWITCH;
137 };
138 ## operational view
139 ($log_type[1] eq 'operational') and do {
140 my $data = Ifeffit::ArtemisLog -> new($log);
141 ## header
142 $notes{$which} -> insert('end', $data->header);
143 my $was_sum = grep {/Fitting was not performed./} ($data->get('warnings'));
144 $notes{$which} -> insert('end', $data->stats) unless $was_sum;
145 foreach my $d ($data->list('data')) {
146 $notes{$which} -> insert('end', $data->dataparams($d,0));
147 }
148 last SWITCH;
149 };
150 };
151 $top -> Unbusy unless $is_busy;
152 };
153
154 sub set_log_style {
155 return ('Raw log file', 'raw') if ($_[0] eq 'raw');
156 return ('Quick view', 'quick') if ($_[0] eq 'quick');
157 return ('Column view', 'column') if ($_[0] eq 'column');
158 };
159
160
161 ## END OF THE LOG SUBSYSTEM
162