Open kinverarity1 opened 4 years ago
One possible solution would be to create a unit conversion module or class with a generic function: convert_unit(las, from, to)
or method: las.converter.convert_unit(from, to)
that:
The conversion formulas could be written in Lasio and/or a unit conversion package could be added as a dependency or optional dependency to do the actual conversions. I lean toward writing the popular conversions in Lasio. I think there is some existing conversion code already in Lasio. That should be considered in code organization decisions.
Then, as a later iteration/enhancement, add a unit conversion package as an option dependency. If a user has the optional package installed then Lasio would use that instead of the internal conversions.
Here is an incomplete list of actively managed unit conversion packages. If one has popular usage in the general LAS community, that is probably the one to consider.
Pint
Astropy.units
unyt
Is this a good approach? Are there other approaches that are of interest?
I think the idea of a generic function is an excellent approach, and I think we should keep the unit conversion code written in lasio for now. I would prefer to avoid any additional dependencies unless they add a lot of functionality.
Let's also keep the list of units fairly short - whatever is currently in there, like meter, foot, inch, and any others.
Feels to me like this should be easier to achieve.
See below for what I guess is close to a minimal working example of how to change a LAS file from index units of centimetres to metres: