{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-11-09T19:45:38.611747Z","iopub.execute_input":"2023-11-09T19:45:38.612474Z","iopub.status.idle":"2023-11-09T19:45:39.177458Z","shell.execute_reply.started":"2023-11-09T19:45:38.612413Z","shell.execute_reply":"2023-11-09T19:45:39.175777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Astropy Coords\nAstropy Coords:Links to an external site.\n\nhttps://docs.astropy.org/en/stable/coordinates/index.htmlLinks to an external site. \n\nCoords More Info: to use the coordinates of the sky in code form\n\nhttps://skyandtelescope.org/astronomy-resources/right-ascension-declination-celestial-coordinates/Links to an external site. \n\nAstropy Coords are: A variety of celestial/spatial coordinates and their velocity components.\n\nexplanation of what RA is: the equator of the space  \n\nexplanation of what DEC is: the latitude of space.\n    \n90 Ra is: the north pole of space,which sits at 90 degree or top of the celecential sphere\n    \n0 Ra is: \n\n0 Dec is: the celestial equator is '0'DEC.\n    \n    RA: is a mess to cal","metadata":{"execution":{"iopub.status.busy":"2023-11-09T19:48:23.207258Z","iopub.execute_input":"2023-11-09T19:48:23.20773Z","iopub.status.idle":"2023-11-09T19:48:23.216545Z","shell.execute_reply.started":"2023-11-09T19:48:23.207693Z","shell.execute_reply":"2023-11-09T19:48:23.215201Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from astropy import units as u\nfrom astropy.coordinates import SkyCoord\n\ncoords = SkyCoord(ra=10.625*u.degree, dec=41.2*u.degree, frame='icrs')\n\n#definding coords as a coordinates a ra of 10.625 degrees, and dec of 41.2 degrees\n\ncoord2=SkyCoord('00h2m30s','+41d2m00', frame='icrs')\n#it is standard for:\n\nprint(coords2)","metadata":{"execution":{"iopub.status.busy":"2023-11-09T19:48:19.923651Z","iopub.execute_input":"2023-11-09T19:48:19.924009Z","iopub.status.idle":"2023-11-09T19:48:19.932584Z","shell.execute_reply.started":"2023-11-09T19:48:19.923982Z","shell.execute_reply":"2023-11-09T19:48:19.931547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nskycoordarray = SkyCoord(ra=[10, 11, 12, 13]*u.degree, dec=[-11, 3, 65, 4]*u.degree)\n#we would replace 10, 11, 12, 13 with out ra array of data\n\n#how we take a series of data ra and dec amd combine them to a list of coordinates.\n#you can take arrays of ra, and arrays of dec and turn them into usable coord","metadata":{"execution":{"iopub.status.busy":"2023-11-09T19:48:29.892833Z","iopub.execute_input":"2023-11-09T19:48:29.89321Z","iopub.status.idle":"2023-11-09T19:48:29.899589Z","shell.execute_reply.started":"2023-11-09T19:48:29.893183Z","shell.execute_reply":"2023-11-09T19:48:29.898518Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"coords = SkyCoord(ra=10.625*u.degree, dec=41.2*u.degree, frame='icrs')\ncoords2 = SkyCoord('00h2m30s','+41d2m00', frame='icrs')\n\ncoords.separation(coord2)\n","metadata":{"execution":{"iopub.status.busy":"2023-11-09T19:48:17.050975Z","iopub.execute_input":"2023-11-09T19:48:17.052197Z","iopub.status.idle":"2023-11-09T19:48:17.066125Z","shell.execute_reply.started":"2023-11-09T19:48:17.052159Z","shell.execute_reply":"2023-11-09T19:48:17.065119Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ptp install regions\n\n ","metadata":{"execution":{"iopub.status.busy":"2023-11-09T19:48:34.769364Z","iopub.execute_input":"2023-11-09T19:48:34.769786Z","iopub.status.idle":"2023-11-09T19:48:34.77599Z","shell.execute_reply.started":"2023-11-09T19:48:34.769758Z","shell.execute_reply":"2023-11-09T19:48:34.774854Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"11/8:\nAdd the markdown\nhttps://astropy-regions.readthedocs.io/en/stable/contains.html\nhttps://astropy-regions.readthedocs.io/en/stable/shapes.html\n\nchecking for coords in a region \n\n \n","metadata":{}},{"cell_type":"code","source":"pip install regions","metadata":{"execution":{"iopub.status.busy":"2023-11-09T20:06:36.312757Z","iopub.execute_input":"2023-11-09T20:06:36.313179Z","iopub.status.idle":"2023-11-09T20:06:50.830324Z","shell.execute_reply.started":"2023-11-09T20:06:36.313148Z","shell.execute_reply":"2023-11-09T20:06:50.828912Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n# Required python moduldes for opening FITS files and plotting\nimport numpy as np\nimport pandas as pd\nimport os\nimport os.path as op\nimport glob\nimport matplotlib.pyplot as plt\nfrom matplotlib import gridspec\nfrom astropy.io import fits\nfrom astropy.table import Table, hstack\nfrom astropy.coordinates import SkyCoord\nfrom astropy.wcs import WCS\nfrom astropy.visualization import make_lupton_rgb, ZScaleInterval\nfrom astropy.coordinates import SkyCoord  # High-level coordinates\nfrom astropy.coordinates import ICRS, Galactic, FK4, FK5  # Low-level frames\nfrom astropy.coordinates import Angle, Latitude, Longitude  # Angles\nfrom regions import Regions\nfrom astropy.coordinates import Angle, SkyCoord\nfrom regions import PixCoord, LineSkyRegion, LinePixelRegion\nfrom regions import CircleSkyRegion, PixCoord, CirclePixelRegion\nfrom astropy import units as u\nfrom astropy.coordinates import SkyCoord\nfrom astropy.cosmology import WMAP9 as cosmo\n\n\n%matplotlib inline","metadata":{"execution":{"iopub.status.busy":"2023-11-09T20:06:50.832965Z","iopub.execute_input":"2023-11-09T20:06:50.833364Z","iopub.status.idle":"2023-11-09T20:06:51.583239Z","shell.execute_reply.started":"2023-11-09T20:06:50.83333Z","shell.execute_reply":"2023-11-09T20:06:51.582093Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"import data ","metadata":{}},{"cell_type":"code","source":"spacedf=pd.read_csv('/kaggle/input/sloan-digital-sky-survey/Skyserver_SQL2_27_2018 6_51_39 PM.csv')\nspacedf.info()\n#we are looking at the colum names to understnad what data we have to work with","metadata":{"execution":{"iopub.status.busy":"2023-11-09T20:05:12.932706Z","iopub.execute_input":"2023-11-09T20:05:12.93306Z","iopub.status.idle":"2023-11-09T20:05:12.983316Z","shell.execute_reply.started":"2023-11-09T20:05:12.933031Z","shell.execute_reply":"2023-11-09T20:05:12.982311Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from astropy import units as u\nfrom astropy.coordinates import SkyCoord\n\ncoords = SkyCoord(ra=10.625*u.degree, dec=41.2*u.degree, frame='icrs')\n\n#definding coords as a coordinates a ra of 10.625 degrees, and dec of 41.2 degrees\n\ncoord2=SkyCoord('00h2m30s','+41d2m00', frame='icrs')\n#it is standard for:\n\nprint(coords2)\n\nimport numpy as np\nskycoordarray = SkyCoord(ra=[10, 11, 12, 13]*u.degree, dec=[-11, 3, 65, 4]*u.degree)\n#we would replace 10, 11, 12, 13 with out ra array of data\n\n#how we take a series of data ra and dec amd combine them to a list of coordinates.\n#you can take arrays of ra, and arrays of dec and turn them into usable coord\n\ncoords = SkyCoord(ra=10.625*u.degree, dec=41.2*u.degree, frame='icrs')\ncoords2 = SkyCoord('00h2m30s','+41d2m00', frame='icrs')\n\ncoords.separation(coord2)\n\nspacedf=pd.read_csv('/kaggle/input/sloan-digital-sky-survey/Skyserver_SQL2_27_2018 6_51_39 PM.csv')\nspacedf.info()\n\n\nra=spacedf.ra*u.deg\ndec=spacedf.dec*u.deg\n\nspacecoord=SkyCoord(ra, dec, frame='icrs',unit='deg')\n#coordarray = skycoord( ra collum )\nspacecoord\nCOMAP_point_one = SkyCoord(ra='01h41m44.4s',dec='00d00m00s')\nCOMAP_point_two = SkyCoord(ra='11h20m00s',dec='52d30m00s')\nCOMAP_point_three = SkyCoord(ra='15h04m00s',dec='55d00m00s')\n\ntolerance=1.5*u.deg\n#this is how far away from the point we are willing to look\n\nsep_point_one=spacecoord.separation(COMAP_point_one)\n\n#we are going index (cut out)the data that is whinin our\n#tolerance, so we only have data whinin 1.5 degree\ngood_idx_one=np.where(sep_point_one<tolerance)[0]\n\n\nfield_one_df=spacedf.iloc[good_idx_one]\n#create a new dataframe from our space dataframe with the rows cut out(iloc)\n#of the\n\nfield_one_df\n#this is a dataframe with only from ra and dec \n\nsep_point_two=spacecoord.separation(COMAP_point_two)\ngood_idx_two=np.where(sep_point_two<tolerance)[0]\nfield_two_df=spacedf.iloc[good_idx_two]\n\nsep_point_three=spacecoord.separation(COMAP_point_three)\ngood_idx_three=np.where(sep_point_three<tolerance)[0]\nfield_three_df=spacedf.iloc[good_idx_three]\n\n\n\ncombined_df=pd.concat((field_one_df, field_two_df, field_three_df))\ncombined_df\n\n","metadata":{"execution":{"iopub.status.busy":"2023-11-09T20:33:23.633577Z","iopub.execute_input":"2023-11-09T20:33:23.633946Z","iopub.status.idle":"2023-11-09T20:33:24.899257Z","shell.execute_reply.started":"2023-11-09T20:33:23.633921Z","shell.execute_reply":"2023-11-09T20:33:24.89815Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spacecoord in stripe82","metadata":{"execution":{"iopub.status.busy":"2023-11-09T20:08:48.585929Z","iopub.execute_input":"2023-11-09T20:08:48.586277Z","iopub.status.idle":"2023-11-09T20:08:48.614939Z","shell.execute_reply.started":"2023-11-09T20:08:48.586251Z","shell.execute_reply":"2023-11-09T20:08:48.613772Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sep_point_two=spacecoord.separation(COMAP_point_two)\ngood_idx_two=np.where(sep_point_two<tolerance)[0]\nfield_two_df=spacedf.iloc[good_idx_two]\n\nsep_point_three=spacecoord.separation(COMAP_point_three)\ngood_idx_three=np.where(sep_point_three<tolerance)[0]\nfield_three_df=spacedf.iloc[good_idx_three]\n\n\n\ncombined_df=pd.concat((field_one_df, field_two_df, field_three_df))\ncombined_df","metadata":{"execution":{"iopub.status.busy":"2023-11-09T20:32:53.471131Z","iopub.execute_input":"2023-11-09T20:32:53.472264Z","iopub.status.idle":"2023-11-09T20:32:53.503389Z","shell.execute_reply.started":"2023-11-09T20:32:53.472218Z","shell.execute_reply":"2023-11-09T20:32:53.502311Z"},"trusted":true},"execution_count":null,"outputs":[]}]}