24
24
##my $athena_fh = *ORIG;
25
25
my @athena_index = ();
26
my %athena_group = ();
29
31
while ($athena_fh->gzreadline($line) > 0) {
31
33
next unless ($line =~ /^\$old_group/);
32
34
push @athena_index, $nline;
35
## need to make a map to the groups by old group name so that
36
## background removal with a standard can be performed correctly
37
$ {$cpt->varglob('old_group')} = $cpt->reval( $line );
38
my $og = $ {$cpt->varglob('old_group')};
39
$athena_group{$og} = {index=>$nline, hlist=>0};
34
41
$athena_fh->gzclose();
50
57
$current_canvas = 'athena';
52
my $canvas = $fat -> Canvas(-relief=>'flat',
55
-highlightcolor=>$config{colors}{background})
58
my $ath = $canvas -> Frame(-relief=>'flat',
60
-highlightcolor=>$config{colors}{background});
61
$canvas -> createWindow(0,0, -anchor=>'nw', -window => $ath, @window_size);
59
my $ath = $fat -> Frame(-relief=>'flat',
61
-highlightcolor=>$config{colors}{background})
62
-> pack(-fill=>'both', -expand=>1);
63
64
my $frm = $ath -> Frame() -> pack(-side=>'top', -anchor=>'w', -padx=>6);
72
73
$widgets{athena_return} = $ath -> Button(-text=>'Cancel and return to the main window', @button3_list,
73
74
#-background=>$config{colors}{background},
74
75
#-activebackground=>$config{colors}{activebackground},
75
-command=>sub{$canvas->packForget;
76
-command=>sub{$ath->packForget;
76
77
$current_canvas = "";
77
78
$edit_menu -> menu -> entryconfigure(13, -state=>'normal');
78
79
&display_properties;
94
95
-background=>'white',
95
96
-selectbackground=>$config{colors}{selected},
96
-browsecmd=>sub{athena_plot($hlist, $prjfile)},
97
-browsecmd=>sub{athena_plot($hlist, $prjfile, \%athena_group)},
98
99
-> pack(-expand=>1, -fill=>'y');
99
100
$hlist->Subwidget("xscrollbar")->configure(-background=>$config{colors}{background},
132
133
-selectcolor => $config{colors}{check},
133
134
-font => $config{fonts}{med},
134
135
-variable => \$ath_params{plot},
135
-command => sub{athena_plot($hlist, $prjfile)});
136
-command => sub{athena_plot($hlist, $prjfile, \%athena_group)});
137
138
$fr = $labframe -> LabFrame(-label=>'Plot as ... ',
138
139
-labelside=>'acrosstop',
191
192
my $old_group = "";
192
193
my $line_number = 1;
194
foreach my $i (@athena_index) {
195
#foreach my $i (@athena_index) {
196
foreach my $g (sort {$athena_group{$a}{index} <=> $athena_group{$b}{index}} keys(%athena_group)) {
197
my $i = $athena_group{$g}{index};
195
198
my %args = athena_get_array($prjfile, $i, "args");
196
199
$args{label} =~ s{[\"\']}{}g;
197
200
next unless ($args{is_xmu} or $args{is_chi});
198
201
$hlist -> add($i, -data=>$i);
199
202
$hlist -> itemCreate($i, 0, -text=>$args{label});
203
$athena_group{$g}{hlist} = $i;
201
205
$hlist -> anchorSet($athena_index[0]);
202
206
$hlist -> selectionSet($athena_index[0]);
203
athena_plot($hlist, $prjfile);
207
athena_plot($hlist, $prjfile, \%athena_group);
205
209
## set_fit_button('fit');
250
254
my $n = $_[0]->info('anchor');
251
255
my $i = $_[0]->info('data', $n);
252
256
my $prjfile = $_[1];
257
my $r_athena_group = $_[2];
259
my $gname = "a___thena" ;
261
$n = $r_athena_group->{$noplot}->{hlist};
262
$i = $_[0]->info('data', $n);
263
$gname = "st___andard";
254
266
## get the args hash
255
267
my %args = athena_get_array($prjfile, $i, "args");
269
281
$widgets{athena_titles} -> insert('end', $l.$/);
272
$paths{data0}->dispose("##\n## reading Athena record \"$title\" into group a___thena:", $dmode);
284
$paths{data0}->dispose("erase \@group $gname\n");
285
$paths{data0}->dispose("##\n## reading Athena record \"$title\" into group $gname:", $dmode);
273
286
$paths{data0}->dispose("set \&status=0", $dmode);
274
287
if ($args{is_xmu}) {
275
Ifeffit::put_array("a___thena.energy", \@x);
276
Ifeffit::put_array("a___thena.xmu", \@y);
288
Ifeffit::put_array($gname.".energy", \@x);
289
Ifeffit::put_array($gname.".xmu", \@y);
290
#Ifeffit::ifeffit("newplot($gname.energy, $gname.xmu)\n");
291
#print join(" ", %args), $/;
277
293
$args{bkg_clamp1} = $clamp{$args{bkg_clamp1}};
278
294
$args{bkg_clamp2} = $clamp{$args{bkg_clamp2}};
279
my $spline = "a___thena.energy, a___thena.xmu, e0=$args{bkg_e0}, ";
296
my $stan_string = q{};
297
if ($args{bkg_stan} ne 'None') {
298
athena_plot($_[0], $_[1], $r_athena_group, $args{bkg_stan});
299
$stan_string = "k_std=st___andard.k, chi_std=st___andard.chi, ";
300
## need to remove background function from standard if standard
304
my $spline = "$gname.energy, $gname.xmu, e0=$args{bkg_e0}, ";
280
305
$spline .= "rbkg=$args{bkg_rbkg}, kmin=$args{bkg_spl1}, ";
281
306
$spline .= "kmax=$args{bkg_spl2}, kweight=$args{bkg_kw}, ";
282
307
$spline .= "dk=$args{bkg_dk}, kwindow=$args{bkg_win}, pre1=$args{bkg_pre1}, ";
283
308
$spline .= "pre2=$args{bkg_pre2}, norm1=$args{bkg_nor1}, norm2=$args{bkg_nor2}, ";
284
309
$spline .= "clamp1=$args{bkg_clamp1}, clamp2=$args{bkg_clamp2}, nclamp=5, ";
310
$spline .= $stan_string;
285
311
$spline .= "interp=quad)\n";
286
312
$spline = wrap("spline(", " ", $spline);
287
313
## remove the background and plot the data
289
315
$paths{data0}->dispose($spline, $dmode);
290
316
my $status = Ifeffit::get_scalar('&status');
291
317
$paths{data0}->dispose($spline, $dmode) if ($status > 1);
318
#Ifeffit::ifeffit("newplot($gname.k, $gname.k*$gname.chi)\n");
292
320
$paths{data0}->dispose("set \&status=0", $dmode);
294
Ifeffit::put_array("a___thena.k", \@x);
295
Ifeffit::put_array("a___thena.chi", \@y);
322
Ifeffit::put_array("$gname.k", \@x);
323
Ifeffit::put_array("$gname.chi", \@y);
326
$top -> Unbusy, return if $noplot;
300
328
## plot this in k-space
301
329
if ($ath_params{plot} eq 'chi') {
315
343
} elsif ($ath_params{plot} =~ /chir/) {
318
$ylabel = sprintf("|\\gx(R)| (\\A\\u-%s\\d)", $args{fft_kw}+1),
346
$ylabel = sprintf("|\\gx(R)| (\\A\\u-%s\\d)", $plot_features{kweight}+1),
319
347
last SWITCH if ($ath_params{plot} =~ /mag$/);
320
$ylabel = sprintf("Re[\\gx(R)] (\\A\\u-%s\\d)", $args{fft_kw}+1),
348
$ylabel = sprintf("Re[\\gx(R)] (\\A\\u-%s\\d)", $plot_features{kweight}+1),
321
349
last SWITCH if ($ath_params{plot} =~ /re$/);
322
$ylabel = sprintf("Im[\\gx(R)] (\\A\\u-%s\\d)", $args{fft_kw}+1),
350
$ylabel = sprintf("Im[\\gx(R)] (\\A\\u-%s\\d)", $plot_features{kweight}+1),
323
351
last SWITCH if ($ath_params{plot} =~ /im$/);
325
my $fft = "a___thena.chi, k=a___thena.k, kweight=$args{fft_kw}, ";
353
my $fft = "a___thena.chi, k=a___thena.k, kweight=$plot_features{kweight}, ";
326
354
$fft .= "kmin=$args{fft_kmin}, kmax=$args{fft_kmax}, ";
327
355
$fft .= "dk=$args{fft_dk}, kwindow=$args{fft_win})\n";
328
356
$fft = wrap("fftf(", " ", $fft);
340
$ylabel = sprintf("|\\gx(q)| (\\A\\u-%s\\d)", $args{fft_kw}),
368
$ylabel = sprintf("|\\gx(q)| (\\A\\u-%s\\d)", $plot_features{kweight}),
341
369
last SWITCH if ($ath_params{plot} =~ /mag$/);
342
$ylabel = sprintf("Re[\\gx(q)] (\\A\\u-%s\\d)", $args{fft_kw}),
370
$ylabel = sprintf("Re[\\gx(q)] (\\A\\u-%s\\d)", $plot_features{kweight}),
343
371
last SWITCH if ($ath_params{plot} =~ /re$/);
344
$ylabel = sprintf("Im[\\gx(q)] (\\A\\u-%s\\d)", $args{fft_kw}),
372
$ylabel = sprintf("Im[\\gx(q)] (\\A\\u-%s\\d)", $plot_features{kweight}),
345
373
last SWITCH if ($ath_params{plot} =~ /im$/);
347
my $fft = "a___thena.chi, k=a___thena.k, kweight=$args{fft_kw}, ";
375
my $fft = "a___thena.chi, k=a___thena.k, kweight=$plot_features{kweight}, ";
348
376
$fft .= "kmin=$args{fft_kmin}, kmax=$args{fft_kmax}, ";
349
377
$fft .= "dk=$args{fft_dk}, kwindow=$args{fft_win})\n";
350
378
$fft = wrap("fftf(", " ", $fft);
381
409
-title => 'Athena: Reading data',
382
410
-buttons => [qw/Change New Cancel/],
383
411
-default_button => 'Change',
412
-font => $config{fonts}{med},
384
413
-popover => 'cursor');
386
415
$response = $dialog->Show();
420
449
$erase .= "erase \$athena_title_$i\n";
423
(my $fname = $args{label}) =~ s/[.:@&\/\\ ]/_/g;
452
(my $fname = $args{label}) =~ s/[.,:@&\/\\ ]/_/g;
424
453
my $file = File::Spec->catfile($project_folder, "chi_data", $fname.".chi");
425
454
$paths{data0}->dispose("write_data(file=$file,\n a___thena.k, a___thena.chi, \$athena_title_*)", $dmode);
426
455
if ($args{is_xmu}) {
427
456
my $file = File::Spec->catfile($project_folder, "chi_data", $fname.".xmu");
428
457
$paths{data0}->dispose("write_data(file=$file,\n a___thena.energy, a___thena.xmu, \$athena_title_*)", $dmode);
430
460
$group = ($response eq 'Change') ?
431
461
read_data($paths{$current}->data, $file, 1) :
432
462
read_data(0, $file, 1);