{"id":1458,"date":"2022-05-29T01:49:51","date_gmt":"2022-05-29T08:49:51","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=1458"},"modified":"2022-05-29T01:51:25","modified_gmt":"2022-05-29T08:51:25","slug":"210-parametric-curve-in-3d-2-2-2-2-2-2-2-2-2-2-2-2-2-3-2-2-2-2-2-2-2-2-2-3-2-2-2-2-2","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2022\/05\/210-parametric-curve-in-3d-2-2-2-2-2-2-2-2-2-2-2-2-2-3-2-2-2-2-2-2-2-2-2-3-2-2-2-2-2\/","title":{"rendered":"#281 How to convert numbers from Nastran notation to float"},"content":{"rendered":"<p>Often, it is necessary to convert numbers from Nastran notation to float. For example, convert -5.75-3 into -5.75e-3.<br \/>\nWe can write a simple python function for such conversion.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#Convert -5.75-3 into -5.75e-3 ?\r\ndef nastran2float(s):\r\n    s = s.replace('-','e-')\r\n    s = s.replace('+','e+')\r\n    if s&#x5B;0] == 'e':\r\n        s = s&#x5B;1:]\r\n    return float(s)\r\n\r\nx=&quot;-5.75-3&quot;\r\nz=nastran2float(x)\r\nprint(z)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Often, it is necessary to convert numbers from Nastran notation to float. For example, convert -5.75-3 into -5.75e-3. We can write a simple python function for such conversion. #Convert -5.75-3 into -5.75e-3 ? def nastran2float(s): s = s.replace(&#8216;-&#8216;,&#8217;e-&#8216;) s = s.replace(&#8216;+&#8217;,&#8217;e+&#8217;) if s&#x5B;0] == &#8216;e&#8217;: s = s&#x5B;1:] return float(s) x=&quot;-5.75-3&quot; z=nastran2float(x) print(z)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_lmt_disableupdate":"yes","_lmt_disable":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[22,2],"tags":[42,3],"class_list":["post-1458","post","type-post","status-publish","format-standard","hentry","category-nastran","category-python","tag-nastran","tag-python"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-nw","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1809,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/03\/342-gravity-loading-in-nastran-grav-card\/","url_meta":{"origin":1458,"position":0},"title":"#342 Gravity loading in Nastran (GRAV card)","author":"gantovnik","date":"2023-03-09","format":false,"excerpt":"Inertia loading: 1G GRAV load (down) Description: Used to define gravity vectors to determine gravity loading for the structural model. [code language=\"python\"] $2345678$2345678$2345678$2345678$2345678$2345678$2345678$2345678 $1111111$0222222$3333333$4444444$5555555$6666666$7777777$8888888 $GRAV SID CID G N1 N2 N3 GRAV 200 0 386.4 0.0 0.0 -1.0 [\/code] SID = load id. CID = coordinate system id. A CID=0\u2026","rel":"","context":"In &quot;nastran&quot;","block_context":{"text":"nastran","link":"https:\/\/gantovnik.com\/bio-tips\/category\/nastran\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":477,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/02\/extract-eigenvalues-from-nastran-f06-file\/","url_meta":{"origin":1458,"position":1},"title":"#68 Extract eigenvalues from Nastran f06 file","author":"gantovnik","date":"2020-02-28","format":false,"excerpt":"grep -i -A 26 'R E A L E I G E N V A L U E S' my_fem.f06 > eigenvalues.txt","rel":"","context":"In &quot;bash&quot;","block_context":{"text":"bash","link":"https:\/\/gantovnik.com\/bio-tips\/category\/bash\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":671,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/09\/114-python-script-for-remove-offsets-from-cbar-elements\/","url_meta":{"origin":1458,"position":2},"title":"#114: Python script for remove offsets from CBAR elements","author":"gantovnik","date":"2020-09-28","format":false,"excerpt":"#114: Python script for remove offsets from CBAR elements SOL 106 does not allow offsets in CBAR elements. [code language=\"python\"] print \"-------------------------------------\" print \"remove_cbush_offsets_v1.0\" print \"Vladimir Gantovnik\" print \"March 15 2016\" print \"-------------------------------------\" #input file inName='test.bdf' inFile=open(inName) #output file outName='stripped.bdf' outFile=open(outName,'w') import string while 1 : line=inFile.readline() if not line\u2026","rel":"","context":"In &quot;nastran&quot;","block_context":{"text":"nastran","link":"https:\/\/gantovnik.com\/bio-tips\/category\/nastran\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":900,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/02\/162-loops-using-command-line-in-bash\/","url_meta":{"origin":1458,"position":3},"title":"#162 Loops using command line in bash","author":"gantovnik","date":"2021-02-19","format":false,"excerpt":"With increment: [code language=\"python\"] $ for i in {1..20..2}; do echo $i; done [\/code] Output: [code language=\"python\"] 1 3 5 7 9 11 13 15 17 19 [\/code] [code language=\"python\"] $ for word in one two three; do echo $word; done [\/code] Output: [code language=\"python\"] one two three [\/code] C-like\u2026","rel":"","context":"In &quot;bash&quot;","block_context":{"text":"bash","link":"https:\/\/gantovnik.com\/bio-tips\/category\/bash\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":677,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/09\/116-nastran-error-1250\/","url_meta":{"origin":1458,"position":4},"title":"#117: Nastran Error 1250","author":"gantovnik","date":"2020-09-28","format":false,"excerpt":"#117: Nastran Error 1250 Error 1250 *** USER FATAL MESSAGE 1250 (BIOWRT) ERROR MESSAGE IS -- There is not enough space on the disk.","rel":"","context":"In &quot;nastran&quot;","block_context":{"text":"nastran","link":"https:\/\/gantovnik.com\/bio-tips\/category\/nastran\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":688,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/09\/121-windows-batch-script-to-run-every-nastran-input-file-in-folder\/","url_meta":{"origin":1458,"position":5},"title":"#121: Windows batch script to run every Nastran input file in folder","author":"gantovnik","date":"2020-09-28","format":false,"excerpt":"This is an example of a Windows bat file to run Nastran for every *.dat file in the current folder. It also calculates the total Nastran execution time. Of course, you should change the path to nastran.exe. The nice thing here is that script uses variable set MyPath=%cd%, so you\u2026","rel":"","context":"In &quot;batch&quot;","block_context":{"text":"batch","link":"https:\/\/gantovnik.com\/bio-tips\/category\/batch\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1458","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/comments?post=1458"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1458\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=1458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=1458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=1458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}