Contour plot in Xmgrace - contour

I have a data file containing 3 columns. Now I want to have a contour plot with xmgrace as I use xmgrace mostly. But somehow, I am unable to do draw it now. Can anyone help me a bit? Thanks in advance.
The data is in format shown below:
3.24 4.78 0.015776
3.24 4.80 0.011777
3.24 4.82 0.00986
3.24 4.84 0.010185
3.24 4.86 0.012515
3.26 4.78 0.009244
3.26 4.80 0.006368
3.26 4.82 0.005792
3.26 4.84 0.007121
3.26 4.86 0.010361
3.28 4.78 0.004666
3.28 4.80 0.0028
3.28 4.82 0.003017
3.28 4.84 0.005285
3.28 4.86 0.0095
3.30 4.78 0.001295
3.30 4.80 0.000557
3.30 4.82 0.001924
3.30 4.84 0.005266
3.30 4.86 0.010401
3.32 4.78 0
3.32 4.80 0.000233
3.32 4.82 0.002508
3.32 4.84 0.006666
3.32 4.86 0.012515
3.34 4.70 0.012943
3.34 4.72 0.006904
3.34 4.74 0.002791
3.34 4.76 0.000662
3.36 4.70 0.011024
3.36 4.72 0.005998
3.36 4.74 0.003063
3.36 4.76 0.001814
3.38 4.70 0.011203
3.38 4.72 0.007077
3.38 4.74 0.004755
3.38 4.76 0.004188
3.40 4.70 0.01263
3.40 4.72 0.009182
3.40 4.74 0.007685
3.40 4.76 0.007985
The final curve should be like as shown in the attachment.

A quick Google search reveals that xmgrace (a.k.a. Grace) does not support contour plots
There are a wealth of example scripts for contour plots using gnuplot, matplotlib, Origin and many more.
Here is a simple example for gnuplot using your data:
Once you have saved your data as the 3-column data file data.dat save the following as a script file:
set parametric
set contour base
set view 0,0,1
unset surface
unset key
unset ztics
set dgrid3d
set title "Simple contour plot example"
set xlabel "X"
set ylabel "Y"
set cntrparam levels 10
splot "data.dat" using 1:2:3 with line
and from the UNIX command line call gnuplot -persist scriptfile.
This gives the following output:
So, it looks like you didn't use xmgrace, you used gnuplot, and that's why you can't work out how to remake the original plot in xmgrace again!

You can plot contour lines with GraceGtk, a fork of Grace that also adds Undo functionality.
Currently, this software is available at https://sourceforge.net/projects/gracegtk/.
This answer is valid as long as GraceGtk is available for download somewhere in the Internet.
Contour plots and undo are planned features for future releases of Grace.

Related

text manipulation by addition and multiplication

I have a text file saved in the name 'test_file' that contain 6 rows and 7 columns as given below
0.00 5.8 2.0 5.0 6.0 8.0 0.0
10.00 5.8 2.0 1.0 1.0 1.2 9.6
10.00 9.3 2.2 2.0 1.4 2.5 9.6
30.00 9.3 2.2 1.2 1.5 1.9 1.4
30.00 9.3 2.2 3.2 2.4 1.2 4.1
60.00 9.8 3.5 1.4 2.7 3.2 4.5
I want to do some text manipulation in second and third column.
In the third column first two rows values should be same (2.0 and 2.0) and next three rows values are just the 0.2 increment of second row value(2.0+0.2=2.2,2.0+0.2=2.2,2.0+0.2=2.2).However, i don't want to change last row i want to keep it as it is.
After that in the second column, first two rows values should be just the multiplication of, first two rows of third column with 2.9.
similarly next three rows of second column are just the multiplication of next three rows of third column with 4.227
other columns values i don't want to change at all.
Now i want to change the first two rows value of third column sequentially, 2.1,2.2....2.5 followed by same increment and multiplication.
For example when i change first two rows values of third column from original 2.0 to 2.1 then the expected output should be
0.00 6.09 2.1 5.0 6.0 8.0 0.0
10.00 6.09 2.1 1.0 1.0 1.2 9.6
10.00 9.722 2.3 2.0 1.4 2.5 9.6
30.00 9.722 2.3 1.2 1.5 1.9 1.4
30.00 9.722 2.3 3.2 2.4 1.2 4.1
60.00 9.8 3.5 1.4 2.7 3.2 4.5
and i want to save the output file in different name such as file2.1.txt....file2.5.txt
awk to the rescue!
$ awk 'p {print p}
{pp=$0; v=$3; $3+=0.1; $2*=$3/v; p=$0}
END {print pp}' file | column -t
0.00 6.09 2.1 5.0 6.0 8.0 0.0
10.00 6.09 2.1 1.0 1.0 1.2 9.6
10.00 9.72273 2.3 2.0 1.4 2.5 9.6
30.00 9.72273 2.3 1.2 1.5 1.9 1.4
30.00 9.72273 2.3 3.2 2.4 1.2 4.1
60.00 9.8 3.5 1.4 2.7 3.2 4.5
since you want special treatment for the last record, delay processing using the previous record p, also you want unmodified last record, so store the original previous record in pp and print at the END. Delayed printing will print the modified records and last one will be unmodified.
You can specify number formatting as well but I didn't think it was important...
To run for multiple increments, just add an outer loop
$ for inc in {1..5};
do awk -v inc=$inc '...
... $3+=(inc/10) ...
...' file > file."$inc".txt
done
You can pass the increment (actually 10 times the increment) to awk script as a variable, use in in the script as well as in the output filename. The only change in the awk script is the increment.
Here's another version if you can't work with the other answer:
awk -vval=2.1 '{ # set "val" to the new value for column 3 on first two lines
if(NR==1 || NR==2) { # if it's the first or second line
$3=val; # set column 3 to val
$2=$3*2.9 # set column 2 to column 3 multiplied with 2.9
} else if(NR>=3 && NR<=5) { # else if it's line 3-5
$3=val+0.2; # set column 3 to val+0.2
$2=$3*4.227 # set column 2 to column 3 multiplied with 4.227
} else $3=$3; # just for formatting
print # print the result
}' test_file
Remove the comments (#) before you run it.
Output:
0.00 6.09 2.1 5.0 6.0 8.0 0.0
10.00 6.09 2.1 1.0 1.0 1.2 9.6
10.00 9.7221 2.3 2.0 1.4 2.5 9.6
30.00 9.7221 2.3 1.2 1.5 1.9 1.4
30.00 9.7221 2.3 3.2 2.4 1.2 4.1
60.00 9.8 3.5 1.4 2.7 3.2 4.5
To loop over a range and save it in different files you can do like below. I also made the other parameters available so you can set them when running the script:
#!/bin/bash
for val in $(seq 2.1 0.1 2.5)
do
awk -vval=$val -vfmul=2.9 -vadd=0.2 -vsmul=4.227 '{
if(NR==1 || NR==2) {
$3=val;
$2=$3*fmul
} else if(NR>=3 && NR<=5) {
$3=val+add;
$2=$3*smul
} else $3=$3;
print
}' test_file > output$val
done

Can a large amount of arguments deteriorate performance of a ksh or bash script?

I'm running a KornShell script which originally has 61 input arguments:
./runOS.ksh 2.8409 24 40 0.350 0.62917 8 1 2 1.00000 4.00000 0.50000 0.00 1 1 4900.00 1.500 -0.00800 1.500 -0.00800 1 100.00000 20.00000 4 1.0 0.0 0.0 0.0 1 90 2 0.10000 0.10000 0.10000 1.500 -0.008 3.00000 0.34744 1.500 -0.008 1.500 -0.008 0.15000 0.21715 1.500 -0.008 0.00000 1 1.334 0 0.243 0.073 0.642 0.0229 38.0 0.03071 2 0 15 -1 20 1
I only vary 6 of them. Would it make a difference in performance if I fixed the remaining 55 arguments inside the script and just call the variable ones, say:
./runOS.ksh 2.8409 24 40 0.350 0.62917 8
If anyone has a quick/general answer to this, it will be highly appreciated, since it might take me a long time to fix the 55 extra arguments inside the script and I'm afraid it won't change anything.
There's no performance impact, as you're asking, but I see other threads:
What is the commandline limitation for your system? You mention 61 input parameters, some of them having a length of 8 characters. If the number of input parameters increases, you might have problems with the maximum command length.
Are you performing 440 million scripts? That's too much, far too much. You need to consider why you're doing this: you mention needing to wait ±153 days for their execution to finish, which is far too much (and unpredictable).

GhostScript: Bug under High Sierra setting PDF Metadata?

