summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkke Viitanen <akke.viitanen@helsinki.fi>2021-12-04 12:18:58 +0000
committerAkke Viitanen <akke.viitanen@helsinki.fi>2021-12-04 12:18:58 +0000
commit5a629e5e488ff436a00e13b9c8fb0bdfa9245033 (patch)
treef016dfccccf18c649b941ab16f011b9a3b28392f
Initial commit
-rw-r--r--get_image.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/get_image.py b/get_image.py
new file mode 100644
index 0000000..83577a8
--- /dev/null
+++ b/get_image.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python3
+# encoding: utf-8
+# Author: Akke Viitanen
+# Email: akke.viitanen@helsinki.fi
+
+"""
+Get ugriz images from SDSS DR12 for given ra, dec combination in sexagesimal
+format
+
+Usage:
+
+ python3 get_image.py [ra in degrees] [dec in degrees] [bands]
+
+Excample:
+
+ python3 get_image.py 150.0 45.0 u
+ python3 get_image.py 150.0 45.0 ugriz
+"""
+
+import sys
+
+import astropy.units as u
+from astroquery.sdss import SDSS
+
+
+def main():
+
+ # Init
+ ra = sys.argv[1]
+ dec = sys.argv[2]
+ band = sys.argv[3]
+
+ # Query the region
+ result = SDSS.query_region(ra + " " + dec,
+ radius=1 * u.arcmin,
+ data_release=12)
+
+ # Fetch the first image of the query
+ result = result[0]
+ im = SDSS.get_images(run=result["run"],
+ camcol=result["camcol"],
+ field=result["field"],
+ data_release=12,
+ band=band)
+
+ # Plot the first image as an example
+ import matplotlib as mpl
+ import matplotlib.pyplot as plt
+ im = im[0][0].data
+ plt.imshow(im, origin="lower")
+ plt.show()
+
+
+if __name__ == "__main__":
+ main()