Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
jikrant3 authored Aug 14, 2022
1 parent 96ebd73 commit d05e1da
Showing 1 changed file with 50 additions and 3 deletions.
53 changes: 50 additions & 3 deletions Cheatsheet and useful functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,9 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"tags": []
},
"source": [
"# Pandas"
]
Expand All @@ -566,6 +568,13 @@
"cant20 = cant20.set_index('Cluster')\n",
"_iso_cut.reset_index(drop=True, inplace=True)\n",
"\n",
"# Renaming columns\n",
"data.rename(columns={'ra_1':'ra_Gaia', 'dec_1':'dec_Gaia'}, \n",
" inplace=True)\n",
"\n",
"# mean of columns as new column\n",
"data['ra_UVIT'] = data[['ra_2','ra_3']].mean(axis=1)\n",
"\n",
"# removing/dropping columns\n",
"df.drop(columns=['B', 'C'])\n",
"# dropping rows\n",
Expand Down Expand Up @@ -791,6 +800,13 @@
" framealpha = 0.8, borderpad = 0.4. labelspacing=0.5,\n",
" columnspacing=2.0,ncol=1) \n",
"\n",
"\n",
"axins = ax[1].inset_axes([0.2, 0.15, 0.79, 0.84])\n",
"xmax = np.ceil(np.nanmax(1/df_bin['frequency_veb']))\n",
"bins = np.arange(0,xmax+1, 1)\n",
"axins.hist(1/df_bin['frequency_veb'], alpha=0.5, label='Variable EB (%d)'%(df_bin.has_veb.sum()),bins=bins, color='C0')\n",
"\n",
"\n",
"# saving\n",
"plt.savefig('plots/CMD_simple/'+cl_name+'_2.png', format='png',dpi=300,bbox_inches='tight')"
]
Expand Down Expand Up @@ -1000,15 +1016,46 @@
"\n",
"def print_progress(current_iteration, total_iterations=100, step=50, message='Progress'): \n",
" if (current_iteration%step==0):\n",
" print ('\\r %s: %d/%d (%d%%)' %(message, current_iteration+1, total_iterations, 100*(current_iteration+1)/total_iterations), end='')\n"
" print ('\\r %s: %d/%d (%d%%)' %(message, current_iteration+1, total_iterations, 100*(current_iteration+1)/total_iterations), end='')\n",
"def reprint(message):\n",
" print ('\\r %s' %(message), end='')\n",
"\n",
" \n",
"# Create folder is not present\n",
"if not os.path.exists('plots/stamps'): os.makedirs('plots/stamps')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"# cone search \n",
"def get_gaiadr3_cone(ra, dec, radius=60./3600, ROW_LIMIT=1000, quick=False):\n",
" Gaia.ROW_LIMIT = ROW_LIMIT # Ensure the default row limit.\n",
" coord = SkyCoord(ra=ra, dec=dec, unit=(u.degree, u.degree), frame='icrs')\n",
" radius = u.Quantity(radius, u.deg)\n",
" if quick: columns = ['source_id', 'ra', 'dec' , 'parallax', 'pmra', 'pmdec', 'phot_g_mean_mag', 'bp_rp']\n",
" else: columns = []\n",
" j = Gaia.cone_search(coord, radius, columns=columns)\n",
" r = j.get_results()\n",
" r.pprint()\n",
" return r\n",
"\n",
"\n",
"# plotting pseudo image from Gaia data\n",
"def plot_gaia_image(gaia_neighbourhood, ax=None):\n",
" if ax == None: fig, ax = plt.subplots(figsize =(8,8))\n",
" \n",
" gaia_neighbourhood['22-G'] = 22-gaia_neighbourhood['phot_g_mean_mag']\n",
" g = sns.scatterplot(\n",
" x=gaia_neighbourhood['ra'], y=gaia_neighbourhood['dec'],\n",
" hue=gaia_neighbourhood['bp_rp'], size=gaia_neighbourhood['22-G'],\n",
" palette='coolwarm', sizes=(10, 200), ax=ax)\n",
" \n",
" return ax"
]
}
],
"metadata": {
Expand Down

0 comments on commit d05e1da

Please sign in to comment.