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

Can't convert Celsius to K #5

Open
letmaik opened this issue Feb 14, 2016 · 3 comments
Open

Can't convert Celsius to K #5

letmaik opened this issue Feb 14, 2016 · 3 comments

Comments

@letmaik
Copy link

letmaik commented Feb 14, 2016

ucum.convert(20, 'Cel', 'K') throws a long syntax error. Shouldn't that work?

@jmandel
Copy link
Owner

jmandel commented Feb 14, 2016

This is a missing feature: the only conversions ucum.js handles are units
that differ in magnitude but share a common "zero". Agreed this would be
good to support (and I'm surprised it hasn't come up before now).
On Feb 14, 2016 06:29, "Maik Riechert" [email protected] wrote:

ucum.convert(20, 'Cel', 'K') throws a long syntax error. Shouldn't that
work?


Reply to this email directly or view it on GitHub
#5.

@letmaik
Copy link
Author

letmaik commented May 31, 2016

For reference, here's all the function-defined units:

   <unit xmlns="" Code="Cel" CODE="CEL" isMetric="yes" isSpecial="yes" class="si">
      <name>degree Celsius</name>
      <printSymbol>&#176;C</printSymbol>
      <property>temperature</property>
      <value Unit="cel(1 K)" UNIT="CEL(1 K)">
         <function name="Cel" value="1" Unit="K"/>
      </value>
   </unit>

   <unit xmlns="" Code="[degF]" CODE="[DEGF]" isMetric="no" isSpecial="yes" class="heat">
      <name>degree Fahrenheit</name>
      <printSymbol>&#176;F</printSymbol>
      <property>temperature</property>
      <value Unit="degf(5 K/9)" UNIT="DEGF(5 K/9)">
         <function name="degF" value="5" Unit="K/9"/>
      </value>
   </unit>

   <unit xmlns="" Code="[p'diop]" CODE="[P'DIOP]" isMetric="no" isSpecial="yes"
         class="clinical">
      <name>prism diopter</name>
      <printSymbol>PD</printSymbol>
      <property>refraction of a prism</property>
      <value Unit="100tan(1 rad)" UNIT="100TAN(1 RAD)">
         <function name="tanTimes100" value="1" Unit="deg"/>
      </value>
   </unit>

   <unit xmlns="" Code="%[slope]" CODE="%[SLOPE]" isMetric="no" isSpecial="yes"
         class="clinical">
      <name>percent of slope</name>
      <printSymbol>%</printSymbol>
      <property>slope</property>
      <value Unit="100tan(1 rad)" UNIT="100TAN(1 RAD)">
         <function name="100tan" value="1" Unit="deg"/>
      </value>
   </unit>

The two last units above are interesting as it seems that their function names are inconsistent (100tan vs tanTimes100). Apart from that, the unit inside <function> is "deg" but should be "rad" I guess. I had a look at the latest ucum xml file version 2.0.1 and it's still the same. Maybe this should be reported to the UCUM guys.

EDIT: Just opened a ticket for that on UCUM's trac.

