Title: export to iode · Issue #503 · larray-project/larray · GitHub
Open Graph Title: export to iode · Issue #503 · larray-project/larray
X Title: export to iode · Issue #503 · larray-project/larray
Description: Here is the current code we use. # la_iode.py # ---------- # Interface between larray objects and IODE ws from larray import * import iode def larray_to_ws(array, time='time', vars='vars'): '''Replace the IODE variables in memory by the ...
Open Graph Description: Here is the current code we use. # la_iode.py # ---------- # Interface between larray objects and IODE ws from larray import * import iode def larray_to_ws(array, time='time', vars='vars'): '''Repl...
X Description: Here is the current code we use. # la_iode.py # ---------- # Interface between larray objects and IODE ws from larray import * import iode def larray_to_ws(array, time='time', vars='var...
Opengraph URL: https://github.com/larray-project/larray/issues/503
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"export to iode","articleBody":"Here is the current code we use.\r\n\r\n```python\r\n# la_iode.py\r\n# ----------\r\n# Interface between larray objects and IODE ws\r\n\r\nfrom larray import *\r\nimport iode\r\n\r\ndef larray_to_ws(array, time='time', vars='vars'):\r\n '''Replace the IODE variables in memory by the array contents\r\n\r\n Parameters\r\n ----------\r\n array : LArray\r\n array with (exactly) 2 axes\r\n - vars = IODE variable names\r\n - time = time labels (yearly : 1990 1991...)\r\n time : str, int or Axis\r\n axis to use for the time.\r\n vars : str, int or Axis\r\n axis to use for the variables.\r\n\r\n Examples\r\n --------\r\n Load an array from a .var file, modify its content and save it back to a\r\n .var file.\r\n\r\n >>> # Load an IODE .var file in an larray object [vars, time]\r\n >>> surv = iode.wsloadvarpy(\"v00Mcj.var\")\r\n >>> surv.info\r\n TODO\r\n >>> # Modify some variables in the array\r\n >>> surv['VF00'] = -0.123\r\n >>> # Replace the IODE variable WS in memory by the larray contents\r\n >>> larray_to_ws(surv)\r\n >>> # Save the IODE ws in a .var file\r\n >>> iode.wssavevar(\"toto.var\")\r\n\r\n Create an array from scratch and save it to a .var file.\r\n\r\n >>> # Create an larray object (with axes vars and time)\r\n >>> arr = ndrange('vars=X,Y;time=2000..2005')\r\n >>> # Copy array into IODE memory\r\n >>> larray_to_ws(arr)\r\n >>> # Save the iode memory contents in a .var file\r\n >>> iode.wssavevar(\"la.var\")\r\n '''\r\n def iodeline(line):\r\n \"Execute a single IODE report line instruction.\"\r\n\r\n rc = iode.reportline(line)\r\n if rc != 0:\r\n # GDM> \r\n # * ideally this should be done in iode.reportline directly\r\n # * ideally, we should raise different exceptions based on rc\r\n raise Exception('report line failed to execute (code {}):\\n{}'\r\n .format(rc, line))\r\n assert isinstance(array, LArray)\r\n time = array.axes[time]\r\n vars = array.axes[vars]\r\n # converting to int to avoid .0 for float labels\r\n smplfrom = str(int(time.i[0])) + 'Y1 ' # \u003c-- GDM: is the space necessary?\r\n smplto = str(int(time.i[-1])) + 'Y1'\r\n\r\n iodeline(\"$WsClearVar\")\r\n iodeline(\"$WsSample {} {}\".format(smplfrom, smplto))\r\n\r\n # loop on vars\r\n # GDM> It would be better if we could pass data directly by value\r\n for name in vars:\r\n cmd_parts = ['$DataUpdateVar {} {}'.format(name, smplfrom)]\r\n cmd_parts += [repr(array[name, t]) for t in time]\r\n cmd = ' '.join(cmd_parts)\r\n iodeline(cmd)\r\n```\r\n\r\nTODO: \r\n* combine_axes if more than 2 axes\r\n* include iode.wssavevar(path)","author":{"url":"https://github.com/gdementen","@type":"Person","name":"gdementen"},"datePublished":"2017-10-25T14:47:07Z","url":"https://github.com/larray-project/larray/issues/503"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:935df18a-1642-37e8-3167-e580ab35a6c9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D09C:2DCAE8:20A1D0B:2C69C2C:6B0021AB |
| html-safe-nonce | f69558ad6947d0154d1827615d7b0bf85d15169ea783b45def2b7a4a7cf0fdef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDlDOjJEQ0FFODoyMEExRDBCOjJDNjlDMkM6NkIwMDIxQUIiLCJ2aXNpdG9yX2lkIjoiMjMxMzkwNzQ4NjQxNjk3MDE1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7d6e3b0d138f7f41ea1186feb5809b1d4a6b2ec02ce42512f17c308e4e267b16 |
| hovercard-subject-tag | issue:268426794 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/larray-project/larray/503/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9c05f109c156bbfa9732fdb0ed155094c25509d2fccf73cea561ad910875f6ae/larray-project/larray/issues/503 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9c05f109c156bbfa9732fdb0ed155094c25509d2fccf73cea561ad910875f6ae/larray-project/larray/issues/503 |
| og:image:alt | Here is the current code we use. # la_iode.py # ---------- # Interface between larray objects and IODE ws from larray import * import iode def larray_to_ws(array, time='time', vars='vars'): '''Repl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gdementen |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/larray-project/larray git https://github.com/larray-project/larray.git |
| octolytics-dimension-user_id | 26460981 |
| octolytics-dimension-user_login | larray-project |
| octolytics-dimension-repository_id | 16981067 |
| octolytics-dimension-repository_nwo | larray-project/larray |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 16981067 |
| octolytics-dimension-repository_network_root_nwo | larray-project/larray |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width