weather.git
3 years agoPrepare for 2.4.1 release 2.4.1
Jeremy Stanley [Sun, 30 Aug 2020 18:08:25 +0000 (18:08 +0000)]
Prepare for 2.4.1 release

Update the version string in the project and manpages.

3 years agoRefresh correlation data
Jeremy Stanley [Sun, 30 Aug 2020 18:07:36 +0000 (18:07 +0000)]
Refresh correlation data

Another data refresh, preparing for an upcoming release.

3 years agoUpdate correlation data
Jeremy Stanley [Sat, 1 Aug 2020 19:21:12 +0000 (19:21 +0000)]
Update correlation data

Normalize the overrides, remove some stale overrides for defunct
stations, and regenerate the correlation data set.

3 years agoRefresh active station list and correlation data
Jeremy Stanley [Sun, 26 Jul 2020 19:10:14 +0000 (19:10 +0000)]
Refresh active station list and correlation data

Perform a fresh build of data sets from current sources, and add a
few additional overrides for previously unknown stations.

3 years agoMake missing alert URLs non-fatal
Jeremy Stanley [Sat, 25 Jul 2020 15:32:44 +0000 (15:32 +0000)]
Make missing alert URLs non-fatal

As a more complete fix and future-proofing for the earlier mismatch
between default_atypes and the alert URLs generated for WX zones
during correlation, stop aborting and simply add a warning if a
requested alert type has no corresponding URL.

3 years agoCorrect default_atypes to match what's generated
Jeremy Stanley [Sat, 25 Jul 2020 15:26:16 +0000 (15:26 +0000)]
Correct default_atypes to match what's generated

Kevin Monceaux reported a regression with the 2.4 release. Running
with the -a/--alert option and no limited --atypes or atypes
override in weatherrc resulted in a message about undefined URLs
and no normal output. This problem crept in when hard-coding alert
types in the correlator after ditching the woefully unmaintained
zonecatalog.curr.tar data source (commit 8a37edd).

Update default_atypes so that it covers all relevant non-forecast
URLs the correlate routine embeds.

3 years agoMake the build reproducible
Chris Lamb [Thu, 9 Jul 2020 14:22:07 +0000 (15:22 +0100)]
Make the build reproducible

While auditing Debian's packages, Chris Lamb reported[*] that
weather-util's correlation set generation is not reproducible
because it embeds timestamps without a means to override them and
also varies by system timezone. Allow SOURCE_DATE_EPOCH from the
calling environment and assume UTC rather than relying on locale
settings when no timezones are specified.

[*] https://bugs.debian.org/964721

3 years agoUpdate release notes and docs for 2.4 release 2.4
Jeremy Stanley [Sun, 21 Jun 2020 20:20:08 +0000 (20:20 +0000)]
Update release notes and docs for 2.4 release

3 years agoGet correlate() working in modern Python 3
Jeremy Stanley [Sun, 21 Jun 2020 20:13:14 +0000 (20:13 +0000)]
Get correlate() working in modern Python 3

Update a bunch of the parsing for various correlation source files
to work in both Python 2.7 and 3.5+, mostly where str vs bytes and
UTF-8 encoding/decoding are concerned. This can be cleaned up
significantly once support for 2.7 is finally dropped.

3 years agoBe more thorough about file copyrights
Jeremy Stanley [Sun, 21 Jun 2020 13:46:39 +0000 (13:46 +0000)]
Be more thorough about file copyrights

Add a copyright header to the .gitignore file with start and end
years determined from its commit history. Add copyright headers for
the current year to overrides.log and qa.log, and also add
functionality to correlate() which adds these headers from now on.
Update the copyright year on overrides.conf, which was missed in
8a37edd and later commits. All files tracked in this repository now
declare a copyright and refer to the main LICENSE file for licensing
terms.

3 years agoDon't use "is" with a literal to test for equality
Jeremy Stanley [Tue, 2 Jun 2020 14:10:49 +0000 (14:10 +0000)]
Don't use "is" with a literal to test for equality