Remaining units:

   <unit xmlns="" Code="[hp'_X]" CODE="[HP'_X]" isMetric="no" isSpecial="yes"
         class="clinical">
      <name>homeopathic potency of decimal series (retired)</name>
      <printSymbol>X</printSymbol>
      <property>homeopathic potency (retired)</property>
      <value Unit="hpX(1 1)" UNIT="HPX(1 1)">
         <function name="hpX" value="1" Unit="1"/>
      </value>
   </unit>

   <unit xmlns="" Code="[hp'_C]" CODE="[HP'_C]" isMetric="no" isSpecial="yes"
         class="clinical">
      <name>homeopathic potency of centesimal series (retired)</name>
      <printSymbol>C</printSymbol>
      <property>homeopathic potency (retired)</property>
      <value Unit="hpC(1 1)" UNIT="HPC(1 1)">
         <function name="hpC" value="1" Unit="1"/>
      </value>
   </unit>

   <unit xmlns="" Code="[hp'_M]" CODE="[HP'_M]" isMetric="no" isSpecial="yes"
         class="clinical">
      <name>homeopathic potency of millesimal series (retired)</name>
      <printSymbol>M</printSymbol>
      <property>homeopathic potency (retired)</property>
      <value Unit="hpM(1 1)" UNIT="HPM(1 1)">
         <function name="hpM" value="1" Unit="1"/>
      </value>
   </unit>

   <unit xmlns="" Code="[hp'_Q]" CODE="[HP'_Q]" isMetric="no" isSpecial="yes"
         class="clinical">
      <name>homeopathic potency of quintamillesimal series (retired)</name>
      <printSymbol>Q</printSymbol>
      <property>homeopathic potency (retired)</property>
      <value Unit="hpQ(1 1)" UNIT="HPQ(1 1)">
         <function name="hpQ" value="1" Unit="1"/>
      </value>
   </unit>

   <unit xmlns="" Code="[pH]" CODE="[PH]" isMetric="no" isSpecial="yes" class="chemical">
      <name>pH</name>
      <printSymbol>pH</printSymbol>
      <property>acidity</property>
      <value Unit="pH(1 mol/l)" UNIT="PH(1 MOL/L)">
         <function name="pH" value="1" Unit="mol/l"/>
      </value>
   </unit>

   <unit xmlns="" Code="Np" CODE="NEP" isMetric="yes" isSpecial="yes" class="levels">
      <name>neper</name>
      <printSymbol>Np</printSymbol>
      <property>level</property>
      <value Unit="ln(1 1)" UNIT="LN(1 1)">
         <function name="ln" value="1" Unit="1"/>
      </value>
   </unit>

   <unit xmlns="" Code="B" CODE="B" isMetric="yes" isSpecial="yes" class="levels">
      <name>bel</name>
      <printSymbol>B</printSymbol>
      <property>level</property>
      <value Unit="lg(1 1)" UNIT="LG(1 1)">
         <function name="lg" value="1" Unit="1"/>
      </value>
   </unit>

   <unit xmlns="" Code="B[SPL]" CODE="B[SPL]" isMetric="yes" isSpecial="yes"
         class="levels">
      <name>bel sound pressure</name>
      <printSymbol>B(SPL)</printSymbol>
      <property>pressure level</property>
      <value Unit="2lg(2 10*-5.Pa)" UNIT="2LG(2 10*-5.PAL)">
         <function name="lgTimes2" value="2" Unit="10*-5.Pa"/>
      </value>
   </unit>

   <unit xmlns="" Code="B[V]" CODE="B[V]" isMetric="yes" isSpecial="yes" class="levels">
      <name>bel volt</name>
      <printSymbol>B(V)</printSymbol>
      <property>electric potential level</property>
      <value Unit="2lg(1 V)" UNIT="2LG(1 V)">
         <function name="lgTimes2" value="1" Unit="V"/>
      </value>
   </unit>

   <unit xmlns="" Code="B[mV]" CODE="B[MV]" isMetric="yes" isSpecial="yes" class="levels">
      <name>bel millivolt</name>
      <printSymbol>B(mV)</printSymbol>
      <property>electric potential level</property>
      <value Unit="2lg(1 mV)" UNIT="2LG(1 MV)">
         <function name="lgTimes2" value="1" Unit="mV"/>
      </value>
   </unit>

   <unit xmlns="" Code="B[uV]" CODE="B[UV]" isMetric="yes" isSpecial="yes" class="levels">
      <name>bel microvolt</name>
      <printSymbol>B(&#956;V)</printSymbol>
      <property>electric potential level</property>
      <value Unit="2lg(1 uV)" UNIT="2LG(1 UV)">
         <function name="lgTimes2" value="1" Unit="uV"/>
      </value>
   </unit>

   <unit xmlns="" Code="B[10.nV]" CODE="B[10.NV]" isMetric="yes" isSpecial="yes"
         class="levels">
      <name>bel 10 nanovolt</name>
      <printSymbol>B(10 nV)</printSymbol>
      <property>electric potential level</property>
      <value Unit="2lg(10 nV)" UNIT="2LG(10 NV)">
         <function name="lgTimes2" value="10" Unit="nV"/>
      </value>
   </unit>

   <unit xmlns="" Code="B[W]" CODE="B[W]" isMetric="yes" isSpecial="yes" class="levels">
      <name>bel watt</name>
      <printSymbol>B(W)</printSymbol>
      <property>power level</property>
      <value Unit="lg(1 W)" UNIT="LG(1 W)">
         <function name="lg" value="1" Unit="W"/>
      </value>
   </unit>

   <unit xmlns="" Code="B[kW]" CODE="B[KW]" isMetric="yes" isSpecial="yes" class="levels">
      <name>bel kilowatt</name>
      <printSymbol>B(kW)</printSymbol>
      <property>power level</property>
      <value Unit="lg(1 kW)" UNIT="LG(1 KW)">
         <function name="lg" value="1" Unit="kW"/>
      </value>
   </unit>

   <unit xmlns="" Code="bit_s" CODE="BIT_S" isMetric="no" isSpecial="yes"
         class="infotech">
      <name>bit</name>
      <printSymbol>bit<sub>s</sub>
      </printSymbol>
      <property>amount of information</property>
      <value Unit="ld(1 1)" UNIT="ld(1 1)">
         <function name="ld" value="1" Unit="1"/>
      </value>
   </unit>

In the latest UCUM release, there's also the following function-defined unit:

   <unit Code="[m/s2/Hz^(1/2)]" CODE="[M/S2/HZ^(1/2)]" isMetric="no" isSpecial="yes"
         class="misc">
      <name>meter per square seconds per square root of hertz</name>
      <printSymbol/>
      <property>amplitude spectral density</property>
      <value Unit="sqrt(1 m2/s4/Hz)" UNIT="SQRT(1 M2/S4/HZ)">
         <function name="sqrt" value="1" Unit="m2/s4/Hz"/>
      </value>
   </unit>

@govpack
Copy link

govpack commented Jun 1, 2016

...

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

3 participants