diff --git a/README.md b/README.md index 0baa46e1..4d9d0741 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,10 @@ The code lives in a git repository: [https://github.com/weewx/weewx](https://github.com/weewx/weewx) -The `master` branch is stable, the `development` branch contains changes that will appear in the next release. See the file [CONTRIBUTING.txt](CONTRIBUTING.txt) for details about branching, and the file [PACKAGING.txt](PACKAGING.txt) for details about the process of creating a release. +See [Notes for WeeWX developers](https://weewx.com/docs/latest/devnotes/) to +learn about how to contribute to WeeWX. See the file +[PACKAGING.txt](PACKAGING.txt) for details about the process of creating a +release. ## Documentation and Support diff --git a/docs_src/devnotes.md b/docs_src/devnotes.md index 801bfc50..aaece7a3 100644 --- a/docs_src/devnotes.md +++ b/docs_src/devnotes.md @@ -60,16 +60,16 @@ To meet these goals, the following strategies were used: [ConfigObj](https://configobj.readthedocs.io) module, by Michael Foord and Nicola Larosa, was chosen to read the configuration file. This allows many options that might otherwise have to go in the - code, to be in a configuration file. + code to be in a configuration file. - A powerful templating engine. The [Cheetah](https://cheetahtemplate.org/) module was chosen for - generating html and other types of files from templates. Cheetah + generating HTML and other types of files from templates. Cheetah allows *search list extensions* to be defined, making it easy to extend WeeWX with new template tags. - Pure Python. The code base is 100% Python — no underlying C - libraries need be built to install WeeWX. This also means no + libraries need to be built in order to install WeeWX. This also means no Makefiles are needed. While WeeWX is nowhere near as fast at generating images and HTML as its @@ -80,10 +80,10 @@ MHz machine where generating the 9 images used in the *Current Conditions* page takes just under 2 seconds (compared with 0.4 seconds for wview). -All writes to the databases are protected by transactions. You can kill +Transactions protect all writes to the databases. You can kill the program at any time without fear of corrupting the databases. -The code makes ample use of exceptions to insure graceful recovery from +The code makes ample use of exceptions to ensure graceful recovery from problems such as network outages. It also monitors socket and console timeouts, restarting whatever it was working on several times before giving up. In the case of an unrecoverable console error (such as the @@ -112,7 +112,7 @@ a difference: 2. In the database. Either US or Metric can be used. -3. In the presentation (i.e., html and image files). +3. In the presentation (i.e., HTML and image files). The general strategy is that measurements are converted by service `StdConvert` as they come off the weather station into a target @@ -142,34 +142,32 @@ is used as the primary key in the SQL database. ## Time -WeeWX stores all data in UTC (roughly, *Greenwich* or *Zulu*) time. -However, usually one is interested in weather events in local time and -want image and HTML generation to reflect that. Furthermore, most -weather stations are configured in local time. This requires that many -data times be converted back and forth between UTC and local time. To -avoid tripping up over time zones and daylight savings time, WeeWX -generally uses Python routines to do this conversion. Nowhere in the -code base is there any explicit recognition of DST. Instead, its -presence is implicit in the conversions. At times, this can cause the -code to be relatively inefficient. +WeeWX stores all data in Unix epoch time (roughly, *UTC*, *Greenwich* or *Zulu*) +time. However, usually one is interested in weather events in local time and +wants image and HTML generation to reflect that. Furthermore, most weather +stations are configured in local time. This requires that many data times be +converted back and forth between Unix time and local time. To avoid tripping up +over time zones and daylight savings time, WeeWX generally uses Python routines +to do this conversion. Nowhere in the code base is there any explicit +recognition of DST. Instead, its presence is implicit in the conversions. At +times, this can cause the code to be relatively inefficient. -For example, if one wanted to plot something every 3 hours in UTC time, -it would be very simple: to get the next plot point, just add 10,800 to +For example, if one wanted to plot something every 3 hours in Unix time, +it would be very simple: to get the next plot point, add 10,800 to the epoch time: ``` next_ts = last_ts + 10800 ``` -But, if one wanted to plot something for every 3 hours *in local time* -(that is, at 0000, 0300, 0600, etc.), despite a possible DST change in -the middle, then things get a bit more complicated. One could modify the -above to recognize whether a DST transition occurs sometime between -`last_ts` and the next three hours and, if so, make the necessary -adjustments. This is generally what `wview` does. WeeWX takes a -different approach and converts from UTC to local, does the arithmetic, -then converts back. This is inefficient, but bulletproof against changes -in DST algorithms, etc.: +But if one wanted to plot something for every 3 hours *in local time* (that is, +at 0000, 0300, 0600, etc.), despite a possible DST change in the middle, then +things get a bit more complicated. One could modify the above to recognize +whether a DST transition occurs sometime between `last_ts` and the next three +hours and, if so, make the necessary adjustments. This is generally what `wview` +does. WeeWX takes a different approach and converts from UTC to local, does the +arithmetic, then converts back. This is inefficient, but bulletproof against +changes in DST algorithms, etc.: ``` time_dt = datetime.datetime.fromtimestamp(last_ts) @@ -188,9 +186,9 @@ times will probably be incorrect. ## Archive records An archive record's timestamp, whether in software or in the database, -represents the *end time* of the record. For example, a record -timestamped 05-Feb-2016 09:35, includes data from an instant after -09:30, through 09:35. Another way to think of it is that it is exclusive +represents the *end time* of the record. For example, with a 5-minute archive +time, a record timestamped 05-Feb-2016 09:35 includes data from an instant +after 09:30, through 09:35. Another way to think of it is that it is exclusive on the left, inclusive on the right. Schematically: ``` @@ -198,7 +196,7 @@ on the left, inclusive on the right. Schematically: ``` Database queries should reflect this. For example, to find the maximum -temperature for the hour between timestamps 1454691600 and 1454695200, +temperature for the hour between timestamps `1454691600` and `1454695200`, the query would be: ``` @@ -206,12 +204,12 @@ SELECT MAX(outTemp) FROM archive WHERE dateTime > 1454691600 and dateTime <= 1454695200; ``` -This ensures that the record at the beginning of the hour (1454691600) +This ensures that the record at the beginning of the hour (`1454691600`) does not get included (it belongs to the previous hour), while the -record at the end of the hour (1454695200) does. +record at the end of the hour (`1454695200`) does. -One must be constantly be aware of this convention when working with -timestamped data records. +One must be constantly aware of this convention when working with timestamped +data records. Better yet, if you need this kind of information, use an [xtypes](https://github.com/weewx/weewx/wiki/WeeWX-V4-user-defined-types) @@ -224,7 +222,7 @@ max_temp = weewx.xtypes.get_aggregate('outTemp', db_manager) ``` -It will not only make sure the limits of the query are correct, but will +It will not only make sure the limits of the query are correct but will also decide whether the daily summary optimization can be used ([details below](#daily-summaries)). If not, it will use the regular archive table. @@ -314,7 +312,7 @@ This is what the table columns mean: