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

Include pint's spectroscopy (and other context) option(s) #18

Closed
jmason86 opened this issue Dec 6, 2016 · 5 comments
Closed

Include pint's spectroscopy (and other context) option(s) #18

jmason86 opened this issue Dec 6, 2016 · 5 comments

Comments

@jmason86
Copy link

jmason86 commented Dec 6, 2016

Great tool! It would be really nice to also take advantage of the more advanced conversions already available in pint, such as converting between energy and length in the context of spectroscopy (e.g., 1 Å = 12398 eV for light).

@deanishe
Copy link
Owner

deanishe commented Dec 6, 2016

I'm afraid that means nothing to me. Are you talking about a new version of pint?

@jmason86
Copy link
Author

jmason86 commented Dec 6, 2016

In the Pint default definition file that you linked to in the description, is this code:
@context(n=1) spectroscopy = sp # n index of refraction of the medium. [length] <-> [frequency]: speed_of_light / n / value [frequency] -> [energy]: planck_constant * value [energy] -> [frequency]: value / planck_constant # allow wavenumber / kayser 1 / [length] <-> [length]: 1 / value @end
I tried conv sp in alfred, but it insists that the first input be a number. I also tried a direct conversion between energy and length (eV to angstrom) but it gave an error that the units didn't make sense.

@deanishe
Copy link
Owner

deanishe commented Dec 6, 2016

Right, I've got you. Contexts are not currently supported.

I'm afraid this is over my head mathematically speaking. Could you give me a couple of examples of conversions that should work (sp 1Å ev -> 12398 eV perhaps?), and I'll adjust the parser to allow a context as the first argument.

@jmason86
Copy link
Author

jmason86 commented Dec 7, 2016

Awesome thanks!
More examples would be
sp 54 Å eV-> 229.60 eV
sp 30 keV Å -> 0.4132 Å
sp 0.5 keV nm -> 2.4796 nm

deanishe added a commit that referenced this issue Nov 2, 2017
@deanishe
Copy link
Owner

deanishe commented Nov 2, 2017

Finally added in v3.2.

@deanishe deanishe closed this as completed Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants