18
26

'Added excercises to 05_AWK;'

This commit is contained in:
Arkadiusz Hypki 2025-04-14 13:09:23 +02:00
parent f9677ec569
commit 208db8d25d
13 changed files with 828756 additions and 0 deletions

View File

@ -0,0 +1,25 @@
Columns description is in the beginning of the files.
1. Compute number of black holes formed per every timesteps (column timenr) from files inter-binevoldat. At the end we should see something like a histogram.
Hints:
* column 17 - initial star's type, it has to be smaller than 14
* column 37 - final star's type, it has to be 14 (internal note that we have a black hole(BH))
So, BH forms if the type was not 14 in column 17, but in the same line, in the column 37 equals 14. Number of such events (rows) have to be computed per every time step (column timenr).
2. Compute the same for inter-binsin.dat file and plot both results on the same plot (with anything). These events from inter-binsin.dat should be smaller.
3. Plot, on the same figure, the results from the 1. and 2. points. You will see when the primordial BHs merge (point 1.) and the dynamical BHs are merging (point 2.).
New task
4. Test in which places all the mergers take place.
A merger is an even in which there non-zero value in inter** columns. If there some value in such a column it means that two or more stars merged together, creating a new object. The position in which it took place in star cluster is denoted with the column 'r1'.
Compute a histogram for such events for all timesteps together (this time we do not split values into different time steps). Write everything into one file in order to plot it.

3
05_AWK/in_class/01.awk Normal file
View File

@ -0,0 +1,3 @@
{
print "Name: ", $1, ", population: ", $2;
}

4
05_AWK/in_class/02.awk Normal file
View File

@ -0,0 +1,4 @@
{
if ($1 != "#")
print "Name: ", $1, ", population: ", $2;
}

6
05_AWK/in_class/03.awk Normal file
View File

@ -0,0 +1,6 @@
{
if ($1 != "#") {
c[$1] = c[$1] + $2;
print "Name: ", $1, ", total population: ", c[$1];
}
}

17
05_AWK/in_class/1.awk Normal file
View File

@ -0,0 +1,17 @@
BEGIN {
print "POCZATEK"
sum = 0.0;
}
{
country = $1;
if ($2 > 40)
print country, $2, NF
sum += $2;
}
END {
print "KONIEC"
print "Sum of the 2nd columns is ", sum
}

16
05_AWK/in_class/2.awk Normal file
View File

@ -0,0 +1,16 @@
BEGIN {
sum = 0.0;
l = 0;
}
{
if ($2 > 40 && l > 0)
print "Country", $1, "has", $2, " mln of people, ", "nr of all columns=", NF
sum += $2;
l++;
}
END {
print "Num of all people is", sum
}

17
05_AWK/in_class/3.awk Normal file
View File

@ -0,0 +1,17 @@
BEGIN {
sum = 0.0;
}
{
pop = $2;
if ($2 > 40 && $2 < 4000) {
print $2, pop, NF;
print $2, pop, NF;
}
sum += pop;
}
END {
print "Sum of all people is ", sum
}

16
05_AWK/in_class/4.awk Normal file
View File

@ -0,0 +1,16 @@
BEGIN {
sum = 0.0;
}
{
if ($2 > 40) {
print $1;
}
sum += $2;
}
END {
print "sum of population", sum;
}

18
05_AWK/in_class/5.awk Normal file
View File

@ -0,0 +1,18 @@
BEGIN {
sum = 0.0;
}
{
if ($1 != "#") {
sum += $2;
if ($2 > 40.0) {
print "Country ", $1, "has", $2, "mln people";
}
}
print "Nr of columns", NF;
}
END {
print "Total population ", sum;
}

View File

@ -0,0 +1,4 @@
# name population area
Poland 38 360
Poland 38 360
Germany 78 500
1 # name population area
2 Poland 38 360
3 Poland 38 360
4 Germany 78 500

237751
05_AWK/inter-binevol.dat Normal file

File diff suppressed because it is too large Load Diff

52249
05_AWK/inter-binsin.dat Normal file

File diff suppressed because it is too large Load Diff

538630
05_AWK/snapshot.dat Normal file

File diff suppressed because it is too large Load Diff