Solve a SyntaxWarning under Python 3.8 and later for use of the "is"
identity operator when comparing literals, by replacing with the
"==" equality operator.

3 years agoCaching support for URLs with port numbers
Jeremy Stanley [Sun, 31 May 2020 14:39:34 +0000 (14:39 +0000)]
Caching support for URLs with port numbers

When mangling URLs of fetched data to store in the local cache, only
split on the first colon so that URLs with port numbers in them are
properly differentiated. Previously, all URLs for the same domain
name landed in a single file if a port number was included, causing
incorrect results to be returned from the cache.

3 years agoUse a dedicated field for cached search timestamps
Jeremy Stanley [Sun, 31 May 2020 00:24:10 +0000 (00:24 +0000)]
Use a dedicated field for cached search timestamps

Fix a cache corruption issue by using a new "cached" field to hold
the timestamp for cached correlation search results. Previously the
"description" field was being overloaded, but this could cause the
cache to no longer load because of duplicate fields.

3 years agoDecode retrieved files as UTF-8 even on Python 2
Jeremy Stanley [Sun, 31 May 2020 00:17:36 +0000 (00:17 +0000)]
Decode retrieved files as UTF-8 even on Python 2

Python 2.7 is likely the only Python 2 anyone is using any longer
(even that's well past EOL upstream now), and reasonably recent
versions of 2.7 it need the same decode hack as Python 3 anyway when
dealing with some retrieved content. Just get rid of the version
detection and do it under any version.

3 years agoAdd weather zone hkz000 for Hong Kong Observatory
Jeremy Stanley [Tue, 26 May 2020 00:04:48 +0000 (00:04 +0000)]
Add weather zone hkz000 for Hong Kong Observatory

Thanks to Bill Agee for suggesting the Hong Kong Observatory's
weather forecast page. A custom filter is implemented to strip the
forecast text from the HTML page in which it is embedded (if anyone
finds a plaintext version published at an alternate URL, let me know
and I'll rip out the extra routine).

3 years agoAdd some fresh overrides
Jeremy Stanley [Sun, 24 May 2020 19:03:15 +0000 (19:03 +0000)]
Add some fresh overrides

Override a number of active weather stations where searches of
various online sites return names and locations for them which are
not provided by the included sources.

3 years agoUpdate correlation sources
Jeremy Stanley [Sat, 23 May 2020 18:09:39 +0000 (18:09 +0000)]
Update correlation sources

Remove the stale metar.tbl and zonecatalog.curr.tar, which the USA
NWS hasn't been updating for many years, and add the public domain
airports.csv file from the amazing ourairports.com community. Also
update to latest (2019) USA Census Bureau location data, March 2020
WX zone information, cooperative sites list from 2018 (latest), and
regenerated active station and zone lists. Loss of the zonecatalog
necessitates directly applying various forecast and alert URL
patterns, though some which appeared unused by NWS for many years
were not included.

Clear out all old overrides, since the vast majority are obsoleted
by refreshed data, and build fresh correlation sets from the above
sources. Basically all sites have switched from HTTP to HTTPS, so
update URLs for this too.

6 years agoAdd FAQ entry about --headers values
Jeremy Stanley [Sat, 16 Sep 2017 15:47:03 +0000 (15:47 +0000)]
Add FAQ entry about --headers values

Be as clear as possible about what the --headers command-line option
or headers configuration option does, and what sorts of values are
valid for it.

7 years agoFix Py3K compatibility for compressed correlation
Jeremy Stanley [Fri, 10 Mar 2017 15:13:31 +0000 (15:13 +0000)]
Fix Py3K compatibility for compressed correlation

When run under Python 3.x, explicitly decode decompressed
bytestreams if reading pre-compressed correlation data files.

7 years agoUpdate release notes and docs for 2.3 release 2.3
Jeremy Stanley [Tue, 8 Nov 2016 00:03:25 +0000 (00:03 +0000)]
Update release notes and docs for 2.3 release

7 years agoCorrect NOAA WX weather product URL regression
Jeremy Stanley [Mon, 7 Nov 2016 15:54:17 +0000 (15:54 +0000)]
Correct NOAA WX weather product URL regression

One piecemeal use of the retired weather.noaa.gov/pub URL was missed
in the correlate() function, causing it to be reintroduced for
zone-based reports (such as forecasts) in a subsequent correlation
dataset update. Correct the invalid URLs in the zones file, and
update the correlation routine to embed the correct and working
tgftp.nws.noaa.gov hostname instead.

7 years agoUpdate release notes and docs for 2.2 release 2.2
Jeremy Stanley [Wed, 5 Oct 2016 01:25:22 +0000 (01:25 +0000)]
Update release notes and docs for 2.2 release

7 years agoCorrelation set update
Jeremy Stanley [Wed, 5 Oct 2016 01:06:27 +0000 (01:06 +0000)]
Correlation set update

* overrides.conf: Latest source data corrections from
script-assisted research.

These remaining files are generated data. Normally they're not
something I feel good about committing into version control, but in
this case it allows for logging and tracking deltas in the data over
time...

* airports: Removed 18 airports corresponding to nonexistent
stations.

* stations: Removed 326 stations with no recent conditions, added
429.

* zones: Removed 45 zones with no recent forecasts, added 104.

* places, zctas: Based on latest Census Bureau data corrections,
updated with new correlations.

* overrides.log: Record of correlation set build.

* slist, zlist: State of active stations and weather zones at the
time of generation.

7 years agoUpdate correlation logic for 2015 Gazetteer
Jeremy Stanley [Wed, 5 Oct 2016 00:49:32 +0000 (00:49 +0000)]
Update correlation logic for 2015 Gazetteer

Simple update to handle new filenames for the 2015 US Census Bureau
Gazetteer. Also update a comment which still had the old NWS station
list URL.

7 years agoCorrect setpath search order
Jeremy Stanley [Mon, 19 Sep 2016 15:25:18 +0000 (15:25 +0000)]
Correct setpath search order

Short-circuit the outer loop in setpath testing so that we stop
iterating through supplied path elements once a match is found.

7 years agoFix minor typo in NEWS file
Jeremy Stanley [Tue, 13 Sep 2016 18:23:51 +0000 (18:23 +0000)]
Fix minor typo in NEWS file

There was an extra "and" in the first sentence of the 2.1 release
prose.

7 years agoUpdate release notes and docs for 2.1 release 2.1
Jeremy Stanley [Tue, 13 Sep 2016 17:30:33 +0000 (17:30 +0000)]
Update release notes and docs for 2.1 release

7 years agoUpdate NOAA WX weather products URLs
Jeremy Stanley [Wed, 24 Aug 2016 22:56:37 +0000 (22:56 +0000)]
Update NOAA WX weather products URLs

Per http://www.wxforum.net/index.php?topic=29502.0 the old
http://weather.noaa.gov/pub site was deprecated and as of August 23
is no longer in service. Update the software and current dataset to
use working http://tgftp.nws.noaa.gov URLs instead.

9 years agoCorrelation set update
Jeremy Stanley [Mon, 10 Nov 2014 22:15:35 +0000 (22:15 +0000)]
Correlation set update

* overrides.conf: Latest source data corrections from
script-assisted research.

These remaining files are generated data. Normally they're not
something I feel good about committing into version control, but in
this case it allows for logging and tracking deltas in the data over
time...

* airports: Removed 527 airports corresponding to nonexistent
stations.

* stations: Removed 176 stations with no recent conditions, added
196.

* zones: Removed 5 zones with no recent forecasts.

* places, zctas: Based on latest Census Bureau data corrections,
updated with new correlations.

* overrides.log: Record of correlation set build.

* slist, zlist: State of active stations and weather zones at the
time of generation.

9 years agoSupport more recent data sources
Jeremy Stanley [Thu, 30 Oct 2014 00:23:01 +0000 (00:23 +0000)]
Support more recent data sources

Add support for 2014 Census Bureau data and the newer version of the
NWS COOP stations file.

10 years agoDocument correlation set rebuilding process
Jeremy Stanley [Thu, 13 Feb 2014 01:54:21 +0000 (01:54 +0000)]
Document correlation set rebuilding process

* INSTALL: Add a new section documenting the way in which newer
correlation data sets can be rebuilt and substituted for officially
distributed copies.

10 years agoCorrelation set update
Jeremy Stanley [Thu, 13 Feb 2014 00:54:05 +0000 (00:54 +0000)]
Correlation set update

* overrides.conf: Latest source data corrections from
script-assisted research.

These remaining files are generated data. Normally they're not
something I feel good about committing into version control, but in
this case it allows for logging and tracking deltas in the data over
time...

* airports: Removed 42 airports corresponding to nonexistent
stations, added 8.

* stations: Removed 303 stations with no recent conditions, added
403.

* zones: Removed 15 zones with no recent forecasts, added 13.

* places, zctas: Based on latest Census Bureau data corrections,
updated with new correlations.

* overrides.log: Record of correlation set build.

* slist, zlist: State of active stations and weather zones at the
time of generation.

10 years agoCorrelation building fixes
Jeremy Stanley [Thu, 13 Feb 2014 00:48:25 +0000 (00:48 +0000)]
Correlation building fixes

* weather.py(correlate): Note the updated URL to Census Bureau data
in file comments, and make the County-Public Forecast Zones
Correlation File parsing more robust against errors in the file
formatting.

11 years agoAdd a .gitignore file.
Jeremy Stanley [Fri, 19 Oct 2012 22:28:35 +0000 (22:28 +0000)]
Add a .gitignore file.

* .gitignore: This is merely for convenience, so that trashfiles from
testing or datafile rebuilds don't make it into the repository.

11 years agoUpdate data files for rounding adjustment.
Jeremy Stanley [Fri, 21 Sep 2012 01:19:43 +0000 (01:19 +0000)]
Update data files for rounding adjustment.

* airports, places, stations, zctas, zones: Regenerated from the same
base dataset used in 2.0, but this time with weather.py's updated
correlate function which rounds radian floats to 7 decimal places. No
nodes were added or removed, and the only changes were to take their
coordinate and distance values from sub-nanometer 10^-16 precision to
sub-meter 10^-7, which is still generally at least an order of magnitude
smaller than the base data precision anyway. This should almost entirely
solve any rounding error fuzz in subsequent data file updates.

11 years agoNormalize data override configuration.
Jeremy Stanley [Wed, 19 Sep 2012 01:33:09 +0000 (01:33 +0000)]
Normalize data override configuration.

* overrides.conf: The data override configuration is now grouped and
alphabetized, so that it can have future updates more easily integrated.
No entries are added or removed in this change.

11 years agoRework data override configuration comments.
Jeremy Stanley [Wed, 19 Sep 2012 01:04:34 +0000 (01:04 +0000)]
Rework data override configuration comments.

* overrides.conf: The data override configuration got very large and
unwieldy. In an effort to be able to normalize the content
programmatically, code comments have been replaced by comment
configuration options for each section.

11 years agoTruncate radian floats in data files.
Jeremy Stanley [Wed, 19 Sep 2012 00:58:31 +0000 (00:58 +0000)]
Truncate radian floats in data files.

* weather.py(correlate): The radian values in data files have a tendency
to vary by the tiniest rounding errors from one Python release to
another. By truncating them to the 7th decimal place, which is still
sub-meter resolution, this problem is minimized and the resulting data
diffs become far less noisy.

11 years agoUpdate sys.path example in INSTALL.
Jeremy Stanley [Wed, 19 Sep 2012 00:42:05 +0000 (00:42 +0000)]
Update sys.path example in INSTALL.

* INSTALL: The example for checking sys.path was syntactically invalid
for Python 3.x, so it has been fixed to work there as well as relatively
modern 2.x (tested with 2.5 since that's the oldest I had on hand).

11 years agoMake sure data files have final newlines.
Jeremy Stanley [Tue, 11 Sep 2012 00:16:18 +0000 (00:16 +0000)]
Make sure data files have final newlines.

* weather.py(correlate): Previously the airports, places, stations,
zctas and zones files lacked trailing newlines, so this trivial patch
adds them before each is closed for writing.

11 years ago2010 Census U.S. Gazetteer file layout changed.
Jeremy Stanley [Mon, 10 Sep 2012 03:28:49 +0000 (03:28 +0000)]
2010 Census U.S. Gazetteer file layout changed.

* weather.py(correlate): The United States Census Bureau altered the
format of their 2010 Gazetteer on August 22, 2012, adding and reordering
a few fields. The previous version of the parser assumed a fixed field
order and ceased to work with the updated data files, so now the order
is inferred from the column headings in the first line of each file
instead.

11 years agoAdd /etc/weather/weatherrc to config search.
Jeremy Stanley [Thu, 30 Aug 2012 11:13:57 +0000 (11:13 +0000)]
Add /etc/weather/weatherrc to config search.

* weather.1(INPUT FILES): Updated the list of potential weatherrc
locations to reflect those mentioned in the INSTALL file, particularly
the addition of /etc/weather/weatherrc in the 2.0 release.

* weather.py(get_config): Adjusted the configuration search locations to
include /etc/weather/weatherrc, since the INSTALL file started
mentioning it in the 2.0 release even though it wasn't actually
implemented as pointed out by Ben Kohler.

11 years agoMake --quiet quieter again.
Jeremy Stanley [Thu, 12 Jul 2012 21:32:13 +0000 (21:32 +0000)]
Make --quiet quieter again.

* weather.py(Selections, guess): The the search cache notification
doesn't belong in terse output, as pointed out by Eric Cooper.

11 years agoImported from archive. 2.0
Jeremy Stanley [Tue, 26 Jun 2012 00:48:37 +0000 (00:48 +0000)]
Imported from archive.

* Release 2.0: Heavy rewrite with too many new features to enumerate
here in the ChangeLog file.

* NEWS: List of important changes since 1.x releases.

* weather, weather.py: Implemented support for Python 3000 as
requested by ptchinster on behalf of Arch Linux, conditions/forecast
searches by latitude/longitude requested by Brandt Daniels, support
for newer NOAA forecasts pointed out by Darryl Mouck and Richard
Dooling, custom URIs requested by Michel Pelzer, international
weather stations requested by Milton Hubsher, and fixed a metric
conversion issue with negative values reported by Jochen Keil,
Michiel Appelman and Stefan Metzlaff. Thanks to everyone for your
input and assistance!

14 years agoImported from archive. 1.5
Jeremy Stanley [Fri, 19 Mar 2010 13:30:22 +0000 (13:30 +0000)]
Imported from archive.

* Release 1.5.

* (all): Updated copyright notices for 2010.

* FAQ, INSTALL, LICENSE, README: Reformatted as ReStructuredText.

* FAQ: Updated to mention alternative sources for NOAA's stations
list, in case the recommended one is unavailable (thanks Celejar!).

* NEWS: Renamed to ChangeLog and refactored into GNU format.

* weather: Added some comment padding between the shebang line and
the copyright, so that distributions wishing to carry patches which
modify the interpreter path don't have to refresh them every year
when the copyright line changes in their context.

* weather, weather.1, weatherrc.5, weather.py: Added experimental
alert, atypes, aurl and zones options to support retrieval,
filtering and formatting of unexpired NWS severe weather advisories.

* weather.1, weatherrc.5: Minor cosmetic fixes to option
descriptions.

* weather.1, weatherrc.5, weather.py: Added imperial and metric
options to filter/convert display units (thanks to Andrew Carter for
this suggestion!).

* weather.py: Fixed a METAR parsing error which would trigger an
IndexError exception if the NWS didn't have a station description on
file (thanks to Celejar for reporting the bug!). Fixed METAR title
line parsing to look for human-readable city and state in the first
line--previous code stopped showing the city name after NWS made
slight format mods. Upped the version to 1.5.

* weatherrc: Additional PIE (Saint Petersburg, FL), PNC (Ponca City,
OK), and PNS (Pensacola, FL) aliases.

15 years agoImported from archive. 1.4
Jeremy Stanley [Sun, 13 Jul 2008 07:49:02 +0000 (07:49 +0000)]
Imported from archive.

* Release 1.4.

* (all): Updated the copyright years for 2008 on some of the files
in the current release and added a copyright statement to any files
previously lacking one.

* LICENSE: Replaced the previous BSD-like license with the one used
by the OpenBSD project (modeled after the Internet Software
Consortium's, a two-clause BSD license removing language made
unnecessary by the Berne convention); this new license is
functionally identical to the old one, just more terse and openly
recognized.

* weather: Clarified function parameters in calls from the wrapper
script to ease future ABI changes in the underlying module.

* weather, weather.py: Some extra comments were added to the source,
indentation style was updated from tab characters to three-space,
and lines longer than 79 columns were refactored or otherwise split.

* weather.1, weather.5, weather.py: Added an flines option to allow
the maximum number of forecast output lines to be shortened. Added
furl and murl options to allow overriding of the default current
conditions and forecast data retrieval URLs. Added a headers option
to allow overriding the default list of header names for current
conditions data filtering. Added a quiet option to suppress the
preamble lines and indentation for both current conditions and
forecast output.

* weather.py: Replaced the hardcoded fallback default METAR station
ID and forecast city/state abbreviation with error messages to
minimize confusion when necessary values are omitted. Adjusted a
couple of hard-coded error message strings to be consistent with the
output format of the option_parser module. Switched from urllib to
urllib2 for retrieving data, providing a simpler means to detect and
report retrieval errors. Upped the version to 1.4.

17 years agoImported from archive. 1.3
Jeremy Stanley [Tue, 25 Jul 2006 23:00:47 +0000 (23:00 +0000)]
Imported from archive.

* Release 1.3.

* FAQ: Update to clarify that specifying an id won't automatically
provide a city and st to get the accompanying forecast.

* weather: Provided a consistent means for relocating weather.py to
a private location; thanks to Mark Tran for pointing out a conflict
with pyweather in ArchLinux (and presumably other distros as well).

* weather.py: Upped the version to 1.3.

17 years agoImported from archive. 1.2
Jeremy Stanley [Fri, 30 Jun 2006 17:42:14 +0000 (17:42 +0000)]
Imported from archive.

* Release 1.2.

* FAQ, README: Updated for inclsuion of weather-util in Debian.

* weather.py: Upped the version to 1.2.

* weatherrc: Added more default aliases PAO and SJC (requested by
Russ Allbery).

18 years agoImported from archive. 1.1
Jeremy Stanley [Tue, 18 Apr 2006 04:33:21 +0000 (04:33 +0000)]
Imported from archive.

* Release 1.1.

* weather: Switched to "#!/usr/bin/env python" instead for
portability.

* weather.1, weather.5, weather.py: Implemented the --omit-forecast
option to cancel --forecast.

* weather.py: Calling with undefined aliases now throws an error and
exits. Aliases, options and default overrides operate more
logically. Upped the version to 1.1.

* weatherrc: Added 214 standard aliases.

18 years agoImported from archive. 1.0
Jeremy Stanley [Sun, 26 Mar 2006 17:08:52 +0000 (17:08 +0000)]
Imported from archive.

* Initial release 1.0.