{ "info": { "author": "Paul Skeie", "author_email": "paul.skeie@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# svalbard\n\nEasy time handling in the context of weather forecasting\n\n## Concepts\n\nForecastTime integrates the concept of two central notions of time in a weather forecasting scenario.\n\nanatime is the time when a numerical weather prediction model is initialized.\n\nvalidtime is the time when the weather forecast is to be validated towards observations.\n\nBetween these times is a time interval which ForecastTime keeps track of in seconds, but\nsince hours is a more common time unit the interface of this time interval is given in hours\n\nfchours denotes that time interval.\nThe time stamps are time zone naive.\n\n## Usage\n\n### Initializing\n\nThe user can choose to initialize the class with no parameters and set time attributes with setters like this:\n\n~~~~python\nfrom svalbard import ForecastTime\nft=ForecastTime()\nft.set_anatime('2018122800')\nft.set_fchours(24)\n~~~~\n\nThe same can be achieved with\n\n~~~~python\nfrom svalbard import ForecastTime\nft=ForecastTime(anatime='2018122800',fchours=24)\n~~~~\n\nOr if you want to provide validtime instead of fchours:\n\n~~~~python\nfrom svalbard import ForecastTime\nft=ForecastTime(anatime='2018122800',validtime='2018122900')\n~~~~\n\n### Updating with consistency checks\n\nForecastTime has getters and setters for anatime, validtime and fchours. The setters make sure that there is consistency among those three. If one of them is updated, one of the others also need to be updated to maintain consistency.\n\nIf fchours is updated while anatime and validtime is set, the default setting keeps the anatime and updates validtime.\n\n~~~~python\nfrom svalbard import ForecastTime\nft=ForecastTime(anatime='2018122800',fchours=24)\nft.get_validtime()\ndatetime.datetime(2018, 12, 29, 0, 0)\nft.set_fchours(48)\nft.get_validtime()\ndatetime.datetime(2018, 12, 30, 0, 0)\n~~~~\n\nHowever if you want to update anatime you can do\n\n~~~~python\nfrom svalbard import ForecastTime\nft=ForecastTime(anatime='2018122800',fchours=24)\nft.set_fchours(48,keep_anatime=False)\nft.get_anatime()\ndatetime.datetime(2018, 12, 27, 0, 0)\n~~~~\n\n### Optional datetime format guessing\n\nYou may choose to initialize datetimes with strings or with python datetime objects.\n\nWhen you set datetimes with strings ForecastTime needs to figure out the string formatting. This is achieved by trying format strings from a list. The first formatting that produces a valid datetime object without trowing an error is chosen. This may seem a bit sloppy, but the list of string formattings to try may be be provided by the user and it may contain only one format string which would eliminate the guesswork. The list is there for convenience.\n\nThis is the list that will be used if the user chooses to go with the defaults.\n\n~~~~python\nsomedatetimeformats=[\n '%Y%m%d%H',\n '%Y%m%d%H',\n '%Y%m%d %H',\n '%Y%m%d%H%M',\n '%Y%m%d%H%M%S',\n '%Y-%m-%d %H',\n '%Y-%m-%d',\n '%Y-%m-%d %H:%M:%S',\n '%Y-%m-%d %H:%M:%SZ',\n '%Y-%m-%dT%H:%M:%SZ',\n '%Y-%m-%d %H%M%SZ',\n '%m-%d-%Y %H:%M:%S'\n]\n~~~~\n\nWhat actually happens is that, if datetimes are provided as strings, the function guess_forecast_datetime_from_string is called.\nThis function can be used separatly.\n\n~~~~python\nfrom svalbard import guess_forecast_datetime_from_string,somedatetimeformats\n\nguess_forecast_datetime_from_string('2010-01-01 12',datetimeformats=somedatetimeformats,verbose=False)\n\n# Returns\n[(5, '%Y-%m-%d %H', datetime.datetime(2010, 1, 1, 12, 0))]\n~~~~\n\nguess_forecast_datetime_from_string returns a list of triplets, (index,format string,datetime object).\n\n### String interpolation in file names\n\nIf you want to download some real world weather forecasts, they often come in files where anatime, validtime or fchours is encoded in the filename.\n\nForecastTime to the rescue:\n\n~~~~python\nfrom svalbard import ForecastTime\nfrom datetime import datetime\ngfs_url_template='http://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.{anatime:%Y%m%d%H}/gfs.t{anatime:%H}z.pgrb2.0p25.f{fchours:03d}'\nanatime=datetime.now().strftime('%Y%m%d00')\nft = ForecastTime(anatime=anatime)\nfor h in range(0,12,3):\n ft.set_fchours(h)\n print(ft)\n print( gfs_url_template.format(**ft.get_dict()) )\n~~~~\n\nForecastTime,anatime:2018-12-28 00:00:00,validtime:2018-12-28 00:00:00,fchours:0\n\nhttp://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.2018122800/gfs.t12z.pgrb2.0p25.f000\n\nForecastTime,anatime:2018-12-28 00:00:00,validtime:2018-12-28 03:00:00,fchours:3\n\nhttp://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.2018122800/gfs.t12z.pgrb2.0p25.f003\n\nForecastTime,anatime:2018-12-28 00:00:00,validtime:2018-12-28 06:00:00,fchours:6\n\nhttp://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.2018122800/gfs.t12z.pgrb2.0p25.f006\n\nForecastTime,anatime:2018-12-28 00:00:00,validtime:2018-12-28 09:00:00,fchours:9\n\nhttp://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.2018122800/gfs.t12z.pgrb2.0p25.f009\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/paulskeie/svalbard", "keywords": "", "license": "Apache-2.0", "maintainer": "", "maintainer_email": "", "name": "svalbard", "package_url": "https://pypi.org/project/svalbard/", "platform": "", "project_url": "https://pypi.org/project/svalbard/", "project_urls": { "Homepage": "http://github.com/paulskeie/svalbard" }, "release_url": "https://pypi.org/project/svalbard/0.2.1/", "requires_dist": [ "requests" ], "requires_python": "", "summary": "Easy time handling in the context of weather forecasting", "version": "0.2.1" }, "last_serial": 4896604, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "3546613e91284a2a196cce6d99c8e37d", "sha256": "78e9a6f47636b65f4e135cf447cfd9b9f99b6b79e2420577ae1a622c25503399" }, "downloads": -1, "filename": "svalbard-0.1-py3.6.egg", "has_sig": false, "md5_digest": "3546613e91284a2a196cce6d99c8e37d", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 4336, "upload_time": "2018-12-31T13:19:36", "url": "https://files.pythonhosted.org/packages/a1/c5/b3ff49531b03efb80cb6a863fd2576a0a67299e65ff3253f4075eb6cb1b0/svalbard-0.1-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "2d91c3771873b7469405381c56f369cb", "sha256": "d7f695ed92ca6c0b44d3b75c83e8b84ece8fa10e91d15e5941bbd8d69b707b0d" }, "downloads": -1, "filename": "svalbard-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "2d91c3771873b7469405381c56f369cb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8056, "upload_time": "2018-12-31T13:19:34", "url": "https://files.pythonhosted.org/packages/be/86/3f154fc79e21b772edf988903830c9240df125dff292f1a844d6f512c719/svalbard-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "81572f7ebce2965da8e8ee0d3ecc65d3", "sha256": "212213503ed4e9cba13ef54ee2c47f8c694048d503d13695932a28257d2814f5" }, "downloads": -1, "filename": "svalbard-0.1.tar.gz", "has_sig": false, "md5_digest": "81572f7ebce2965da8e8ee0d3ecc65d3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3707, "upload_time": "2018-12-31T13:19:37", "url": "https://files.pythonhosted.org/packages/55/d4/0c6c1eb1a404c8ad32c86d20f8b17fe478299a3f3fca57791ea9e9610b21/svalbard-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "a75e1fba379f49b16ab622dfefbec09a", "sha256": "d849a1b0ce2a514d5ff9e13968ab429c9d5278d56f8ae1646b60d80b775dfddd" }, "downloads": -1, "filename": "svalbard-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "a75e1fba379f49b16ab622dfefbec09a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8798, "upload_time": "2019-03-04T22:52:57", "url": "https://files.pythonhosted.org/packages/f9/60/ad44dd5a794090a0a905ab61595799ce159ec0eb17ffa6a54a3c8440e36b/svalbard-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "eed1a7764ccde2b5b6b7a59cf237741d", "sha256": "b4e2ced55a0868030c88ee4c3289c2be58ecbec53edc3c7efaf13c8423a76899" }, "downloads": -1, "filename": "svalbard-0.2.tar.gz", "has_sig": false, "md5_digest": "eed1a7764ccde2b5b6b7a59cf237741d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4386, "upload_time": "2019-03-04T22:52:58", "url": "https://files.pythonhosted.org/packages/5b/4e/a3c3e7fad482e6b0c29fab8aef26e4c29641da596e59b6e45c21982f2b80/svalbard-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "751a3e742a9a8240975d789cac13df28", "sha256": "09c554607282c969cfaeb3a234ae02390b21d2e1df5168e2355d37d0c802a188" }, "downloads": -1, "filename": "svalbard-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "751a3e742a9a8240975d789cac13df28", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8837, "upload_time": "2019-03-04T23:09:09", "url": "https://files.pythonhosted.org/packages/f0/8f/1f3ec7fb83c5e3aca8fc82b5cdbb441dfecd14ec0965e577902341d287ab/svalbard-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8f8d3f76563e95340ba92f48950f3548", "sha256": "c9061ab028d1ede85c7c0e924152e92d7576ada22f9dcc7964a860550e856742" }, "downloads": -1, "filename": "svalbard-0.2.1.tar.gz", "has_sig": false, "md5_digest": "8f8d3f76563e95340ba92f48950f3548", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4421, "upload_time": "2019-03-04T23:09:10", "url": "https://files.pythonhosted.org/packages/ff/ab/216d425365077a266a2f80cef549fb354e558748d9e1ba20adb5e1fe762c/svalbard-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "751a3e742a9a8240975d789cac13df28", "sha256": "09c554607282c969cfaeb3a234ae02390b21d2e1df5168e2355d37d0c802a188" }, "downloads": -1, "filename": "svalbard-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "751a3e742a9a8240975d789cac13df28", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8837, "upload_time": "2019-03-04T23:09:09", "url": "https://files.pythonhosted.org/packages/f0/8f/1f3ec7fb83c5e3aca8fc82b5cdbb441dfecd14ec0965e577902341d287ab/svalbard-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8f8d3f76563e95340ba92f48950f3548", "sha256": "c9061ab028d1ede85c7c0e924152e92d7576ada22f9dcc7964a860550e856742" }, "downloads": -1, "filename": "svalbard-0.2.1.tar.gz", "has_sig": false, "md5_digest": "8f8d3f76563e95340ba92f48950f3548", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4421, "upload_time": "2019-03-04T23:09:10", "url": "https://files.pythonhosted.org/packages/ff/ab/216d425365077a266a2f80cef549fb354e558748d9e1ba20adb5e1fe762c/svalbard-0.2.1.tar.gz" } ] }