As always, a pull request is welcome.

-tk

On Mon, Aug 22, 2016 at 7:11 PM, Andrew Milner <[email protected]>
wrote:

> Just seen this thread, and this is something that somewhat annoyed me as
> well, since all the extra digits cluttered up the database viewing.  I
> 'solved' (got around) it by specifying the precision in the column
> definitions since MySQL allows this for float, real and double precision.
> Couldn't the schema just be altered to specify the precision for all fields
> and make weewx more human friendly? Most columns only require at most 2
> decimals, and many 0 or 1 for practical purposes, and weewx remains
> oblivious to the column definition change.  I changed the schema in mesowx
> with no issues so it should work for weewx.
>
>
> On Friday, 12 February 2016 15:11:38 UTC+2, Pat O'Brien wrote:
>
>> Thanks for the explanation. It all makes sense, especially laid out like
>> that. Many areas in play with the observations, so I'm glad to see I'm
>> doing it right!
>>
>>
>> On Friday, February 12, 2016 at 8:03:53 AM UTC-5, mwall wrote:
>>>
>>> On Thursday, February 11, 2016 at 7:28:24 PM UTC-5, Pat O'Brien wrote:
>>>
>>> I was having a look in the database today, and noticed that a lot of the
>>>> archive records and the archive_day_* tables have observations with 12
>>>> decimals. Seems to be a bit long.
>>>>
>>>> So I'm just checking to see if my driver should control the float
>>>> length (maybe _packet['windSpeed'] = '{0:.2f}'.format( data["windSpeed"
>>>> ] ) this is untested)  or is this supposed to be handled within weewx
>>>> somewhere and I have it configured incorrectly?
>>>>
>>>
>>> hi pat,
>>>
>>> you are doing it right - using float() is the appropriate way to convert
>>> from string.
>>>
>>> precision (number of decimal places) shows up in a few places, including:
>>>
>>> 1) how the database stores a REAL number.  nothing to do here.  it is
>>> what it is.
>>>
>>> 2) how your database browser displays a REAL number.  some database
>>> browsing tools let you specify how many decimal places you want to see,
>>> some even on a per-column basis.  this does not affect the data - just what
>>> you see.
>>>
>>> 3) how weewx (in python) represents a float.  nothing to do here.  it is
>>> what it is.
>>>
>>> 4) how weewx displays a float.  this is an issue when writing a weewx
>>> template.  use the cheetah/python formatting to display the number of
>>> decimal places you want to see.
>>>
>>> 5) how weewx uploads a float to wunderground, etc.  this is only an
>>> issue if you are writing an uploader - an extension that uploads data.
>>> values are typically converted to a string then sent using http POST or
>>> similar mechanism.  use python formatting in your uploader to specify the
>>> number of decimal places that the destination requires.
>>>
>>> m
>>>
>>

Reply via email to