Name | pysunnoaa JSON |
Version |
0.1.8
JSON |
| download |
home_page | |
Summary | python implementation of NOAA's Solar Position Calculators |
upload_time | 2024-02-29 06:09:14 |
maintainer | |
docs_url | None |
author | Santosh Philip |
requires_python | >=3.7,<4.0 |
license | Mozilla Public License, v. 2.0 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
pysunNOAA
=========
Python implementation of NOAA's Solar Position Calculators
`NOAA <https://www.noaa.gov>`_ has the calculation details at their website at `Solar Calculation Details <source ~/venvs/pysunnoaa/bin/activate>`_
**pysunNOAA** is based on the spreadsheet `NOAA_Solar_Calculations_day.xls <https://www.gml.noaa.gov/grad/solcalc/NOAA_Solar_Calculations_day.xls>`_ . All the calculation cells in row 2 of the spreadsheet are implemented in pysunNOAA. This is a work in progress. But it is fully usable at this point
Sun Position
------------
Here is what it can do::
import datetime
from pysunnoaa import noaa
latitude = 40 # Latitude (+ to N)
longitude = -105 # Longitude (+ to E)
timezone = -6 # Time Zone (+ to E)
thedatetime = datetime.datetime(2010, 6, 21, 9, 54)
altitude, azimuth = noaa.sunposition(
latitude, longitude, timezone, thedatetime, atm_corr=True
)
print(f"{altitude=}, {azimuth=}")
>> altitude=47.36178497432497, azimuth=98.30691558695895
The above calculation is corrected for atmospheric diffraction. We can also do the calculation without the correction for atmospheric diffraction by setting ``atm_corr=False``::
altitude, azimuth = noaa.sunposition(
latitude, longitude, timezone, thedatetime, atm_corr=False
)
print(f"{altitude=}, {azimuth=}")
>> altitude=47.346932081680364, azimuth=98.30691558695895
Many Sun Positions
------------------
Let us take a look at generating multiple sun positions for a time series. First we have to generate the time series::
thedates = noaa.datetimerange(
datetime.datetime(2024, 6, 21, 10), # start
datetime.datetime(2024, 6, 21, 11), # stop
minutes=10 # step
) # The arguments are similar to python's range.
# It returns a generator
for thedate in thedates:
print(thedate)
2024-06-21 10:00:00
2024-06-21 10:10:00
2024-06-21 10:20:00
2024-06-21 10:30:00
2024-06-21 10:40:00
2024-06-21 10:50:00
So let us generate the sun positions for this time series::
thedates = noaa.datetimerange(
datetime.datetime(2024, 6, 21, 10),
datetime.datetime(2024, 6, 21, 11),
minutes=10
)
positions = noaa.sunpositions(latitude, longitude, timezone, thedates, atm_corr=False)
for altitude, azimuth in positions:
print(f"{altitude=}, {azimuth=}")
altitude=48.44972994443188, azimuth=99.43756106034147
altitude=50.33276597510335, azimuth=101.44934328356527
altitude=52.20206053830976, azimuth=103.57347468902549
altitude=54.05415607848319, azimuth=105.82830623146941
altitude=55.88497413825557, azimuth=108.23537482765607
altitude=57.689656999063025, azimuth=110.82001062044083
Let us print this again::
for altitude, azimuth in positions:
print(f"{altitude=}, {azimuth=}")
WHAT !!! Why did it not print anything ??
Both ``noaa.datetimerange`` and ``noaa.sunpositions`` are generators. Once you loop through the generator, the values are exhausted (or emptied). To get the values again you will need to call the functions again::
thedates = noaa.datetimerange(
datetime.datetime(2024, 6, 21, 10),
datetime.datetime(2024, 6, 21, 11),
minutes=10
)
positions = noaa.sunpositions(latitude, longitude, timezone, thedates, atm_corr=False)
for altitude, azimuth in positions:
print(f"{altitude=}, {azimuth=}")
altitude=48.44972994443188, azimuth=99.43756106034147
altitude=50.33276597510335, azimuth=101.44934328356527
altitude=52.20206053830976, azimuth=103.57347468902549
altitude=54.05415607848319, azimuth=105.82830623146941
altitude=55.88497413825557, azimuth=108.23537482765607
altitude=57.689656999063025, azimuth=110.82001062044083
Sunrise and Sunset
------------------
Another useful thing is to be able to calculate sunset and sunrise. Here we go::
sunrise = noaa.sunrise(40, -105, -6, datetime.datetime(2010, 6, 21))
sunset = noaa.sunset(40, -105, -6, datetime.datetime(2010, 6, 21))
print(f"{sunrise=}")
print(f"{sunset=}")
>> sunrise=datetime.datetime(2010, 6, 21, 5, 31, 15, 842680)
>> sunset=datetime.datetime(2010, 6, 21, 20, 32, 8, 805539)
That's all for now.
Raw data
{
"_id": null,
"home_page": "",
"name": "pysunnoaa",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Santosh Philip",
"author_email": "santosh@noemail.com",
"download_url": "https://files.pythonhosted.org/packages/60/1b/2b590b78fc29631d5663a01f5902df39d78396fd0a5aef6a17070ccc7bdc/pysunnoaa-0.1.8.tar.gz",
"platform": null,
"description": "pysunNOAA\n=========\n\nPython implementation of NOAA's Solar Position Calculators\n\n\n`NOAA <https://www.noaa.gov>`_ has the calculation details at their website at `Solar Calculation Details <source ~/venvs/pysunnoaa/bin/activate>`_ \n\n**pysunNOAA** is based on the spreadsheet `NOAA_Solar_Calculations_day.xls <https://www.gml.noaa.gov/grad/solcalc/NOAA_Solar_Calculations_day.xls>`_ . All the calculation cells in row 2 of the spreadsheet are implemented in pysunNOAA. This is a work in progress. But it is fully usable at this point\n\nSun Position\n------------\n\nHere is what it can do::\n\n import datetime\n from pysunnoaa import noaa\n\n latitude = 40 # Latitude (+ to N)\n longitude = -105 # Longitude (+ to E)\n timezone = -6 # Time Zone (+ to E)\n thedatetime = datetime.datetime(2010, 6, 21, 9, 54)\n\n altitude, azimuth = noaa.sunposition(\n latitude, longitude, timezone, thedatetime, atm_corr=True\n )\n\n print(f\"{altitude=}, {azimuth=}\")\n\n >> altitude=47.36178497432497, azimuth=98.30691558695895\n\nThe above calculation is corrected for atmospheric diffraction. We can also do the calculation without the correction for atmospheric diffraction by setting ``atm_corr=False``::\n\n altitude, azimuth = noaa.sunposition(\n latitude, longitude, timezone, thedatetime, atm_corr=False\n )\n print(f\"{altitude=}, {azimuth=}\")\n \n >> altitude=47.346932081680364, azimuth=98.30691558695895\n\nMany Sun Positions\n------------------\n\nLet us take a look at generating multiple sun positions for a time series. First we have to generate the time series::\n\n thedates = noaa.datetimerange(\n datetime.datetime(2024, 6, 21, 10), # start\n datetime.datetime(2024, 6, 21, 11), # stop\n minutes=10 # step\n ) # The arguments are similar to python's range. \n # It returns a generator\n for thedate in thedates:\n print(thedate)\n\n 2024-06-21 10:00:00\n 2024-06-21 10:10:00\n 2024-06-21 10:20:00\n 2024-06-21 10:30:00\n 2024-06-21 10:40:00\n 2024-06-21 10:50:00\n\nSo let us generate the sun positions for this time series::\n\n thedates = noaa.datetimerange(\n datetime.datetime(2024, 6, 21, 10),\n datetime.datetime(2024, 6, 21, 11),\n minutes=10\n )\n\n positions = noaa.sunpositions(latitude, longitude, timezone, thedates, atm_corr=False)\n for altitude, azimuth in positions:\n print(f\"{altitude=}, {azimuth=}\")\n\n altitude=48.44972994443188, azimuth=99.43756106034147\n altitude=50.33276597510335, azimuth=101.44934328356527\n altitude=52.20206053830976, azimuth=103.57347468902549\n altitude=54.05415607848319, azimuth=105.82830623146941\n altitude=55.88497413825557, azimuth=108.23537482765607\n altitude=57.689656999063025, azimuth=110.82001062044083\n\nLet us print this again::\n\n for altitude, azimuth in positions:\n print(f\"{altitude=}, {azimuth=}\")\n\nWHAT !!! Why did it not print anything ??\n\nBoth ``noaa.datetimerange`` and ``noaa.sunpositions`` are generators. Once you loop through the generator, the values are exhausted (or emptied). To get the values again you will need to call the functions again::\n\n\n thedates = noaa.datetimerange(\n datetime.datetime(2024, 6, 21, 10),\n datetime.datetime(2024, 6, 21, 11),\n minutes=10\n )\n\n positions = noaa.sunpositions(latitude, longitude, timezone, thedates, atm_corr=False)\n for altitude, azimuth in positions:\n print(f\"{altitude=}, {azimuth=}\")\n\n altitude=48.44972994443188, azimuth=99.43756106034147\n altitude=50.33276597510335, azimuth=101.44934328356527\n altitude=52.20206053830976, azimuth=103.57347468902549\n altitude=54.05415607848319, azimuth=105.82830623146941\n altitude=55.88497413825557, azimuth=108.23537482765607\n altitude=57.689656999063025, azimuth=110.82001062044083\n\nSunrise and Sunset\n------------------\n\nAnother useful thing is to be able to calculate sunset and sunrise. Here we go::\n\n sunrise = noaa.sunrise(40, -105, -6, datetime.datetime(2010, 6, 21))\n sunset = noaa.sunset(40, -105, -6, datetime.datetime(2010, 6, 21))\n print(f\"{sunrise=}\")\n print(f\"{sunset=}\")\n\n >> sunrise=datetime.datetime(2010, 6, 21, 5, 31, 15, 842680)\n >> sunset=datetime.datetime(2010, 6, 21, 20, 32, 8, 805539)\n\n\nThat's all for now.\n",
"bugtrack_url": null,
"license": "Mozilla Public License, v. 2.0",
"summary": "python implementation of NOAA's Solar Position Calculators",
"version": "0.1.8",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e93860f6054b10eafd6b679c80ba7ce4cc1763a397ec0ba67dc0dda44fe1ee5a",
"md5": "9d6d368af9cd23b8c0864629c7a15cd3",
"sha256": "443c65c0e656cbf2674f10bdfacbe8b4002e353ce2a03313f21301d98c004e91"
},
"downloads": -1,
"filename": "pysunnoaa-0.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9d6d368af9cd23b8c0864629c7a15cd3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7,<4.0",
"size": 12421,
"upload_time": "2024-02-29T06:09:12",
"upload_time_iso_8601": "2024-02-29T06:09:12.595576Z",
"url": "https://files.pythonhosted.org/packages/e9/38/60f6054b10eafd6b679c80ba7ce4cc1763a397ec0ba67dc0dda44fe1ee5a/pysunnoaa-0.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "601b2b590b78fc29631d5663a01f5902df39d78396fd0a5aef6a17070ccc7bdc",
"md5": "2e5548ef6c9846691b0523149b60661b",
"sha256": "8a7ebb289f0c155d19789b2ef79b6cd217bd6986df90d52011124299c2ecb109"
},
"downloads": -1,
"filename": "pysunnoaa-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "2e5548ef6c9846691b0523149b60661b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7,<4.0",
"size": 12288,
"upload_time": "2024-02-29T06:09:14",
"upload_time_iso_8601": "2024-02-29T06:09:14.046858Z",
"url": "https://files.pythonhosted.org/packages/60/1b/2b590b78fc29631d5663a01f5902df39d78396fd0a5aef6a17070ccc7bdc/pysunnoaa-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-29 06:09:14",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pysunnoaa"
}