Skip to content

Instantly share code, notes, and snippets.

@rbiswas4
Last active November 13, 2015 09:06
Show Gist options
  • Save rbiswas4/b1952341e75a049f820f to your computer and use it in GitHub Desktop.
Save rbiswas4/b1952341e75a049f820f to your computer and use it in GitHub Desktop.
This gist shows that in the patch of sky used by @SimonKrughoff contains a small number of galaxies, and the galtileid % (2^32 -1) values are unique
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/manual/anaconda/lib/python2.7/site-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated. You should import from ipykernel or jupyter_client instead.\n",
" \"You should import from ipykernel or jupyter_client instead.\", ShimWarning)\n",
"Duplicate object type id 25 specified: \n",
"Output object ids may not be unique.\n",
"This may not be a problem if you do not want globally unique id values\n",
"Duplicate object type id 40 specified: \n",
"Output object ids may not be unique.\n",
"This may not be a problem if you do not want globally unique id values\n",
"Duplicate object type id 40 specified: \n",
"Output object ids may not be unique.\n",
"This may not be a problem if you do not want globally unique id values\n",
"Duplicate object type id 40 specified: \n",
"Output object ids may not be unique.\n",
"This may not be a problem if you do not want globally unique id values\n",
"Duplicate object type id 40 specified: \n",
"Output object ids may not be unique.\n",
"This may not be a problem if you do not want globally unique id values\n"
]
}
],
"source": [
"from lsst.sims.catUtils.mixins import CosmologyMixin\n",
"from lsst.sims.utils import ObservationMetaData\n",
"from lsst.sims.catUtils.utils import ObservationMetaDataGenerator\n",
"from lsst.sims.catalogs.generation.db import CatalogDBObject\n",
"from lsst.sims.catalogs.measures.instance import InstanceCatalog\n",
"import eups"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import os"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/manual/anaconda/lib/python2.7/site-packages/sqlalchemy/dialects/mssql/base.py:1294: SAWarning: Did not recognize type 'geography' of column 'geopoint'\n",
" return fn(*arg, **kw)\n"
]
}
],
"source": [
"galDB = CatalogDBObject.from_objid('galaxyTiled')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"class galCopy(InstanceCatalog):\n",
" column_outputs = ['galtileid', 'raJ2000', 'decJ2000', 'redshift']\n",
" override_formats = {'raJ2000': '%8e', 'decJ2000': '%8e'}"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"opsimPath = os.path.join(os.getenv('HOME'), 'data', 'LSST', 'OpSimData')\n",
"opsimDB = os.path.join(opsimPath,'enigma_1189_sqlite.db')\n",
"generator = ObservationMetaDataGenerator(database=opsimDB, driver='sqlite')\n",
"obsMetaDataResults = generator.getObservationMetaData(limit=1, fieldRA=(53, 54), fieldDec=(-29, -27), boundLength=0.3)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"49353.051334000003"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"obsMetaDataResults[0].mjd"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"galphot = galCopy(db_obj=galDB, obs_metadata=obsMetaDataResults[0])"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"galphot.write_catalog('Twinkles_galphot_2.dat')"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/manual/anaconda/lib/python2.7/site-packages/pandas/io/parsers.py:644: ParserWarning: Falling back to the 'python' engine because the 'c' engine does not support regex separators; you can avoid this warning by specifying engine='python'.\n",
" ParserWarning)\n"
]
}
],
"source": [
"df = pd.read_csv('Twinkles_galphot_2.dat',sep=', ')"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"df.rename(columns={'#galtileid':'galtileid'}, inplace=True)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>galtileid</th>\n",
" <th>raJ2000</th>\n",
" <th>decJ2000</th>\n",
" <th>redshift</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>60016401894</td>\n",
" <td>0.921689</td>\n",
" <td>-0.482484</td>\n",
" <td>0.2575</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>60015814101</td>\n",
" <td>0.921661</td>\n",
" <td>-0.482505</td>\n",
" <td>1.3331</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>60012610249</td>\n",
" <td>0.921696</td>\n",
" <td>-0.482492</td>\n",
" <td>0.8434</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>60006127897</td>\n",
" <td>0.921689</td>\n",
" <td>-0.482503</td>\n",
" <td>1.3539</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>60000415840</td>\n",
" <td>0.921686</td>\n",
" <td>-0.482507</td>\n",
" <td>0.4542</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" galtileid raJ2000 decJ2000 redshift\n",
"0 60016401894 0.921689 -0.482484 0.2575\n",
"1 60015814101 0.921661 -0.482505 1.3331\n",
"2 60012610249 0.921696 -0.482492 0.8434\n",
"3 60006127897 0.921689 -0.482503 1.3539\n",
"4 60000415840 0.921686 -0.482507 0.4542"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(df['galtileid'].apply(lambda x: x % 4294967295).unique()) - len(df)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"243476"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(df)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0 4181827059\n",
"1 4181239266\n",
"2 4178035414\n",
"3 4171553062\n",
"4 4165841005\n",
"5 4168468800\n",
"6 4170413215\n",
"7 4175210446\n",
"8 4175194837\n",
"9 4176415060\n",
"10 4165645588\n",
"11 4179792637\n",
"12 4171471010\n",
"13 4178185390\n",
"14 4176154311\n",
"15 4178109644\n",
"16 4171544353\n",
"17 4167131785\n",
"18 4181087901\n",
"19 4169603638\n",
"20 4172923985\n",
"21 4181757424\n",
"22 4182696679\n",
"23 4165452768\n",
"24 4166060950\n",
"25 4181052317\n",
"26 4169604980\n",
"27 4176405549\n",
"28 4180737400\n",
"29 4173609486\n",
" ... \n",
"243446 4176607123\n",
"243447 4182317223\n",
"243448 4175365036\n",
"243449 4175078991\n",
"243450 4175356851\n",
"243451 4181730091\n",
"243452 4169229953\n",
"243453 4174609048\n",
"243454 4172588327\n",
"243455 4171183522\n",
"243456 4178135555\n",
"243457 4173782217\n",
"243458 4180243547\n",
"243459 4172240851\n",
"243460 4167548226\n",
"243461 4172651870\n",
"243462 4168811147\n",
"243463 4173650575\n",
"243464 4174326357\n",
"243465 4168802714\n",
"243466 4170868442\n",
"243467 4167038611\n",
"243468 4182108197\n",
"243469 4176153210\n",
"243470 4174195429\n",
"243471 4174879639\n",
"243472 4167357471\n",
"243473 4176213633\n",
"243474 4180178395\n",
"243475 4166789026\n",
"Name: galtileid, dtype: int64"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['galtileid'].apply(lambda x: x % 4294967295)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"55722460950"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['galtileid'].max() - 2**32"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment