diff --git a/notebooks/adler_demo.ipynb b/notebooks/adler_demo.ipynb index 289dace..b2de112 100644 --- a/notebooks/adler_demo.ipynb +++ b/notebooks/adler_demo.ipynb @@ -4,7 +4,15 @@ "cell_type": "code", "execution_count": null, "id": "7fafdbd9", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:22.264374Z", + "iopub.status.busy": "2024-10-22T13:49:22.264159Z", + "iopub.status.idle": "2024-10-22T13:49:24.365469Z", + "shell.execute_reply": "2024-10-22T13:49:24.364557Z", + "shell.execute_reply.started": "2024-10-22T13:49:22.264357Z" + } + }, "outputs": [], "source": [ "from adler.objectdata.AdlerPlanetoid import AdlerPlanetoid\n", @@ -24,21 +32,39 @@ "cell_type": "code", "execution_count": null, "id": "b9b8d9be", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:24.367159Z", + "iopub.status.busy": "2024-10-22T13:49:24.366563Z", + "iopub.status.idle": "2024-10-22T13:49:26.858571Z", + "shell.execute_reply": "2024-10-22T13:49:26.857667Z", + "shell.execute_reply.started": "2024-10-22T13:49:24.367135Z" + } + }, "outputs": [], "source": [ - "# ssoid = \"6098332225018\" # good test object\n", - "ssoid = \"8268570668335894776\" # NEO\n", + "ssoid = \"6098332225018\" # good test object\n", + "# ssoid = \"8268570668335894776\" # NEO\n", + "# ssoid = \"-4973461691235584486\" # NEO\n", "\n", - "fname = \"/Users/jrobinson/lsst-adler/notebooks/gen_test_data/adler_demo_testing_database.db\"\n", - "planetoid = AdlerPlanetoid.construct_from_SQL(ssoid, sql_filename=fname)" + "# fname = \"/Users/jrobinson/lsst-adler/notebooks/gen_test_data/adler_demo_testing_database.db\"\n", + "# planetoid = AdlerPlanetoid.construct_from_SQL(ssoid, sql_filename=fname)\n", + "planetoid = AdlerPlanetoid.construct_from_RSP(ssoid)" ] }, { "cell_type": "code", "execution_count": null, "id": "dfca7299", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:26.861022Z", + "iopub.status.busy": "2024-10-22T13:49:26.860753Z", + "iopub.status.idle": "2024-10-22T13:49:26.910514Z", + "shell.execute_reply": "2024-10-22T13:49:26.909442Z", + "shell.execute_reply.started": "2024-10-22T13:49:26.861003Z" + } + }, "outputs": [], "source": [ "planetoid.__dict__" @@ -47,8 +73,16 @@ { "cell_type": "code", "execution_count": null, - "id": "3639679e", - "metadata": {}, + "id": "477268a2-7e9d-4962-a81e-187ab61b7b87", + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:26.911998Z", + "iopub.status.busy": "2024-10-22T13:49:26.911740Z", + "iopub.status.idle": "2024-10-22T13:49:26.917243Z", + "shell.execute_reply": "2024-10-22T13:49:26.916406Z", + "shell.execute_reply.started": "2024-10-22T13:49:26.911979Z" + } + }, "outputs": [], "source": [ "planetoid.MPCORB" @@ -58,7 +92,15 @@ "cell_type": "code", "execution_count": null, "id": "334fd033", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:26.918460Z", + "iopub.status.busy": "2024-10-22T13:49:26.918225Z", + "iopub.status.idle": "2024-10-22T13:49:26.965001Z", + "shell.execute_reply": "2024-10-22T13:49:26.963946Z", + "shell.execute_reply.started": "2024-10-22T13:49:26.918437Z" + } + }, "outputs": [], "source": [ "filters = planetoid.filter_list" @@ -68,7 +110,15 @@ "cell_type": "code", "execution_count": null, "id": "960ee095", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:26.966552Z", + "iopub.status.busy": "2024-10-22T13:49:26.966297Z", + "iopub.status.idle": "2024-10-22T13:49:26.985388Z", + "shell.execute_reply": "2024-10-22T13:49:26.984534Z", + "shell.execute_reply.started": "2024-10-22T13:49:26.966534Z" + } + }, "outputs": [], "source": [ "# get all obs as dataframe\n", @@ -85,17 +135,88 @@ "cell_type": "code", "execution_count": null, "id": "6f188ab5", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:26.986708Z", + "iopub.status.busy": "2024-10-22T13:49:26.986460Z", + "iopub.status.idle": "2024-10-22T13:49:27.015012Z", + "shell.execute_reply": "2024-10-22T13:49:27.013967Z", + "shell.execute_reply.started": "2024-10-22T13:49:26.986690Z" + } + }, "outputs": [], "source": [ "df_obs" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "d8a3ca51", + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:27.016477Z", + "iopub.status.busy": "2024-10-22T13:49:27.016231Z", + "iopub.status.idle": "2024-10-22T13:49:27.025836Z", + "shell.execute_reply": "2024-10-22T13:49:27.024894Z", + "shell.execute_reply.started": "2024-10-22T13:49:27.016459Z" + } + }, + "outputs": [], + "source": [ + "# calculate elongation angle\n", + "R = df_obs[\"heliocentricDist\"]\n", + "Delta = df_obs[\"topocentricDist\"]\n", + "alpha = np.radians(df_obs[\"phaseAngle\"])\n", + "\n", + "R_E = np.sqrt((R * R) + (Delta * Delta) - (2.0 * R * Delta * np.cos(alpha)))\n", + "df_obs[\"elong\"] = np.degrees(np.arccos(((R_E * R_E) + (Delta * Delta) - (R * R)) / (2.0 * R_E * Delta)))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0d45807d", + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:27.048396Z", + "iopub.status.busy": "2024-10-22T13:49:27.048063Z", + "iopub.status.idle": "2024-10-22T13:49:27.317638Z", + "shell.execute_reply": "2024-10-22T13:49:27.316589Z", + "shell.execute_reply.started": "2024-10-22T13:49:27.048373Z" + } + }, + "outputs": [], + "source": [ + "x_plot = \"midPointMjdTai\"\n", + "y_plot = \"elong\"\n", + "df_plot = df_obs\n", + "\n", + "fig = plt.figure()\n", + "gs = gridspec.GridSpec(1, 1)\n", + "ax1 = plt.subplot(gs[0, 0])\n", + "\n", + "ax1.scatter(df_plot[x_plot], df_plot[y_plot])\n", + "\n", + "ax1.set_xlabel(x_plot)\n", + "ax1.set_ylabel(y_plot)\n", + "\n", + "plt.show()" + ] + }, { "cell_type": "code", "execution_count": null, "id": "8a0f5291", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:27.319596Z", + "iopub.status.busy": "2024-10-22T13:49:27.319182Z", + "iopub.status.idle": "2024-10-22T13:49:27.355353Z", + "shell.execute_reply": "2024-10-22T13:49:27.354328Z", + "shell.execute_reply.started": "2024-10-22T13:49:27.319562Z" + } + }, "outputs": [], "source": [ "tmin = np.amin(np.floor(df_obs[\"midPointMjdTai\"])) # mjd\n", @@ -107,7 +228,15 @@ "cell_type": "code", "execution_count": null, "id": "0a293038", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:27.357205Z", + "iopub.status.busy": "2024-10-22T13:49:27.356817Z", + "iopub.status.idle": "2024-10-22T13:49:27.669853Z", + "shell.execute_reply": "2024-10-22T13:49:27.669093Z", + "shell.execute_reply.started": "2024-10-22T13:49:27.357176Z" + } + }, "outputs": [], "source": [ "# cumulative data in filter\n", @@ -140,7 +269,15 @@ "cell_type": "code", "execution_count": null, "id": "09c7d0cb", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:27.672870Z", + "iopub.status.busy": "2024-10-22T13:49:27.672622Z", + "iopub.status.idle": "2024-10-22T13:49:27.679269Z", + "shell.execute_reply": "2024-10-22T13:49:27.678468Z", + "shell.execute_reply.started": "2024-10-22T13:49:27.672852Z" + } + }, "outputs": [], "source": [ "data_nights" @@ -150,7 +287,15 @@ "cell_type": "code", "execution_count": null, "id": "d57a9e80", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:27.680435Z", + "iopub.status.busy": "2024-10-22T13:49:27.680218Z", + "iopub.status.idle": "2024-10-22T13:49:27.695007Z", + "shell.execute_reply": "2024-10-22T13:49:27.694150Z", + "shell.execute_reply.started": "2024-10-22T13:49:27.680419Z" + } + }, "outputs": [], "source": [ "N_data" @@ -160,7 +305,15 @@ "cell_type": "code", "execution_count": null, "id": "504569cb", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:27.696425Z", + "iopub.status.busy": "2024-10-22T13:49:27.696205Z", + "iopub.status.idle": "2024-10-22T13:49:27.710841Z", + "shell.execute_reply": "2024-10-22T13:49:27.710150Z", + "shell.execute_reply.started": "2024-10-22T13:49:27.696408Z" + } + }, "outputs": [], "source": [ "# create the empty AdlerData object\n", @@ -172,7 +325,15 @@ "cell_type": "code", "execution_count": null, "id": "87a6de72", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:27.712024Z", + "iopub.status.busy": "2024-10-22T13:49:27.711804Z", + "iopub.status.idle": "2024-10-22T13:49:27.750033Z", + "shell.execute_reply": "2024-10-22T13:49:27.749252Z", + "shell.execute_reply.started": "2024-10-22T13:49:27.712006Z" + } + }, "outputs": [], "source": [ "planetoid.SSObject" @@ -182,7 +343,15 @@ "cell_type": "code", "execution_count": null, "id": "8de34419", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:27.751267Z", + "iopub.status.busy": "2024-10-22T13:49:27.751024Z", + "iopub.status.idle": "2024-10-22T13:49:27.756256Z", + "shell.execute_reply": "2024-10-22T13:49:27.755486Z", + "shell.execute_reply.started": "2024-10-22T13:49:27.751248Z" + } + }, "outputs": [], "source": [ "planetoid.SSObject_in_filter(\"r\")" @@ -192,7 +361,15 @@ "cell_type": "code", "execution_count": null, "id": "cd3e6491", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:27.757763Z", + "iopub.status.busy": "2024-10-22T13:49:27.757542Z", + "iopub.status.idle": "2024-10-22T13:49:27.770935Z", + "shell.execute_reply": "2024-10-22T13:49:27.770130Z", + "shell.execute_reply.started": "2024-10-22T13:49:27.757745Z" + } + }, "outputs": [], "source": [ "# TODO: we need a translation between planetoid.SSObject attributes and AdlerData attributes\n", @@ -204,7 +381,15 @@ "cell_type": "code", "execution_count": null, "id": "71776f60", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:27.772332Z", + "iopub.status.busy": "2024-10-22T13:49:27.772091Z", + "iopub.status.idle": "2024-10-22T13:49:27.786653Z", + "shell.execute_reply": "2024-10-22T13:49:27.785661Z", + "shell.execute_reply.started": "2024-10-22T13:49:27.772315Z" + } + }, "outputs": [], "source": [ "ADLER_SSOBJECT, SSOBJECT_ADLER" @@ -214,7 +399,15 @@ "cell_type": "code", "execution_count": null, "id": "c74ef722", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:27.788411Z", + "iopub.status.busy": "2024-10-22T13:49:27.788064Z", + "iopub.status.idle": "2024-10-22T13:49:27.799860Z", + "shell.execute_reply": "2024-10-22T13:49:27.799133Z", + "shell.execute_reply.started": "2024-10-22T13:49:27.788382Z" + } + }, "outputs": [], "source": [ "sso_r = planetoid.SSObject_in_filter(\"r\")\n", @@ -225,7 +418,15 @@ "cell_type": "code", "execution_count": null, "id": "0d979da6", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:27.801232Z", + "iopub.status.busy": "2024-10-22T13:49:27.801000Z", + "iopub.status.idle": "2024-10-22T13:49:36.318337Z", + "shell.execute_reply": "2024-10-22T13:49:36.317155Z", + "shell.execute_reply.started": "2024-10-22T13:49:27.801215Z" + } + }, "outputs": [], "source": [ "N_pc_fit = 25 # minimum number of observations to fit phase curve parameter (otherwise just fit H)\n", @@ -303,6 +504,7 @@ " # store values in AdlerData\n", " adler_data.populate_phase_parameters(filt, **ad_params)\n", "\n", + " ad_params[\"filter_name\"] = filt\n", " ad_params_list.append(ad_params)\n", "\n", "# break\n", @@ -310,11 +512,37 @@ "# break" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "e1bdad8b-e2e2-4edf-82c4-7d653921ba57", + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:36.319502Z", + "iopub.status.busy": "2024-10-22T13:49:36.319239Z", + "iopub.status.idle": "2024-10-22T13:49:36.354366Z", + "shell.execute_reply": "2024-10-22T13:49:36.353090Z", + "shell.execute_reply.started": "2024-10-22T13:49:36.319475Z" + } + }, + "outputs": [], + "source": [ + "ad_params" + ] + }, { "cell_type": "code", "execution_count": null, "id": "ed4d567b", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:36.356222Z", + "iopub.status.busy": "2024-10-22T13:49:36.355886Z", + "iopub.status.idle": "2024-10-22T13:49:36.622298Z", + "shell.execute_reply": "2024-10-22T13:49:36.621538Z", + "shell.execute_reply.started": "2024-10-22T13:49:36.356193Z" + } + }, "outputs": [], "source": [ "fig = plot_errorbar(planetoid, filt_list=[\"r\"])" @@ -324,7 +552,15 @@ "cell_type": "code", "execution_count": null, "id": "04139eac", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:36.623648Z", + "iopub.status.busy": "2024-10-22T13:49:36.623396Z", + "iopub.status.idle": "2024-10-22T13:49:36.629099Z", + "shell.execute_reply": "2024-10-22T13:49:36.628368Z", + "shell.execute_reply.started": "2024-10-22T13:49:36.623628Z" + } + }, "outputs": [], "source": [ "ad_params" @@ -334,10 +570,17 @@ "cell_type": "code", "execution_count": null, "id": "0910c4ab", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-10-22T13:49:36.630700Z", + "iopub.status.busy": "2024-10-22T13:49:36.630138Z", + "iopub.status.idle": "2024-10-22T13:49:37.427375Z", + "shell.execute_reply": "2024-10-22T13:49:37.426547Z", + "shell.execute_reply.started": "2024-10-22T13:49:36.630677Z" + } + }, "outputs": [], "source": [ - "# x_plot = \"midPointMjdTai\"\n", "x_plot = \"modelFitMjd\"\n", "y_plot = \"H\"\n", "\n", @@ -355,72 +598,18 @@ " gs = gridspec.GridSpec(1, 1)\n", " ax1 = plt.subplot(gs[0, 0])\n", "\n", - " # ax1.scatter(df_plot[x_plot],df_plot[y_plot])\n", - " ax1.scatter(df_plot.index.values, df_plot[y_plot])\n", + " for filt in np.unique(df_plot[\"filter_name\"]):\n", + " _df_plot = df_plot[df_plot[\"filter_name\"] == filt]\n", + " ax1.scatter(_df_plot[x_plot], _df_plot[y_plot], label=filt)\n", + " ax1.plot(_df_plot[x_plot], _df_plot[y_plot])\n", + " # ax1.scatter(_df_plot.index.values, _df_plot[y_plot])\n", "\n", " # ax1.set_xlabel(x_plot)\n", " ax1.set_ylabel(y_plot)\n", "\n", - " plt.show()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c79c682f", - "metadata": {}, - "outputs": [], - "source": [ - "_df_n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f64970b7", - "metadata": {}, - "outputs": [], - "source": [ - "df_obs.columns" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d8a3ca51", - "metadata": {}, - "outputs": [], - "source": [ - "# calculate elongation angle\n", - "R = df_obs[\"heliocentricDist\"]\n", - "Delta = df_obs[\"topocentricDist\"]\n", - "alpha = np.radians(df_obs[\"phaseAngle\"])\n", - "\n", - "R_E = np.sqrt((R * R) + (Delta * Delta) - (2.0 * R * Delta * np.cos(alpha)))\n", - "df_obs[\"elong\"] = np.degrees(np.arccos(((R_E * R_E) + (Delta * Delta) - (R * R)) / (2.0 * R_E * Delta)))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "0d45807d", - "metadata": {}, - "outputs": [], - "source": [ - "x_plot = \"midPointMjdTai\"\n", - "y_plot = \"elong\"\n", - "df_plot = df_obs\n", - "\n", - "fig = plt.figure()\n", - "gs = gridspec.GridSpec(1, 1)\n", - "ax1 = plt.subplot(gs[0, 0])\n", + " ax1.legend()\n", "\n", - "ax1.scatter(df_plot[x_plot], df_plot[y_plot])\n", - "\n", - "ax1.set_xlabel(x_plot)\n", - "ax1.set_ylabel(y_plot)\n", - "\n", - "plt.show()" + " plt.show()" ] }, {