[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20040510: Question on ucar.units package: getting scale factor



Rashad,

>Date: Mon, 10 May 2004 14:04:34 -0400
>From: "El-Badrawi,Rashad" <address@hidden>
>Organization: UCHC
>To: "Steve Emmerson" <address@hidden>
>Subject: RE: 20040510: Question on ucar.units package: getting scale factor

The above message contained the following:

> Thanks a lot for your reply. Can you give me an example of what you
> suggested, because it seems a little abstract to me.

Here's an example:

    utUnit      unit = utScan("millimoles per meter^3);
    double      amountOfUnit = ...
    utUnit      stdUnit = utScan("micromoles per liter");
    double      scale, offset;

    utConvert(unit, stdUnit, &scale, &offset);

    printf("The concentration is %g micromoles per liter\n",
        amountOfUnit*scale);

I've omitted any tests for errors or unit compatibility.

The idea is that, if you have a canonical unit (to which everything
should be related) then you can convert all values to that unit in order
to display them.

>       Regards,
>       Rashad 

Regards,
Steve Emmerson


NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.