Debian Codegraph @

artemis_parts/data.pl

raw
1 # -*- cperl -*-
2 ## This file is part of Artemis, copyright (c) 2002-2010 Bruce Ravel
3 ##
4
5 ###===================================================================
6 ### dealing with data
7 ###===================================================================
8
9
10 ## return the name of the data at the top of the paths list
11 sub first_data {
12 foreach my $d (&all_data) {
13 return $d if ($paths{$d}->get('include'));
14 };
15 return 'data0';
16 };
17
18 sub next_data {
19 my $next = -1;
20 foreach my $d (keys %paths) {
21 next unless (ref($paths{$d}) =~ /Ifeffit/);
22 next unless ($paths{$d}->type eq 'data');
23 my $this = $1 if ($d =~ /^data(\d+)$/);
24 ($next = $this) if ($this > $next);
25 };
26 return ($paths{'data'.$next}->{file}) ? $next+1 : $next;
27 };
28
29
30 ## return a list of all data sets included in the fit
31 sub all_data {
32 my @list = (sort (grep {$paths{$_}->get('include')} (grep /^data(\d+)$/, (keys %paths) )));
33 my %hash = ();
34 foreach my $d (@list) {
35 (my $key = $d) =~ s{\Adata}{};
36 $hash{$key} = $d;
37 };
38 @list = @hash{sort {$a <=> $b} keys(%hash)};
39 #print "all ", join(" ", @list), $/;
40 return @list;
41 };
42
43 ## return a list of every data in %paths regardless of whether it is
44 ## included in the fit
45 sub every_data {
46 my @list = (sort (grep /^data(\d+)$/, (keys %paths) ));
47 my %hash = ();
48 foreach my $d (@list) {
49 (my $key = $d) =~ s{\Adata}{};
50 $hash{$key} = $d;
51 };
52 @list = @hash{sort {$a <=> $b} keys(%hash)};
53 #print "every ", join(" ", @list), $/;
54 return @list;
55 };
56
57 ## return a list of all feff calculations associated with the
58 ## specified data set
59 sub data_feff {
60 my $this = shift;
61 my @list = ();
62 foreach my $p (&path_list) {
63 next unless (ref($paths{$p}) =~ /Ifeffit/);
64 next unless $paths{$p}->type;
65 next unless ($paths{$p}->type eq 'feff');
66 next unless ($paths{$p}->data eq $this);
67 push(@list, $p);
68 };
69 return @list;
70 };
71
72 ## return a list of all included paths associated with the specified
73 ## data set
74 sub data_paths {
75 my $this = shift;
76 my @list = ();
77 foreach my $p (&path_list) {
78 next unless (ref($paths{$p}) =~ /Ifeffit/);
79 next unless ($paths{$p}->type eq 'path');
80 next unless ($paths{$p}->data eq $this);
81 next unless $paths{$p}->get('include');
82 push(@list, $p);
83 };
84 return @list;
85 };
86
87 sub rename_data {
88 Error("There is no data."), return unless $n_data;
89 my $this = $current;
90 $this = $paths{$current}->data;
91 ##($this = $paths{$current}->{data}) if (exists $paths{$current}->{data});
92 ##($this = &first_data) if ($current eq 'gsd');
93 my $oldname = $paths{$this}->get('lab');
94 my $newname = $oldname;
95 my $label = "New name for data \"$oldname\": ";
96 my $dialog = get_string($dmode, $label, \$newname, \@rename_buffer);
97 $dialog -> waitWindow; # the get_string dialog will be
98 # destroyed once the user hits ok,
99 # then we can move on...
100 Echo("Not renaming ". $paths{$this}->get('lab')), return if ($oldname eq $newname);
101 $newname =~ s{[\"\']}{}g;
102 my $exists = 0;
103 foreach my $d (&every_data) {
104 $exists = 1, last if ($newname eq $paths{$d}->get('lab'));
105 };
106 Error("There is already a data set named \"$newname\"!"), return if $exists;
107 project_state(0);
108 push @rename_buffer, $newname;
109 $paths{$this} -> make(lab=>$newname);
110 $list -> itemConfigure($this, 0, -text=>$newname);
111 };
112
113
114 sub toggle_data {
115 my $data = $_[0];
116 my $style = ($paths{$data}->get('include')) ? $list_styles{enabled} : $list_styles{disabled};
117 $list -> entryconfigure($data, -style => $style);
118 foreach my $p (keys %paths) {
119 next unless (ref($paths{$p}) =~ /Ifeffit/);
120 next unless $paths{$p}->type;
121 SWITCH: {
122 ($paths{$p}->type =~ /(bkg|data|fit|res)/) and do {
123 last SWITCH unless ($paths{$p}->get('sameas') eq $data);
124 last SWITCH unless $list->infoExists($paths{$p}->get('id'));
125 my $style = ($paths{$data}->get('include')) ? $list_styles{enabled} : $list_styles{disabled};
126 $list -> entryconfigure($paths{$p}->get('id'), -style => $style);
127 last SWITCH;
128 };
129 ($paths{$p}->type eq 'feff') and do {
130 last SWITCH unless ($paths{$p}->data eq $data);
131 my $style = ($paths{$data}->get('include')) ? $list_styles{noplot} : $list_styles{noplotdis};
132 $list -> entryconfigure($paths{$p}->get('id'), -style => $style);
133 last SWITCH;
134 };
135 ($paths{$p}->type eq 'path') and do {
136 last SWITCH unless ($paths{$p}->data eq $data);
137 my $style = $list_styles{$paths{$data}->pathstate("enabled")};
138 $style = $list_styles{$paths{$data}->pathstate("disabled")} if (not $paths{$data}->get('include'));
139 $style = $list_styles{$paths{$data}->pathstate("disabled")} if ($paths{$data}->get('include') and
140 not $paths{$p}->get('include'));
141 $list -> entryconfigure($paths{$p}->get('id'), -style => $style);
142 last SWITCH;
143 };
144 };
145 };
146 if ($paths{$current}->type =~ /(bkg|data|diff|fit|res)/) {
147 my @all = &every_data;
148 $widgets{op_do_bkg} -> configure(-state=>($#all) ? 'disabled' : 'normal' );
149 ##$widgets{op_use_bkg} -> configure(-state=>($#all) ? 'disabled' : 'normal' );
150 };
151 project_state(0);
152 };
153
154
155 sub make_difference_spectrum {
156 my $this = $paths{$current}->data;
157 unless (-e $paths{$this}->get('file')) {
158 Error("You have not yet imported this data file.");
159 return;
160 };
161 unless ($list->info(exists=>$paths{$this}->get('id').'.0')) {
162 Error("You have not yet done a fit. You cannot yet make a difference spectrum.");
163 return;
164 };
165
166 my @paths = grep {(ref($paths{$_}) =~ /Ifeffit/) and
167 ($paths{$_}->type eq 'path')} $list->info('selection');
168 Error("You did not select any paths. The difference spectrum is computed from the set of highlighted paths."),
169 return unless @paths;
170 $top -> Busy;
171 my $not_from_this = 0;
172 foreach (@paths) {
173 ++$not_from_this if ($paths{$_}->data ne $this);
174 };
175 if ($not_from_this) {
176 my $dialog =
177 $top -> Dialog(-bitmap => 'questhead',
178 -text => "You have selected paths not associated with the current data set. Do you want to continue making the difference spectrum?",
179 -title => 'Athena: Question...',
180 -buttons => [qw/Yes No/],
181 -default_button => 'No',
182 -font => $config{fonts}{med},
183 -popover => 'cursor');
184 &posted_Dialog;
185 my $response = $dialog->Show();
186 if ($response eq 'No') {
187 Echo("Difference spectrum aborted");
188 $top -> Unbusy;
189 return;
190 };
191 };
192
193 my $explanation = "Difference between " . $paths{$this}->descriptor() .
194 " and these paths:\n";
195 my $string = "## Making difference spectrum from data ";
196 $string .= $paths{$this}->descriptor() . $/;
197 $paths{$this} -> make(diff_paths=>[], diff_list=>[], diff_mapping=>[]);
198 foreach my $p (sort {(split(/\./,$a))[0] cmp (split(/\./,$b))[0]
199 or
200 (split(/\./,$a))[1] cmp (split(/\./,$b))[1]
201 or
202 (split(/\./,$a))[2] <=> (split(/\./,$b))[2]
203 } @paths) { # make sure they are in order
204 next unless ($paths{$p}->get('include')); # skip paths deselected for fit
205 my $ind = $paths{$p}->index;
206 my $data = $paths{$p}->data;
207 my $pathto = $paths{$p}->get('path');
208 ## need to keep track of which paths went into this diff spectrum
209 ## so they can be deselected for a fit to the diff spectrum
210 push @{$paths{$data}->{diff_paths}}, $p;
211 push @{$paths{$data}->{diff_list}}, $ind;
212 $paths{$data}->{diff_mapping}->[$ind] = $p;
213 $string .= $paths{$p} -> write_path($ind, $pathto, $config{paths}{extpp}, $stash_dir);
214 $explanation .= ".\t" . $paths{$p}->descriptor() . $/;
215 };
216
217 ## do an ff2chi on the selected paths
218 my $group = $paths{$this}->get('group');
219 $string .= $paths{$this} ->
220 write_ff2chi( &normalize_paths($paths{$this}->{diff_list}), $group."_sum" );
221
222 ## make the difference spectrum
223 $string .= "set ${group}_diff.k = $group.k\n";
224 if ((lc($paths{$this}->get('do_bkg')) eq 'yes') or $paths{$this}->get('use_bkg')) {
225 $string .= "set ${group}_diff.chi = $group.chi - ${group}_sum.chi - ${group}_bkg.chi\n";
226 } else {
227 $string .= "set ${group}_diff.chi = $group.chi - ${group}_sum.chi\n";
228 };
229
230 ## get the filename to save this diff spectrum to
231 my $types = [['chi Files', '*.chi'],
232 ['All Files', '*'],];
233 my $path = File::Spec->catfile($project_folder, "chi_data", "");
234 my $fname = basename($paths{$this}->get('file'));
235 my @list = split(/\./, $fname);
236 $fname = $list[0] . "_diff." . $list[1];
237 my $file = $top -> getSaveFile(-filetypes=>$types,
238 #(not $is_windows) ?
239 # (-sortcmd=>sub{$Tk::FBox::a cmp $Tk::FBox::b}) : () ,
240 -initialdir=>$path,
241 -initialfile=>$fname,
242 -title => "Artemis: Save difference spectrum");
243 $top -> Unbusy, return unless $file;
244 ## fetch the titles for this data
245 my $titles = $widgets{op_titles}->get(qw(1.0 end));
246 my $n = 1;
247 foreach my $e (split(/\n/, $explanation)) {
248 $string .= "\$artemis_title$n = \"$e\"\n";
249 ++$n;
250 };
251 foreach my $t (split(/\n/,$titles)) {
252 next if ($t =~ /^\s*$/);
253 $string .= "\$artemis_title$n = \"$t\"\n";
254 ++$n;
255 };
256 $string .= "\$artemis_title$n = \"artemis: " . $paths{$this}->get('lab') . " as background subtracted chi(k)\"\n";
257 ## write and erase the difference data
258 $string .= "write_data(file=$file,\n" .
259 wrap(" ", " ", "\$artemis_title*, ${group}_diff.k, ${group}_diff.chi)");
260 $string .= "\n";
261 $string .= "erase \@group ${group}_diff\n";
262 $paths{$this} -> dispose($string, $dmode);
263
264 ## offer to reload the bkg sub data
265 my $dialog =
266 $top -> Dialog(-bitmap => 'questhead',
267 -text => "Would you like to replace the current data set with the difference spectrum?",
268 -title => 'Athena: Replace data?',
269 -buttons => [qw/Yes No/],
270 -default_button => 'Yes',
271 -font => $config{fonts}{med},
272 -popover => 'cursor');
273 &posted_Dialog;
274 if ($dialog->Show() eq 'Yes') {
275 $paths{$this}->make(do_bkg=>'no');
276 &read_data($paths{$current}->data, $file, 1);
277 ## need to uninclude the paths that went into the diff spectrum
278 foreach my $p (@paths) {
279 &select_paths('toggle', $p, 1)
280 };
281 };
282 $top -> Unbusy;
283 Echo("Saved difference spectrum to $file");
284 };
285
286
287
288
289 sub delete_data {
290 my $data = $paths{$current}->data;
291 my $label = $paths{$data}->get('lab');
292
293 Error("You cannot discard the first data set. Try changing the data via the \"Open data file\" in the Data menu."),
294 return if ($data eq 'data0');
295 my $dialog =
296 $top -> Dialog(-bitmap => 'questhead',
297 -text => "Are you sure you want to discard \"$label\" and all it's paths?",
298 -title => 'Artemis: Verifying...',
299 -buttons => [qw/Discard Cancel/],
300 -default_button => 'Discard',
301 -font => $config{fonts}{med},
302 -popover => 'cursor');
303 &posted_Dialog;
304 my $response = $dialog->Show();
305 Echo("Not discarding \"$label\""), return unless ($response eq 'Discard');
306 Echo("Discarding \"$label\" and all its paths ... ");
307
308 ## discard titles for this data group
309 $paths{$data}->delete_titles;
310
311 my $first = &first_data;
312 ($first = 'data0') if ($first eq $data);
313 $paths{$first}->make(include=>1), &toggle_data($first) unless $paths{$first}->included;
314 display_page($first);
315
316 $list -> delete('offsprings', $data);
317 $list -> delete('entry', $data);
318 my (@delete_em, @rmtree);
319 foreach my $k (keys %paths) {
320 #print $k, $/;
321 #next unless exists($paths{$k});
322 next unless (ref($paths{$k}) =~ /Ifeffit/);
323 next unless $paths{$k}->type;
324 ## push(@delete_em, $k) if ($k eq $data);
325 ## push(@rmtree, $k) if (($paths{$k}->type eq 'feff') and ($k =~ /^$data/));
326 push(@delete_em, $k) if ($paths{$k}->data eq $data);
327 ## if (exists $paths{$k}->{data}) {
328 ## push(@delete_em, $k) if ($paths{$k}->data eq $data);
329 ## };
330 ## if (exists $paths{$k}->{sameas}) {
331 ## push(@delete_em, $k) if ($paths{$k}->{sameas} eq $data);
332 ## };
333 };
334 map { delete $paths{$_} } @delete_em;
335 map { rmtree(File::Spec->catfile($project_folder, $_)) } @rmtree;
336
337 ## deactivate these two checkbuttons if we now have only one active
338 ## data set
339 my $n = 0; map {++$n} (&all_data);
340 if ($n == 1) {
341 $widgets{op_include} -> configure(-state=>'disabled');
342 $widgets{op_plot} -> configure(-state=>'disabled');
343 };
344
345 ## is at least one data set included in the fit?
346 my $ok = 0;
347 foreach my $d (&all_data) {
348 $ok++ if $paths{$d}->get('include');
349 };
350 ## if not, turn on data0
351 unless ($ok) {
352 $paths{data0}->make(include=>1);
353 toggle_data('data0');
354 #foreach my $p (keys %paths) {
355 # next unless ($paths{$p}->get('parent') eq 'data0');
356 # next unless ($paths{$p}->type eq 'feff');
357 # $paths{$p}->make(include=>1);
358 #};
359 };
360
361 Echo("Discarding \"$label\" and all its paths ... done!");
362 };
363
364 sub nidp {
365 Error("You have not opened a data file yet."), return unless $paths{&first_data}->get('file');
366 my ($nidp, $ndat) = (0, 0);
367 foreach my $k (keys %paths) {
368 next unless (ref($paths{$k}) =~ /Ifeffit/);
369 next unless ($paths{$k}->type eq 'data');
370 next unless ($paths{$k}->{include});
371 my $deltak = $paths{$k}->get('kmax') - $paths{$k}->get('kmin');
372 my $deltar = $paths{$k}->get('rmax') - $paths{$k}->get('rmin');
373 $nidp += int( 2 * $deltak * $deltar / PI );
374 ++$ndat;
375 };
376 ($nidp = 0) if ($nidp < 0);
377 my $nvar = 0;
378 foreach (@gds) {
379 ++$nvar if ($_->type eq 'guess');
380 };
381 my $message = "$nidp independent points data points (Nyquist): ($ndat data set";
382 $message .= ($ndat > 1) ? "s)" : ")";
383 $message .= " ($nvar variable";
384 $message .= ($nvar > 1) ? "s)" : ")";
385 $props{'Information content'} = $message;
386 Echo($message);
387 };
388
389
390 sub fetch_epsilon_k {
391 Error("You have not opened a data file yet."), return unless $paths{&first_data}->get('file');
392 my $this = $paths{$current}->data;
393 my $lab = $paths{$this}->descriptor;
394 my @noise = $paths{$this}->chi_noise;
395 Echo(sprintf("The noise in k for \"$lab\" is %.7f and in R is %.7f", @noise));
396 };
397
398
399 ## this currently only works on the most recent fit -- need to
400 ## generalize to all fits...
401 sub running_r_factor {
402 Error("You have not opened a data file yet."), return unless $paths{&first_data}->get('file');
403 my $space = $_[0];
404
405 ## presumably, the current is a fit and not the head of the branch
406 my $this = $paths{$current}->data;
407
408 my (@x, @y, $max_y);
409
410
411 ## before doing this, shift anchor from head of fit branch to latest
412 my $data = $paths{$current}->data;
413 my $which = (($paths{$current}->type eq 'fit') and $paths{$current}->get('parent')) ?
414 $current :
415 $paths{$data.".0"}->get('thisfit');
416 display_page($which);
417 $top -> update;
418
419 ## plot the data and fit for this data set
420 my $group = $paths{$this}->get('group');
421 $list -> selectionSet($this);
422 &plot($space, 0);
423
424 ## compute the running r-factor in the appropriate space
425 my ($datasum, $diffsum, $ndata) = (0, 0, 0);
426 if (lc($space) eq 'k') {
427 my $kw = $plot_features{kweight};
428 my @k = Ifeffit::get_array($group.".k");
429 my @chi = Ifeffit::get_array($group.".chi");
430 unless ($paths{$current}->get('imported')) {
431 ## read this fit into its group if it has not already been imported
432 my $command = "read_data(file=\"" .
433 $paths{$current}->get('fitfile') .
434 "\",\n" .
435 " type=chi, group=". $paths{$current}->get('group') . ")\n";
436 $paths{$current}->dispose($command, $dmode);
437 $paths{$current}->make(imported=>1);
438 };
439 my @fit = Ifeffit::get_array($paths{$current}->get('group').".chi");
440 foreach (0 .. $#k) {
441 if ($k[$_] < $paths{$this}->get('kmin')) {
442 push @x, 0;
443 push @y, 0;
444 next;
445 };
446 last if ($k[$_] > $paths{$this}->get('kmax'));
447 ##$datasum += $chi[$_]**2;
448 $diffsum += ($chi[$_]*$k[$_]**$kw - $fit[$_]*$k[$_]**$kw)**2;
449 push @x, $k[$_];
450 push @y, $diffsum;
451 ##++$ndata;
452 };
453 $paths{$this} -> dispose("___x = ceil($group.chi*$group.k^$kw)", 1);
454 $max_y = Ifeffit::get_scalar("___x");
455 } elsif (lc($space) eq 'r') {
456 my @r = Ifeffit::get_array($group.".r");
457 my @chi = Ifeffit::get_array($group.".chir_re");
458 my @chi2 = Ifeffit::get_array($group.".chir_im");
459 unless ($paths{$current}->get('imported')) {
460 ## read this fit into its group if it has not already been imported
461 my $command = "read_data(file=\"" .
462 $paths{$current}->get('fitfile') .
463 "\",\n" .
464 " type=chi, group=". $paths{$current}->get('group') . ")\n";
465 $paths{$current}->dispose($command, $dmode);
466 $paths{$current}->make(imported=>1);
467 };
468 $paths{$current}->dispose($paths{$current}->write_fft(0,$config{data}{rmax_out}), $dmode);
469 my @fit = Ifeffit::get_array($paths{$current}->get('group').".chir_re");
470 my @fit2 = Ifeffit::get_array($paths{$current}->get('group').".chir_im");
471 my $rmin = $paths{$this}->get('rmin');
472 ($rmin = 0) if (lc($paths{$this}->get('do_bkg')) eq 'yes');
473 foreach (0 .. $#r) {
474 if ($r[$_] < $rmin) {
475 push @x, 0;
476 push @y, 0;
477 next;
478 };
479 last if ($r[$_] > $paths{$this}->get('rmax'));
480 ##$datasum += $chi[$_]**2 + $chi2[$_]**2;
481 $diffsum += ($chi[$_]-$fit[$_])**2 + ($chi2[$_]-$fit2[$_])**2;
482 push @x, $r[$_];
483 push @y, $diffsum;
484 ##++$ndata;
485 };
486 $paths{$this} -> dispose("set ___x = ceil($group.chir_mag)", 1);
487 $max_y = Ifeffit::get_scalar("___x");
488 } elsif (lc($space) eq 'q') {
489 my @q = Ifeffit::get_array($group.".q");
490 my @chi = Ifeffit::get_array($group.".chiq_re");
491 my @chi2 = Ifeffit::get_array($group.".chiq_im");
492 unless ($paths{$current}->get('imported')) {
493 ## read this fit into its group if it has not already been imported
494 my $command = "read_data(file=\"" .
495 $paths{$current}->get('fitfile') .
496 "\",\n" .
497 " type=chi, group=". $paths{$current}->get('group') . ")\n";
498 $paths{$current}->dispose($command, $dmode);
499 $paths{$current}->make(imported=>1);
500 };
501 $paths{$current}->dispose($paths{$current}->write_fft(0,$config{data}{rmax_out}), $dmode);
502 $paths{$current}->dispose($paths{$current}->write_bft, $dmode);
503 my @fit = Ifeffit::get_array($paths{$current}->get('group').".chiq_re");
504 my @fit2 = Ifeffit::get_array($paths{$current}->get('group').".chiq_im");
505 foreach (0 .. $#q) {
506 if ($q[$_] < $paths{$this}->get('kmin')) {
507 push @q, 0;
508 push @y, 0;
509 next;
510 };
511 last if ($q[$_] > $paths{$this}->get('kmax'));
512 ##$datasum += $chi[$_]**2 + $chi2[$_]**2;
513 $diffsum += ($chi[$_]-$fit[$_])**2 + ($chi2[$_]-$fit2[$_])**2;
514 push @x, $q[$_];
515 push @y, $diffsum;
516 ##++$ndata;
517 };
518 $paths{$this} -> dispose("___x = ceil($group.chiq_mag)", 1);
519 $max_y = Ifeffit::get_scalar("___x");
520 };
521
522 ## normalize the running r-factor to the data
523 my $scale = $max_y / $y[$#y];
524 foreach my $i (0 .. $#y) {
525 $y[$i] *= $scale;
526 };
527
528 ## load the arrays into ifeffit
529 Ifeffit::put_array('r___unning.x', \@x);
530 Ifeffit::put_array('r___unning.y', \@y);
531
532 my $color = ($plot_features{win}) ? 'c3' : 'c2';
533 ## plot the running r-factor over the data+fit
534 my $message = "r___unning.x, r___unning.y, key=\"running R-factor\", ";
535 $message .= "color=$config{plot}{$color}, style=lines, ";
536 $message .= "title=\"Running R-factor, " . $paths{$this}->get('lab') . ", and fit\")";
537 $message = wrap("plot(", " ", $message);
538 $paths{$this}->dispose($message, $dmode);
539
540 };
541
542
543 sub verify_data_parameters {
544 my $message = "";
545 foreach my $d (&all_data) {
546
547 $message .= $paths{$d}->get('lab') . ": kmin is greater than kmax\n"
548 if ($paths{$d}->get('kmin') > $paths{$d}->get('kmax'));
549
550 $message .= $paths{$d}->get('lab') . ": kmax is zero\n"
551 if ($paths{$d}->get('kmax') < EPSILON);
552
553 $message .= $paths{$d}->get('lab') . ": rmin is greater than rmax\n"
554 if ($paths{$d}->get('rmin') > $paths{$d}->get('rmax'));
555
556 $message .= $paths{$d}->get('lab') . ": rmax is zero\n"
557 if ($paths{$d}->get('rmax') < EPSILON);
558
559 };
560 return $message;
561 };
562
563 sub verify_reffs {
564 my $message = "";
565 foreach my $d (&all_data) {
566 my $this_rmax = $paths{$d}->get('rmax');
567 my $this_ok = 1;
568 foreach my $p (&path_list) {
569 next unless (ref($paths{$p}) =~ /Ifeffit/);
570 next unless ($paths{$p}->type eq 'path');
571 next unless ($paths{$p}->get('data') eq $d);
572 next unless ($paths{$p}->get('include'));
573 if ( $paths{$p}->get('reff') > $this_rmax*$config{warnings}{reff_margin} ) {
574 $message .= "\t" . $paths{$p}->descriptor . "\n";
575 $this_ok = 0;
576 };
577 };
578 unless ($this_ok) {
579 $message = "Artemis found one or more paths that are far outside the fitting range:\n" . $message;
580 $message .= "Check the R-range of data set \"" . $paths{$d}->descriptor . "\"\n\n";
581 };
582 };
583 return $message;
584 };
585
586 sub verify_rmin_rbkg {
587 my $message = "";
588 foreach my $d (&all_data) {
589 my $this_rmin = $paths{$d}->get('rmin');
590 my $this_rbkg = $paths{$d}->get('bkg_rbkg');
591 next unless $this_rbkg;
592 if ($this_rmin < $this_rbkg) {
593 $message .= "\nThe value of rmin for \"" . $paths{$d}->descriptor . "\" is smaller than the value of\n";
594 $message .= "Rbkg used during background removal in Athena.\n";
595 $message .= " rmin = $this_rmin Rbkg = $this_rbkg\n";
596 };
597 };
598 if ($message) {
599 $message .= "\nLetting rmin be smaller than Rbkg is dangerous in that it masks important\n";
600 $message .= "correlations between the data and the background.\n\n";
601 };
602 return $message;
603 };
604
605 ## END OF THE DATA SUBSECTION
606