{ "info": { "author": "Suriyan Laohaprapanon, Gaurav Sood", "author_email": "suriyant@gmail.com, gsood07@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Topic :: Scientific/Engineering :: Information Analysis", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Get Weather Data\n~~~~~~~~~~~~~~~~\n.. image:: https://travis-ci.org/soodoku/get-weather-data.svg?branch=master\n :target: https://travis-ci.org/soodoku/get-weather-data\n.. image:: https://img.shields.io/pypi/v/get-weather-data.svg?maxAge=2592000\n :target: https://pypi.python.org/pypi/get-weather-data\n.. image:: https://img.shields.io/pypi/dd/get-weather-data.svg?maxAge=2592000\n :target: https://pypi.python.org/pypi/get-weather-data\n\nScripts for finding out the weather in a particular zip code on a\nparticular day (or a set of dates). You can also find weather stations\nnear a zip code, and vice-versa.\n\nBackground\n^^^^^^^^^^\n\nFrom `Bad Weather: Getting weather data by zip and\ndate `__:\n\nSome brief ground clearing before we begin. Weather data come from\nweather stations, which can belong to any of the five or more\n'networks,' each of which collect somewhat different data, sometimes\nlabel the same data differently, and have different reporting protocols.\nThe only geographic information that typically comes with weather\nstations is their latitude and longitude. By \u201cweather\u201d, we may mean\ntemperature, rain, wind, snow, etc. and we may want data on these for\nevery second, minute, hour, day, month etc. It is good to keep in mind\nthat not all weather stations report data for all units of time, and\nthere can be a fair bit of missing data. Getting data at coarse time\nunits like day, month, etc. typically involves making some decisions\nabout what particular statistic is the most useful. So for instance, you\nmay want, minimum and maximum (for daily temperature), or totals (for\nrainfall and snow). With that primer, let\u2019s begin.\n\nWe begin with what not to do. Do not use the `NOAA web\nservice `__. The API\nprovides a straightforward way to get 'weather' data for a particular\nzip for a particular month. Except, the requests often return nothing.\nIt isn't clear why. The documentation doesn't say whether the search for\nthe closest weather station is limited to X kilometers because without\nthat, one should have data for all zip codes and all dates. Nor does the\nAPI bother to return how far the weather station is from which it got\nthe data, though one can get that post hoc using `Google Geocoding\nAPI `__.\nHowever, given the possibility that the backend for the API would\nimprove over time, here's an usage example :-\n\nUsage\n-----\n\n::\n\n Usage: noaaweb-script.py [options] \n \n Options:\n -h, --help show this help message and exit\n -o OUTFILE, --outfile=OUTFILE\n CSV Output file name (default: output.csv)\n\n\nExample\n-------\n\nNCDC Web service requires token to access, you'll get it from https://www.ncdc.noaa.gov/cdo-web/token.\n\nYou must set environment variable NCDC_TOKEN with the valid NCDC token, On Windows\n\n::\n\n set NCDC_TOKEN=\n\nor On Linux\n\n::\n\n export NCDC_TOKEN=\n\n::\n\n noaaweb intput.csv\n\n\nSample input file\n=================\n\n::\n\n no,uniqid,zip,year,month,day\n 2000,1,7853,1999,12,15\n 2000,2,70503,1999,12,15\n 2000,3,38118,1999,12,26\n 2000,4,32548,1999,12,17\n 2000,5,7863,1999,12,17\n 2000,6,10705,1999,12,15\n 2000,7,80931,1999,12,19\n 2000,8,3878,1999,12,17\n 2000,9,17222,1999,12,16\n 2000,10,7831,1999,12,20\n ...\n\nOn to what can be done. The 'web service' that you can use is `Farmer's\nAlmanac's `__. Sleuthing using scripts\nthat we discuss later reveal that The Almanac reports data from the\nNWS-USAF-NAVY stations (`ftp link to the data\nfile `__. And\nit appears to have data for most times though no information is provided\non the weather station from which it got the data and the distance to\nthe zip code.\n\nIf you intend to look for data from `GHCND `_ and `ISD `_, there are two\nkinds of crosswalks that you can create \u2013 one that goes from zip codes\nto weather stations, and one that goes from weather stations to zip\ncodes. I assume that we don\u2019t have access to shape files (for census zip\ncodes), and that postal zip codes encompass a geographic region. To\ncreate a weather station to zip code crosswalk, web service such as\nGeonames or Google Geocoding API can be used. If the station lat,./long.\nis in the zip code, the distance comes up as zero. Otherwise the\ndistance is calculated as distance from the \u201ccentroid\u201d of the zip code. For creating a zip code to weather station\ncrosswalk, we get centroids of each zip using a web service such as\nGoogle (or use already provided centroids from free zip databases). And\nthen find the 'nearest' weather stations by calculating distances to\neach of the weather stations. For a given set of zip codes, you can get\na list of closest weather stations (you can choose to get n closest\nstations, or say all weather stations within x kilometers radius, and/or\nchoose to get stations from particular network(s)) using the following usage example :-\n\nUsage\n-----\n\n::\n\n Usage: zip2ws-script.py [options]\n \n Options:\n -h, --help show this help message and exit\n -D DATABASE, --database=DATABASE\n Database name (default: zip2ws.sqlite)\n -i, --import Create and import database\n -g, --geocode Query and update Lat/Lon by Google Maps Geocoding API\n -c, --closest Calculate and update closest table\n --ghcn=GHCN Number of closest stations for GHCN (default: 3)\n --coop=COOP Number of closest stations for COOP (default: 0)\n --usaf=USAF Number of closest stations for USAF (default: 2)\n -d DISTANCE, --distance=DISTANCE\n Maximum distance of stations from Zip location\n (Default: 0)\n -e, --export Export closest stations for each Zip to CSV file\n -o OUTFILE, --outfile=OUTFILE\n CSV Output file name (default: F:\\sandbox\\gsood\\get-\n weather-data\\get-weather-data\\venv\\lib\\site-\n packages\\zip2ws\\data\\zip-stations.csv)\n --drop-closest Drop closet table\n --clear-glatlon Clear Google Maps Geocoding API Lat/Lon\n --use-zlatlon Use Zip Lat/Lon instead of Google Geocoding Lat/Lon\n \nExample\n-------\n\n- **Import zip codes and weather stations to database**\n ::\n \n zip2ws -i\n\n- **Build closest weather station table for each zip code**\n ::\n \n zip2ws -c\n \n *It takes several minutes to process all zip codes*\n \n- **Export closest stations for each zip codes to file**\n ::\n \n zip2ws -e -o output.csv\n \n\nThe output lists for each zip code weather\nstations arranged by proximity. The task of getting weather data from\nthe closest station is simple thereon \u2013 get data (on a particular set of\ncolumns of your choice) from the closest weather station from which the\ndata are available. You can do that for a particular zip code and date\n(and date range) combination using the following usage example :-\n\nTo getting weather data there are two commands, one is the manager command (`zipwd-manager`) it will create a server process to dispatch job (list of zip codes and date range) to the workers process that will be create by another command (`zipwd-worker`) All workers will looking for weather data from thiers local database and put back the results to the manager process. We can have multiple workers run on same or difference machine also.\n\nUsage\n-----\n\n- **Manager**\n ::\n \n usage: zip2wd-manager-script.py [-h] [--config CONFIG] [-o OUTFILE] [-v]\n inputs [inputs ...]\n \n Weather search by ZIP (Manager)\n \n positional arguments:\n inputs CSV input file(s) name\n \n optional arguments:\n -h, --help show this help message and exit\n --config CONFIG Default configuration file (default: zip2wd.cfg)\n -o OUTFILE, --out OUTFILE\n Search results in CSV (default: output.csv)\n -v, --verbose Verbose message\n\n- **Worker**\n ::\n \n usage: zip2wd-worker-script.py [-h] [--config CONFIG] [-v]\n \n Weather search by ZIP (Worker)\n \n optional arguments:\n -h, --help show this help message and exit\n --config CONFIG Default configuration file (default: zip2wd.cfg)\n -v, --verbose Verbose message \n\nConfiguration file\n------------------\nThere are script settings in the configuration (`zip2wd.cfg`)\n\n::\n\n [manager]\n ip = 127.0.0.1\n port = 9999\n authkey = 1234\n batch_size = 10\n\n [worker]\n uses_sqlite = yes\n processes = 4\n nth = 0\n distance = 30\n\n [output]\n columns = column-names.txt\n\n [db]\n zip2ws = zip2ws.sqlite\n path = ./data/\n\n- ``ip`` and ``port`` - IP address and port of manager process that the\n worker will be connect to.\n- ``authkey`` - A shared password which is used to authenticate between\n manager and worker processes.\n- ``batch_size`` - A number of zipcodes that manager process dispatch\n to worker process each time.\n\n- ``uses_sqlite`` - Uses weather data from imported SQLite3 database if\n ``yes`` (recommend for speed) or download weather data for individual\n weather station on demand if ``no``\n- ``processes`` - A number of process will be forked on the worker\n process.\n- ``nth`` - Search within n-th closest station [set to ``0`` for\n unlimited]\n- ``distance`` - Search within distance (KM) [set to ``0`` for\n unlimited]\n\n- ``column`` - A column file that contains list of weather data column\n to be output\n\n- ``zip2ws`` - SQLite3 database of zip codes and weather stations\n- ``path`` - Path relative to database files\n\nExample\n-------\n\n- **Manager**\n ::\n \n zip2wd-manager input.csv\n \n- **Worker**\n ::\n \n zip2wd-worker\n\nAuthors\n^^^^^^^\n\nSuriyan Laohaprapanon and Gaurav Sood\n\nLicense\n^^^^^^^\n\nScripts are released under the `MIT License `__.", "description_content_type": null, "docs_url": "https://pythonhosted.org/get-weather-data/", "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/soodoku/get-weather-data", "keywords": "weather zip cdo noaa", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "get-weather-data", "package_url": "https://pypi.org/project/get-weather-data/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/get-weather-data/", "project_urls": { "Homepage": "https://github.com/soodoku/get-weather-data" }, "release_url": "https://pypi.org/project/get-weather-data/0.1.31/", "requires_dist": null, "requires_python": "", "summary": "Scripts for finding out the weather in a particular zip code", "version": "0.1.31" }, "last_serial": 2227581, "releases": { "0.1.29": [ { "comment_text": "", "digests": { "md5": "4f60398bf39236f38d3cdceeaf3d0e38", "sha256": "2dec45bb92d6ca435c2e6ff71eba90e36327b868f6ccfa8cb733fab11c6239b2" }, "downloads": -1, "filename": "get-weather-data-0.1.29.zip", "has_sig": false, "md5_digest": "4f60398bf39236f38d3cdceeaf3d0e38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49691, "upload_time": "2016-07-16T10:06:15", "url": "https://files.pythonhosted.org/packages/59/05/6436ff9a5b755835315b626b768912e0de7e5d1126f622e0816e74753479/get-weather-data-0.1.29.zip" } ], "0.1.31": [ { "comment_text": "", "digests": { "md5": "c0806a05f454bc19f7b8e57c849f3de5", "sha256": "14f4bce292a64a3d857ba561cd55b2a0006a49940281c0d878791389ef3f85c8" }, "downloads": -1, "filename": "get-weather-data-0.1.31.tar.gz", "has_sig": false, "md5_digest": "c0806a05f454bc19f7b8e57c849f3de5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34966, "upload_time": "2016-07-18T05:27:55", "url": "https://files.pythonhosted.org/packages/76/74/b7b24b3a1fd0c14155c5ccaf1be035af9a705723da8e96def27666b4a272/get-weather-data-0.1.31.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c0806a05f454bc19f7b8e57c849f3de5", "sha256": "14f4bce292a64a3d857ba561cd55b2a0006a49940281c0d878791389ef3f85c8" }, "downloads": -1, "filename": "get-weather-data-0.1.31.tar.gz", "has_sig": false, "md5_digest": "c0806a05f454bc19f7b8e57c849f3de5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34966, "upload_time": "2016-07-18T05:27:55", "url": "https://files.pythonhosted.org/packages/76/74/b7b24b3a1fd0c14155c5ccaf1be035af9a705723da8e96def27666b4a272/get-weather-data-0.1.31.tar.gz" } ] }