| Name | sdss JSON |
| Version |
1.1.1
JSON |
| download |
| home_page | https://github.com/behrouzz/sdss |
| Summary | A python package for retrieving and analysing data from SDSS (Sloan Digital Sky Survey) |
| upload_time | 2023-02-09 13:07:14 |
| maintainer | |
| docs_url | None |
| author | Behrouz Safari |
| requires_python | >=3.8 |
| license | MIT |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
**Author:** [Behrouz Safari](https://behrouzz.github.io/)<br/>
**License:** [MIT](https://opensource.org/licenses/MIT)<br/>
# sdss
*A python package for retrieving and analysing data from SDSS (Sloan Digital Sky Survey)*
## Installation
Install the latest version of *sdss* from [PyPI](https://pypi.org/project/sdss/):
pip install sdss
Requirements are *numpy*, *requests*, *Pillow*, *matplotlib*, *pandas* and *astropy*.
Versions before 1.0.0 are not dependent on *astropy*.
## Quick start
Let's create a Region:
```python
from sdss import Region
ra = 179.689293428354
dec = -0.454379056007667
reg = Region(ra, dec, fov=0.033)
```
To see the image:
```python
reg.show()
```

To see the image in three *gri* filter bands (green, red, infrared) separately:
```python
reg.show3b()
```

To find nearest objects:
```python
df_obj = reg.nearest_objects()
```
To find nearest objects with spectrum:
```python
df_sp = reg.nearest_spects()
```
## Photometry example
Let's download a frame, in fits and jpg, retrieve all of its objects.:
```python
from sdss.photometry import frame_filename, obj_frame_url, \
download_file, unzip, get_df, df_radec2pixel
objid = 1237646587710014999
zip_file = 'data/' + frame_filename(objid) + '.fits.bz2'
fits_file = zip_file[:-4]
jpg_file = fits_file.replace('-r-', '-irg-').replace('fits', 'jpg')
zip_url = obj_frame_url(objid, 'r')
download_file(zip_url, 'data/')
unzip(zip_file)
jpg_url = obj_frame_url(objid, 'irg', jpg=True)
download_file(jpg_url, 'data/')
df = get_df(objid)
df = df_radec2pixel(df=df, fits_file=fits_file)
df.to_csv('data/COMP.csv', index=False)
```
Now we can plot our target image:
```python
import pandas as pd
import matplotlib.pyplot as plt
from sdss.photometry import frame_filename, obj_from_jpg
objid = 1237646587710014999
jpg_file = 'data/' + frame_filename(objid).replace('-r-', '-irg-') + '.jpg'
df = pd.read_csv('data/COMP.csv')
img = obj_from_jpg(jpg_file=jpg_file, df=df, objid=objid)
fig, ax = plt.subplots()
ax.imshow(img)
plt.show()
```
Let's find the best apparture:
```python
from sdss.photometry import flux
data = img[:,:,0]
half = data.shape[0]//2
center = (half, half)
ls_r_star = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
ls_background = []
ls_real_flux = []
for r_star in ls_r_star:
background, real_flux = flux(data, center, r_star)
ls_background.append(background)
ls_real_flux.append(real_flux)
fig, ax = plt.subplots()
ax.scatter(ls_r_star, ls_real_flux, c='b')
ax.set_xlabel('R star')
ax.set_ylabel('Sky subtracted flux')
plt.grid()
plt.show()
```
See more examples at [astrodatascience.net](https://astrodatascience.net/)
Raw data
{
"_id": null,
"home_page": "https://github.com/behrouzz/sdss",
"name": "sdss",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "",
"author": "Behrouz Safari",
"author_email": "behrouz.safari@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/a0/3d/5035a6ef32b94c18be7c25fd4085c1090260fa4268b59954161d4b0263ee/sdss-1.1.1.tar.gz",
"platform": null,
"description": "**Author:** [Behrouz Safari](https://behrouzz.github.io/)<br/>\r\n**License:** [MIT](https://opensource.org/licenses/MIT)<br/>\r\n\r\n# sdss\r\n*A python package for retrieving and analysing data from SDSS (Sloan Digital Sky Survey)*\r\n\r\n\r\n## Installation\r\n\r\nInstall the latest version of *sdss* from [PyPI](https://pypi.org/project/sdss/):\r\n\r\n pip install sdss\r\n\r\nRequirements are *numpy*, *requests*, *Pillow*, *matplotlib*, *pandas* and *astropy*.\r\nVersions before 1.0.0 are not dependent on *astropy*.\r\n\r\n## Quick start\r\n\r\nLet's create a Region:\r\n\r\n```python\r\nfrom sdss import Region\r\n\r\nra = 179.689293428354\r\ndec = -0.454379056007667\r\n\r\nreg = Region(ra, dec, fov=0.033)\r\n```\r\n\r\nTo see the image:\r\n\r\n```python\r\nreg.show()\r\n```\r\n\r\n\r\n\r\nTo see the image in three *gri* filter bands (green, red, infrared) separately:\r\n\r\n```python\r\nreg.show3b()\r\n```\r\n\r\n\r\n\r\nTo find nearest objects:\r\n\r\n```python\r\ndf_obj = reg.nearest_objects()\r\n```\r\n\r\nTo find nearest objects with spectrum:\r\n\r\n```python\r\ndf_sp = reg.nearest_spects()\r\n```\r\n\r\n## Photometry example\r\n\r\nLet's download a frame, in fits and jpg, retrieve all of its objects.:\r\n\r\n```python\r\nfrom sdss.photometry import frame_filename, obj_frame_url, \\\r\n download_file, unzip, get_df, df_radec2pixel\r\n\r\nobjid = 1237646587710014999\r\n\r\nzip_file = 'data/' + frame_filename(objid) + '.fits.bz2'\r\nfits_file = zip_file[:-4]\r\njpg_file = fits_file.replace('-r-', '-irg-').replace('fits', 'jpg')\r\n\r\nzip_url = obj_frame_url(objid, 'r')\r\ndownload_file(zip_url, 'data/')\r\nunzip(zip_file)\r\n\r\njpg_url = obj_frame_url(objid, 'irg', jpg=True)\r\ndownload_file(jpg_url, 'data/')\r\n\r\ndf = get_df(objid)\r\ndf = df_radec2pixel(df=df, fits_file=fits_file)\r\n\r\ndf.to_csv('data/COMP.csv', index=False)\r\n```\r\n\r\nNow we can plot our target image:\r\n\r\n```python\r\nimport pandas as pd\r\nimport matplotlib.pyplot as plt\r\nfrom sdss.photometry import frame_filename, obj_from_jpg\r\n\r\nobjid = 1237646587710014999\r\n\r\njpg_file = 'data/' + frame_filename(objid).replace('-r-', '-irg-') + '.jpg'\r\n\r\ndf = pd.read_csv('data/COMP.csv')\r\n\r\nimg = obj_from_jpg(jpg_file=jpg_file, df=df, objid=objid)\r\n\r\nfig, ax = plt.subplots()\r\nax.imshow(img)\r\nplt.show()\r\n```\r\n\r\nLet's find the best apparture:\r\n\r\n```python\r\nfrom sdss.photometry import flux\r\n\r\ndata = img[:,:,0]\r\nhalf = data.shape[0]//2\r\ncenter = (half, half)\r\n\r\nls_r_star = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\r\nls_background = []\r\nls_real_flux = []\r\nfor r_star in ls_r_star:\r\n background, real_flux = flux(data, center, r_star)\r\n ls_background.append(background)\r\n ls_real_flux.append(real_flux)\r\n\r\nfig, ax = plt.subplots()\r\nax.scatter(ls_r_star, ls_real_flux, c='b')\r\nax.set_xlabel('R star')\r\nax.set_ylabel('Sky subtracted flux')\r\nplt.grid()\r\nplt.show()\r\n```\r\n\r\nSee more examples at [astrodatascience.net](https://astrodatascience.net/)\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A python package for retrieving and analysing data from SDSS (Sloan Digital Sky Survey)",
"version": "1.1.1",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "df31c194d9c3857ccda0b50bf99195577865200e05ca0a984871fc9aaa33d0ee",
"md5": "f9c9f9da616d119ceb1cfdbf19cbc812",
"sha256": "479ceea56d60febfc73a575640a81cedd71a07b957fab07dd23c4e27661f612d"
},
"downloads": -1,
"filename": "sdss-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f9c9f9da616d119ceb1cfdbf19cbc812",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 11166,
"upload_time": "2023-02-09T13:07:11",
"upload_time_iso_8601": "2023-02-09T13:07:11.388678Z",
"url": "https://files.pythonhosted.org/packages/df/31/c194d9c3857ccda0b50bf99195577865200e05ca0a984871fc9aaa33d0ee/sdss-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a03d5035a6ef32b94c18be7c25fd4085c1090260fa4268b59954161d4b0263ee",
"md5": "07c85913a665fd89f693f8037637fdd4",
"sha256": "e40c3bd43c28df692d10e05bbd06a1ef06d55b84e4cb4c11cf0adb61556fa344"
},
"downloads": -1,
"filename": "sdss-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "07c85913a665fd89f693f8037637fdd4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 10565,
"upload_time": "2023-02-09T13:07:14",
"upload_time_iso_8601": "2023-02-09T13:07:14.130892Z",
"url": "https://files.pythonhosted.org/packages/a0/3d/5035a6ef32b94c18be7c25fd4085c1090260fa4268b59954161d4b0263ee/sdss-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-02-09 13:07:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "behrouzz",
"github_project": "sdss",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "sdss"
}