how to generate graph from trace file in ns2? - tcl

I am facing a problem in generating xgraph from .tr file. The error message is like this:
Error in file `voip.tr' at line 610:
Unknown line type
Problems found with input data.
The format of .tr file is like this:
+ 1 0 1 sctp 56 -------I 0 0.0 3.0 1 -1 2 65535 65535
- 1 0 1 sctp 56 -------I 0 0.0 3.0 1 -1 2 65535 65535
r 1.01224 0 1 sctp 56 -------I 0 0.0 3.0 1 -1 2 65535 65535
+ 1.01224 1 3 sctp 56 -------I 0 0.0 3.0 1 -1 2 65535 65535
- 1.01224 1 3 sctp 56 -------I 0 0.0 3.0 1 -1 2 65535 65535
r 1.02448 1 3 sctp 56 -------I 0 0.0 3.0 1 -1 2 65535 65535
+ 1.02448 3 1 sctp 56 -------I 0 3.0 0.0 1 -1 3 65535 65535
- 1.02448 3 1 sctp 56 -------I 0 3.0 0.0 1 -1 3 65535 65535
r 1.03672 3 1 sctp 56 -------I 0 3.0 0.0 1 -1 3 65535 65535
+ 1.03672 1 0 sctp 56 -------I 0 3.0 0.0 1 -1 3 65535 65535
- 1.03672 1 0 sctp 56 -------I 0 3.0 0.0 1 -1 3 65535 65535
r 1.04896 1 0 sctp 56 -------I 0 3.0 0.0 1 -1 3 65535 65535
+ 1.04896 0 1 sctp 36 -------I 0 0.0 3.0 1 -1 4 65535 65535
- 1.04896 0 1 sctp 36 -------I 0 0.0 3.0 1 -1 4 65535 65535
r 1.0604 0 1 sctp 36 -------I 0 0.0 3.0 1 -1 4 65535 65535
+ 1.0604 1 3 sctp 36 -------I 0 0.0 3.0 1 -1 4 65535 65535
I have used command like this in ubuntu in ns2.
xgraph voip.tr
So how can I generate graph from the trace file?

You cannot give your trace file as a direct input to Xgraph. you have to give file with only two lines like
1 5
5 89
8 98 here first row is x axis 2nd is y axis for example save this file as graph.tr
now you can execute using xgraph graph.tr here instead of using random values you have to use your QOS valuse such as number of packets received or sent like that..

xgraph can only be used with .xgr files. While executing the awk command add this (watch for the greater than symbol):
.... > anyname.xgr
Now you can use xgraph to plot, the command is:
xgraph anyname.xgr

Related

Scrapy - how to index and extract from html tables

This is the webpage I am scraping: http://laxreports.sportlogiq.com/nll/GS2200.html
Below is the code for the spider I created:
import scrapy
class MatchesSpider(scrapy.Spider):
name = 'matches'
allowed_domains = ['laxreports.sportlogiq.com']
start_urls = ['http://laxreports.sportlogiq.com/nll/GS2200.html']
def parse(self, response):
tables = response.xpath('//table')
print(tables)
table = tables[0].xpath('//tbody')
I see 22 tables that have been selected for this XPath expression but my problem is that I don't fully understand how to select each individual table and extract its contents.
I am a beginner in scrapy and after searching online for a solution all I see is how to select the tables using the class or ID which in this case is not an option.
You can do that using only pandas
Code:
import pandas as pd
dfs = pd.read_html('https://laxreports.sportlogiq.com/nll/GS2200.html')
df = dfs[10]#.to_csv('d.csv', index = False)
print(df)
Output:
0 1 2 3 4 5 6 7 8 9 10 11 12
0 # Name G A +/- PIM S SOFF LB T CT FO TOF
1 2 W.Malcom 0 0 0 0 1 1 1 4 0 - 11:28
2 3 T.Edwards 0 0 -2 2 0 0 8 1 2 7-18 20:28
3 4 J.Sullivan 0 0 -3 2 0 0 3 0 0 - 15:29
4 11 T.Stuart 0 0 -3 0 0 0 4 1 1 - 21:09
5 14 W.Jeffrey 0 1 -1 0 0 0 9 2 1 - 19:17
6 16 R.Lee 2 1 2 0 9 4 6 6 1 - 23:13
7 17 C.Wardle 2 0 1 2 5 3 4 2 2 - 20:55
8 18 R.Hope (A) 0 0 -2 2 0 0 11 0 0 - 22:02
9 20 J.Ruest 3 2 3 0 8 1 3 2 0 - 24:16
10 23 J.Gilles 0 0 -1 0 0 0 4 0 3 - 14:44
11 27 S.Carnegie 0 0 -1 0 0 0 3 0 0 - 12:19
12 37 D.Coates (C) 0 0 0 0 1 0 1 0 0 1-1 2:31
13 51 E.McLaughlin 0 5 2 0 7 3 5 7 0 - 21:41
14 55 D.Kinnear 0 1 2 0 2 0 2 1 0 0-2 10:14
15 67 K.Killen 1 1 0 0 6 1 4 2 0 - 16:42
16 82 J.Cupido (A) 0 1 -1 0 3 0 4 1 0 - 20:52
17 86 J.Lintz 0 1 -1 0 0 0 4 0 1 - 19:26
18 30 T.Carlson 0 0 NaN 0 0 0 0 0 0 - NaN
19 45 D.Ward 0 0 NaN 0 0 0 0 1 0 - NaN
20 NaN Totals: 8 13 NaN 8 42 13 76 30 11 8-21 NaN

In PARI/GP in function FACTOR the -1 is a bug or means somthing else?

First run the function b(n):
? b(n) = lcm(vector(n, i, i))/n
After function c(n):
? c(n)=sum(j=1,n,sum(i=1,n,(-1)^(i+j)/(i+j-1)))
Last run d(n):
? d(n)=factor(denominator(c(n))/b(n))~
and test with 202
? d(202)
The result is:
%8 =
[3 7 17 19 31 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293
307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401]
[1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
What indicates the -1 in factoring results?
You try to factor the rational number. Note, type(denominator(c(202))/b(202)) is t_FRAC instead of t_INT because of denominator(c(202))/b(202) = <some big number>/31. So -1 means just -1 power for divisor 31, and no bug is here.

DXF ASCII to write multiple text strings

I can't seem to add multiple text strings to a DXF file. It works for when I only have a block of code for 1 line of text. I can't seem to add multiple lines.
I created the code shown below. Any help would be very much appreciated.
0
SECTION
2
ENTITIES
0
TEXT
5
31
8
0
6
BYLAYER
62
256
10
161.25
20
120.25
30
0
40
1
1
Sample Text 1
50
0
41
1
51
0
7
71
0
11
161.25
21
120.25
31
0
210
0
220
0
230
1
73
3
0
TEXT
5
31
8
0
6
BYLAYER
62
256
10
100
20
100
30
0
40
1
1
Sample Text 2
50
0
41
1
51
0
7
71
0
11
100
21
100
31
0
210
0
220
0
230
1
73
3
0
ENDSEC
0
EOF
The DXF file with the code shown above will not open in AutoCAD and/or Microstation. However it does open in LibreCAD which appears to be more forgiving with syntax.
I'd like it to open in AutoCAD AND Microstation. Any input would very much be appreciated.
Handles (DXF group 5) should be unique within a file.
As such, you should not use the same handle for both text entities:
0
SECTION
2
ENTITIES
0
TEXT
5
31 <----------+
|
< ... > |
|
0 +----- Identical handles
TEXT |
5 |
31 <----------+

CUDA shared memory efficiency at 50%?

I have the following code that performs a tiled matrix transpose using shared memory to improve performance. The shared memory is padded with 1 column to avoid bank conflict for a 32x32 thread block.
__global__ void transpose_tiled_padded(float *A, float *B, int n)
{
int i_in = blockDim.x*blockIdx.x + threadIdx.x;
int j_in = blockDim.y*blockIdx.y + threadIdx.y;
int i_out = blockDim.x*blockIdx.y + threadIdx.x;
int j_out = blockDim.y*blockIdx.x + threadIdx.y;
extern __shared__ float tile[];
// coalesced read of A rows to (padded) shared tile column (transpose)
tile[threadIdx.y + threadIdx.x*(blockDim.y+1)] = A[i_in + j_in*n];
__syncthreads();
// coalesced write from (padded) shared tile column to B rows
B[i_out + j_out*n] = tile[threadIdx.x + threadIdx.y*(blockDim.x+1)];
}
Running this code, I get 100% shared memory efficiency in the NVIDIA visual profiler, as I expect. But, when I run it with a 16x16 thread block, I only get 50% efficiency. Why is that? As far as I can tell, no thread in a warp reads from the same bank with this layout. Or am I mistaken?
Yes, you are mistaken.
Considering this (read) access for warp 0 in a 16x16 block:
tile[threadIdx.x + threadIdx.y*(blockDim.x+1)];
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
"index"
Here are the relevant calculations for each thread in the warp:
warp lane: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 23 25 26 27 28 29 30 31
threadIdx.x: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
threadIdx.y: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
"index": 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
bank: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0
So we see that for this warp, the first and the last thread both read from bank 0. This results in a 2-way bank conflict, 2-way serialization, and 50% efficiency.

Adding SPLINE to DXF makes the file corrupt (content not shown)

I am working on my own DXF writer because I only need certain elements (such as LINE, POLYLINE, POINT an SPLINE).
I started with tfpdxfbridge and the idea was to include SPLINE support too. When I tried to manually add SPLINE to ENTITIES in the *.dxf file, the file is not opened anymore. Example of SPLINE:
SPLINE
5
274
330
1F
100
AcDbEntity
8
0
100
AcDbSpline
210
0.0
220
0.0
230
1.0
70
8
71
3
72
9
73
5
74
0
42
0.0000000001
43
0.0000000001
40
0.0
40
0.0
40
0.0
40
0.0
40
1.0
40
2.0
40
2.0
40
2.0
40
2.0
10
747.2822841342859
20
1453.676625339077
30
0.0
10
1364.898523055965
20
2324.178049512178
30
0.0
10
2830.924436828291
20
1999.364085075557
30
0.0
10
1130.854480067877
20
862.5152127789023
30
0.0
10
2837.42565094653
20
791.0561394394999
30
0.0
0
Does anybody know what the problem might be or how to make the file work again?
Here is the full file generated with tfpdxfbridge (except the SPLINE part, obviously).
0
SECTION
2
HEADER
999
Generator: TFPDxfWriteBridge
999
By jmpessoa#hotmail.com
9
$DIMASZ
40
0.1800
9
$DIMTSZ
40
0
9
$DIMGAP
40
0.0900
9
$DIMEXO
40
0.0625
9
$DIMDLI
40
0.38
9
$DIMDLE
40
0.0
9
$DIMEXE
40
0.1800
9
$DIMTXT
40
0.1800
9
$DIMTXTDIRECTION
70
0
9
$DIMTIH
70
1
9
$DIMTAD
70
0
9
$DIMCLRD
70
256
9
$DIMCLRE
70
256
9
$DIMCLRT
70
256
9
$DIMASO
70
1
9
$DIMASSOC
280
2
9
$DIMSHO
70
0
9
$DIMLUNIT
70
2
9
$DIMDEC
70
4
9
$DIMADEC
70
2
9
$INSBASE
10
0.0
20
0.0
30
0.0
9
$EXTMIN
10
0.0
20
0.0
9
$EXTMAX
10
3200.0
20
3200.0
9
$LINMIN
10
0.0
20
0.0
9
$LINMAX
10
3200.0
20
3200.0
0
ENDSEC
0
SECTION
2
TABLES
0
TABLE
2
LTYPE
70
8
100
AcDbSymbolTable
100
AcDbLTypeTable
0
LTYPE
2
CONTINUOUS
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
____________
72
65
73
0
40
0.000
70
0
0
LTYPE
2
HIDDEN
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
__ __ __
72
65
73
2
40
0.375
49
0.250
49
-0.125
70
0
0
LTYPE
2
CENTER
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
____ _ ____ _
72
65
73
4
40
2.000
49
1.250
49
-0.250
49
0.250
49
-0.250
70
0
0
LTYPE
2
DOT
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
. . . . .
72
65
73
2
40
0.250
49
0.000
49
-0.250
70
0
0
LTYPE
2
DASHDOT
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
__ . __ .
72
65
73
4
40
1.000
49
0.500
49
-0.250
49
0.000
49
-0.250
70
0
0
LTYPE
2
DIVIDE
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
____ . . ____ . .
72
65
73
6
40
1.250
49
0.500
49
-0.250
49
0.000
49
-0.250
49
0.000
49
-0.250
70
0
0
LTYPE
2
BORDER
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
__ __ . __ __ .
72
65
73
6
40
1.750
49
0.500
49
-0.250
49
0.500
49
-0.250
49
0.000
49
-0.250
70
0
0
LTYPE
2
MJLINE
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
__ __ __
72
65
73
2
40
0.375
49
0.250
49
-0.125
70
0
0
ENDTAB
0
TABLE
2
STYLE
70
2
100
AcDbSymbolTable
100
AcDbStyleTable
0
STYLE
2
DEFAULT
71
0
40
0.00
42
1.00
50
0.00
41
1.00
3
ARIAL.TTF
100
AcDbSymbolTableRecord
100
AcDbTextStyleTableRecord
70
0
0
STYLE
2
ISOCPEUR
71
0
40
0.00
42
1.00
50
0.00
41
1.00
3
isocpeur.ttf
100
AcDbSymbolTableRecord
100
AcDbTextStyleTableRecord
70
0
0
ENDTAB
0
TABLE
2
LAYER
70
9
100
AcDbSymbolTable
100
AcDbLayerTable
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
0
70
0
62
7
6
CONTINUOUS
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
HIDDEN_YELLOW
70
0
62
2
6
HIDDEN
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
CENTER_RED
70
0
62
1
6
CENTER
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
DOT_GREEN
70
0
62
3
6
DOT
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
DASHDOT_CYAN
70
0
62
4
6
DASHDOT
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
DIVIDE_BLUE
70
0
62
5
6
DIVIDE
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
BORDER_MAGENTA
70
0
62
6
6
BORDER
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
CONTINUOUS_GRAY
70
0
62
8
6
CONTINUOUS
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
MYLAYER
70
0
62
5
6
MJLINE
0
ENDTAB
0
TABLE
2
DIMSTYLE
70
2
100
AcDbSymbolTable
100
AcDbDimStyleTable
0
DIMSTYLE
100
AcDbSymbolTableRecord
100
AcDbDimStyleTableRecord
2
GENERIC
70
0
77
0
176
256
177
256
178
256
41
0.18
46
0.00
44
0.18
42
0.06
147
0.09
140
0.18
3
4
5
6
7
40
1.0
43
0.38
45
0.0
47
0.0
48
0.0
141
0.09
142
0.0
143
25.39999
144
1.0
145
0.0
146
1.0
71
0
72
0
73
1
74
1
75
0
76
0
78
0
170
0
171
2
172
0
173
0
174
0
175
0
0
DIMSTYLE
100
AcDbSymbolTableRecord
100
AcDbDimStyleTableRecord
2
CUSTOM
70
0
77
0
176
3
177
3
178
3
41
0.18
46
0.00
44
0.18
42
0.06
147
0.09
140
0.18
3
4
5
6
7
40
1.0
43
0.38
45
0.0
47
0.0
48
0.0
141
0.09
142
0.0
143
25.39999
144
1.0
145
0.0
146
1.0
71
0
72
0
73
1
74
1
75
0
76
0
78
0
170
0
171
2
172
0
173
0
174
0
175
0
0
ENDTAB
0
ENDSEC
0
SECTION
2
BLOCKS
0
ENDSEC
0
SECTION
2
ENTITIES
0
CIRCLE
100
AcDbEntity
8
BORDER_MAGENTA
62
256
6
BYLAYER
39
0.00
100
AcDbCircle
10
6.00
20
4.00
30
0.00
40
1.20
0
ARC
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbCircle
10
10.00
20
6.00
30
0.00
40
1.20
100
AcDbArc
50
10.00
51
80.00
0
POLYLINE
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
100
AcDb2dPolyline
70
0
66
1
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
0.00
20
0.00
30
0.0
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
0.00
20
3.00
30
0.0
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
1.50
20
1.50
30
0.0
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
3.00
20
3.00
30
0.0
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
3.00
20
0.00
30
0.0
0
SEQEND
0
POLYLINE
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
100
AcDb2dPolyline
70
1
66
1
0
VERTEX
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
-1.00
20
-1.00
30
0.0
0
VERTEX
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
-1.00
20
4.00
30
0.0
0
VERTEX
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
4.00
20
4.00
30
0.0
0
VERTEX
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
5.00
20
-3.00
30
0.0
0
SEQEND
0
ENDSEC
0
EOF
When I try to recover your DXF file I get the following:
Unknown header variable $LINMAX ignored on line 116.
Undefined group code 330 for object on line 1018.
Invalid or incomplete DXF input -- drawing discarded.
In your DXF you have:
330
1F
I see that 330 is included when I do my own spline and save as DXF. But, 330 is according to the documents:
Soft-pointer ID/handle to owner dictionary (optional)
This DXF will recover without any errors:
https://pastebin.com/KRpzCd4M
Perhaps you can do a comparison.