Can anyone confirm the following behaviour on MacOS 10.13 High Sierra with GhostScript? I don't get the problem when using 10.12 Sierra.
When I create PDFs in GhostScript, it always leaves the Title, Author and other metadata blank.
I know that you can set the metadata with PDFmarks within the PostScript file itself (or a secondary merged PS file that just contains PDFmarks), but that requires manually setting the field for each file.
Currently, my PDFs fail PDF-X validation until I manually add the metadata.
My PostScript does contain DSC comments, and the GS documentation implies that this should be picked up, as ParseDSCCommentsForDocInfo is true by default.
/usr/local/bin/gs \
-dPDFX \
-dNOPAUSE \
-dBATCH \
-sDEVICE=pdfwrite \
-sOutputFile="$filename" \
-dProcessColorModel=/DeviceCMYK \
-dCompatibilityLevel=1.4 \
"$f" \
/Library/PostScript/PDFX_def.ps
The source of the PostScript does not seem to be a factor: Adobe apps like InDesign, MacOS's cgpdftops, all behave similarly.
Here's a simple test PS file. Distiller takes the comments and uses them for DocInfo; GhostScript doesn't on MacOS 10.13.
%!PS-Adobe-3.0
%%Title: (MyTitle.file)
%%Creator: (MyApp: cgpdftops CUPS filter)
%%CreationDate: (Saturday, February 03 2018 10:19:01 GMT)
%%For: (User Me)
%%BoundingBox: 36 36 576 756
%%Pages: 1
%%LanguageLevel: 2
%%EndComments
%%BeginSetup
% this is where fonts would be embedded
%%EndSetup
%%Page: (1) 1
%%BeginPageSetup
% this is where page-specific features would be specified
%%EndPageSetup
% Draw a black box around the page
0 setgray
1 setlinewidth
36 36 540 720 rectstroke
% Draw a two inch blue circle in the middle of the page
0 0 1 setrgbcolor
306 396 144 0 360 arc closepath fill
% Draw two half inch yellow circles for eyes
1 1 0 setrgbcolor
252 432 36 0 360 arc closepath fill
360 432 36 0 360 arc closepath fill
% Draw the smile
1 setlinecap
18 setlinewidth
306 396 99 200 340 arc stroke
% Print it!
showpage
%%EOF
As of MacOS Mojave 10.14.3 and GhostScript version 9.26, this now fixed. I can only presume it was a bug in GhostScript or MacOS.

Core usage in scala actor model

I just started learning scala. Is there any way to find CPU time and real time and the cores used by the program when using actor model??
Thanks in advance.
You may use a profiler such as VisualVM or more adhoc and pleasant solution: Typesafe console.
how about using the unix system time function ?
time scalac HelloWorld.scala
If you are running in Linux (specifically here I'm describing Ubuntu) mpstat is a useful program.
You can install it using the following command:
sudo apt-get install sysstat
Once installed you can run a bash script to record CPU info. In this case I'm logging 10 times a second. This will block until you press Control-C to kill the logging. (Also, consider removing the sleep 0.1; for better data.)
while x=0; do mpstat -P ALL >> cpu_log.txt; sleep 0.1; done
In another terminal you can fire off your program (or ANY program) and see track the performance data. The output looks like this:
03:21:08 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
03:21:08 PM all 0.37 0.00 0.33 0.50 0.00 0.02 0.00 0.00 98.78
03:21:08 PM 0 0.51 0.00 0.45 0.57 0.00 0.03 0.00 0.00 98.43
03:21:08 PM 1 0.29 0.00 0.26 0.45 0.00 0.01 0.00 0.00 99.00

Analyzing iostat output

I'm suffering performance issues with my application, and one of my suspects is excessive IO.
iostat shows rate of 10K blocks written per second. How can I tell if this is a lot or not? How can I know the limit of the specific machine and disk?
Edit:Following Elliot's request:
iostat output:
avg-cpu: %user %nice %system %iowait %steal %idle
16.39 0.00 0.52 11.43 0.00 71.66
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
cciss/c0d0 315.20 0.00 10341.80 0 51709
uptime:
2:08am up 17 days 17:26, 5 users, load average: 9.13, 9.32, 8.73
top:
top - 02:10:02 up 17 days, 17:27, 5 users, load average: 8.89, 9.18, 8.72
Tasks: 202 total, 2 running, 200 sleeping, 0 stopped, 0 zombie
Cpu(s): 5.9%us, 0.7%sy, 0.0%ni, 90.5%id, 2.9%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 96556M total, 15930M used, 80626M free, 221M buffers
Swap: 196615M total, 93M used, 196522M free, 2061M cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
20027 root 16 0 10.5g 9.8g 12m S 74 10.4 2407:55 /usr/intel/pkgs/java/1.6.0.31-64/jre//bin/java -server -X
Thanks
I can tell you from experience that's a very high block write rate for most systems. However, your system could be perfectly capable of handling that--depends on what kind of hardware you have. What's important is your server load figure and the iowait percentage. If your server load is high (i.e., higher than the number of cores on your system) and your load largely consists of iowait, then you have a problem.
Could you share with us the full output of iostat, uptime, and a snapshot of top -c output while your application is running?
Perspective:
If it's spinning disk, that's a high value.
If it's an SSD or a SAN with a write cache, that's reasonable.
Use iostat -x for wide and extended metrics:
[xxx#xxxxxxxxxx]$ iostat -x
Linux 2.6.32-358.6.2.el6.x86_64 (boxname.goes.here) 12/12/2013 _x86_64_ (24 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.57 0.00 0.21 0.00 0.00 99.21
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.06 28.38 0.04 3.99 0.99 259.15 64.58 0.01 2.11 0.55 0.22
The %util is your friend. If you look at iostat.c (see it at: http://code.google.com/p/tester-higkoo/source/browse/trunk/Tools/iostat/iostat.c) you can see it calculates this percentage by looking at the amount of time (in processor ticks) spent doing IO versus the total number of ticks that have passed. In other words, the PERCENTAGE-UTIL is the percent of time the IO was in a busy state.

Resources