{"id":266,"date":"2011-09-03T05:48:25","date_gmt":"2011-09-03T05:48:25","guid":{"rendered":"http:\/\/ahay.org\/blog\/?p=266"},"modified":"2015-09-10T19:52:37","modified_gmt":"2015-09-10T19:52:37","slug":"program-of-the-month-sfclip","status":"publish","type":"post","link":"https:\/\/ahay.org\/blog\/2011\/09\/03\/program-of-the-month-sfclip\/","title":{"rendered":"Program of the month: sfclip"},"content":{"rendered":"<p><a href=\"\/RSF\/sfclip.html\">sfclip<\/a> is very simple yet very useful program. It &#8220;clips&#8221; the data to the specified maximum by the absolute value. <\/p>\n<p>Here is a simple test. First, let us make some data.  <\/p>\n<div class=\"code-box\"><div class=\"code-title\"><i class=\"fa fa-code\"><\/i> <div class=\"pull-right\"><a href=\"#\" class=\"btn btn-default btn-xs toggle-code\" data-toggle=\"tooltip\" title=\"Toggle code\"><i class=\"fa fa-toggle-up\"><\/i><\/a><\/div><\/div><pre ><code>bash$ sfmath n1=10 output=\"sin(x1)\" &gt; data.rsf\nbash$ &lt; data.rsf sfdisfil\n   0:             0       0.8415       0.9093       0.1411      -0.7568\n   5:       -0.9589      -0.2794        0.657       0.9894       0.4121\n<\/code><\/pre><\/div>\n<p>Now clip it to 0.5 by maximum absolute value.  <\/p>\n<div class=\"code-box\"><div class=\"code-title\"><i class=\"fa fa-code\"><\/i> <div class=\"pull-right\"><a href=\"#\" class=\"btn btn-default btn-xs toggle-code\" data-toggle=\"tooltip\" title=\"Toggle code\"><i class=\"fa fa-toggle-up\"><\/i><\/a><\/div><\/div><pre ><code>bash$ &lt; data.rsf sfclip clip=0.5 &gt; clip.rsf\nbash$ &lt; clip.rsf sfdisfil\n   0:           0.5          0.5          0.5       0.1411         -0.5\n   5:          -0.5      -0.2794          0.5          0.5       0.4121 \n<\/code><\/pre><\/div>\n<p>What if you need to clip the data not by the maximum value but to a specified range? Use <a href=\"\/RSF\/sfclip2.html\">sfclip2<\/a>.  <\/p>\n<div class=\"code-box\"><div class=\"code-title\"><i class=\"fa fa-code\"><\/i> <div class=\"pull-right\"><a href=\"#\" class=\"btn btn-default btn-xs toggle-code\" data-toggle=\"tooltip\" title=\"Toggle code\"><i class=\"fa fa-toggle-up\"><\/i><\/a><\/div><\/div><pre ><code>bash$ &lt; data.rsf sfclip2 lower=0 upper=0.9 &gt; clip2.rsf\nbash$ &lt; clip2.rsf sfdisfil\n   0:             0       0.8415          0.9       0.1411            0\n   5:             0            0        0.657          0.9       0.4121\n<\/code><\/pre><\/div>\n<p><strong>sfclip<\/strong> should handle correctly infinite values, for example those resulting from division by zero.  <\/p>\n<div class=\"code-box\"><div class=\"code-title\"><i class=\"fa fa-code\"><\/i> <div class=\"pull-right\"><a href=\"#\" class=\"btn btn-default btn-xs toggle-code\" data-toggle=\"tooltip\" title=\"Toggle code\"><i class=\"fa fa-toggle-up\"><\/i><\/a><\/div><\/div><pre ><code>bash$ sfmath n1=10 output=1\/x1 &gt; data.rsf\nbash$ &lt; data.rsf sfdisfil\n   0:           inf            1          0.5       0.3333         0.25\n   5:           0.2       0.1667       0.1429        0.125       0.1111\nbash$ &lt; data.rsf sfclip clip=0.3 &gt; clip.rsf\nbash$ &lt; clip.rsf sfdisfil\n   0:           0.3          0.3          0.3          0.3         0.25\n   5:           0.2       0.1667       0.1429        0.125       0.1111\n<\/code><\/pre><\/div>\n<p>A prototype of <strong>sfclip<\/strong> is used as an example in <a href=\"\/wiki\/Guide_to_madagascar_API\">Guide to madagascar API<\/a>. The <a href=\"https:\/\/github.com\/ahay\/src\/blob\/master\/system\/generic\/Mclip.c\">actual program<\/a> is a little different.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>sfclip is very simple yet very useful program. It &#8220;clips&#8221; the data to the specified maximum by the absolute value. Here is a simple test. First, let us make some data. bash$ sfmath n1=10 output=&#8221;sin(x1)&#8221; &gt; data.rsf bash$ &lt; data.rsf sfdisfil 0: 0 0.8415 0.9093 0.1411 -0.7568 5: -0.9589 -0.2794 0.657 0.9894 0.4121 Now clip [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[3],"tags":[],"class_list":["post-266","post","type-post","status-publish","format-standard","hentry","category-programs"],"_links":{"self":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts\/266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/comments?post=266"}],"version-history":[{"count":3,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts\/266\/revisions"}],"predecessor-version":[{"id":22589,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts\/266\/revisions\/22589"}],"wp:attachment":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/media?parent=266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/categories?post=266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/tags?post=266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}