{"action":"created","issue":{"url":"https://api.github.com/repos/ComputationalRadiationPhysics/libSplash/issues/220","labels_url":"https://api.github.com/repos/ComputationalRadiationPhysics/libSplash/issues/220/labels{/name}","comments_url":"https://api.github.com/repos/ComputationalRadiationPhysics/libSplash/issues/220/comments","events_url":"https://api.github.com/repos/ComputationalRadiationPhysics/libSplash/issues/220/events","html_url":"https://github.com/ComputationalRadiationPhysics/libSplash/issues/220","id":125412223,"number":220,"title":"Writing an Array Attribute of String","user":{"login":"ax3l","id":1353258,"avatar_url":"https://avatars.githubusercontent.com/u/1353258?v=3","gravatar_id":"","url":"https://api.github.com/users/ax3l","html_url":"https://github.com/ax3l","followers_url":"https://api.github.com/users/ax3l/followers","following_url":"https://api.github.com/users/ax3l/following{/other_user}","gists_url":"https://api.github.com/users/ax3l/gists{/gist_id}","starred_url":"https://api.github.com/users/ax3l/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ax3l/subscriptions","organizations_url":"https://api.github.com/users/ax3l/orgs","repos_url":"https://api.github.com/users/ax3l/repos","events_url":"https://api.github.com/users/ax3l/events{/privacy}","received_events_url":"https://api.github.com/users/ax3l/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ComputationalRadiationPhysics/libSplash/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ComputationalRadiationPhysics/libSplash/milestones/10","html_url":"https://github.com/ComputationalRadiationPhysics/libSplash/milestones/Version%201.4/1.3.x","labels_url":"https://api.github.com/repos/ComputationalRadiationPhysics/libSplash/milestones/10/labels","id":1406815,"number":10,"title":"Version 1.4/1.3.x","description":"Either 1.4 or 1.3 revisions","creator":{"login":"ax3l","id":1353258,"avatar_url":"https://avatars.githubusercontent.com/u/1353258?v=3","gravatar_id":"","url":"https://api.github.com/users/ax3l","html_url":"https://github.com/ax3l","followers_url":"https://api.github.com/users/ax3l/followers","following_url":"https://api.github.com/users/ax3l/following{/other_user}","gists_url":"https://api.github.com/users/ax3l/gists{/gist_id}","starred_url":"https://api.github.com/users/ax3l/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ax3l/subscriptions","organizations_url":"https://api.github.com/users/ax3l/orgs","repos_url":"https://api.github.com/users/ax3l/repos","events_url":"https://api.github.com/users/ax3l/events{/privacy}","received_events_url":"https://api.github.com/users/ax3l/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":9,"state":"open","created_at":"2015-11-11T15:50:36Z","updated_at":"2016-01-07T15:13:33Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2016-01-07T15:13:29Z","updated_at":"2016-01-11T10:23:49Z","closed_at":null,"body":"Two write an array of constant size string one can currently do as equivalent to:\r\n\r\n```python\r\nimport h5py\r\n# [...]\r\n\r\nmeshes.create_group(b\"E\")\r\nE = meshes[b\"E\"]\r\nE.attrs[\"axisLabels\"] = np.array([b\"x\", b\"y\", b\"z\"])\r\n```\r\n\r\nWrite an array of three strings, example here of size 1, one can do in C-style notation:\r\n```C++\r\ntypedef char MyChar2[2];\r\nMyChar2 *axisLabels = new MyChar2[simDim];\r\nColTypeString ctAxisLabels(1); // this can also be longer, but all must have the same size (?)\r\nfor( uint32_t d = 0; d < simDim; ++d )\r\n{\r\n    /* \\todo is the order correct? */\r\n    axisLabels[d][0] = char(120 + d); // x, y, z\r\n    axisLabels[d][1] = '\\0';          // terminator is important!\r\n}\r\nparams->dataCollector->writeAttribute(params->currentStep,\r\n                                      ctAxisLabels, recordName.c_str(),\r\n                                      \"axisLabels\",\r\n                                      1u, Dimensions(simDim,0,0),\r\n                                      axisLabels);\r\n```\r\n\r\nwhich works.\r\n\r\nI am not 100% sure currently if one can write something like the following python equivalent where the three const-size static lengths strings can vary between each other in size:\r\n\r\n```python\r\nimport h5py\r\n# [...]\r\n\r\nmeshes.create_group(b\"E\")\r\nE = meshes[b\"E\"]\r\nE.attrs[\"axisLabels\"] = np.array([b\"short\", b\"middle long\", b\"very long description\"])\r\n```\r\n\r\nIt might be possible to do something like `char**` for the `writeAttribute()` argument `axisLabels` and then putting in each entry a different size c-string (null-terminated as usual). But I am not sure that will work since we only have *one* `ColTypeString ctAxisLabels(N)` and this would mean `N` can vary.\r\n\r\nSo if you can, make your labels of the same lengths. (In your case \"spatial idx\" and \"frequen idx\" / \" omega idx \", add trailing spaces before the `'\\0'` etc. ... nasty)\r\n\r\n[Official (but VLEN) example](http://www.hdfgroup.org/ftp/HDF5/examples/misc-examples/attrvstr.c)\r\n\r\nCCing @PrometheusPi "},"comment":{"url":"https://api.github.com/repos/ComputationalRadiationPhysics/libSplash/issues/comments/170500569","html_url":"https://github.com/ComputationalRadiationPhysics/libSplash/issues/220#issuecomment-170500569","issue_url":"https://api.github.com/repos/ComputationalRadiationPhysics/libSplash/issues/220","id":170500569,"user":{"login":"ax3l","id":1353258,"avatar_url":"https://avatars.githubusercontent.com/u/1353258?v=3","gravatar_id":"","url":"https://api.github.com/users/ax3l","html_url":"https://github.com/ax3l","followers_url":"https://api.github.com/users/ax3l/followers","following_url":"https://api.github.com/users/ax3l/following{/other_user}","gists_url":"https://api.github.com/users/ax3l/gists{/gist_id}","starred_url":"https://api.github.com/users/ax3l/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ax3l/subscriptions","organizations_url":"https://api.github.com/users/ax3l/orgs","repos_url":"https://api.github.com/users/ax3l/repos","events_url":"https://api.github.com/users/ax3l/events{/privacy}","received_events_url":"https://api.github.com/users/ax3l/received_events","type":"User","site_admin":false},"created_at":"2016-01-11T10:23:49Z","updated_at":"2016-01-11T10:23:49Z","body":"What you are referring to is just a quick hack that I needed and documented for testing.\r\n\r\nThe usage that is of interest for you is in\r\n  https://github.com/ComputationalRadiationPhysics/picongpu/pull/1323\r\nand works a bit more sophisticated :)"}}