Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set SI units #1622

Open
rl3418 opened this issue May 23, 2024 · 5 comments
Open

set SI units #1622

rl3418 opened this issue May 23, 2024 · 5 comments
Labels

Comments

@rl3418
Copy link

rl3418 commented May 23, 2024

I pip installed openpmd_api 0.15.2 and tried to do particle writing. I have attached the script I used down below. Setting Unit.si showed an error saying that 'openpmd_api.openpmd_api_cxx.Record' object has no attribute 'unit_SI'. Everything else works just fine.

boost along z.txt

@rl3418
Copy link
Author

rl3418 commented May 24, 2024

It seems that set units should be applied to electrons["momentum"]['x'].unit_SI instead of electrons["momentum"].unit_SI. Just wanna check if that is correct.

@franzpoeschel
Copy link
Contributor

Hello,

yes, the unit_SI should be applied to the last level as it is possible that it needs to be specified separately for each component.

I also see a comment "This section I don't know how to implement" down in the file. Do you have a specific question there? Otherwise, the workflow is the same as for the other data, except that you specify io.Record_Component.SCALAR] to indicate that the last level is not needed, i.e.:

weighting = electrons["weighting"][io.Record_Component.SCALAR]
weighting.reset_dataset(...)
weighting.store_chunk(w)

@rl3418
Copy link
Author

rl3418 commented May 24, 2024

For weighting how do I set the SI unit? I thought [io.Record_Component.SCALAR] declares that the last level is not needed, so I just applied unit_SI to the top level. This is the code I used.

weighting = electrons["weighting"][io.Record_Component.SCALAR]
electrons["weighting"].unit_dimension = {Unit_Dimension.L: 0}
electrons["weighting"].unit_SI = 1.0

@franzpoeschel
Copy link
Contributor

That will work in the next version of openPMD-api (or to be more precise: [io.Record_Component.SCALAR] is no longer necessary at all since it causes too much confusion). For now, you'll have to write electrons["weighting"][io.RecordComponent.SCALAR].unit_SI = 1.0.

@rl3418
Copy link
Author

rl3418 commented May 24, 2024

Great, thanks for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants