{"id":19,"date":"2017-06-16T09:45:15","date_gmt":"2017-06-16T09:45:15","guid":{"rendered":"https:\/\/propagationtools.com\/wireless\/?p=19"},"modified":"2017-06-16T15:21:20","modified_gmt":"2017-06-16T15:21:20","slug":"how-to-process-the-2d-antenna-pattern-text-files-using-php-script","status":"publish","type":"post","link":"https:\/\/propagationtools.com\/wireless\/how-to-process-the-2d-antenna-pattern-text-files-using-php-script\/","title":{"rendered":"How to Process the 2D Antenna Pattern Text Files using PHP Script?"},"content":{"rendered":"\n<div id=\"fb-root\"><\/div>\n<script>(function(d, s, id) {\n  var js, fjs = d.getElementsByTagName(s)[0];\n  if (d.getElementById(id)) return;\n  js = d.createElement(s); js.id = id;\n  js.src = \"\/\/connect.facebook.net\/en_GB\/sdk.js#xfbml=1&version=v2.6&appId=857807644244147\";\n  fjs.parentNode.insertBefore(js, fjs);\n}(document, 'script', 'facebook-jssdk'));<\/script>\n\n<div class=\"fb-like\" data-href=\"https:\/\/propagationtools.com\/wireless\/wp-json\/wp\/v2\/posts\/19\" data-layout=\"button_count\" data-action=\"like\" data-show-faces=\"false\" data-share=\"false\"><\/div><BR\/><div class='wp_content'><p>Antennas are not easy to manufacture, and their patterns are usually represented using 2x2D array. For example, the below represents a horizontal antenna pattern that contains 360 gain values which are stored by 36 (rows) times 10 (columns).<\/p>\n<pre lang='txt'>\r\n#HUBER+SUHNER AG XXXX \/ XXXX 0627\/360\/7\/0\/MIMO \/ File name:XXXX\r\n#XXXX \/ Version 1\r\nName = 1399.17.0229\r\nNumber of Points = 360\r\nStart Ang. = 0\r\nRange = 40.000000\r\nIncrement = 1.0\r\nOrientation = Horizontal\r\n-3.89 -4.08 -4.27 -4.47 -4.66 -4.85 -5.05 -5.25 -5.44 -5.64 \r\n-5.84 -6.04 -6.24 -6.44 -6.64 -6.83 -7.03 -7.22 -7.42 -7.61 \r\n-7.81 -7.98 -8.16 -8.34 -8.51 -8.69 -8.82 -8.94 -9.07 -9.20 \r\n-9.32 -9.36 -9.40 -9.43 -9.47 -9.50 -9.43 -9.36 -9.29 -9.22 \r\n-9.15 -9.01 -8.87 -8.72 -8.58 -8.44 -8.28 -8.13 -7.97 -7.81 \r\n-7.66 -7.53 -7.39 -7.26 -7.13 -7.00 -6.92 -6.83 -6.75 -6.66 \r\n-6.58 -6.55 -6.52 -6.49 -6.46 -6.43 -6.45 -6.47 -6.50 -6.52 \r\n-6.54 -6.62 -6.70 -6.77 -6.85 -6.93 -7.06 -7.19 -7.32 -7.45 \r\n-7.58 -7.76 -7.94 -8.12 -8.30 -8.49 -8.72 -8.95 -9.18 -9.41 \r\n-9.64 -9.89 -10.14 -10.39 -10.64 -10.89 -11.08 -11.26 -11.45 -11.63 \r\n-11.82 -11.81 -11.79 -11.78 -11.77 -11.76 -11.53 -11.31 -11.09 -10.86 \r\n-10.64 -10.34 -10.04 -9.74 -9.44 -9.14 -8.88 -8.61 -8.35 -8.08 \r\n-7.82 -7.63 -7.44 -7.25 -7.06 -6.87 -6.77 -6.67 -6.56 -6.46 \r\n-6.36 -6.34 -6.32 -6.30 -6.28 -6.26 -6.31 -6.37 -6.42 -6.47 \r\n-6.53 -6.63 -6.73 -6.83 -6.94 -7.04 -7.14 -7.24 -7.34 -7.44 \r\n-7.54 -7.57 -7.59 -7.62 -7.64 -7.66 -7.56 -7.46 -7.36 -7.25 \r\n-7.15 -6.95 -6.75 -6.54 -6.34 -6.14 -5.91 -5.67 -5.44 -5.20 \r\n-4.97 -4.75 -4.53 -4.31 -4.09 -3.87 -3.68 -3.50 -3.31 -3.13 \r\n-2.94 -2.79 -2.65 -2.50 -2.35 -2.20 -2.09 -1.97 -1.86 -1.75 \r\n-1.63 -1.55 -1.46 -1.37 -1.29 -1.20 -1.14 -1.08 -1.01 -0.95 \r\n-0.89 -0.85 -0.81 -0.76 -0.72 -0.68 -0.66 -0.63 -0.61 -0.58 \r\n-0.56 -0.54 -0.53 -0.52 -0.51 -0.50 -0.51 -0.51 -0.51 -0.51 \r\n-0.51 -0.53 -0.54 -0.55 -0.56 -0.58 -0.60 -0.62 -0.64 -0.66 \r\n-0.68 -0.70 -0.73 -0.75 -0.78 -0.80 -0.83 -0.86 -0.89 -0.92 \r\n-0.95 -0.98 -1.01 -1.03 -1.06 -1.09 -1.12 -1.15 -1.18 -1.21 \r\n-1.24 -1.26 -1.29 -1.32 -1.35 -1.37 -1.40 -1.42 -1.44 -1.46 \r\n-1.49 -1.50 -1.52 -1.54 -1.55 -1.57 -1.57 -1.58 -1.58 -1.59 \r\n-1.59 -1.58 -1.58 -1.57 -1.56 -1.55 -1.53 -1.51 -1.48 -1.46 \r\n-1.43 -1.40 -1.36 -1.32 -1.28 -1.24 -1.19 -1.14 -1.09 -1.04 \r\n-0.99 -0.94 -0.89 -0.83 -0.78 -0.73 -0.67 -0.62 -0.57 -0.52 \r\n-0.47 -0.43 -0.38 -0.34 -0.30 -0.26 -0.22 -0.19 -0.16 -0.13 \r\n-0.10 -0.08 -0.06 -0.05 -0.03 -0.02 -0.01 -0.01 -0.01 -0.01 \r\n-0.01 -0.02 -0.04 -0.06 -0.07 -0.09 -0.13 -0.16 -0.20 -0.23 \r\n-0.27 -0.33 -0.39 -0.44 -0.50 -0.56 -0.64 -0.72 -0.81 -0.89 \r\n-0.97 -1.08 -1.19 -1.30 -1.41 -1.51 -1.65 -1.79 -1.92 -2.06 \r\n-2.19 -2.35 -2.51 -2.67 -2.83 -2.99 -3.17 -3.35 -3.53 -3.71 \r\n<\/pre>\n<h2>How to construct 3D Full Antenna Pattern from Both Horizontal and Vertical 1-D array?<\/h2>\n<p>You might need the interopolation methods, that allow you to construct an estimate of a full 3D pattern given 2x2D gain values. The industry uses 2x2D gain values to represent an antenna for simplicity.<\/p>\n<div id=\"attachment_20\" style=\"width: 613px\" class=\"wp-caption alignnone\"><a  href=\"https:\/\/propagationtools.com\/wireless\/wp-content\/uploads\/2017\/06\/directional-antenna-pattern-3d.png\"><img  title=\"directional-antenna-pattern-3d How to Process the 2D Antenna Pattern Text Files using PHP Script? Antenna \" loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-20\" src=\"https:\/\/propagationtools.com\/wireless\/wp-content\/uploads\/2017\/06\/directional-antenna-pattern-3d.png\"  alt=\"directional-antenna-pattern-3d How to Process the 2D Antenna Pattern Text Files using PHP Script? Antenna \"  width=\"603\" height=\"412\" class=\"size-full wp-image-20\" srcset=\"https:\/\/propagationtools.com\/wireless\/wp-content\/uploads\/2017\/06\/directional-antenna-pattern-3d.png 603w, https:\/\/propagationtools.com\/wireless\/wp-content\/uploads\/2017\/06\/directional-antenna-pattern-3d-300x205.png 300w, https:\/\/propagationtools.com\/wireless\/wp-content\/uploads\/2017\/06\/directional-antenna-pattern-3d-100x68.png 100w, https:\/\/propagationtools.com\/wireless\/wp-content\/uploads\/2017\/06\/directional-antenna-pattern-3d-200x137.png 200w, https:\/\/propagationtools.com\/wireless\/wp-content\/uploads\/2017\/06\/directional-antenna-pattern-3d-400x273.png 400w, https:\/\/propagationtools.com\/wireless\/wp-content\/uploads\/2017\/06\/directional-antenna-pattern-3d-500x342.png 500w, https:\/\/propagationtools.com\/wireless\/wp-content\/uploads\/2017\/06\/directional-antenna-pattern-3d-600x410.png 600w\" sizes=\"auto, (max-width: 603px) 100vw, 603px\" \/><\/a><p id=\"caption-attachment-20\" class=\"wp-caption-text\">directional-antenna-pattern-3d<\/p><\/div>\n<p>Full 360 antenna gain matrix need to be applied to Path Loss, in order to compute the signal strength, for example:<\/p>\n<p><a rel=\"nofollow\" target=\"blank\" href=\"http:\/\/buy.thulasidas.com\/easy-latex\/\"><img  title=\"tex_7ee95bd57c1e6c2d6d481e435b70a217 How to Process the 2D Antenna Pattern Text Files using PHP Script? Antenna \"  alt=\"tex_7ee95bd57c1e6c2d6d481e435b70a217 How to Process the 2D Antenna Pattern Text Files using PHP Script? Antenna \" src='https:\/\/propagationtools.com\/wireless\/wp-content\/uploads\/easy-latex-cache\/tex_7ee95bd57c1e6c2d6d481e435b70a217.png' title='P_\\text{r} = P_\\text{t} + G - L ' style='vertical-align:1%' class='tex' alt='P_\\text{r} = P_\\text{t} + G - L ' \/><\/a><\/p>\n<p>where P<sup>r<\/sup> and P<sup>t<\/sup> are signal strength for receiver and transmitter respectively. The G is the antenna gains (for both transmitter and receiver), and the L denotes the <a  href=\"https:\/\/propagationtools.com\/wireless\/free-space-path-loss-calculator-with-api\/\">path loss<\/a>.<\/p>\n<h2>How to Extract Gain Values from Antenna Text File?<\/h2>\n<p>We want to merge two gain text files into one, something like this:<\/p>\n<pre lang='txt'>\r\n0 h1 v1\r\n1 h2 v2\r\n2 h3 v3\r\n..\r\n..\r\n359 h359 v359\r\n<\/pre>\n<p>The quickest way is to copy these 360 gain values for horizontal and vertical patterns respectively into spreadsheet e.g. <a target=\"blank\" href=\"https:\/\/helloacm.com\/excel-tip-faster-auto-complete\/\">Microsoft Excel<\/a>. So how to extract 36&#215;10 gain matrix into 360 gain values?<\/p>\n<p>Let&#8217;s create a <a rel=\"nofollow\" target=\"blank\" href=\"http:\/\/php.net\/manual\/en\/intro-whatis.php\">PHP script<\/a> e.g. <em>process_ant.php<\/em> with the following content:<\/p>\n<pre lang=php>\r\n\/\/ https:\/\/propagationtools.com\/wireless\/how-to-process-the-2d-antenna-pattern-text-files-using-php-script\/\r\nif (count($argv) &gt;= 1) {\r\n\techo (\"files missing\");\t\r\n\tdie();\r\n}\r\n\r\nfunction process_pat($filename) {\r\n\t$s = file_get_contents($filename);\r\n\t$array = preg_split('\/\\s*\\R\\s*\/', trim($s), NULL, PREG_SPLIT_NO_EMPTY);\r\n\t$r = array();\r\n\tforeach ($array as $line) {\r\n\t\tif ($line[0] == '#') continue;\r\n\t\t$tmp = explode(' ', $line);\t\t\r\n\t\tif (count($tmp) &gt;= 2) { \/\/ if it looks like pattern values\r\n\t\t\t$r = array_merge($r, $tmp);\r\n\t\t}\r\n\t}\r\n\treturn $r;\r\n}\r\n\r\nfor ($i = 1; $i &lt; count($argv); ++ $i) {\r\n\t$filename = $argv[$i];\r\n\tif (!is_file($filename)) {\r\n\t\techo \"cannot open: $filename\\n\";\r\n\t\tcontinue;\r\n\t}\r\n\t\t\r\n\t$r = process_pat($filename);\r\n\tif (count($r) == 0) continue;\r\n\r\n\t$s = \"\";\r\n\tforeach ($r as $t) {\r\n\t\t$s .= \"$t\\r\\n\";\r\n\t}\r\n\r\n\tfile_put_contents($filename . \".txt\", $s);\r\n\techo \"Saved: $filename\\n\";\r\n}\r\n<\/pre>\n<p>This script converts antenna files to text files that contain 360 lines of values. For example, <\/p>\n<pre lang=bash>\r\nphp process_ant.php sample.pat\r\n<\/pre>\n<p>That will read sample.pat and write to sample.pat.txt. You can loop folders recursively for all pattern files, for example (Windows Command Line Prompt):<\/p>\n<pre lang='cmd'>\r\nFOR \/F \"usebackq delims==\" %i IN (`dir \/s \/b *`) do php process_ant.php \"%i\"\r\n<\/pre>\n<p>For Linux shells, use this instead:<\/p>\n<pre lang='bash'>\r\nfind . -name \\* -exec php process_ant.php {} \\;\r\n<\/pre>\n\n<div class=\"fb-like\" data-href=\"https:\/\/propagationtools.com\/wireless\/wp-json\/wp\/v2\/posts\/19\" data-layout=\"button_count\" data-action=\"like\" data-show-faces=\"false\" data-share=\"false\"><\/div>  <font color=gray>980 words<\/font> \n\n<BR\/><\/div> <div>\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\n<!-- propagation blog bot -->\n<ins class=\"adsbygoogle\"\n     style=\"display:block\"\n     data-ad-client=\"ca-pub-5311181282559050\"\n     data-ad-slot=\"8425782656\"\n     data-ad-format=\"auto\"><\/ins>\n<script>\n(adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/div><div>\n\n<\/div><div class=\"addthis_toolbox addthis_default_style addthis_32x32_style\">\n<a class=\"addthis_button_facebook\"><\/a>\n<a class=\"addthis_button_twitter\"><\/a>\n<a class=\"addthis_button_linkedin\"><\/a>\n<a class=\"addthis_button_google_plusone_share\"><\/a>\n<a class=\"addthis_button_reddit\"><\/a>\n<a class=\"addthis_button_email\"><\/a>\n<\/div><BR\/>","protected":false},"excerpt":{"rendered":"<p>Antennas are not easy to manufacture, and their patterns are usually represented using 2x2D array. For example, the below represents a horizontal antenna pattern that contains 360 gain values which are stored by 36 (rows) times 10 (columns). #HUBER+SUHNER AG XXXX \/ XXXX 0627\/360\/7\/0\/MIMO \/ File name:XXXX #XXXX \/ Version 1 Name = 1399.17.0229 Number<span class=\"continue-reading\"> <a href=\"https:\/\/propagationtools.com\/wireless\/how-to-process-the-2d-antenna-pattern-text-files-using-php-script\/\"><B>Continue Reading<\/B> &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":20,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[25,26,27,28],"class_list":["post-19","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-antenna","tag-antenna-files","tag-antenna-gains","tag-horizontal-patterns","tag-vertical-patterns"],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/propagationtools.com\/wireless\/wp-json\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/propagationtools.com\/wireless\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/propagationtools.com\/wireless\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/propagationtools.com\/wireless\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/propagationtools.com\/wireless\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":0,"href":"https:\/\/propagationtools.com\/wireless\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/propagationtools.com\/wireless\/wp-json\/wp\/v2\/media\/20"}],"wp:attachment":[{"href":"https:\/\/propagationtools.com\/wireless\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/propagationtools.com\/wireless\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/propagationtools.com\/wireless\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}