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

Mixing ratios and the like for Climate Science #768

Open
natgeo-wong opened this issue Feb 13, 2025 · 3 comments
Open

Mixing ratios and the like for Climate Science #768

natgeo-wong opened this issue Feb 13, 2025 · 3 comments

Comments

@natgeo-wong
Copy link

Hi! I have a question.

In Climate Science, it is very common for units to be expressed in kg kg^-1 (e.g., specific humidity). However, in Unitful.jl this is taken to be (i.e., unitless), which while technically accurate is not how it is done realistically.

Is there a way to specify to prevent the default multiplication of units?

@Ickaser
Copy link

Ickaser commented Feb 14, 2025

If I am not mistaken, the reason that you do not want them to cancel is that strictly, you are thinking of e.g. kg H2O / kg air or similar. You might consider https://github.com/rafaqz/UnitfulMoles.jl , or a similar approach, where you explicitly include the substance in your units.

Worth noting is that if you have e.g g/kg, this won't be cancelled automatically, but neither is it any more informative than kg kg^-1.

@natgeo-wong
Copy link
Author

natgeo-wong commented Feb 14, 2025

Yes, this is true. However, what I am trying to do in ERA5Reanalysis.jl is to try and convert the units provided by default from the dataset into actual usable units in Unitful.jl for printing and later manipulation.

What you are suggesting is good if we are self-defining units, but I'm not self-defining these units, I am taking them from a dataset, so I do need to try and find some way to convert back and forth.

@Ickaser
Copy link

Ickaser commented Feb 15, 2025

I am assuming that the underlying dataset is essentially a bunch of numbers, with human-readable column headers or some such that you are using to attach Unitful units to the numbers. Does that need to be done programmatically? If you as the human are reading these units and manually interpreting e.g. kg H20/kg air, then if for your analysis you have already defined a unit named "kgH2O" there is nothing to stop you applying that to the column.

What are the specific contexts where you need kg kg^-1 not to cancel? I imagine that by the time you provide an actionable number one or the other will have been cancelled anyway, by multiplying. Or do you want it to show up in plots or results as kg/kg? Fundamentally the only reason I can see for it not cancelling is if it truly means "kg of substance A"/"kg of substance B", otherwise the number truly is a dimensionless number and shouldn't need any unit annotation.

I am not a maintainer of the package, really, but spend a lot of time thinking about this kind of thing and am curious what the use case looks like (and eager to offer any help if I can).

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

No branches or pull requests

2 participants