Questions tagged [units-of-measurement]
Units of Measure are compile-time attributes that can be associated with numeric values, typically used to indicate length, volume, mass, and so on.
606
questions
0
votes
1
answer
72
views
F# Bitwise operators and units of measure
When I define a unit of measure in my code, I can use the basic arithmetic operators on values with the unit without any problems, e.g.
type [<Measure>] m
let a = 1<m>
let b = 2<m>
(...
3
votes
0
answers
48
views
Unitful - Automatic conversion to preferred units under multiplication and division
I've just started using Unitful.jl to automatically perform dimensional analysis and unit conversion in my code. This does exactly what I want if I add or subtract variables - I work with atoms and ...
1
vote
0
answers
25
views
How I can convert the value of a unit into an other unit?
I have to convert a value from the old unit into the new unit.
The old unit can be mg/l and the new unit can be ug/ml. The oldValue is 8 mg/l. When I use the converter of google it shows me that the ...
-2
votes
1
answer
63
views
How to add two numbers having same units in python
I have a pandas dataframe where one column has values in kiloTon as abbreviated 'kt'. Now when I perform groupby on Country column and year column and call aggregation function sum on Value column, it'...
0
votes
1
answer
25
views
How to store Measurement in NSUbiquitousKeyValueStore?
I have a Measurement<UnitMass> object that I want to store in NSUbiquitousKeyValueStore. I use Measurement because I need to convert values between various locale on a regular basis.
I have ...
2
votes
2
answers
62
views
How to measure an monochrome area with unit squares made from a custom gridline?
I have an image with gridline like this and I want to measure each monochrome area with unit squares made from that gridline. The squares that mix with different colours shall not be counted. In the ...
0
votes
0
answers
51
views
problem using ggplot2::stat_summary with units in R
I receive an error when using stat_summary on values with defined units. The code works fine on unitless data. Any suggestions what I am doing wrong?
library(tidyverse)
library(units)
tb <- tibble(...
0
votes
0
answers
15
views
How can I ensure consistency in CRS and units between a spatial polygon dataframe and a list of observations with coordinates?
I have two files, one is a spatial polygon dataframe with a country boundary. The second is a list of observations and associated coordinates.
I need to ensure that these files are in the same CRS and ...
0
votes
3
answers
45
views
Where has the "units" sub-module in qiskit_nature gone?
I am trying to follow this qiskit "Electronic Structure" tutorial, but at the very first step, setting up the PySCF driver with the following
from qiskit_nature.units import DistanceUnit
...
1
vote
0
answers
52
views
Return pound-ounces instead of decimal pounds when using Measurement
Is it possible to have Measurement return 2lb 8oz instead of 2.5 lb when 2.5 is provided as the value as in the example below?
var pounds = Measurement(value:2.5, unit: UnitMass.pounds)// outputs 2.5 ...
0
votes
0
answers
48
views
How to show different mesurement units according to the user locale in flutter/dart
I have to display a Value in both imperial and metric systems for example 1000 Liter could be displayed as 1000 Gallons or 1000 Gl for shorl if the user is in the USA. or
500 ml vs 500 Oz
100 Miles ...
0
votes
0
answers
67
views
satisfaction of atomic constraint ' ' depends on itself and ICE when overloading operator*
I wanted to create custom Vector class that would work with mp-units, but i can't make operator*() and `operator*(). I reproduced issue on godbolt: https://godbolt.org/z/sMbxccMev Here is problematic ...
0
votes
0
answers
27
views
Why CSS sets a different computed style to width and margin when using mm units?
Changing a visible node's style width or marginLeft to 10px gives the same computed style: 10px.
However, on several navigators, it gives different results with 1mm.
Why ?
I ran this code:
const d = ...
0
votes
0
answers
87
views
Make an image the same size as a vector icon in React Native
I am using square vector icons stored in a font. I can specify a font size for the icons. The React Native docs for text props do not specify a unit for fontSize:
I also have some square .png images. ...
1
vote
0
answers
80
views
Retreive the Quantity used to define a Unit in Java Unit of Measurement API (JSR 385)
I'm using JSR-385 with the RI (Indriya). I have a Quantity q1 and defined as such:
QuantityFormat qf = ServiceProvider.current().getFormatService().getQuantityFormat();
Quantity q1 = qf.parse("10 ...
1
vote
1
answer
147
views
Automatic reduction and cancellation of units with SymPy
I am having issues with getting units to cleanly simplify. The program I am writing is involved with the calculation of spring properties, requiring 10/11 user controlled variables and about a dozen ...
2
votes
2
answers
146
views
How can I parse the unit : "g/100mL" using unit-parse in Python?
I'm trying to parse strings in Python, looking for scientific values and units. I want to retrieve them in order to convert them to some other units.
I'm using the library unit-parse (based on pint) ...
0
votes
0
answers
58
views
Convert image pixels and display in a Word document
I'm trying the following code conversion to fit images in a table frame defined in a Word document.
The calculation is working fine and generates fitting images. But still I want to understand what is ...
1
vote
1
answer
34
views
R Reference Class: Field of type 'units'
I have a reference class, one of the fields for which is a 'units' object from the R units package. My initial class definition looked like this:
MyClass =
setRefClass(
"MyClass"...
0
votes
1
answer
131
views
How should I extract specific words in a string in a dataframe into a different column?
I have a dataset where one of the columns' rows are populated with strings with a few pieces of information, some of which I would like to extract into a different column.
Currently, I have something ...
0
votes
1
answer
75
views
std::cin and units library
I'm having a problem with a program I'm making when I try to ask the user to enter a value and then saving it to use it later in a formula.
This what I have done, the problem is that I can't use std::...
1
vote
1
answer
147
views
how to set a relative box size in toga python
I'm making an app with Beeware and toga using python and I need a box to be half size of its parent.
Does toga have relative size units like CSS? How do I use them?
I thought to use the parent box ...
1
vote
0
answers
197
views
Explain total memory reported by node on AKS
I'm trying to understand what the memory capacity means when running: kubectl describe node <mynode>
Snippet of the Result:
status:
capacity:
cpu: '16'
ephemeral-storage: 129886128Ki
...
0
votes
0
answers
39
views
LibreOffice Writer: the Outling/Spacing units have changed inches to ch / lines. How to change them back?
That's basically it. Outline/Spacing units have somehow switch to "ch" for the Before Text and like attributes, and have changed to "lines" for the spacing between paragraphs. Gone ...
0
votes
1
answer
48
views
Setting an alias name on a ProductUnit fails to return that alias during serialization
Task
I am trying to set an alias name on a UOM ProductUnitto allow the unit to be displayed in a human-friendly name in JSON/my frontend. The unit in question is "kg/h", so a mass-flow rate ...
0
votes
0
answers
167
views
How to have Leaflet.draw display Imperial units while drawing?
This doesn't work for much of anything really that I can tell.
I want to remove the meters while drawing without having to do it in a hackish way. I am thinking I can just grab it and do some stuff ...
0
votes
0
answers
71
views
Basic units in Python doesn't run graph
I'm trying to run this code(Below) that try to run 4 graphs in a single image help to run it please:
But I'm receiveing this error:
ModuleNotFoundError: No module named 'basic_units'
code:
from ...
1
vote
2
answers
65
views
How to calibrate length units for different display devices?
I need to be able to work with real length units for any display device and have to be able to rely on them. So I made myself a little ruler. On my laptop screen it comes out way too small. On my ...
0
votes
2
answers
25
views
What source of implicit spacing in a sequence of inline-block div (why does my "ruler" show too wide?)
I am trying to understand and test absolute length measurements by making a ruler that should show 1 cm wide major divs, with 1 mm wide minor divs with the half way mark being a little taller. But it'...
0
votes
0
answers
63
views
Who has a success story using a C++ units of measure library?
Automatic checking and conversion of unit of measure seems compelling for engineering or scientific programming but there is not widespread uptake and there have been many complaints about some of the ...
0
votes
1
answer
181
views
Is there a way to use a percent value in window.scrollTo()
I have a window.scrollTo() function on my website. It uses just a number value (or pixels) which works fine in a larger-sized window but does not scroll where I want on mobile devices. Instead, I want ...
0
votes
1
answer
43
views
MATLAB Can't assign VariableUnits to TimeTable
I'm trying to create a timetable for a motor simulation. I would like to keep track of the units of each variable.
Here is my code, a script in a file called CreateTT.m:
time.start = duration(0,0,0,0);...
0
votes
1
answer
438
views
How do I convert a Sympy expression to a floating point number?
I have been trying to swap from using Pint.py for units to using the Sympy units system.
I have examples of both code working in the image.
I need help please, converting the Sympy expresion to a ...
0
votes
1
answer
402
views
How are currency units used with Python Pint units?
I would like to do something like this:
import pint
ureg = pint.UnitRegistry()
kg = ureg.kg
USD = ureg.USD # not the way to do this
weight = 2.3 * kg
price = 1.49 * USD / kg
cost = weight * price
...
3
votes
2
answers
1k
views
How do I measure the center of the largest segmented region within an image?
I am following the code here, and after finishing step 3, I am given the segmented region of a particular slice image. My question is, how can I find the center of the large white region in the ...
1
vote
1
answer
86
views
Issue with generically casting a float with units to different units in F#
I am having a major issue handling units of measure in F#. I have handled them successfully so far, but I have only either been removing units to get back a float or casting a float to one with units. ...
0
votes
1
answer
81
views
Find the original MeasureBase value with python-measurement
python-measurement is a library to read measurements pythonically, https://python-measurement.readthedocs.io/en/latest/index.html e.g.
>>> from measurement.measures import Weight
>>> ...
0
votes
0
answers
137
views
Why is one CSS pixel not always equal to 1/96 inch?
Recently, I was reading about the different types of pixels. I came across device pixels, CSS pixels, and device-independent pixels. I found out that device-independent pixels or dips can't be used on ...
2
votes
1
answer
32
views
Removing Measurement Units from Cell Array
I am trying to remove the units out of a column of cell array data i.e.:
cArray =
time temp
2022-05-10 20:19:43 '167 °F'
2022-05-10 20:19:53 '173 °F'
2022-05-10 20:20:03 '177 °F'
......
2
votes
1
answer
924
views
C++ concept: Requiring a static variable to be present in a policy class
I want to constraint the template parameters of a policy class.
That is, when I call Foo<policy>, I want the compiler to stop here if the policy class does not fulfill the requirements I want.
...
1
vote
1
answer
347
views
Pint: How do I define my own units in the Pint Python library?
I am working with Pint to do unit conversions in a Python project. The project involves temperature gradients, which are not defined in Pint. My units are typically "deg.C/km" so I'd like ...
2
votes
1
answer
115
views
D3D12 CreateHeap alignment, Does MSDN use 1024 or 1000 for its definition of KB
I am trying to use CreateHeap and PlacedResources in DirectX12. However for CreateHeap it requires a D3D12_HEAP_DESC where it says "applications should pass SizeInBytes (a field of the ...
1
vote
0
answers
135
views
When I convert pixels to physical units using "extent" inside of plt.imshow(), my subplots that rely on units of pixels break
I'm trying to plot an image using physical units instead of pixels (I use extent to imitate this). On the top and side of my plot is a plot of the lineout of my image. Everything is originally in ...
0
votes
1
answer
96
views
How to convert <class 'UnitsNet.Ratio'> to a float type number for calculations?
When I call a function via my company's API, I get a result which looks like a float number - for example 0.38
However, the type of these numbers are Ratio objects with the type UnitsNet.Ratio. I ...
2
votes
2
answers
118
views
Any way to fix or ignore warning FS1240 "This type test or downcast will ignore the unit-of-measure" in F#?
I have the following code:
/// Constant for use in comparing floats within the ray tracer
[<Literal>]
let epsilon = 0.00001
/// Compares the two floats to see if they are epsilon away from each ...
1
vote
0
answers
25
views
How to generalise printing measure [duplicate]
I'm dealing with fees in some currency. My question is about implementing the currency with a unit of measurement, which seems more "natural" than a discriminated union type Currency = EUR | ...
2
votes
1
answer
102
views
Should I enforce a type with F# units of measure? [Style vs generality]
This question relates to F# units of measure.
Should I enforce a type for a unit I am using.
For example should I enforce that seconds are always a float?
let asSeconds time = float(time)*1.0<...
0
votes
1
answer
154
views
pint: electron_volt as base unit
Is there any way to have the composed unit eV as a base unit in pint using a straight forward combination of @system, @group and possibly some contextual conversions in a definition file?
What I want ...
-2
votes
1
answer
1k
views
Removing units of measurement from a database (python)
I have a database that looks like the picture. I would like to remove all units of measurement. Some columns have writing on them is there any way I can do this?
3 390 kg/m3 1081 J/kgK 0.1 W/mK
4 ...
1
vote
1
answer
142
views
How do I format a JSR-385 Quantity with fixed number of decimal digits?
I'm trying to convert hard-coded formatting to a Java Units API implementation.
The existing code outputs (for this example, the temperature value in degrees) with two decimal places. For example, 38....