"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "visualize_fit(t, xs, ys, xes, yes, x_model, y_model, xe_model, ye_model, mm.name, t_test)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "f7ae3e7f",
+ "metadata": {},
+ "source": [
+ "## 1.3. Example: Parallax Model Fit"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "08eceab5",
+ "metadata": {},
+ "source": [
+ "Parallax model requires some fixed parameters: `ra`, `dec`, `pa`, `obsLocation`, and `t0`.\n",
+ "- `ra` and `dec` are required parameters. \n",
+ "- `pa = 0` by default\n",
+ "- `obsLocation = 'earth'` by default\n",
+ "- `t0 = np.average(t, 1./np.hypot(xe, ye))` by default\n",
+ "\n",
+ "We need to provide the fixed parameters in the `fixed_params_dict`:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "id": "018fc13a",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/home/weilingfeng/Software/miniconda3/envs/main/lib/python3.12/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"dtf2d\" yielded 1 of \"dubious year (Note 6)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/home/weilingfeng/Software/miniconda3/envs/main/lib/python3.12/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"dtf2d\" yielded 2 of \"dubious year (Note 6)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/home/weilingfeng/Software/miniconda3/envs/main/lib/python3.12/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"utctai\" yielded 2 of \"dubious year (Note 3)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/home/weilingfeng/Software/miniconda3/envs/main/lib/python3.12/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"utctai\" yielded 1 of \"dubious year (Note 3)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/home/weilingfeng/Software/miniconda3/envs/main/lib/python3.12/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"taiutc\" yielded 1 of \"dubious year (Note 4)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n"
+ ]
+ }
+ ],
+ "source": [
+ "mm = Parallax()\n",
+ "fixed_params_dict = {'ra': 0., 'dec': 10., 'pa': 0., 'obsLocation': 'earth'}\n",
+ "params, param_errs = mm.fit(t, x, y, xe, ye, fixed_params_dict)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "id": "73dafb1f",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/home/weilingfeng/Software/miniconda3/envs/main/lib/python3.12/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"dtf2d\" yielded 20 of \"dubious year (Note 6)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/home/weilingfeng/Software/miniconda3/envs/main/lib/python3.12/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"dtf2d\" yielded 40 of \"dubious year (Note 6)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/home/weilingfeng/Software/miniconda3/envs/main/lib/python3.12/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"utctai\" yielded 40 of \"dubious year (Note 3)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/home/weilingfeng/Software/miniconda3/envs/main/lib/python3.12/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"utctai\" yielded 20 of \"dubious year (Note 3)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/home/weilingfeng/Software/miniconda3/envs/main/lib/python3.12/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"taiutc\" yielded 20 of \"dubious year (Note 4)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n"
+ ]
+ },
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAA9wAAAHqCAYAAAD27EaEAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjMsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvZiW1igAAAAlwSFlzAAAPYQAAD2EBqD+naQAA71tJREFUeJzs3XeYXGXZ+PHvmV62991kWzpJSIBAYqgJICEg1UJTigIWUAEV5WcBFMXyivTwvioEFAQRCagUCYTQAumkJ5vtvcxO7zPn/P7YZMmStpud2Znd3J/rmuvKnDlzzj07m33OfZ7nuR9F0zQNIYQQQgghhBBCJJQu1QEIIYQQQgghhBBjkSTcQgghhBBCCCFEEkjCLYQQQgghhBBCJIEk3EIIIYQQQgghRBJIwi2EEEIIIYQQQiSBJNxCCCGEEEIIIUQSSMIthBBCCCGEEEIkgSTcQgghhBBCCCFEEkjCLYQQQgghhBBCJIEk3EIMUVVVFddee23/87fffhtFUXj77bdTFtNIW7p0KYqi0NDQkOpQRsxdd92FoihH9N5rr72WqqqqlMYghBBC2nCQNnyopA0XwyUJt0hrexuFvQ+LxcKUKVO4+eab6ezsTHV4KbXvz+a9997b73VN0ygvL0dRFD73uc8d0Tl+9atfsWzZsmFGmlhVVVUoisLZZ599wNf/+Mc/9v9c1q5dO8LRDc+CBQsG/L7v+9ixY8cB35OO35EQQoC04Ycibbi04ZCe35FIPEOqAxBiMH7+859TXV1NKBTivffeY8mSJbzyyits2bIFm82W6vBSymKx8Mwzz3DqqacO2L5y5UpaWlowm81HfOxf/epXfOELX+Diiy8esP0rX/kKl19++bCOPRwWi4UVK1bQ0dFBSUnJgNeefvppLBYLoVAoJbEN1/jx47n33nv3215WVsZPfvITfvSjHw3YfrDvSAgh0oW04Qcnbbi04dKGj32ScItRYfHixZx44okAXH/99eTn53Pffffx0ksvccUVVxzxcVVVJRKJYLFYEhXqiDvvvPN4/vnnefDBBzEYPvkv/cwzzzBnzhx6enoSfk69Xo9er0/4cQfrlFNOYc2aNTz33HN897vf7d/e0tLCu+++yyWXXMILL7yQsviGIzs7my9/+csHfX3f71gIIUYDacMPTtpwacPF2CdDysWodOaZZwJQX18PwP/8z/9w8sknk5+fj9VqZc6cOfzjH//Y732KonDzzTfz9NNPM2PGDMxmM6+99tqQjjEY7777Ll/84hepqKjAbDZTXl7OrbfeSjAY7N+nq6uLwsJCFixYgKZp/dt3796N3W7nsssuG9S5rrjiChwOB2+88Ub/tkgkwj/+8Q+uvPLKA77H7/fzve99j/LycsxmM1OnTuV//ud/BsShKAp+v58nn3yyf0jU3nlvB5v/9eijj/b/XMvKyrjppptwuVwD9lmwYAEzZ85k27ZtLFy4EJvNxrhx4/jtb387qM8LfXfHL730Up555pkB2//2t7+Rm5vLokWLDvi+t956i9NOOw273U5OTg4XXXQR27dv32+/9957j5NOOgmLxcLEiRP53//934PG8te//pU5c+ZgtVrJy8vj8ssvp7m5edCfZSg+Pf/rUN+REEKkK2nDPyFt+CekDZc2fKyShFuMSrW1tQDk5+cD8MADD3D88cfz85//nF/96lcYDAa++MUv8p///Ge/97711lvceuutXHbZZTzwwAP9hTCGcozDef755wkEAnzzm9/koYceYtGiRTz00ENcffXV/fsUFRWxZMkSVq5cyUMPPQT03a2/9tpryczM5NFHHx3Uuaqqqpg/fz5/+9vf+re9+uqruN1uLr/88v321zSNCy+8kD/84Q+ce+653HfffUydOpUf/OAH3Hbbbf37/eUvf8FsNnPaaafxl7/8hb/85S98/etfP2gcd911FzfddBNlZWX8/ve/5/Of/zz/+7//yznnnEM0Gh2wr9Pp5Nxzz2X27Nn8/ve/Z9q0afzwhz/k1VdfHdRnBrjyyitZvXp1/+8C9PUIfOELX8BoNO63//Lly1m0aBFdXV3cdddd3HbbbXzwwQecc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C/0sY5Z0RERJOUSCno8cewsNKOdU0eZogREdG0sScpITajDstqnUikFcSSyim3UYVAz2gM1S4zR7eJiIgmKZFS0O2PYX6lDeuaPCw2SkREOcGAu8Q0eS1oLbOiJxBDOD5+PncipeDIUAQeqwEr61zQcnSbiIjotIQQGAwl0OOPYV6FDesZbBMRUQ5pi90Ayo4sS1hR54JGknF4KIyBcBxlViPSqoqRaBLzKmxYWe+C3agrdlOJiIhmtERaweGhCFxmPc5q9aGlzMo0ciIiyikG3CXIZtRhU6sXrRVWHOgL4chQBACwvsmDhZV2jmwTERFNgsOkQ1u5DQuq7LxQTUREecGAu4SV2YzwWQ1oq7ABAiizG4vdJCIiopLQ7LOixm1CmY19JxER5Q8D7hInSRJPFoiIiLLkMOsAcFSbiIjyi7nHRERERERERHnAgJuIiIiIiIgoDxhwExEREREREeUBA24iIiIiIiKiPGDATURERERERJQHDLiJiIiIiIiI8oABNxEREREREVEeMOAmIiIiIiIiygMG3ERERERERER5wICbiIiIiIiIKA8YcBMRERERERHlAQNuIiIiIiIiojxgwE1ERERERESUBwy4iYiIiIiIiPKAATcRERERERFRHmiL3YBCEkIAAILBYJFbQkREc92JvuhE30Snxz6ciIhmksn243Mq4A6FQgCA2traIreEiIgoIxQKweFwFLsZMx77cCIimonO1I9LYg5dWldVFb29vbDZbJAkaVrvFQwGUVtbi66uLtjt9hy1cPbi8coej1n2eMyyw+OVvVweMyEEQqEQqqqqIMuc4XUm7MOLi8csezxm2eHxyh6PWXZyfbwm24/PqRFuWZZRU1OT0/e02+38A88Cj1f2eMyyx2OWHR6v7OXqmHFke/LYh88MPGbZ4zHLDo9X9njMspPL4zWZfpyX1ImIiIiIiIjygAE3ERERERERUR4w4J4ig8GAm2++GQaDodhNKQk8XtnjMcsej1l2eLyyx2M2O/DfMXs8ZtnjMcsOj1f2eMyyU6zjNaeKphEREREREREVCke4iYiIiIiIiPKAATcRERERERFRHjDgJiIiIiIiIsqDORtwb926FWvWrIHNZkNZWRkuu+wy7N+/f9w28Xgc119/PTweD6xWK97znvegv79/7PmXXnoJV155JWpra2EymbBgwQLcdttt497j8ccfhyRJJ936+voKsp+5VKhjBgCJRAL/+q//ivr6ehgMBjQ0NODOO+/M+z7mUqGO10c+8pFT/o0tWrSoIPuZS4X8G/vFL36BZcuWwWw2o7KyEh/96EcxPDyc933MtUIes9tvvx0LFiyAyWTCvHnz8LOf/Szv+5druThew8PDuOiii1BVVQWDwYDa2lrccMMNCAaD497n8ccfx8qVK2EwGNDS0oK77767ELs4Z7Afzw778OyxH88e+/HssA/PXkn242KOuvDCC8Vdd90l9uzZI1588UVxySWXiLq6OhEOh8e2+eQnPylqa2vFtm3bxPPPPy/Wr18vNm7cOPb8T37yE/GZz3xGPP7446K9vV3cc889wmQyie9+97tj2zz22GMCgNi/f784duzY2E1RlILuby4U6pgJIcQ73/lOsW7dOvHwww+LI0eOiKefflo8+eSTBdvXXCjU8fL7/eP+trq6uoTb7RY333xzIXc3Jwp1zJ588kkhy7K47bbbxOHDh8UTTzwhFi1aJN71rncVdH9zoVDH7Pvf/76w2Wzi3nvvFe3t7eJXv/qVsFqt4o9//GNB93e6cnG8RkZGxPe//33x3HPPiaNHj4pHHnlEzJs3T1x55ZVj2xw+fFiYzWaxZcsW8dprr4nvfve7QqPRiIceeqig+zubsR/PDvvw7LEfzx778eywD89eKfbjczbgfrOBgQEBQGzfvl0Ikfnx0+l04te//vXYNnv37hUAxI4dOyZ8n0996lPi/PPPH7t/oqMeHR3NW9uLJV/H7MEHHxQOh0MMDw/nr/FFkK/j9Wa/+93vhCRJ4ujRo7lrfJHk65h9+9vfFk1NTeO2+Z//+R9RXV2d4z0ovHwdsw0bNojPfe5z47bZsmWL2LRpU473oLBydbxuu+02UVNTM3b/C1/4gli0aNG4ba644gpx4YUX5ngP6AT249lhH5499uPZYz+eHfbh2SuFfnzOppS/WSAQAAC43W4AwK5du5BKpbB58+axbebPn4+6ujrs2LHjtO9z4j3eaPny5aisrMTb3vY2PPXUUzlufXHk65j98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leb/Tmv5+zzz5bfPaznx23zZ133insdntO2k+vYz+eHfbh2WM/nj3249lhH569UurH52zAraqquP7660VVVdUpO4ATE+5/85vfjD22b9++kybc79mzR5SVlYnPf/7zk/7szZs3l1wVRSEKd8x++MMfCpPJJEKh0Nhjv//974UsyyIajeZwj/Kr0H9jJwr7vPLKK7nbiQIr1DF797vfLd73vveNe+zpp58WAERPT0+O9qYwivlbds4554yr6FkKcnW83mz79u0CgDhy5IgQIlNsZfHixeO2ufLKK1k0LYfYj2eHfXj22I9nj/14dtiHZ68U+/E5G3Bfd911wuFwiMcff3zcUgxv7Aw++clPirq6OvHoo4+K559/XmzYsEFs2LBh7PlXXnlF+Hw+cdVVV417j4GBgbFtbr31VvH73/9eHDx4ULzyyivis5/9rJBlWTzyyCMF3d9cKNQxC4VCoqamRrz3ve8Vr776qti+fbtobW0VH//4xwu6v9NVqON1wlVXXSXWrVtXkH3Ll0Ids7vuuktotVrx/e9/X7S3t4snn3xSrF69Wqxdu7ag+5sLhTpm+/fvF/fcc484cOCAePbZZ8UVV1wh3G73WMdUKnJxvP7yl7+IO++8U7zyyiviyJEj4s9//rNYsGDBuGqvJ5YT+fznPy/27t0rbr/9di4LlmPsx7PDPjx77Mezx348O+zDs1eK/ficDbgBnPJ21113jW0Ti8XEpz71KeFyuYTZbBbvete7xLFjx8aev/nmm0/5HvX19WPbfPOb3xTNzc3CaDQKt9stzjvvPPHoo48WcE9zp1DHTIhM+f7NmzcLk8kkampqxJYtW0ruynghj5ff7xcmk0n87//+b4H2Lj8Kecz+53/+RyxcuFCYTCZRWVkpPvjBD4ru7u4C7WnuFOqYvfbaa2L58uXCZDIJu90uLr30UrFv374C7mlu5OJ4Pfroo2LDhg3C4XAIo9EoWltbxT//8z+flL722GOPieXLlwu9Xi+amprGfQZNH/vx7LAPzx778eyxH88O+/DslWI/Lh1vOBERERERERHlUOmWpSMiIiIiIiKawRhwExEREREREeUBA24iIiIiIiKiPGDATURERERERJQHDLiJiIiIiIiI8oABNxEREREREVEeMOAmIiIiIiIiygMG3ERERERERER5wICbiE7ykY98BJdddlmxm0FERERTwH6caObQFrsBRFRYkiSd9vmbb74Zt912G4QQBWoRERERTRb7caLSIgl+G4nmlL6+vrH/v++++/CVr3wF+/fvH3vMarXCarUWo2lERER0BuzHiUoLU8qJ5piKioqxm8PhgCRJ4x6zWq0npaKdd955+PSnP40bb7wRLpcL5eXl+NGPfoRIJIJrrrkGNpsNLS0tePDBB8d91p49e3DxxRfDarWivLwcH/rQhzA0NFTgPSYiIpo92I8TlRYG3EQ0KT/96U/h9Xqxc+dOfPrTn8Z1112Hyy+/HBs3bsTu3btxwQUX4EMf+hCi0SgAwO/34y1veQtWrFiB559/Hg899BD6+/vxvve9r8h7QkRENPewHycqDgbcRDQpy5Ytw5e+9CW0trbipptugtFohNfrxbXXXovW1lZ85StfwfDwMF5++WUAwPe+9z2sWLEC3/jGNzB//nysWLECd955Jx577DEcOHCgyHtDREQ0t7AfJyoOFk0joklZunTp2P9rNBp4PB4sWbJk7LHy8nIAwMDAAADgpZdewmOPPXbKeWTt7e1oa2vLc4uJiIjoBPbjRMXBgJuIJkWn0427L0nSuMdOVE1VVRUAEA6H8Y53vAPf/OY3T3qvysrKPLaUiIiI3oz9OFFxMOAmorxYuXIlfvvb36KhoQFaLX9qiIiISgn7caLc4BxuIsqL66+/HiMjI7jyyivx3HPPob29HX/9619xzTXXQFGUYjePiIiIToP9OFFuMOAmoryoqqrCU089BUVRcMEFF2DJkiW48cYb4XQ6Icv86SEiIprJ2I8T5YYkhBDFbgQRERERERHRbMPLU0RERERERER5wICbiIiIiIiIKA8YcBMRERERERHlAQNuIiIiIiIiojxgwE1ERERERESUBwy4iYiIiIiIiPKAATcRERERERFRHjDgJiIiIiIiIsoDBtxEREREREREecCAm4iIiIiIiCgPGHATERERERER5QEDbiIiIiIiIqI8+P/U0OqaNq/eTAAAAABJRU5ErkJggg==",
+ "text/plain": [
+ "
"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "x_model, y_model, xe_model, ye_model = mm.model(t_test, params, param_errs)\n",
+ "visualize_fit(t, x, y, xe, ye, x_model, y_model, xe_model, ye_model, mm.name, t_test)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "5be8fb7e",
+ "metadata": {},
+ "source": [
+ "# 2. Fit Motion Model in StarTable"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "3bd8dec7",
+ "metadata": {},
+ "source": [
+ "Examples on `flystar.StarTable.fit_motion_model`. Prepare the data with invalid values:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "id": "aa698e86",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "t = np.array([0, 1., 2.2, 3.5, 5.]) + 2025.0\n",
+ "\n",
+ "x = np.array([\n",
+ " [0., 0.5, 2.1, 3.2, 8.0], # Increasing 5 Epochs\n",
+ " [10.0, 8.9, 9.2, 7.4, 7.0], # Decreasing 5 Epochs\n",
+ " [2.5, np.nan, 5.2, np.nan, 5.0], # 3 Epochs\n",
+ " [np.nan, 6.2, np.nan, np.nan, 9.2], # 2 Epochs\n",
+ " [np.nan, 2.0, np.nan, np.nan, np.nan], # 1 Epoch\n",
+ " [np.nan, np.nan, np.nan, np.nan, np.nan] # All NaNs\n",
+ "])\n",
+ "\n",
+ "y = np.array([\n",
+ " [10.2, 8.5, 9.1, 10.5, 13.0], # Increasing 5 Epochs\n",
+ " [8.0, 9.9, 8.2, 7.4, 7.0], # Decreasing 5 Epochs\n",
+ " [5.2, np.nan, 4.7, np.nan, 6.0], # 3 Epochs\n",
+ " [np.nan, 1.2, np.nan, np.nan, 3.2], # 2 Epochs\n",
+ " [np.nan, 2.0, np.nan, np.nan, np.nan], # 1 Epoch\n",
+ " [np.nan, np.nan, np.nan, np.nan, np.nan] # All NaNs\n",
+ "])\n",
+ "\n",
+ "xe = np.array([\n",
+ " [0.2, 0.5, 0.3, 0.4, 0.6],\n",
+ " [0.5, 0.2, 0.7, 0.3, 0.2],\n",
+ " [0.5, np.nan, 0.6, np.nan, 0.3],\n",
+ " [np.nan, 0.6, np.nan, np.nan, 0.3],\n",
+ " [np.nan, 0.4, np.nan, np.nan, np.nan],\n",
+ " [np.nan, np.nan, np.nan, np.nan, np.nan]\n",
+ "])\n",
+ "\n",
+ "ye = np.array([\n",
+ " [0.3, 0.2, 0.5, 0.2, 0.4],\n",
+ " [0.2, 0.5, 0.6, 0.4, 0.2],\n",
+ " [0.7, np.nan, 0.5, np.nan, 0.2],\n",
+ " [np.nan, 0.4, np.nan, np.nan, 0.5],\n",
+ " [np.nan, 0.5, np.nan, np.nan, np.nan],\n",
+ " [np.nan, np.nan, np.nan, np.nan, np.nan]\n",
+ "])\n",
+ "\n",
+ "x = np.ma.masked_invalid(x)\n",
+ "y = np.ma.masked_invalid(y)\n",
+ "xe = np.ma.masked_invalid(xe)\n",
+ "ye = np.ma.masked_invalid(ye)\n",
+ "mask = np.ma.getmaskarray(x) | np.ma.getmaskarray(y) | np.ma.getmaskarray(xe) | np.ma.getmaskarray(ye)\n",
+ "\n",
+ "tab = StarTable({\n",
+ " 'x': x,\n",
+ " 'y': y,\n",
+ " 'xe': xe,\n",
+ " 'ye': ye\n",
+ "})\n",
+ "tab.meta['list_times'] = t"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "9201897f",
+ "metadata": {},
+ "source": [
+ "There are a 2 ways to specify the desired motion models:\n",
+ "1. Let MotionModel automatically determine which motion model to use among the given `motion_models` list based on the number of valid observations. MotionModel will choose the motion model that has enough observations, i.e. $n_\\text{fit} \\geq n_\\text{params}$. \n",
+ "2. Specify a motion model for each star in the `motion_model_input` column. In case there is not enough observations, MotionModel will \"downgrade\" to a model with less parameters until $n_\\text{fit} \\geq n_\\text{params}$ among all the unique motion models specified in the column.\n",
+ "\n",
+ "Note that when `absolute_sigma=False` and `n_fit == n_params`, we don't have enough degree of freedom to rescale the uncertainties, so the uncertainties will be set to infinity -- the same behavior as `scipy.optimize.curve_fit`. By default `motion_models = [Empty, Fixed, Linear]`. `Empty` and `Fixed` will always be added in the list to handle 0 and 1 point cases. See examples below for details. Let's start with the most basic usage."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "e58f429d",
+ "metadata": {},
+ "source": [
+ "## 2.1. Example: Default Fitting"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "id": "02642d3b",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Fitting motion model Empty: 0%| | 0/1 [00:00, ?it/s]/home/weilingfeng/Software/flystar/flystar/motion_model.py:119: OptimizeWarning: Empty data cannot be fit. Setting parameters to nan and uncertainties to np.inf.\n",
+ " fit_result = self.run_fit(\n",
+ "Fitting motion model Empty: 100%|██████████| 1/1 [00:00<00:00, 2323.71it/s]\n",
+ "Fitting motion model Fixed: 0%| | 0/1 [00:00, ?it/s]/home/weilingfeng/Software/flystar/flystar/motion_model.py:403: UserWarning: Fixed model has no non-scipy fitter option. Running with scipy.\n",
+ " warnings.warn(\"Fixed model has no non-scipy fitter option. Running with scipy.\")\n",
+ "Fitting motion model Fixed: 100%|██████████| 1/1 [00:00<00:00, 5363.56it/s]\n",
+ "Fitting motion model Linear: 100%|██████████| 4/4 [00:00<00:00, 7895.16it/s]\n"
+ ]
+ }
+ ],
+ "source": [
+ "tab.fit_motion_model()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "81059189",
+ "metadata": {},
+ "source": [
+ "Since we do not specify the `motion_models` parameter in the `fit_motion_model` function, the default motion model of `Empty`, `Fixed` and `Linear` will be used. The function automatically determines which motion models among the three to use based on the number of valid observations, i.e., $n_\\text{fit} \\geq n_\\text{params}$:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 38,
+ "id": "a7573e51",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
StarTable length=6\n",
+ "
\n",
+ "
n_fit
n_required
motion_model_used
\n",
+ "
int64
int64
str20
\n",
+ "
5
2
Linear
\n",
+ "
5
2
Linear
\n",
+ "
3
2
Linear
\n",
+ "
2
2
Linear
\n",
+ "
1
2
Fixed
\n",
+ "
0
2
Empty
\n",
+ "
"
+ ],
+ "text/plain": [
+ "\n",
+ "n_fit n_required motion_model_used\n",
+ "int64 int64 str20 \n",
+ "----- ---------- -----------------\n",
+ " 5 2 Linear\n",
+ " 5 2 Linear\n",
+ " 3 2 Linear\n",
+ " 2 2 Linear\n",
+ " 1 2 Fixed\n",
+ " 0 2 Empty"
+ ]
+ },
+ "execution_count": 38,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "tab['n_required'] = 2\n",
+ "tab[['n_fit', 'n_required', 'motion_model_used']]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "20470c6e",
+ "metadata": {},
+ "source": [
+ "Next, let's try `absolute_sigma=False`. As mentioned above, we don't have enough degree of freedom to rescale the uncertainties for the forth star. In this case, the parameter uncertainties will be set to infinity, which is the same behavior as `scipy.optimize.curve_fit`. The same `OptmizieWarning` as in `scipy` will be raised."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "id": "26b11593",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Fitting motion model Empty: 0%| | 0/1 [00:00, ?it/s]/Users/weilingfeng/Academic/Software/flystar/flystar/motion_model.py:119: OptimizeWarning: Empty data cannot be fit. Setting parameters to nan and uncertainties to np.inf.\n",
+ " fit_result = self.run_fit(\n",
+ "Fitting motion model Empty: 100%|██████████| 1/1 [00:00<00:00, 4524.60it/s]\n",
+ "Fitting motion model Fixed: 0%| | 0/1 [00:00, ?it/s]/Users/weilingfeng/Academic/Software/flystar/flystar/motion_model.py:404: UserWarning: Fixed model has no non-scipy fitter option. Running with scipy.\n",
+ " warnings.warn(\"Fixed model has no non-scipy fitter option. Running with scipy.\")\n",
+ "/Users/weilingfeng/Academic/Software/flystar/flystar/motion_model.py:119: OptimizeWarning: Degree of freedom < 0. Covariance of the parameters could not be estimated. Setting parameter uncertainties to fill value np.inf.\n",
+ " fit_result = self.run_fit(\n",
+ "Fitting motion model Fixed: 100%|██████████| 1/1 [00:00<00:00, 710.30it/s]\n",
+ "Fitting motion model Linear: 100%|██████████| 4/4 [00:00<00:00, 4723.32it/s]\n"
+ ]
+ }
+ ],
+ "source": [
+ "tab.fit_motion_model(absolute_sigma=False)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "id": "a411e006",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "<Column name='vx_err' dtype='float64' length=6>\n",
+ "
\n",
+ "
0.2398025689409276
\n",
+ "
0.07197698078673948
\n",
+ "
0.26723109004421475
\n",
+ "
inf
\n",
+ "
inf
\n",
+ "
inf
\n",
+ "
"
+ ],
+ "text/plain": [
+ "\n",
+ " 0.2398025689409276\n",
+ "0.07197698078673948\n",
+ "0.26723109004421475\n",
+ " inf\n",
+ " inf\n",
+ " inf"
+ ]
+ },
+ "execution_count": 22,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "tab['vx_err']"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "241ab6d6",
+ "metadata": {},
+ "source": [
+ "## 2.2. Example: Specify Motion Models"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "220922c5",
+ "metadata": {},
+ "source": [
+ "Alternatively, one can specify a list of motion models to use, and the function will also automatically determine which model to use for each star depending on the valid observed epochs. In the following example, we specify `Acceleration` model, but **the function will always implicitly add `Empty` and `Fixed`** to handle the 0 or 1 epoch stars."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "id": "a596c8e8",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Fitting motion model Acceleration: 0%| | 0/3 [00:00, ?it/s]/Users/weilingfeng/Academic/Software/flystar/flystar/motion_model.py:785: UserWarning: Acceleration model has no non-scipy fitter option. Running with scipy.\n",
+ " warnings.warn(\"Acceleration model has no non-scipy fitter option. Running with scipy.\")\n",
+ "Fitting motion model Acceleration: 100%|██████████| 3/3 [00:00<00:00, 2933.08it/s]\n",
+ "Fitting motion model Empty: 100%|██████████| 1/1 [00:00<00:00, 15141.89it/s]\n",
+ "Fitting motion model Fixed: 100%|██████████| 2/2 [00:00<00:00, 10754.63it/s]\n"
+ ]
+ }
+ ],
+ "source": [
+ "tab.fit_motion_model(motion_models=['Acceleration'])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "id": "7d66e979",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
StarTable length=6\n",
+ "
\n",
+ "
n_fit
motion_model_used
\n",
+ "
int64
str20
\n",
+ "
5
Acceleration
\n",
+ "
5
Acceleration
\n",
+ "
3
Acceleration
\n",
+ "
2
Fixed
\n",
+ "
1
Fixed
\n",
+ "
0
Empty
\n",
+ "
"
+ ],
+ "text/plain": [
+ "\n",
+ "n_fit motion_model_used\n",
+ "int64 str20 \n",
+ "----- -----------------\n",
+ " 5 Acceleration\n",
+ " 5 Acceleration\n",
+ " 3 Acceleration\n",
+ " 2 Fixed\n",
+ " 1 Fixed\n",
+ " 0 Empty"
+ ]
+ },
+ "execution_count": 24,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "tab[['n_fit', 'motion_model_used']]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "188290a9",
+ "metadata": {},
+ "source": [
+ "## 2.3. Example: Specify the `motion_model_input` Column"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "99624463",
+ "metadata": {},
+ "source": [
+ "One can also specify a motion model for each star as a column in the star table. However, the function will \"downgrade\" the model to one with fewer parameters until $n_\\text{fit} \\geq n_\\text{params}$:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 39,
+ "id": "04db5f9e",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "ra = np.zeros(len(x))\n",
+ "dec = np.zeros(len(x))\n",
+ "pa = np.zeros(len(x))\n",
+ "\n",
+ "motion_model_input = [\n",
+ " 'Acceleration', # Will use Acceleration\n",
+ " 'Parallax', # Will use Parallax\n",
+ " 'Linear', # Will use Linear\n",
+ " 'Acceleration', # Will use Linear, as n_fit = 2 < 3\n",
+ " 'Linear', # Will use Fixed, as n_fit = 1 < 2\n",
+ " 'Fixed' # Will use Empty, as n_fit = 0 < 1\n",
+ "]\n",
+ "tab = StarTable({\n",
+ " 'x': x,\n",
+ " 'y': y,\n",
+ " 'xe': xe,\n",
+ " 'ye': ye,\n",
+ " 'ra': ra,\n",
+ " 'dec': dec,\n",
+ " 'pa': pa,\n",
+ " 'motion_model_input': motion_model_input\n",
+ "})\n",
+ "tab.meta['list_times'] = t"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 40,
+ "id": "2b61fbcf",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Fitting motion model Acceleration: 0%| | 0/1 [00:00, ?it/s]/Users/weilingfeng/Academic/Software/flystar/flystar/motion_model.py:785: UserWarning: Acceleration model has no non-scipy fitter option. Running with scipy.\n",
+ " warnings.warn(\"Acceleration model has no non-scipy fitter option. Running with scipy.\")\n",
+ "Fitting motion model Acceleration: 100%|██████████| 1/1 [00:00<00:00, 1086.04it/s]\n",
+ "Fitting motion model Empty: 0%| | 0/1 [00:00, ?it/s]/Users/weilingfeng/Academic/Software/flystar/flystar/motion_model.py:119: OptimizeWarning: Empty data cannot be fit. Setting parameters to nan and uncertainties to np.inf.\n",
+ " fit_result = self.run_fit(\n",
+ "Fitting motion model Empty: 100%|██████████| 1/1 [00:00<00:00, 9258.95it/s]"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "Fitting motion model Fixed: 0%| | 0/1 [00:00, ?it/s]/Users/weilingfeng/Academic/Software/flystar/flystar/motion_model.py:404: UserWarning: Fixed model has no non-scipy fitter option. Running with scipy.\n",
+ " warnings.warn(\"Fixed model has no non-scipy fitter option. Running with scipy.\")\n",
+ "Fitting motion model Fixed: 100%|██████████| 1/1 [00:00<00:00, 4405.78it/s]\n",
+ "Fitting motion model Linear: 100%|██████████| 2/2 [00:00<00:00, 5302.53it/s]\n",
+ "Fitting motion model Parallax: 0%| | 0/1 [00:00, ?it/s]/Users/weilingfeng/Academic/Software/flystar/flystar/motion_model.py:1002: UserWarning: Parallax model has no non-scipy fitter option. Running with scipy.\n",
+ " warnings.warn(\"Parallax model has no non-scipy fitter option. Running with scipy.\", UserWarning)\n",
+ "/Users/weilingfeng/Software/miniconda3/envs/main/lib/python3.13/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"dtf2d\" yielded 1 of \"dubious year (Note 6)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/Users/weilingfeng/Software/miniconda3/envs/main/lib/python3.13/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"dtf2d\" yielded 2 of \"dubious year (Note 6)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/Users/weilingfeng/Software/miniconda3/envs/main/lib/python3.13/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"utctai\" yielded 2 of \"dubious year (Note 3)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/Users/weilingfeng/Software/miniconda3/envs/main/lib/python3.13/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"utctai\" yielded 1 of \"dubious year (Note 3)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/Users/weilingfeng/Software/miniconda3/envs/main/lib/python3.13/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"taiutc\" yielded 1 of \"dubious year (Note 4)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "Fitting motion model Parallax: 100%|██████████| 1/1 [00:00<00:00, 292.33it/s]\n"
+ ]
+ }
+ ],
+ "source": [
+ "tab.fit_motion_model(fixed_params_dict={\n",
+ " 'ra': ra, \n",
+ " 'dec': dec, \n",
+ " 'pa': pa,\n",
+ " 'obsLocation': 'earth'\n",
+ "})"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "5a625ccb",
+ "metadata": {},
+ "source": [
+ "Let's check if the actually used motion model is corrected:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 41,
+ "id": "b30ffb16",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
StarTable length=6\n",
+ "
\n",
+ "
n_fit
n_required
motion_model_input
motion_model_used
\n",
+ "
int64
int64
str12
str12
\n",
+ "
5
3
Acceleration
Acceleration
\n",
+ "
5
3
Parallax
Parallax
\n",
+ "
3
2
Linear
Linear
\n",
+ "
2
3
Acceleration
Linear
\n",
+ "
1
2
Linear
Fixed
\n",
+ "
0
1
Fixed
Empty
\n",
+ "
"
+ ],
+ "text/plain": [
+ "\n",
+ "n_fit n_required motion_model_input motion_model_used\n",
+ "int64 int64 str12 str12 \n",
+ "----- ---------- ------------------ -----------------\n",
+ " 5 3 Acceleration Acceleration\n",
+ " 5 3 Parallax Parallax\n",
+ " 3 2 Linear Linear\n",
+ " 2 3 Acceleration Linear\n",
+ " 1 2 Linear Fixed\n",
+ " 0 1 Fixed Empty"
+ ]
+ },
+ "execution_count": 41,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "all_mm_map = motion_model.motion_model_map()\n",
+ "tab['n_required'] = np.array([all_mm_map[mm].n_params for mm in tab['motion_model_input']], dtype=int)\n",
+ "tab[['n_fit', 'n_required', 'motion_model_input', 'motion_model_used']]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "d4f96fcb",
+ "metadata": {},
+ "source": [
+ "## 2.4. Example: Infer Positions"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "c660ec98",
+ "metadata": {},
+ "source": [
+ "Continuing from the previous example: Once we fit the motion models and the parameters are added into the table, we can infer the positions at arbitrary times with `StarTable.infer_positions`"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 42,
+ "id": "095be28f",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/Users/weilingfeng/Software/miniconda3/envs/main/lib/python3.13/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"dtf2d\" yielded 20 of \"dubious year (Note 6)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/Users/weilingfeng/Software/miniconda3/envs/main/lib/python3.13/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"dtf2d\" yielded 40 of \"dubious year (Note 6)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/Users/weilingfeng/Software/miniconda3/envs/main/lib/python3.13/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"utctai\" yielded 40 of \"dubious year (Note 3)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/Users/weilingfeng/Software/miniconda3/envs/main/lib/python3.13/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"utctai\" yielded 20 of \"dubious year (Note 3)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n",
+ "/Users/weilingfeng/Software/miniconda3/envs/main/lib/python3.13/site-packages/erfa/core.py:133: ErfaWarning: ERFA function \"taiutc\" yielded 20 of \"dubious year (Note 4)\"\n",
+ " warn(f'ERFA function \"{func_name}\" yielded {wmsg}', ErfaWarning)\n"
+ ]
+ }
+ ],
+ "source": [
+ "x_model, y_model, xe_model, ye_model = tab.infer_positions(t_test)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "a4df5458",
+ "metadata": {},
+ "source": [
+ "As in `MotionModel.model`, `StarTable.infer_positions` is also vectorized and returns positions and uncertainties in shapes of $(N_\\text{stars}, N_\\text{times})$"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 44,
+ "id": "2f7e8b7a",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(6, 100)"
+ ]
+ },
+ "execution_count": 44,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "x_model.shape"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "id": "7aab0868",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAA9wAAAHqCAYAAAD27EaEAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjcsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvTLEjVAAAAAlwSFlzAAAPYQAAD2EBqD+naQABAABJREFUeJzs3Xd8XOWVN/DfrdPVuy3bciMYU8xCMNUGYkIJS0khSzZgSFg2kBAChCxkE+wli1M2QLKU3WQBQwglvJSQECAGg2kGTDEYY1wlW1av09st7x9nRsVqU+7MSPL5fj6D0WjmzjNq957nOc85gmmaJhhjjDHGGGOMMWYpsdADYIwxxhhjjDHGpiMOuBljjDHGGGOMsRzggJsxxhhjjDHGGMsBDrgZY4wxxhhjjLEc4ICbMcYYY4wxxhjLAQ64GWOMMcYYY4yxHOCAmzHGGGOMMcYYywEOuBljjDHGGGOMsRzggJsxxhhjjDHGGMsBDrjZlLB27VoIgjBwk2UZM2fOxGWXXYaWlpaCjGnlypWYM2fOsPvmzJmDlStX5n0sy5cvhyAImDt3LkzTHPH51157beBrt3bt2rSP/+mnn2LVqlVoamoa8bnRvg75knxPY33N/+M//mPgMaONPVPZvOfly5dj+f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7+cTmeBR8Iylfze8V4+xhib3vicPbUlU8l1Xc/qOJMi4N6wYQOuvvpqvP3221i3bh00TcMZZ5yBYDA47HFnnnkm2traBm5/+9vfCjRixhgrLE5Jm7r4e8cYYwcX/rs/NVn1fZsUKeUvvPDCsI8feOABVFVV4f3338cpp5wycL/NZkNNTU2+h8cYY9NSPBLBby/9CgDgmgf/HxS7vcAjYowxxtiB+Hw9tU2KFe4Deb1eAEBZWdmw+1999VVUVVVh4cKFuOKKKwYKzzDGGGOMMcYYY5PNpAu4TdPEddddh5NOOgmLFy8euP+ss87CH//4R6xfvx6//vWvsWnTJpx22mmIRqNjHisajcLn8w27McYYI4YxuCdp/7ZPhn2cC0NrcSiKgurqaqxYsQL3338/DMNI+Thr165FSUlJ7gbKGGOMTSL5Pl8DfM620qQLuL/73e/i448/xqOPPjrs/osuugjnnHMOFi9ejHPPPRfPP/88duzYgeeee27MY61ZswbFxcUDt/r6+lwPnzHGpoSd77yFtdddNfDxUz9fhd9f/S3sfOetnL5ushZHU1MTnn/+eZx66qn4/ve/jy996UvQNC2nr80YY4xNNYU6XwN8zrbKpAq4v/e97+HZZ5/FK6+8gpkzZ4772NraWsyePRs7d+4c8zE33XQTvF7vwK25udnqITPG2JSz85238OzttyHQ1zPs/kBvN569/bacnsSTtThmzJiBo48+GjfffDP+/Oc/4/nnn8fatWsBALfffjsOP/xwuFwu1NfX46qrrkIgEABAW4suu+wyeL3egZn3VatWAQAefvhhHHPMMfB4PKipqcHFF1/MW48YY4xNWYU8XwN8zrbKpAi4TdPEd7/7XTz11FNYv349GhoaJnxOT08PmpubUVtbO+ZjbDYbioqKht0YY+xgZhg61q/93biPeeXB3+UlXS3ptNNOw5FHHomnnnoKACCKIn7729/ik08+wYMPPoj169fjxhtvBACccMIJuPPOO1FUVDTQseKGG24AAMRiMdx666346KOP8Mwzz6CxsRErV67M2/tgjDHGrDIZz9cAn7MzMSmqlF999dV45JFH8Oc//xkejwft7e0AgOLiYjgcDgQCAaxatQpf/v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ay2IP95NPPok9e/bg7W9/O2KxGJ5++mnccsstuOKKK9Df39/s4RER0Uql60Ckq9mjICIiosUYXiDc0fC7XRYBt2ma2LVrF+666y5ks1kMDAzghhtuwKc+9almD42IiIiIiIhoTssi4N6xYwf27NnT7GEQERERERERVYz9TIiIiIiIiIhcwICbiIiIiIiIyAUMuImIiIiIiIhcwICbiIiIiIiIyAUMuImIiIiIiIhcwICbiIiIiIiIyAUMuImIiIiIiIhcwICbiIiIiIiIyAUMuImIiIiIiIhcwICbiIiIHDU4OAhN06Z93Hbbbc0eFhERUcN5mj0AIiIiOvPcfffduOGGG8rfh8PhJo6GiIioORhwExERkeMikQi6u7ubPQwiIqKmYko5EREROe7zn/882trasH37dnzmM5+BZVnzXjebzSKRSEz7ICIiOhOsqBVupRQAcCInIqIlqTQ/lear5ermm2/Gjh07EI/H8dRTT+H222/HwYMH8eCDD855/XvuuQd33XXXrMs5XxMR0VJUzXytqeU+q1fh8OHDWL16dbOHQUREtKBDhw6hr6+v2cOY5s4775wzKJ7q6aefxrnnnjvr8u9+97v44Ac/iOHhYbS1tc36eTabRTabLX9/5MgRnHXWWfUPmoiIyEWVzNcrKuC2bRtHjx5FJBKBpml13VYikcDq1atx6NAhRKNRh0Z45uNxqx6PWfV4zGrD41Y9p4+ZUgrJZBK9vb3Q9aW162t4eBjDw8MLXmdwcBB+v3/W5UeOHEFfXx/27NmD8847b9H7cnK+BvjcrgWPWW143KrHY1Y9HrPaOHncqpmvV1RKua7rjq8YRKNRPtFrwONWPR6z6vGY1YbHrXpOHrNYLObI7Titvb0d7e3tNf3uvn37AAA9PT0VXd+N+Rrgc7sWPGa14XGrHo9Z9XjMauPUcat0vl5RATcRERG568knn8SePXvw9re/HbFYDE8//TRuueUWXHHFFejv72/28IiIiBqKATcRERE5xjRN7Nq1C3fddRey2SwGBgZwww034FOf+lSzh0ZERNRwDLhrZJom7rjjDpim2eyhLCs8btXjMasej1lteNyqx2M2244dO7Bnz55mD2Ma/p2qx2NWGx636vGYVY/HrDbNOm4rqmgaERERERERUaMsrRKoRERERERERGcIBtxERERERERELmDATUREREREROSCFRtw33PPPXjTm96ESCSCzs5OvP/978cLL7ww7TpKKdx5553o7e1FIBDA2972Nvz2t78t//z06dP4xCc+gU2bNiEYDKK/vx9/8Rd/gbGxsWm3Mzg4CE3Tpn3cdtttDXmcTmvkcQOA//zP/8R5552HQCCA9vZ2XHXVVa4/Rqc16pj99Kc/nfU8K308/fTTDXu8Tmnkc+3FF1/ElVdeifb2dkSjUVx00UV49NFHG/I4ndTIY/bMM8/g3e9+N1paWtDW1oY//dM/xfj4eEMep9OcOG4A8LGPfQzr1q1DIBBAR0cHrrzySuzfv3/adUZGRnDttdciFoshFovh2muvxejoqNsPcdnjnF09zte14ZxdPc7XteGcXb1lO1+rFeo973mPeuihh9RvfvMb9eyzz6r3vve9qr+/X42Pj5ev87nPfU5FIhH13e9+Vz333HPq6quvVj09PSqRSCillHruuefUVVddpR5++GF14MAB9V//9V9qw4YN6gMf+MC0+xoYGFB33323GhoaKn8kk8mGPl6nNPK4fec731HxeFx95StfUS+88ILav3+/+va3v93Qx+uERh2zbDY77Tk2NDSkrr/+ejU4OKhs2274465XI59r69evV7/3e7+nfvWrX6kXX3xR3XTTTSoYDKqhoaGGPuZ6NeqYHTlyRMXjcXXjjTeq/fv3q6eeekpdeOGFs47rcuHEcVNKqQceeEA99thj6uDBg2rv3r3q93//99Xq1atVPp8vX+eyyy5TW7duVU888YR64okn1NatW9X73ve+hj7e5YhzdvU4X9eGc3b1OF/XhnN29ZbrfL1iA+6ZTpw4oQCoxx57TCmllG3bqru7W33uc58rXyeTyahYLKa++tWvzns7//7v/658Pp/K5XLlywYGBtQXv/hF18beTG4dt1wup1atWqUefPBBdx9AE7j5XJvKsizV2dmp7r77bmcfQJO4ddxOnjypAKjHH3+8fJ1EIqEAqB//+McuPZrGcOuYPfDAA6qzs1MVCoXydfbt26cAqJdeesmlR9M4Th23X/3qVwqAOnDggFJKqeeff14BUHv27Clf58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66xJMpnEZZddhnA4jO9///vwer0L3uf5558PADhw4IATD6Ep3D5uPT09AICzzjqrfJlpmli7di1ef/11xx9PIzTyufbQQw+hra0NV1xxhcOPovHcPm4/+clP8IMf/ADf+ta3cNFFF2HHjh24//77EQgE8I1vfMPFR+aeRjzXPvzhD+PYsWM4cuQITp06hTvvvBMnT57EmjVrXHpU7nPiuMViMWzYsAEXX3wxvvOd72D//v34/ve/X76d48ePz7rfkydPzrodmhvn7Opxvq4N5+zqcb6uDefs6i23+XrFBtxKKXz84x/H9773PfzkJz+Z9YRbs2YNuru7sXv37vJllmXhsccew4UXXli+LJFI4NJLL4XP58PDDz8Mv9+/6H3v27cPwOQktZw06rjt3LkTpmlOK/Wfy+Xw6quvYmBgwKVH545GP9eUUnjooYfwx3/8x4u+kVzKGnXcUqkUAEzb21T6vrRys1w043Wtq6sL4XAYu3btgt/vx7vf/W7nH5jLnDpu8912NpsFAFxwwQUYGxvDU089Vf75L37xC4yNjS16Oysd5+zqcb6uDefs6nG+rg3n7Oot2/m66jJrZ4g/+7M/U7FYTP30pz+d1pIhlUqVr/O5z31OxWIx9b3vfU8999xz6kMf+tC0svKJREKdd9556uyzz1YHDhyYdjulsvJPPPGEuvfee9W+ffvUK6+8onbt2qV6e3vVFVdc0ZTHXa9GHTellLr55pvVqlWr1COPPKL279+vrrvuOtXZ2alOnz7d8Mddj0YeM6WU+vGPf6wAqOeff76hj9NpjTpuJ0+eVG1tbeqqq65Szz77rHrhhRfUX/3VXymv16ueffbZpjz2WjXyufalL31J7d27V73wwgvqy1/+sgoEAuof//EfG/6YneDEcXv55ZfVZz/7WfXLX/5Svfbaa+qJJ55QV155pWptbVXHjx8v385ll12mtm3bpp588kn15JNPqrPPPpttwSrAObt6nK9rwzm7epyva8M5u3rLdb5esQE3gDk/HnroofJ1bNtWd9xxh+ru7lamaaqLL75YPffcc+WfP/roo/PezsGDB5VSSu3du1edd955KhaLKb/frzZt2qTuuOMONTEx0eBH7IxGHTelpEXGX/7lX6rOzk4ViUTUu971LvWb3/ymgY/WGY08Zkop9aEPfUhdeOGFDXp07mnkcXv66afVpZdeqlpbW1UkElHnn3+++uEPf9jAR+uMRh6za6+9VrW2tiqfz6e2bdumvvnNbzbwkTrLieN25MgRdfnll6vOzk7l9XpVX1+f+vCHPzyrfcipU6fUNddcoyKRiIpEIuqaa65RIyMjDXqkyxfn7Opxvq4N5+zqcb6uDefs6i3X+VorDp6IiIiIiIiIHLRi93ATERERERERuYkBNxEREREREZELGHATERERERERuYABNxEREREREZELGHATERERERERuYABNxEREREREZELGHATERERERERuYABNxEREREREZELGHAT0YLuvPNObN++vdnDICIiogVwviZamjSllGr2IIioOTRNW/Dnf/Inf4Ivf/nLyGazaGtra9CoiIiIaCrO10TLFwNuohXs2LFj5a937dqFv/u7v8MLL7xQviwQCCAWizVjaERERFTE+Zpo+WJKOdEK1t3dXf6IxWLQNG3WZTNT1D7ykY/g/e9/Pz772c+iq6sLLS0tuOuuu5DP5/HXf/3XaG1tRV9fH77+9a9Pu68jR47g6quvRjweR1tbG6688kq8+uqrjX3AREREyxDna6LliwE3EVXtJz/5CY4ePYrHH38c9957L+688068733vQzwexy9+8QvceOONuPHGG3Ho0CEAQCqVwtvf/naEw2E8/vjj+PnPf45wOIzLLrsMlmU1+dEQERGdmThfEzUfA24iqlprayv+6Z/+CZs2bcJHP/pRbNq0CalUCp/+9KexYcMG3H777fD5fPjv//5vAMC3vvUt6LqOBx98EGeffTY2b96Mhx56CK+//jp++tOfNvfBEBERnaE4XxM1n6fZAyCi5WfLli3Q9cnzdV1dXdi6dWv5e8Mw0NbWhhMnTgAA9u7diwMHDiASiUy7nUwmg5dffrkxgyYiIlphOF8TNR8DbiKqmtfrnfa9pmlzXmbbNgDAtm3s3LkT//qv/zrrtjo6OtwbKBER0QrG+Zqo+RhwE5HrduzYgV27dqGzsxPRaLTZwyEiIqI5cL4mch73cBOR66655hq0t7fjyiuvxM9+9jMcPHgQjz32GG6++WYcPny42cMjIiIicL4mcgMDbiJyXTAYxOOPP47+/n5cddVV2Lx5Mz760Y8inU7zDDoREdESwfmayHmaUko1exBEREREREREZxqucBMRERERERG5gAE3ERERERERkQsYcBMRERERERG5gAE3ERERERERkQsYcBMRERERERG5gAE3ERERERERkQsYcBMRERERERG5gAE3ERERERERkQsYcBMRERERERG5gAE3ERERERERkQsYcBMRERERERG5gAE3ERERERERkQv+f8ZqD6VV4nMSAAAAAElFTkSuQmCC",
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "visualize_fit(t, x, y, xe, ye, x_model, y_model, xe_model, ye_model, mm.name, t_test)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "12bb0136",
+ "metadata": {},
+ "source": [
+ "## 2.5. Speed Test"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "43fd87c5",
+ "metadata": {},
+ "source": [
+ "Speed test for the most commonly used Linear model. As the `use_scipy=False` option for the Linear model uses the [matrix multiplication solution](https://en.wikipedia.org/wiki/Weighted_least_squares#Solution), it is extremely fast at fewer epochs: "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "id": "de576a47",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Fitting 10 epochs...\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Fitting motion model Linear: 100%|██████████| 10000/10000 [00:01<00:00, 6350.75it/s]\n",
+ "Fitting motion model Linear: 100%|██████████| 10000/10000 [00:00<00:00, 25802.05it/s]\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Fitting 31 epochs...\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Fitting motion model Linear: 100%|██████████| 10000/10000 [00:01<00:00, 6184.77it/s]\n",
+ "Fitting motion model Linear: 100%|██████████| 10000/10000 [00:00<00:00, 23908.79it/s]\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Fitting 100 epochs...\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Fitting motion model Linear: 100%|██████████| 10000/10000 [00:01<00:00, 6347.19it/s]\n",
+ "Fitting motion model Linear: 100%|██████████| 10000/10000 [00:00<00:00, 14309.49it/s]\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Fitting 316 epochs...\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Fitting motion model Linear: 100%|██████████| 10000/10000 [00:01<00:00, 5023.37it/s]\n",
+ "Fitting motion model Linear: 100%|██████████| 10000/10000 [00:03<00:00, 3288.47it/s]\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Fitting 1000 epochs...\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Fitting motion model Linear: 100%|██████████| 10000/10000 [00:02<00:00, 4314.91it/s]\n",
+ "Fitting motion model Linear: 100%|██████████| 10000/10000 [01:19<00:00, 125.47it/s]\n"
+ ]
+ }
+ ],
+ "source": [
+ "import time\n",
+ "N = 10000\n",
+ "dims = np.logspace(1, 3, 5, dtype=int)\n",
+ "rng = np.random.default_rng(42)\n",
+ "\n",
+ "scipy_times = []\n",
+ "analytic_times = []\n",
+ "\n",
+ "for dim in dims:\n",
+ " print(f'Fitting {dim} epochs...')\n",
+ " t = np.linspace(2025.0, 2030.0, dim)\n",
+ " x = rng.random((N, dim))\n",
+ " y = rng.random((N, dim))\n",
+ " xe = rng.uniform(0, 0.2, size=(N, dim))\n",
+ " ye = rng.uniform(0, 0.2, size=(N, dim))\n",
+ " tab = StarTable({\n",
+ " 'x': x,\n",
+ " 'y': y,\n",
+ " 'xe': xe,\n",
+ " 'ye': ye\n",
+ " })\n",
+ " tab.meta['list_times'] = t\n",
+ " \n",
+ " start = time.time()\n",
+ " tab.fit_motion_model(use_scipy=True)\n",
+ " end = time.time()\n",
+ " scipy_times.append(end - start)\n",
+ " \n",
+ " start = time.time()\n",
+ " tab.fit_motion_model(use_scipy=False)\n",
+ " end = time.time()\n",
+ " analytic_times.append(end - start)\n",
+ "\n",
+ "scipy_times = np.array(scipy_times)\n",
+ "analytic_times = np.array(analytic_times)\n",
+ " "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "id": "3d2a8457",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "280"
+ ]
+ },
+ "execution_count": 31,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# Collect memory garbage data\n",
+ "import gc\n",
+ "gc.collect()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "06442faf",
+ "metadata": {},
+ "source": [
+ "Let's visualize the performance:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 32,
+ "id": "03d53769",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAk0AAAHJCAYAAACYMw0LAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjcsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvTLEjVAAAAAlwSFlzAAAPYQAAD2EBqD+naQAAmFJJREFUeJzs3XdcE+cfB/DPhQx2WEIAWYri3lXR1lEVHIBW6xbFXVu1tO7+6mpV3K3VOlqtW7HWbZWqrdpacYsLtyDIlhE2hOT5/YFcCQEMCobxfb9eac3d9+6+l0Dy5Xmee45jjDEQQgghhJBSCXSdACGEEEJIVUBFEyGEEEKIFqhoIoQQQgjRAhVNhBBCCCFaoKKJEEIIIUQLVDQRQgghhGiBiiZCCCGEEC1Q0UQIIYQQogUqmgghhBBCtEBFE8G2bdvAcRw4jsO5c+c01jPG4OrqCo7j0KVLl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xEWFgYvLy8sX74cNjY2suunlHj11VcRFxeHuLg4eHt7Iy8vD3v37sWIESM6HHNeXh6cnZ1ly8SJE2V9EhISsHv3bvj4+GDnzp347LPP4OHhAQCwsrLCgQMHUFdXh8DAQMyfPx8hISHYsWOHYf+oqCikpKQgLS0Nnp6emDlzpuFOPyXMzMywZs0a+Pj4YNKkSdBoNNi9e3eHz5WoP5LEg//piIhIFZIkIScnB3PmzFE7FCJ6CM40ERERESnAoomIiIhIAT5ygIiol+DVEkS9G2eaiIiIiBRg0URERESkAIsmIiIiIgVYNBEREREpwKKJiIiISAEWTUREREQKsGgiIiIiUoBFExEREZEC/wUz/wd8UZuS3gAAAABJRU5ErkJggg==",
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "fig, ax = plt.subplots()\n",
+ "ax.plot(dims, N / scipy_times, marker='o', label='Scipy Curve Fit')\n",
+ "ax.plot(dims, N / analytic_times, marker='o', color='C3', label='Motion Model Analytic')\n",
+ "ax.set_xscale('log')\n",
+ "ax.set_xlabel('Number of Epochs')\n",
+ "ax.set_ylabel('Stars Fit per Second')\n",
+ "ax.set_title(f'Motion Model Fitting Performance of {N} Stars')\n",
+ "ax.legend()\n",
+ "plt.show()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "ea672ab4",
+ "metadata": {},
+ "source": [
+ "It can be seen that for epochs < 200, the analytic solution is faster than scipy, and vice versa for > 300 epochs."
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "main",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.12.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/docs/flystar/index.rst b/docs/flystar/index.rst
index 99e85a8..50a5bdd 100644
--- a/docs/flystar/index.rst
+++ b/docs/flystar/index.rst
@@ -8,3 +8,33 @@ Reference/API
=============
.. automodapi:: flystar
+
+.. Alignment Tools
+.. ---------------
+.. automodapi:: flystar.align
+ :allowed-package-names: flystar
+.. :no-heading:
+
+.. Starlists Tools
+.. ---------------
+.. automodapi:: flystar.starlists
+ :allowed-package-names: flystar
+.. :no-heading:
+
+.. Transforms Tools
+.. ----------------
+.. automodapi:: flystar.transforms
+ :allowed-package-names: flystar
+.. :no-heading:
+
+.. Analysis Tools
+.. --------------
+.. automodapi:: flystar.analysis
+ :allowed-package-names: flystar
+.. :no-heading:
+
+.. Ploting Tools
+.. -------------
+.. automodapi:: flystar.plots
+ :allowed-package-names: flystar
+.. :no-heading:
diff --git a/flystar/align.py b/flystar/align.py
index b0fcd6d..8463522 100755
--- a/flystar/align.py
+++ b/flystar/align.py
@@ -1,41 +1,62 @@
+import os
+import gc
+import pdb
+import copy
+import pickle
+import warnings
+import datetime
import numpy as np
-from flystar import match
-from flystar import transforms
-from flystar import plots
+import matplotlib.pyplot as plt
+from tqdm import tqdm
+from flystar import match, transforms, plots, motion_model
from flystar.starlists import StarList
from flystar.startables import StarTable
from astropy.table import Table, Column, vstack
-import datetime
-import copy
-import os
-import pdb
-import time
-import warnings
from astropy.utils.exceptions import AstropyUserWarning
-# Keep a list of columns that are "aggregated" motion model terms.
-motion_model_col_names = ['x0', 'x0e', 'y0', 'y0e',
- 'vx', 'vxe', 'vy', 'vye',
- 'ax', 'axe', 'ay', 'aye',
- 't0', 'm0', 'm0e', 'use_in_trans']
class MosaicSelfRef(object):
- def __init__(self, list_of_starlists, ref_index=0, iters=2,
- dr_tol=[1, 1], dm_tol=[2, 1],
- outlier_tol=[None, None],
- trans_args=[{'order': 2}, {'order': 2}],
- init_order=1,
- mag_trans=True, mag_lim=None, weights=None,
- trans_input=None, trans_class=transforms.PolyTransform,
- use_vel=False, calc_trans_inverse=False,
- init_guess_mode='miracle', iter_callback=None,
- verbose=True):
-
+ def __init__(
+ self,
+ list_of_starlists,
+ starlist_vertices=None,
+ # Alignment parameters
+ ref_index=0,
+ iters=1,
+ dr_tol=[1.],
+ dm_tol=[1.],
+ outlier_tol=None,
+ # Transformation parameters
+ trans_class=transforms.PolyTransform,
+ trans_args=[{'order': 1}],
+ trans_input=None,
+ trans_weights=None,
+ init_order=1,
+ init_guess_mode='miracle',
+ briteN=None,
+ calc_trans_inverse=False,
+ # Magnitude parameters
+ mag_trans=True,
+ mag_lim=None,
+ # Motion model parameters
+ motion_models=['Empty', 'Fixed'],
+ fixed_params_dict=None,
+ vel_weights='var',
+ use_scipy=True,
+ absolute_sigma=True,
+ scipy_method=None,
+ # Advanced options
+ inherit_n_detect=True,
+ iter_callback=None,
+ save_path=None,
+ prefix_name='msr',
+ verbose=True
+ ):
"""
- Make a mosaic object by passing in a list of starlists and then running fit().
+ Make a mosaic object by passing in a list of starlists and then running fit().
Required Parameters
- ----------
+ -------------------
list_of_starlists : array of StarList objects
An array or list of flystar.starlists.StarList objects (which are Astropy Tables).
There should be one for each starlist and they must contain 'x', 'y', and 'm' columns.
@@ -43,25 +64,28 @@ def __init__(self, list_of_starlists, ref_index=0, iters=2,
Note that there is an optional weights column called 'w'. If this column exists
in any of the lists, it will be queried to determine if an individual star can be
used to derive the transformations between starlists. This is the most flexible way
- to allow you to determine, as a function of time and star, which ones are good enough
- in the transformation. Note that just because it can be used (i.e. w_in=1),
- doesn't meant that it will be used. The mag limits and outliers still take precedence.
- Note also that the weights that go into the transformation are
+ to allow you to determine, as a function of time and star, which ones are good enough
+ in the transformation. Note that just because it can be used (i.e. w_in=1),
+ doesn't meant that it will be used. The mag limits and outliers still take precedence.
+ Note also that the weights that go into the transformation are
star_list['w'] * ref_list['w'] * weight_from_keyword (see the weights parameter)
- for those stars not trimmed out by the other criteria.
-
+ for those stars not trimmed out by the other criteria.
Optional Parameters
- ----------
+ -------------------
+ starlist_vertices : list or array
+ A list or array of polygon vertices coordinates for each starlist. Initial guess will only use stars in overlapping regions defined by these polygons.
+ Shape of (N_lists, N_vertices, 2) in the format of [[x1, y1], [x2, y2], ..., [xN, yN]] for each starlist, by default None
+
ref_index : int
The index of the reference epoch. (default = 0). Note that this is the reference
- list only for the first iteration. Subsequent iterations will utilize the sigma-clipped
- mean of the positions from all the starlists.
+ list only for the first iteration. Subsequent iterations will utilize the sigma-clipped
+ mean of the positions from all the starlists.
iters : int
- The number of iterations used in the matching and transformation. TO DO: INNER/OUTER?
+ The number of iterations used in the matching and transformation. TO DO: INNER/OUTER?
dr_tol : list or array
The delta-radius (dr) tolerance for matching in units of the reference coordinate system.
@@ -69,130 +93,213 @@ def __init__(self, list_of_starlists, ref_index=0, iters=2,
dm_tol : list or array
The delta-magnitude (dm) tolerance for matching in units of the reference coordinate system.
- This is a list of dm values, one for each iteration of matching/transformation.
+ This is a list of dm values, one for each iteration of matching/transformation.
outlier_tol : list or array
- The outlier tolerance (in units of sigma) for rejecting outlier stars.
+ The outlier tolerance (in units of sigma) for rejecting outlier stars.
This is a list of tol values, one for each iteration of matching/transformation.
+ If not provided, will be None for each iteration.
- mag_trans : boolean
- If true, this will also calculate and (temporarily) apply a zeropoint offset to
- magnitudes in each list to bring them into a common magnitude system. This is
- essential for matching (with finite dm_tol) starlists of different filters or
- starlists that are not photometrically calibrated. Note that the final_table columns
- of 'm', 'm0', and 'm0e' will contain the transformed magnitudes while the
- final_table column 'm_orig' will contain the original un-transformed magnitudes.
- If mag_trans = False, then no such zeropoint offset it applied at any point.
+ trans_class : transforms.Transform2D object (or subclass)
+ The transform class that will be used to when deriving the optimal
+ transformation parameters between each list and the reference list.
- mag_lim : array
- If different from None, it indicates the minimum and maximum magnitude
- on the catalogs for finding the transformations. Note, if you want specify the mag_lim
- separately for each list and each iteration, you need to pass in a 2D array that
- has shape (N_lists, 2).
+ trans_args : dictionary
+ A dictionary (or a list of dictionaries) containing any extra keywords that are needed
+ in the transformation object. For instance, "order". Note that if a list is passed in,
+ then the transformation argument (i.e. order) will be changed for every iteration in
+ iters.
+
+ trans_input : array or list of transform objects
+ def = None. If not None, then this should contain an array or list of transform
+ objects that will be used as the initial guess in the alignment and matching.
- weights : str
+ trans_weights : str
Either None (def), 'both,var', 'list,var', or 'ref,var' depending on whether you want
to weight by the positional uncertainties (variances) in the individual starlists, or also with
the uncertainties in the reference frame itself. Note weighting only works when there
are positional uncertainties availabe. Other options include 'both,std', 'list,std', 'list,var'.
- trans_input : array or list of transform objects
- def = None. If not None, then this should contain an array or list of transform
- objects that will be used as the initial guess in the alignment and matching.
+ init_order : int
+ The order of the initial transformation used for the first iteration.
- trans_class : transforms.Transform2D object (or subclass)
- The transform class that will be used to when deriving the optimal
- transformation parameters between each list and the reference list.
-
- trans_args : dictionary
- A dictionary (or a list of dictionaries) containing any extra keywords that are needed
- in the transformation object. For instance, "order". Note that if a list is passed in,
- then the transformation argument (i.e. order) will be changed for every iteration in
- iters.
+ init_guess_mode : string
+ If no initial transformations are passed in via the trans_input keyword, then we have
+ to make the initial transformation and matching blindly. We can do this in a couple of
+ different ways. Options are 'miracle' or 'name' (see trans_initial_guess() for more details).
- use_vel : boolean
- If velocities are present in the reference list and use_vel == True, then during
- each iteration of the alignment, the reference list will be propogated in time
- using the velocity information. So all transformations will be derived w.r.t.
- the propogated positions. See also update_vel.
+ briteN : int
+ If init_guess_mode is 'miracle', this is the number of brightest stars to use in the miracle match.
+ Default is min(50, len(star_list)).
- calc_trans_inverse: boolean
+ calc_trans_inverse: boolean
If true, then calculate the inverse transformation (from reference to starlist)
in addition to the normal transformation (from starlist to reference). The inverse
calculation is calculated by switching the order to the positions in match_and_transform.
The inverse transformations are saved in self.trans_list_inverse.
-
self.trans_list_inverse doesn't exist if calc_trans_inverse == False
- init_guess_mode : string
- If no initial transformations are passed in via the trans_input keyword, then we have
- to make the initial transformation and matching blindly. We can do this in a couple of
- different ways. Options are 'miracle' or 'name' (see trans_initial_guess() for more details).
+ mag_trans : boolean
+ If true, this will also calculate and (temporarily) apply a zeropoint offset to
+ magnitudes in each list to bring them into a common magnitude system. This is
+ essential for matching (with finite dm_tol) starlists of different filters or
+ starlists that are not photometrically calibrated. Note that the final_table columns
+ of 'm', 'm0', and 'm0_err' will contain the transformed magnitudes while the
+ final_table column 'm_orig' will contain the original un-transformed magnitudes.
+ If mag_trans = False, then no such zeropoint offset it applied at any point.
+
+ mag_lim : array
+ If different from None, it indicates the minimum and maximum magnitude
+ on the starlists for finding the transformations BEFORE mag trans.
+ Note, if you want specify the mag_lim separately for each list,
+ you need to pass in a 2D array that has shape (N_lists, 2).
+
+ motion_models : list of MotionModel or str, or str, optional
+ Motion models or their names to use for new or unassigned stars. 'Empty' and 'Fixed' will always be added.
+ Can be a single string (e.g., 'Linear') or a list of motion models string or class (e.g., ['Linear', 'Parallax'], [Linear, Acceleration])
+ Note that the provided motion models have to have different numbers of parameters, otherwise the code will not know which one to use for new stars.
+ The most complex motion model will be used for new stars, by default None.
+
+ motion_model_for_new_star : str or MotionModel, optional
+ Motion model or its name for newly added stars in the ref table. Used in add_rows_for_new_stars().
+ If None, the most complex motion model in motion_models will be used, by default None.
+
+ fixed_params_dict : None or dict
+ Dictionary of motion model fixed parameters, e.g., ra, dec, pa, obsLocation, t0, etc. See motion_model classes for details.
+
+ vel_weights : str
+ Either 'var' (def) or 'std', depending on whether you want to weight the motion model
+ fits by the variance or standard deviation of the position data
+
+ use_scipy : bool, optional
+ If True, use scipy.optimize.curve_fit for velocity fitting. If False, use linear
+ algebra fitting of posible, by default True.
+
+ absolute_sigma : bool, optional
+ If True, the velocity fit will use absolute errors in the data. If False, relative
+ errors will be used, by default False.
+
+ scipy_method : str, optional
+ Method of scipy.curve_fit, {'lm', 'trf', 'dogbox'}, by default None
+
+ inherit_n_detect : bool, optional
+ If True, and an input starlist already has its own 'n_detect' column
+ (e.g. it is itself the output of a previous, lower-level align pass),
+ use that starlist's own n_detect value -- instead of counting 1 --
+ as the contribution from that starlist when computing this mosaic's
+ n_detect. So a star's final n_detect reflects the total number of
+ raw detections it represents, however many alignment layers deep.
+ Starlists without their own 'n_detect' still contribute 1 per
+ detection, same as when this is False. By default True.
iter_callback : None or function
A function to call (that accepts a StarTable object and an iteration number)
- at the end of every iteration. This can be used for plotting or printing state.
+ at the end of every iteration. This can be used for plotting or printing state.
- verbose : int (0 to 9, inclusive)
+ save_path : str, optional
+ Path to save the MosaicSelfRef object as a pickle file.
+
+ prefix_name : str, optional
+ Prefix for the file names, including PREFIX_input.log, PREFIX.pkl, PREFIX_ref_table.fits.
+
+ verbose : bool or int (0 to 9, inclusive)
Controls the verbosity of print statements. (0 least, 9 most verbose).
For backwards compatibility, 0 = False, 9 = True.
(Note: technically right now no checks on whether the number is an integer or not...)
Example
- ----------
- msc = align.MosaicToRef(list_of_starlists, iters=1,
+ -------
+ mtr = align.MosaicToRef(list_of_starlists, iters=1,
dr_tol=[0.1], dm_tol=[5],
outlier_tol=[None], mag_lim=[13, 21],
trans_class=transforms.PolyTransform,
trans_args=[{'order': 1}],
weights='both,std',
init_guess_mode='miracle', verbose=False)
- msc.fit()
+ mtr.fit()
# Access a list of all the transformation parameters:
- trans_list = msc.trans_list
+ trans_list = mtr.trans_list
# Access the fully-combined reference table.
- stars_table = msc.ref_table
+ stars_table = mtr.ref_table
# Plot the magnitude of the first star vs. time:
- # Overplot the mean magnitude.
+ # Overplot the mean magnitude.
plt.plot(stars_table['t'][0, :], stars_table['m'][0, :], 'k.')
- plt.axhline(stars_table['m0'][0])
+ plt.axhline(stars_table['m0'][0])
# Plot the X position of the first star vs. time:
# Overplot the best-fit proper motion.
times = stars_table['t'][0, :]
plt.errorbar(times, stars_table['x'][0, :], yerr=stars_table['xe'][0, :])
- plt.axhline(stars_table['x0'][0] + stars_table['vx'][0]*(times - stars_table['t0'][0]))
-
+ plt.axhline(stars_table['x0'][0] + stars_table['vx'][0]*(times - stars_table['t0'][0]))
"""
+ dr_tol = np.atleast_1d(dr_tol)
+ self.iters = len(dr_tol)
+ if dm_tol is not None:
+ dm_tol = np.atleast_1d(dm_tol)
+ assert self.iters == len(dm_tol), f'dr_tol (len={self.iters}) and dm_tol (len={len(dm_tol)}) must all have the same length!'
+ if outlier_tol is not None:
+ assert self.iters == len(outlier_tol), f'dr_tol (len={self.iters}) and outlier_tol (len={len(outlier_tol)}) must all have the same length!'
self.star_lists = list_of_starlists
+ self.starlist_vertices = starlist_vertices
self.ref_index = ref_index
- self.iters = iters
self.dr_tol = dr_tol
self.dm_tol = dm_tol
- self.outlier_tol = outlier_tol
self.trans_args = trans_args
self.init_order = init_order
self.mag_trans = mag_trans
self.mag_lim = mag_lim
- self.weights = weights
+ self.trans_weighting = trans_weights
+ self.vel_weighting = vel_weights
self.trans_input = trans_input
self.trans_class = trans_class
- self.calc_trans_inverse = calc_trans_inverse
- self.use_vel = use_vel
+ self.calc_trans_inverse = calc_trans_inverse
+ self.use_scipy = use_scipy
+ self.absolute_sigma = absolute_sigma
+ self.scipy_method = scipy_method
+ self.inherit_n_detect = inherit_n_detect
+ self.fixed_params_dict = fixed_params_dict
self.init_guess_mode = init_guess_mode
+ self.briteN = briteN
self.iter_callback = iter_callback
+ self.save_path = save_path
+ self.prefix_name = prefix_name
self.verbose = verbose
- # For backwards compatibility.
- if self.verbose is True:
- self.verbose = 9
- if self.verbose is False:
- self.verbose = 0
-
+ if self.starlist_vertices is not None:
+ import shapely
+ self.reflist_polygon = shapely.make_valid(shapely.Polygon(self.starlist_vertices[self.ref_index]))
+ else:
+ self.reflist_polygon = None
+
+ for ii in range(len(self.star_lists)):
+ # Check x and y are 1d
+ if self.star_lists[ii]['x'].ndim != 1 or self.star_lists[ii]['y'].ndim != 1:
+ raise ValueError(f"StarList at index {ii} has x and y that are not 1D. x.ndim={self.star_lists[ii]['x'].ndim}, y.ndim={self.star_lists[ii]['y'].ndim}. Please flatten these columns to be 1D.")
+ # Add list_time to meta if not present
+ if 'list_time' not in self.star_lists[ii].meta:
+ assert 't' in self.star_lists[ii].colnames, f"StarList at index {ii} does not have 'list_time' in meta and does not have 't' column. Please add one of these."
+ unique_t = np.unique(self.star_lists[ii]['t'])
+ assert unique_t.size == 1, f"The time values of starlist at index {ii} are not unique."
+ self.star_lists[ii].meta['list_time'] = unique_t[0]
+
+ if outlier_tol is None:
+ self.outlier_tol = [None] * self.iters
+ else:
+ self.outlier_tol = outlier_tol
+
+ # Organize motion models into a list of MotionModel classes, sorted by increasing number of parameters.
+ self.motion_models = motion_model.organize_motion_models(motion_models)
+
+ # if motion_model_for_new_star is None:
+ # self.motion_model_for_new_star = self.motion_models[-1]
+ # elif isinstance(motion_model_for_new_star, str):
+ # assert motion_model_for_new_star in all_mm_map.keys(), f"motion_model_for_new_star must be in {list(all_mm_map.keys())}"
+ # self.motion_model_for_new_star = all_mm_map[motion_model_for_new_star]
+
self.N_lists = len(self.star_lists)
# Hard-coded values:
@@ -203,7 +310,6 @@ def = None. If not None, then this should contain an array or list of transform
# Error checking for parameters.
##########
self.fix_iterable_conditions() # fix dr_tol, dm_tol, outlier_tol, mag_lim to be iterable.
- check_iter_tolerances(self.iters, self.dr_tol, self.dm_tol, self.outlier_tol)
check_trans_input(self.star_lists, self.trans_input, self.mag_trans)
##########
@@ -214,41 +320,48 @@ def = None. If not None, then this should contain an array or list of transform
# is passed in, replicate for all star lists, all loop iterations.
##########
self.setup_trans_info()
-
return
def fix_iterable_conditions(self):
if not np.iterable(self.dr_tol):
self.dr_tol = np.repeat(self.dr_tol, self.iters)
- assert len(self.dr_tol) == self.iters
+ assert len(self.dr_tol) == self.iters, f'len(dr_tol)={len(self.dr_tol)} != iters={self.iters}'
if not np.iterable(self.dm_tol):
self.dm_tol = np.repeat(self.dm_tol, self.iters)
- assert len(self.dm_tol) == self.iters
+ assert len(self.dm_tol) == self.iters, f'len(dm_tol)={len(self.dm_tol)} != iters={self.iters}'
if not np.iterable(self.outlier_tol):
self.outlier_tol = np.repeat(self.outlier_tol, self.iters)
- assert len(self.outlier_tol) == self.iters
+ assert len(self.outlier_tol) == self.iters, f'len(outlier_tol)={len(self.outlier_tol)} != iters={self.iters}'
+ # Format self.mag_lim to be (N_iters, N_lists, 2) array. If only a single mag_lim is passed in, replicate for all lists.
if self.mag_lim is None:
- self.mag_lim = np.repeat([[None, None]], len(self.star_lists), axis=0)
- elif (len(self.mag_lim) == 2):
- self.mag_lim = np.repeat([self.mag_lim], len(self.star_lists), axis=0)
- assert len(self.mag_lim) == len(self.star_lists)
-
- return
+ self.mag_lim = np.array([[None] * len(self.star_lists)] * self.iters)
+ elif (np.ndim(self.mag_lim) == 1) and (len(self.mag_lim) == 2):
+ # 2-element array, replicate for all lists and iterations
+ self.mag_lim = np.array([[self.mag_lim] * len(self.star_lists)] * self.iters)
+ elif (np.ndim(self.mag_lim) == 2) and (len(self.mag_lim) == len(self.star_lists)) and (self.mag_lim.shape[1] == 2):
+ # (N_lists, 2) array, replicate for all iterations
+ self.mag_lim = np.array([self.mag_lim] * self.iters)
+ elif np.ndim(self.mag_lim) == 3:
+ assert np.shape(self.mag_lim) == (self.iters, len(self.star_lists), 2), f"mag_lim must have shape (iters, N_lists, 2) = ({self.iters}, {len(self.star_lists)}, 2), but has shape {np.shape(self.mag_lim)}"
+ else:
+ raise ValueError(f"mag_lim must be None, a 2-element array, a (N_lists, 2) array, or a (N_iters, N_lists, 2) array. Got shape {np.shape(self.mag_lim)}")
-
- def fit(self):
+ return
+
+
+ def fit(self, processes=1, chunksize=None, match_workers=1, mp_star_threshold=100_000):
"""
Using the current parameter settings, match and transform all the lists
to a reference position. Note in the first pass, the reference position
is just the specified input reference starlist. In subsequent iterations,
- this is updated.
+ this is updated.
The ultimate outcome is the creation of self.ref_table. This reference
- table will contain "averaged" quantites as well as a big 2D array of all
- the matched original and transformed quantities.
+ table will contain "averaged" quantities as well as a big 2D array of all
+ the matched original and transformed quantities.
Averaged columns on ref_table:
x0
@@ -257,12 +370,71 @@ def fit(self):
x0e
y0e
m0e
- vx (only if use_vel=True)
- vy (only if use_vel=True)
- vxe (only if use_vel=True)
- vye (only if use_vel=True)
+ additional motion_model columns
+ Parameters
+ ----------
+ processes : int, optional
+ Number of processes to use for parallel processing, maximum os.cpu_count(), by default 1 (no multiprocessing)
+ chunksize : int, optional
+ Chunk size for multiprocessing, by default None (auto)
+ match_workers : int, optional
+ Number of worker threads scipy uses for the KDTree neighbor search inside
+ match.match(). Default is 1 (single-threaded), which is the safe choice on
+ shared/multi-tenant machines where grabbing all cores would step on other
+ users' jobs. Set to -1 to use all available CPU cores (measurably faster on
+ large starlists, with no change in matching results -- the neighbor lists
+ returned per query point are identical, order included, regardless of thread
+ count), or to a specific positive integer to cap the thread count on a shared
+ machine.
+ mp_star_threshold : int, optional
+ Minimum number of stars needing the per-star motion-model fitting
+ path before a multiprocessing Pool is used for fitting, even if
+ processes > 1. A star needs that path when its motion model has no
+ vectorized run_fit_batch, or when bootstrap > 0. Below this
+ threshold, fitting runs serially instead -- Pool startup/IPC
+ overhead isn't worth it for small workloads. See
+ StarTable.fit_motion_models for details. By default 100_000.
"""
+ # Setup save_path:
+ if self.save_path:
+ if not os.path.exists(os.path.dirname(self.save_path)):
+ os.makedirs(os.path.dirname(self.save_path))
+
+ # Save input params
+ input_filename = f'{self.prefix_name}_input.txt'
+ input_dict = {
+ 'ref_index': self.ref_index,
+ 'iters': self.iters,
+ 'dr_tol': self.dr_tol,
+ 'dm_tol': self.dm_tol,
+ 'outlier_tol': self.outlier_tol,
+ 'trans_class': self.trans_class,
+ 'trans_args': self.trans_args,
+ 'trans_input': self.trans_input,
+ 'trans_weights': self.trans_weighting,
+ 'init_order': self.init_order,
+ 'init_guess_mode': self.init_guess_mode,
+ 'calc_trans_inverse': self.calc_trans_inverse,
+ 'mag_trans': self.mag_trans,
+ 'mag_lim': self.mag_lim,
+ 'motion_models': self.motion_models,
+ 'fixed_params_dict': self.fixed_params_dict,
+ 'vel_weights': self.vel_weighting,
+ 'use_scipy': self.use_scipy,
+ 'absolute_sigma': self.absolute_sigma,
+ 'iter_callback': self.iter_callback,
+ 'save_path': self.save_path,
+ 'prefix_name': self.prefix_name,
+ 'verbose': self.verbose
+ }
+ if self.save_path is not None:
+ if not os.path.exists(self.save_path):
+ os.makedirs(self.save_path)
+ with open(os.path.join(self.save_path, input_filename), 'w') as file:
+ for key, value in input_dict.items():
+ file.write(f'{key}:\t{value}\n')
+
##########
# Setup a reference table to store data. It will contain:
# x0, y0, m0 -- the running average of positions: 1D
@@ -270,8 +442,9 @@ def fit(self):
# x_orig, y_orig, m_orig, (opt. errors) -- the transformed errors for the lists: 2D
# w, w_orig (optiona) -- the input and output weights of stars in transform: 2D
##########
+ if 't0' in self.star_lists[self.ref_index].colnames: self.t0_provided = True
+ else: self.t0_provided = False
self.ref_table = self.setup_ref_table_from_starlist(self.star_lists[self.ref_index])
-
# Save the reference index to the meta data on the reference list.
self.ref_table.meta['ref_list'] = self.ref_index
@@ -281,44 +454,52 @@ def fit(self):
#
##########
for nn in range(self.iters):
-
- # If we are on subsequent iterations, remove matching results from the
+
+ # If we are on subsequent iterations, remove matching results from the
# prior iteration. This leaves aggregated (1D) columns alone.
if nn > 0:
self.reset_ref_values()
if self.verbose > 0:
- print(" ")
- print("**********")
+ print("\n**********")
print("**********")
print('Starting iter {0:d} with ref_table shape:'.format(nn), self.ref_table['x'].shape)
print("**********")
print("**********")
# ALL the action is in here. Match and transform the stack of starlists.
- # This updates trans objects and the ref_table.
- self.match_and_transform(self.mag_lim[self.ref_index],
- self.dr_tol[nn], self.dm_tol[nn], self.outlier_tol[nn],
- self.trans_args[nn])
-
+ # This updates trans objects and the ref_table.
+ self.match_and_transform(
+ self.mag_lim[nn][self.ref_index],
+ self.dr_tol[nn],
+ self.dm_tol[nn],
+ self.outlier_tol[nn],
+ self.trans_args[nn],
+ nn,
+ processes=processes,
+ chunksize=chunksize,
+ match_workers=match_workers,
+ mp_star_threshold=mp_star_threshold
+ )
# Clean up the reference table
# Find where stars are detected.
- self.ref_table.detections()
+ self.ref_table.detections(weight_col='n_detect_list' if self.inherit_n_detect else None)
### Drop all stars that have 0 detections.
- idx = np.where(self.ref_table['n_detect'] == 0)[0]
- print(' *** Getting rid of {0:d} out of {1:d} junk sources'.format(len(idx), len(self.ref_table)))
+ idx = np.where((self.ref_table['n_detect'] == 0))[0]
+ if self.verbose:
+ print(' *** Getting rid of {0:d} out of {1:d} junk sources'.format(len(idx), len(self.ref_table)))
self.ref_table.remove_rows(idx)
- if self.iter_callback != None:
+ if self.iter_callback is not None:
self.iter_callback(self.ref_table, nn)
-
+
##########
#
# Re-do all matching given final transformations.
# No trimming this time.
- # First rest the reference table 2D values.
+ # First rest the reference table 2D values.
##########
self.reset_ref_values(exclude=['used_in_trans'])
@@ -327,50 +508,172 @@ def fit(self):
print("Final Matching")
print("**********")
- self.match_lists(self.dr_tol[-1], self.dm_tol[-1])
- self.update_ref_table_aggregates()
+ self.match_lists(self.dr_tol[-1], self.dm_tol[-1], workers=match_workers)
+ # Hard-coded not to keep ref values for MosaicSelfRef
+ self.update_ref_table_aggregates(processes=processes, chunksize=chunksize, mp_star_threshold=mp_star_threshold)
##########
# Clean up output table.
- #
+ #
##########
# Find where stars are detected.
if self.verbose > 0:
print('')
print(' Preparing the reference table...')
-
- self.ref_table.detections()
+
+ self.ref_table.detections(weight_col='n_detect_list' if self.inherit_n_detect else None)
### Drop all stars that have 0 detections.
- idx = np.where(self.ref_table['n_detect'] == 0)[0]
- print(' *** Getting rid of {0:d} out of {1:d} junk sources'.format(len(idx), len(self.ref_table)))
+ idx = np.where((self.ref_table['n_detect'] == 0))[0]
+ if self.verbose:
+ print(f' *** Getting rid of {len(idx):d} out of {len(self.ref_table):d} junk sources')
self.ref_table.remove_rows(idx)
- if self.iter_callback != None:
+ if self.iter_callback is not None:
self.iter_callback(self.ref_table, nn)
-
+
+ # Add times into ref_table meta data
+ all_epochs = [s.meta['list_time'] for s in self.star_lists]
+ self.ref_table.meta['list_times'] = all_epochs
+
+ # Update chi2 values in ref table, as motion_model_used may have changed
+ x_inferred, y_inferred, _, _ = self.ref_table.infer_positions(all_epochs)
+ # Ensure x_inferred and y_inferred is 2D for chi2 calculation
+ if x_inferred.ndim == 1:
+ x_inferred = x_inferred[:, np.newaxis]
+ if y_inferred.ndim == 1:
+ y_inferred = y_inferred[:, np.newaxis]
+ weighted_xy = ('xe' in self.ref_table.colnames) and ('ye' in self.ref_table.colnames)
+ if weighted_xy:
+ chi2_x_2d = ((self.ref_table['x'] - x_inferred) / self.ref_table['xe'])**2
+ chi2_y_2d = ((self.ref_table['y'] - y_inferred) / self.ref_table['ye'])**2
+ else:
+ chi2_x_2d = (self.ref_table['x'] - x_inferred)**2
+ chi2_y_2d = (self.ref_table['y'] - y_inferred)**2
+ chi2_x = np.nansum(chi2_x_2d, axis=1)
+ chi2_y = np.nansum(chi2_y_2d, axis=1)
+ chi2_x[~np.isfinite(chi2_x_2d).any(axis=1)] = np.nan
+ chi2_y[~np.isfinite(chi2_y_2d).any(axis=1)] = np.nan
+ self.ref_table['chi2_x'] = chi2_x
+ self.ref_table['chi2_y'] = chi2_y
+
+ # Update t0 and n_fit when no fitting is run because all motion_model_input==Fixed.
+ # 't0' may already exist as a column (e.g. supplied by the input
+ # reference list) without being populated for every row -- newly
+ # added stars get a NaN placeholder when their row is created (see
+ # add_rows_for_new_stars), and nothing else ever fills it in for the
+ # all-Fixed case. So the check has to be "which rows still need a
+ # value", not just "does the column exist".
+ needs_t0 = (
+ np.ones(len(self.ref_table), dtype=bool) if 't0' not in self.ref_table.colnames
+ else ~np.isfinite(self.ref_table['t0'])
+ )
+ needs_n_fit = 'n_fit' not in self.ref_table.colnames
+
+ if needs_t0.any() or needs_n_fit:
+ x_data = np.ma.masked_invalid(self.ref_table['x'].data, copy=True)
+ y_data = np.ma.masked_invalid(self.ref_table['y'].data, copy=True)
+ if weighted_xy:
+ xe_data = np.ma.masked_invalid(self.ref_table['xe'].data, copy=True)
+ ye_data = np.ma.masked_invalid(self.ref_table['ye'].data, copy=True)
+ xe_data.mask[np.isclose(xe_data, 0.)] = True
+ ye_data.mask[np.isclose(ye_data, 0.)] = True
+ fill_with_one = np.all(xe_data.mask, axis=1) & np.all(ye_data.mask, axis=1)
+ xe_data[fill_with_one] = 1.
+ ye_data[fill_with_one] = 1.
+ else:
+ xe_data = None
+ ye_data = None
+
+ if np.ndim(x_data) == 1:
+ x_data = x_data[:, np.newaxis]
+ if np.ndim(y_data) == 1:
+ y_data = y_data[:, np.newaxis]
+ if weighted_xy:
+ if np.ndim(xe_data) == 1:
+ xe_data = xe_data[:, np.newaxis]
+ if np.ndim(ye_data) == 1:
+ ye_data = ye_data[:, np.newaxis]
+
+ if 't' in self.ref_table.colnames:
+ t_data = copy.deepcopy(self.ref_table['t'].data)
+ else:
+ t_data = np.array(self.ref_table.meta['list_times'])
+ t_data = np.broadcast_to(t_data, xe_data.shape)
+
+ # Update t0, adapted from startables.fit_motion_models. Only the
+ # rows that need it are written -- rows that already have a
+ # valid t0 (e.g. from the input reference list) are left alone.
+ if needs_t0.any():
+ weights = 1. / np.hypot(xe_data, ye_data) if weighted_xy else None
+ # t_data must be masked (not just weights) and np.ma.average
+ # (not plain np.average) must be used here: for the
+ # fill_with_one rows above (no usable xe/ye anywhere at all),
+ # the substitute weight is uniform/unmasked, but t can still
+ # be genuinely NaN in undetected epochs. Plain np.average's
+ # weight-sum denominator doesn't respect t's own mask in that
+ # case, silently corrupting the result. np.ma.average does,
+ # and with a uniform weight that's equivalent to
+ # combine_lists()'s plain (unweighted) mean of just the valid
+ # epochs -- i.e. these stars' t0 still reflects their real
+ # detections, it's just not astrometric-error-weighted.
+ t0_new = np.ma.average(np.ma.masked_invalid(t_data), axis=1, weights=weights).filled(np.nan)
+ if 't0' not in self.ref_table.colnames:
+ self.ref_table['t0'] = t0_new
+ else:
+ self.ref_table['t0'][needs_t0] = t0_new[needs_t0]
+
+ # Update n_fit: unique epochs with valid data
+ if needs_n_fit:
+ xy_mask = ~ (x_data.mask | y_data.mask)
+ if weighted_xy:
+ xy_mask &= ~ (xe_data.mask | ye_data.mask)
+
+ self.ref_table['n_fit'] = np.array([
+ len(set(t_data[i][xy_mask[i]]))
+ for i in range(len(self.ref_table))
+ ])
+
+ if self.save_path is not None:
+ suppress_meta_warnings(self.ref_table)
+ with open(os.path.join(self.save_path, f'{self.prefix_name}.pkl'), 'wb') as file:
+ pickle.dump(self, file)
+ # Using pickle here because nan in a fits file is auto-converted to a masked value in astropy.io.fits.open()
+ with open(os.path.join(self.save_path, f'{self.prefix_name}_ref_table.pkl'), 'wb') as file:
+ pickle.dump(self.ref_table, file)
+ self.ref_table.write(os.path.join(self.save_path, f'{self.prefix_name}_ref_table.fits'), overwrite=True)
+
+ if self.verbose > 0:
+ print('===================================')
+ print('========== Done with fit ==========')
+ print('===================================')
return
- def match_and_transform(self, ref_mag_lim, dr_tol, dm_tol, outlier_tol, trans_args):
+ def match_and_transform(self, ref_mag_lim, dr_tol, dm_tol, outlier_tol, trans_args, nn=None, processes=1, chunksize=None, match_workers=1, mp_star_threshold=100_000):
"""
Given some reference list of positions, loop through all the starlists
transform and match them.
"""
+ if self.starlist_vertices is not None:
+ import shapely
for ii in range(len(self.star_lists)):
if self.verbose > 0:
- msg = ' Matching catalog {0} / {1} with {2:d} stars'
- msg2 = ' {0:8s} < {1:0.3f}'
- print(" ")
- print(" **********")
- print(msg.format((ii + 1), len(self.star_lists), len(self.star_lists[ii])))
- print(msg2.format('dr', dr_tol))
- print(msg2.format('|dm|', dm_tol))
- print(' outlier tol: ', outlier_tol)
- print(' mag_lim: ', self.mag_lim[ii])
- print(" **********")
+ print()
+ print(" **********")
+ if nn is not None:
+ print(f" Iteration {nn+1} / {self.iters}")
+ print(f' Matching catalog {ii + 1} / {len(self.star_lists)} with {len(self.star_lists[ii]):d} stars')
+ print(f' dr < {dr_tol}')
+ print(f' |dm| < {dm_tol}')
+ print(f' outlier tol: {outlier_tol}')
+ print(f' mag_lim: {self.mag_lim[nn][ii]}')
+ print(" **********")
star_list = self.star_lists[ii]
- ref_list = self.get_ref_list_from_table(star_list['t'][0])
+
+ list_epoch = star_list.meta['list_time']
+ ref_list = self.get_ref_list_from_table(list_epoch, processes=processes, chunksize=chunksize)
+
trans = self.trans_list[ii]
# Trim a COPY of the reference and star lists based on magnitude.
@@ -378,69 +681,91 @@ def match_and_transform(self, ref_mag_lim, dr_tol, dm_tol, outlier_tol, trans_ar
# star_list_orig_trim is actually trimmed but not yet transformed.
# star_list_T is trimmed and transformed
self.apply_mag_lim_via_use_in_trans(ref_list, ref_mag_lim)
- star_list_orig_trim = apply_mag_lim(star_list, self.mag_lim[ii]) # trimmed, untransformed copy
- star_list_T = apply_mag_lim(star_list, self.mag_lim[ii]) # trimmed, will be transformed copy
+ star_list_orig_trim = apply_mag_lim(star_list, self.mag_lim[nn][ii]) # trimmed, untransformed copy
+ star_list_T = StarList(star_list_orig_trim, copy=True) # trimmed, will be transformed copy
+
+ assert len(star_list_orig_trim) > 0, f"No stars remain after applying mag_lim={self.mag_lim[nn][ii]} to star_list at index {ii}. Please check your mag_lim."
### Initial match and transform: 1st order (if we haven't already).
if trans is None:
# Only use "use_in_trans" reference stars, even for initial guessing.
- keepers = np.where(ref_list['use_in_trans'] == True)[0]
-
- trans = trans_initial_guess(ref_list[keepers], star_list_orig_trim, self.trans_args[0],
- mode=self.init_guess_mode,
- order=self.init_order,
- verbose=self.verbose,
- mag_trans=self.mag_trans)
+ keepers = ref_list['use_in_trans']
+ trans = trans_initial_guess(
+ ref_list=ref_list[keepers],
+ star_list=star_list_orig_trim,
+ trans_args=self.trans_args[0],
+ mode=self.init_guess_mode,
+ order=self.init_order,
+ briteN=self.briteN,
+ polygon_reflist=self.reflist_polygon,
+ polygon_starlist=shapely.Polygon(self.starlist_vertices[ii]) if self.starlist_vertices is not None else None,
+ buffer=dr_tol,
+ motion_models=self.motion_models,
+ fixed_params_dict=self.fixed_params_dict,
+ mag_trans=self.mag_trans,
+ verbose=self.verbose
+ )
+ if np.isnan(trans.px.parameters).any() or np.isnan(trans.py.parameters).any():
+ raise ValueError(f"Initial transformation contains NaN parameters. trans.px={trans.px.parameters}, trans.py={trans.py.parameters}.")
if self.mag_trans:
star_list_T.transform_xym(trans) # trimmed, transformed
else:
- star_list_T.transform_xy(trans)
-
+ star_list_T.transform_xy(trans)
+
# Match stars between the transformed, trimmed lists.
- idx1, idx2, dr, dm = match.match(star_list_T['x'], star_list_T['y'], star_list_T['m'],
- ref_list['x'], ref_list['y'], ref_list['m'],
- dr_tol=dr_tol, dm_tol=dm_tol, verbose=self.verbose)
+ # Only use stars specified by "use_in_trans" column.
+ use_in_trans = ref_list['use_in_trans']
+ idx1, idx2, dr, dm = match.match(
+ star_list_T['x'], star_list_T['y'], star_list_T['m'],
+ ref_list['x'][use_in_trans], ref_list['y'][use_in_trans], ref_list['m'][use_in_trans],
+ dr_tol=dr_tol, dm_tol=dm_tol, workers=match_workers, verbose=self.verbose
+ )
+ # Restore idx2 to the full reference list indices
+ idx2 = np.where(use_in_trans)[0][idx2]
+
+ if len(idx1) == 0 or len(idx2) == 0:
+ fig, ax = plt.subplots()
+ ax.scatter(star_list_T['x'], star_list_T['y'], s=1, c='C0', alpha=0.5, label='Transformed Star List')
+ ax.scatter(ref_list['x'][use_in_trans], ref_list['y'][use_in_trans], s=1, c='C3', alpha=0.5, label='Reference List (use_in_trans=True)')
+ ax.set_xlabel('X')
+ ax.set_ylabel('Y')
+ ax.set_title(f'Matching Results for Catalog {ii + 1}')
+ ax.legend()
+ plt.show()
+ raise ValueError(f"align.match_and_transform: No matches found between star_list at index {ii} and the reference list. Check your dr_tol={dr_tol} and dm_tol={dm_tol} values.")
+
if self.verbose > 1:
print( ' Match 1: Found ', len(idx1), ' matches out of ', len(star_list_T),
'. If match count is low, check dr_tol, dm_tol.' )
- # Outlier rejection on ref_stars
- if outlier_tol != None:
- keepers = self.outlier_rejection_indices(star_list_T[idx1], ref_list[idx2],
- outlier_tol)
+ # Outlier rejection
+ if outlier_tol is not None:
+ keepers = self.outlier_rejection_indices(star_list_T[idx1], ref_list[idx2], outlier_tol, verbose=self.verbose)
if self.verbose > 1:
- print( ' Rejected ', len(idx1) - len(keepers), ' outliers.' )
-
- idx1 = idx1[keepers]
- idx2 = idx2[keepers]
+ print( ' Rejected ', len(idx1) - sum(keepers), ' outliers.' )
- # Only use stars specified by "use_in_trans" column.
- if 'use_in_trans' in ref_list.colnames:
- keepers = np.where(ref_list[idx2]['use_in_trans'] == True)[0]
-
- if self.verbose > 1:
- print( ' Rejected ', len(idx1) - len(keepers), ' with use_in_trans=False.' )
-
idx1 = idx1[keepers]
idx2 = idx2[keepers]
# Determine weights in the fit.
- weight = self.get_weights_for_lists(ref_list[idx2], star_list_T[idx1])
+ weight = self.get_weights_for_lists(ref_list[idx2], star_list_T[idx1])
- # Derive the best-fit transformation parameters.
+ # Derive the best-fit transformation parameters.
if self.verbose > 1:
print( ' Using ', len(idx1), ' stars in transformation.' )
- trans = self.trans_class.derive_transform(star_list_orig_trim['x'][idx1], star_list_orig_trim['y'][idx1],
- ref_list['x'][idx2], ref_list['y'][idx2],
- **trans_args,
- m=star_list_orig_trim['m'][idx1], mref=ref_list['m'][idx2],
- weights=weight, mag_trans=self.mag_trans)
+ trans = self.trans_class.derive_transform(
+ star_list_orig_trim['x'][idx1], star_list_orig_trim['y'][idx1],
+ ref_list['x'][idx2], ref_list['y'][idx2],
+ **trans_args,
+ m=star_list_orig_trim['m'][idx1], mref=ref_list['m'][idx2],
+ weights=weight, mag_trans=self.mag_trans
+ )
# Outlier rejection: ref stars in final transformation, if desired
if outlier_tol != None:
# Apply transformation to starlist, run match between starlist and ref_list
- star_list_T = copy.deepcopy(star_list)
+ star_list_T = StarList(star_list, copy=True)
if self.mag_trans:
star_list_T.transform_xym(trans)
else:
@@ -448,8 +773,9 @@ def match_and_transform(self, ref_mag_lim, dr_tol, dm_tol, outlier_tol, trans_ar
idx_lis, idx_ref, dr, dm = match.match(star_list_T['x'], star_list_T['y'], star_list_T['m'],
ref_list['x'], ref_list['y'], ref_list['m'],
- dr_tol=dr_tol, dm_tol=dm_tol, verbose=self.verbose)
-
+ dr_tol=dr_tol, dm_tol=dm_tol, workers=match_workers,
+ verbose=self.verbose)
+
# Let's look at just the ref stars used in the transformation, which are idx1 and idx2
keepers = self.outlier_rejection_indices(star_list_T[idx1], ref_list[idx2],
outlier_tol)
@@ -468,7 +794,7 @@ def match_and_transform(self, ref_mag_lim, dr_tol, dm_tol, outlier_tol, trans_ar
for jj in outlier_names:
print('{0}'.format(jj))
print('=========================')
-
+
# Update set of ref stars (indices are idx1, idx2 here, to be compatible downstream)
idx1 = idx1[keepers]
idx2 = idx2[keepers]
@@ -479,7 +805,7 @@ def match_and_transform(self, ref_mag_lim, dr_tol, dm_tol, outlier_tol, trans_ar
# Redo transformation
if self.verbose > 1:
print( 'Recalculating trans after outlier reject. Using ', len(idx1), ' stars in transformation.' )
- trans = self.trans_class.derive_transform(star_list_orig_trim['x'][idx1], star_list_orig_trim['y'][idx1],
+ trans = self.trans_class.derive_transform(star_list_orig_trim['x'][idx1], star_list_orig_trim['y'][idx1],
ref_list['x'][idx2], ref_list['y'][idx2],
**trans_args,
m=star_list_orig_trim['m'][idx1], mref=ref_list['m'][idx2],
@@ -492,22 +818,25 @@ def match_and_transform(self, ref_mag_lim, dr_tol, dm_tol, outlier_tol, trans_ar
# NOTE: We will not recalculate weights here
if self.calc_trans_inverse:
if self.verbose > 1:
- print('Doing inverse')
- trans_inv = self.trans_class.derive_transform(ref_list['x'][idx2], ref_list['y'][idx2],
- star_list_orig_trim['x'][idx1], star_list_orig_trim['y'][idx1],
- trans_args['order'], m=ref_list['m'][idx2],
- mref=star_list_orig_trim['m'][idx1], weights=weight,
- mag_trans=self.mag_trans)
+ print('Calculating inverse transformation...')
+
+ trans_inv = self.trans_class.derive_transform(
+ ref_list['x'][idx2], ref_list['y'][idx2],
+ star_list_orig_trim['x'][idx1], star_list_orig_trim['y'][idx1],
+ trans_args['order'], m=ref_list['m'][idx2],
+ mref=star_list_orig_trim['m'][idx1], weights=weight,
+ mag_trans=self.mag_trans
+ )
self.trans_list_inverse[ii] = trans_inv
# Apply the XY transformation to a new copy of the starlist and
# do one final match between the two (now transformed) lists.
- star_list_T = copy.deepcopy(star_list)
+ star_list_T = StarList(star_list, copy=True)
if self.mag_trans:
star_list_T.transform_xym(self.trans_list[ii])
else:
star_list_T.transform_xy(self.trans_list[ii])
-
+
if self.verbose > 7:
hdr = '{nr:20s} {n:s} {xl:9s} {xr:9s} {yl:9s} {yr:9s} {ml:6s} {mr:6s} '
hdr += '{dx:7s} {dy:7s} {dm:6s} {xo:9s} {yo:9s} {mo:6s}'
@@ -517,7 +846,7 @@ def match_and_transform(self, ref_mag_lim, dr_tol, dm_tol, outlier_tol, trans_ar
ml='m_lis_T', mr='m_ref',
dx='dx_mpix', dy='dy_mpix', dm='dm',
xo='x_orig', yo='y_orig', mo='m_orig'))
-
+
fmt = '{nr:20s} {n:s} {xl:9.5f} {xr:9.5f} {yl:9.5f} {yr:9.5f} {ml:6.2f} {mr:6.2f} '
fmt += '{dx:7.2f} {dy:7.2f} {dm:6.2f} {xo:9.5f} {yo:9.5f} {mo:6.2f}'
for foo in range(len(idx1)):
@@ -527,51 +856,73 @@ def match_and_transform(self, ref_mag_lim, dr_tol, dm_tol, outlier_tol, trans_ar
print(fmt.format(nr=star_r['name'], n=star_s['name'], xl=star_t['x'], xr=star_r['x'],
yl=star_t['y'], yr=star_r['y'],
ml=star_t['m'], mr=star_r['m'],
- dx=(star_t['x'] - star_r['x']) * 1e3,
+ dx=(star_t['x'] - star_r['x']) * 1e3,
dy=(star_t['y'] - star_r['y']) * 1e3,
dm=(star_t['m'] - star_r['m']),
xo=star_s['x'], yo=star_s['y'], mo=star_s['m']))
-
- idx_lis, idx_ref, dr, dm = match.match(star_list_T['x'], star_list_T['y'], star_list_T['m'],
- ref_list['x'], ref_list['y'], ref_list['m'],
- dr_tol=dr_tol, dm_tol=dm_tol, verbose=self.verbose)
-
+
+ idx_lis, idx_ref, dr, dm = match.match(
+ star_list_T['x'], star_list_T['y'], star_list_T['m'],
+ ref_list['x'], ref_list['y'], ref_list['m'],
+ dr_tol=dr_tol, dm_tol=dm_tol, workers=match_workers, verbose=self.verbose
+ )
+
if self.verbose > 1:
print( ' Match 2: After trans, found ', len(idx_lis), ' matches out of ', len(star_list_T),
'. If match count is low, check dr_tol, dm_tol.' )
## Make plot, if desired
- plots.trans_positions(ref_list, ref_list[idx_ref], star_list_T, star_list_T[idx_lis],
- fileName='ep{0}'.format(ii))
+ if self.save_path:
+ plot_path = os.path.join(self.save_path, 'transformation_plots', f'iter{nn}', f"Transformed_Positions_Starlist_{ii}_t_{list_epoch}.png")
+ plots.trans_positions(ref_list, ref_list[idx_ref], star_list_T, star_list_T[idx_lis], save_path=plot_path, show_plot=False)
### Update the observed (but transformed) values in the reference table.
self.update_ref_table_from_list(star_list, star_list_T, ii, idx_ref, idx_lis, idx2)
-
+
### Update the "average" values to be used as the reference frame for the next list.
- if self.update_ref_orig != 'periter':
- self.update_ref_table_aggregates()
+ keep_ref_orig = (self.update_ref_orig==False) or (self.update_ref_orig=='atend') or (self.update_ref_orig=='periter' and ii<(len(self.star_lists) - 1))
+ if keep_ref_orig and ii < (len(self.star_lists) - 1):
+ keep_orig = self.ref_table['ref_orig'] | (~np.isfinite(self.ref_table['x'][:,ii]))
+ elif keep_ref_orig:
+ keep_orig = self.ref_table['ref_orig']
+ elif ii < (len(self.star_lists) - 1):
+ keep_orig = ~np.isfinite(self.ref_table['x'][:,ii])
+ else:
+ keep_orig=None
+ self.update_ref_table_aggregates(keep_orig=keep_orig, processes=processes, chunksize=chunksize, mp_star_threshold=mp_star_threshold)
+
+ # Update ref list polygon
+ if self.starlist_vertices is not None:
+ self.reflist_polygon = shapely.make_valid(self.reflist_polygon.union(shapely.Polygon(self.starlist_vertices[ii])))
# Print out some metrics
if self.verbose > 0:
msg1 = ' {0:2s} (mean and std) for {1:10s}: {2:8.5f} +/- {3:8.5f}'
- print(' Residuals: ')
+ print(' Residuals: ')
print(msg1.format('dr', 'all stars', dr.mean(), dr.std()))
- print(msg1.format('dm', 'all stars', dm.mean(), dm.std()))
+ print(msg1.format('dm', 'all stars', dm.mean(), dm.std())) # ref_list - ref_table
# Calculate the residuals just for those used in the transformation
- used = np.where(self.ref_table['used_in_trans'][:, ii] == True)[0]
- used_good = used[ np.where(np.isin(used, idx_ref) == True)[0] ]
-
- dr_u = np.hypot(self.ref_table['x'][used_good, ii] - ref_list['x'][used_good],
- self.ref_table['y'][used_good, ii] - ref_list['y'][used_good])
- dm_u = np.abs(self.ref_table['m'][used_good, ii] - ref_list['m'][used_good])
+ used = np.where(self.ref_table['used_in_trans'][:, ii])[0]
+ used_good = used[np.isin(used, idx_ref)]
+
+ dr_u = np.hypot(ref_list['x'][used_good] - self.ref_table['x'][used_good, ii],
+ ref_list['y'][used_good] - self.ref_table['y'][used_good, ii])
+ dm_u = ref_list['m'][used_good] - self.ref_table['m'][used_good, ii]
print(msg1.format('dr', 'trans stars', dr_u.mean(), dr_u.std()))
print(msg1.format('dm', 'trans stars', dm_u.mean(), dm_u.std()))
print(' Used {0:d} trans ref stars.'.format(len(used)))
print(' Dropped {0:d} matches after transform.'.format(len(used) - len(used_good)))
+ gc.collect() # clean up memory after each iteration
+
+ # Save ref_table after each iteration
+ # print(f"Saving self after iteration {ii=}")
+ # if self.save_path:
+ # with open(os.path.join(self.save_path, f"{self.prefix_name}_iter.pkl"), 'wb') as file:
+ # pickle.dump(self, file)
return
-
+
def setup_trans_info(self):
""" Setup transformation info into a usable format.
@@ -584,9 +935,9 @@ def setup_trans_info(self):
trans_args = self.trans_args
N_lists = len(self.star_lists)
iters = self.iters
-
+
trans_list = [None for ii in range(N_lists)]
- if trans_input != None:
+ if trans_input is not None:
trans_list = [trans_input[ii] for ii in range(N_lists)]
# Keep a list of trans_args, one for each starlist. If only
@@ -600,33 +951,42 @@ def setup_trans_info(self):
# Add inverse trans list, if desired
if self.calc_trans_inverse:
- trans_list_inverse = [None for ii in range(N_lists)]
+ trans_list_inverse = [None] * N_lists
self.trans_list_inverse = trans_list_inverse
return
def setup_ref_table_from_starlist(self, star_list):
- """
+ """
Start with the reference list.... this will change and grow
over time, so make a copy that we will keep updating.
- The reference table will contain one columne for every named
+ The reference table will contain one column for every named
array in the original reference star list.
"""
col_arrays = {}
+
+ motion_model_col_names = motion_model.all_motion_model_param_names(with_errors=True, with_fixed=True) + ['m0','m0_err','use_in_trans', 'motion_model_input', 'motion_model_used']
for col_name in star_list.colnames:
if col_name == 'name':
# The "name" column will be 1D; but we will also add a "name_in_list" column.
col_arrays['name'] = star_list[col_name].data
new_col_name = "name_in_list"
+ elif col_name == 'n_detect' and self.inherit_n_detect:
+ # Don't let this collide with the 1D 'n_detect' aggregate
+ # that update_n_detect() computes -- store this starlist's
+ # own per-star detection count (e.g. from a previous,
+ # lower-level align pass) under its per-list name instead,
+ # same as every other list-column.
+ new_col_name = 'n_detect_list'
else:
new_col_name = col_name
- # Make every column's 2D arrays except "name" and those
+ # Make every column's 2D arrays per star except "name" and those
# columns used for the motion model.
if col_name in motion_model_col_names:
col_arrays[new_col_name] = star_list[col_name].data
else:
- new_col_data = np.array([star_list[col_name].data]).T
+ new_col_data = star_list[col_name].data[:, np.newaxis]
col_arrays[new_col_name] = new_col_data
# Use the columns from the ref list to make the ref_table.
@@ -634,11 +994,9 @@ def setup_ref_table_from_starlist(self, star_list):
# Make new columns to hold original values. These will be copies
# of the old columns and will only include x, y, m, xe, ye, me.
- # The columns we have already created will hold transformed values.
+ # The columns we have already created will hold transformed values.
trans_col_names = ['x', 'y', 'm', 'xe', 'ye', 'me', 'w']
- for tt in range(len(trans_col_names)):
- old_name = trans_col_names[tt]
-
+ for old_name in trans_col_names:
if old_name in ref_table.colnames:
new_col = ref_table[old_name].copy()
new_col.name = old_name + '_orig'
@@ -646,104 +1004,120 @@ def setup_ref_table_from_starlist(self, star_list):
# Make sure ref_table has the necessary x0, y0, m0 and associated
# error columns. If they don't exist, then add them as a copy of
- # the original x,y,m etc columns.
+ # the original x,y,m etc columns.
new_cols_arr = ['x0', 'y0', 'm0']
orig_cols_arr = ['x', 'y', 'm']
ref_cols = ref_table.keys()
- for ii in range(len(new_cols_arr)):
- if not new_cols_arr[ii] in ref_cols:
+ for new_col, orig_col in zip(new_cols_arr, orig_cols_arr):
+ if new_col not in ref_cols:
# Some munging to convert data shape from (N,1) to (N,),
# since these are all 1D cols
- vals = np.transpose(np.array(ref_table[orig_cols_arr[ii]]))[0]
+ vals = np.array(ref_table[orig_col]).flatten()
# Now add to ref_table
- new_col = Column(vals, name=new_cols_arr[ii])
- ref_table.add_column(new_col)
+ ref_table.add_column(vals, name=new_col)
# Do the same thing for the x0e, y0e, m0e columns, but
# ONLY IF THEY ALREADY EXIST IN REF_TABLE! Otherwise,
# just fill these tables with zeros. We need something
# in these columns in order for the error propagation to
# work later on.
- new_err_cols = ['x0e', 'y0e', 'm0e']
+ new_err_cols = ['x0_err', 'y0_err', 'm0_err']
orig_err_cols = ['xe', 'ye', 'me']
- for ii in range(len(new_err_cols)):
+ for new_err_col, orig_err_col in zip(new_err_cols, orig_err_cols):
# If the orig col name (e.g. xe) is in the ref_table, but the new col name
# (e.g. x0e) doesn't exist, then add the x0e column as a duplicate of xe.
- if (orig_err_cols[ii] in ref_cols) & (not new_err_cols[ii] in ref_cols):
+ if (orig_err_col in ref_cols) and (new_err_col not in ref_cols):
# Some munging to convert data shape from (N,1) to (N,),
# since these are all 1D cols
- vals = np.transpose(np.array(ref_table[orig_err_cols[ii]]))[0]
-
+ vals = np.transpose(np.array(ref_table[orig_err_col]))[0]
# Now add to ref_table
- new_col = Column(vals, name=new_err_cols[ii])
- ref_table.add_column(new_col)
- elif (not orig_err_cols[ii] in ref_cols) & (not new_err_cols[ii] in ref_cols):
+ ref_table.add_column(vals, name=new_err_col)
+ elif (orig_err_col not in ref_cols) and (new_err_col not in ref_cols):
# If neither the orig_err_col or new_err_col is in the ref_table, put in the
# new_err_cols as an array of zeros
vals = np.zeros(len(ref_table))
- new_col = Column(vals, name=new_err_cols[ii])
- ref_table.add_column(new_col)
+ ref_table.add_column(vals, name=new_err_col)
# Final check: ref_table should now have x0, y0, m0, x0e, y0e, and m0e columns
# This is necessary for later steps, even if the columns are just zeros.
final_new_cols = np.concatenate((new_cols_arr, new_err_cols))
for ii in final_new_cols:
- assert ii in ref_table.keys()
-
+ assert ii in ref_table.keys(), f"ref_table is missing necessary column {ii}."
+
# Make sure we have a column to indicate whether each star
# CAN BE USED in the transformation. This will be 1D
if 'use_in_trans' not in ref_table.colnames:
- new_col = Column(np.ones(len(ref_table), dtype=bool), name='use_in_trans')
- ref_table.add_column(new_col)
+ ref_table.add_column(np.ones(len(ref_table), dtype=bool), name='use_in_trans')
# Make sure we have a column to indicate whether each star
# IS USED in the transformation. This will be 2D
if 'used_in_trans' not in ref_table.colnames:
- new_col = Column(np.zeros([len(ref_table),1], dtype=bool), name='used_in_trans')
- ref_table.add_column(new_col)
-
+ ref_table.add_column(np.zeros([len(ref_table), 1], dtype=bool), name='used_in_trans')
+
# Keep track of whether this is an original reference star.
- col_ref_orig = Column(np.ones(len(ref_table), dtype=bool), name='ref_orig')
- ref_table.add_column(col_ref_orig)
+ ref_table.add_column(np.ones(len(ref_table), dtype=bool), name='ref_orig')
+
+ # Make sure we have a per-list column to track each starlist's
+ # detection-count contribution, even if this particular (seed)
+ # starlist doesn't provide its own 'n_detect' -- a later starlist
+ # in the mosaic still might, and copy_over_values needs somewhere
+ # to write it. Gets reset to invalid below like any other 2D
+ # column, then correctly (re)populated once this starlist goes
+ # through its own match/copy_over_values pass.
+ if self.inherit_n_detect and 'n_detect_list' not in ref_table.colnames:
+ ref_table.add_column(np.zeros((len(ref_table), 1), dtype=int), name='n_detect_list')
# Now reset the original values to invalids... they will be filled in
# at later times. Preserve content only in the columns: name, x0, y0, m0 (and 0e).
# Note that these are all the 1D columsn.
for col_name in ref_table.colnames:
if len(ref_table[col_name].data.shape) == 2: # Find the 2D columns
- ref_table._set_invalid_list_values(col_name, -1)
+ if col_name in ['xe', 'ye', 'me']:
+ ref_table[col_name][:, -1] = np.inf
+ else:
+ ref_table._set_invalid_list_values(col_name, -1)
+
+ if 'motion_model_input' not in ref_table.colnames:
+ ref_table.add_column(np.repeat(self.motion_models[-1].name, len(ref_table)), name='motion_model_input')
+
+ # Add time column if it doesn't exist
+ if 't' not in ref_table.colnames:
+ ref_table.add_column(np.full((len(ref_table), 1), np.nan), name='t')
return ref_table
def apply_mag_lim_via_use_in_trans(self, ref_list, ref_mag_lim):
- """Set the use_in_trans flag to False for any star in the
- star list that falls beyond the magnitude limits.
+ """Set the use_in_trans flag to False for any star in the
+ star list that falls beyond the magnitude limits.
This should really only be applied to reference star lists.
"""
- if ((ref_mag_lim is not None) and (ref_mag_lim[0] is not None)):
+ if ref_mag_lim is not None:
# Support 'm0' (primary) or 'm' column name.
if 'm0' in ref_list.colnames:
mcol = 'm0'
else:
mcol = 'm'
- no_use = np.where((ref_list[mcol] < ref_mag_lim[0]) |
- (ref_list[mcol] >= ref_mag_lim[1]))
+ # NaN comparisons are always False, so a star with a non-finite
+ # magnitude (e.g. no usable 'me' to weight it by) would otherwise
+ # never get excluded by the range check below and would flood
+ # into use_in_trans with an unknown magnitude.
+ no_use = ~np.isfinite(ref_list[mcol]) | (ref_list[mcol] < ref_mag_lim[0]) | (ref_list[mcol] >= ref_mag_lim[1])
ref_list['use_in_trans'][no_use] = False
-
+
return
def outlier_rejection_indices(self, star_list, ref_list, outlier_tol, verbose=True):
"""
Determine the outliers based on the residual positions between two different
- starlists and some threshold (in sigma). Return the indices of the stars
- to keep (that shouldn't be rejected as outliers).
+ starlists and some threshold (in sigma). Return the indices of the stars
+ to keep (that shouldn't be rejected as outliers).
Note that we assume that the star_list and ref_list are already transformed and
- matched.
+ matched.
Parameters
----------
@@ -754,8 +1128,8 @@ def outlier_rejection_indices(self, star_list, ref_list, outlier_tol, verbose=Tr
starlist with 'x0', 'y0'
outlier_tol : float
- Number of sigma inside which we keep stars and outside of which we
- reject stars as outliers.
+ Number of sigma inside which we keep stars and outside of which we
+ reject stars as outliers.
Optional Parameters
--------------------
@@ -763,8 +1137,8 @@ def outlier_rejection_indices(self, star_list, ref_list, outlier_tol, verbose=Tr
Returns
----------
- keepers : nd.array
- The indicies of the stars to keep.
+ keepers : boolean array
+ The boolean array of the stars to keep.
"""
# Optionally propogate the reference positions forward in time.
xref = ref_list['x']
@@ -776,11 +1150,11 @@ def outlier_rejection_indices(self, star_list, ref_list, outlier_tol, verbose=Tr
resid_on_old_trans = np.hypot(x_resid_on_old_trans, y_resid_on_old_trans)
threshold = np.median(resid_on_old_trans) + (outlier_tol * resid_on_old_trans.std())
- keepers = np.where(resid_on_old_trans < threshold)[0]
+ keepers = resid_on_old_trans < threshold
if verbose:
msg = ' Outlier Rejection: Keeping {0:d} of {1:d}'
- print(msg.format(len(keepers), len(resid_on_old_trans)))
+ print(msg.format(sum(keepers), len(resid_on_old_trans)))
return keepers
@@ -789,7 +1163,7 @@ def update_ref_table_from_list(self, star_list, star_list_T, ii, idx_ref, idx_li
Inputs
----------
star_list : StarList
- The original star list.
+ The original star list.
star_list_T : StarList
The original star list now transformed into the reference coordinate system.
@@ -804,105 +1178,211 @@ def update_ref_table_from_list(self, star_list, star_list_T, ii, idx_ref, idx_li
The indices of the matched targets in the origin starlist (epoch).
idx_ref_in_trans : np.array dtype=int
- The indices in the reference table (self.ref_table).
+ The indices in the reference table (self.ref_table).
"""
### Update the reference table for matched stars.
# Add the matched stars to the reference table.
# For every epoch except the reference, we need to add a starlist.
+
if ((self.ref_table['x'].shape[1] != len(self.star_lists)) and
(ii != self.ref_index) and
(ii >= self.ref_table['x'].shape[1])):
-
- self.ref_table.add_starlist()
-
+ # This call only grows the table by one blank list-column --
+ # copy_over_values() below fills in the real x/y/m/etc data for
+ # it. list_times is tracked as per-list meta, not a column, and
+ # add_starlist() has no value for it to give here -- but that's
+ # fine, since fit() unconditionally rebuilds the whole list_times
+ # array from self.star_lists every iteration (a few lines below
+ # match_and_transform's return), superseding whatever this call
+ # would set anyway. Silence the "missing" warning rather than
+ # compute a value here just to have it immediately overwritten.
+ self.ref_table.add_starlist(warn_missing_meta=False)
+
copy_over_values(self.ref_table, star_list, star_list_T, ii, idx_ref, idx_lis)
self.ref_table['used_in_trans'][idx_ref_in_trans, ii] = True
### Add the unmatched stars and grow the size of the reference table.
- self.ref_table, idx_lis_new, idx_ref_new = add_rows_for_new_stars(self.ref_table, star_list, idx_lis)
+ self.ref_table, idx_lis_new, idx_ref_new = add_rows_for_new_stars(
+ self.ref_table,
+ star_list,
+ idx_lis,
+ # motion_model_name=self.motion_model_for_new_star.name
+ motion_model_name=self.motion_models[-1].name,
+ fixed_params_dict=self.fixed_params_dict
+ )
+
if len(idx_ref_new) > 0:
if self.verbose > 0:
print(' Adding {0:d} new stars to the reference table.'.format(len(idx_ref_new)))
-
+
copy_over_values(self.ref_table, star_list, star_list_T, ii, idx_ref_new, idx_lis_new)
# Copy the single-epoch values to the aggregate (only for new stars).
self.ref_table['x0'][idx_ref_new] = star_list_T['x'][idx_lis_new]
self.ref_table['y0'][idx_ref_new] = star_list_T['y'][idx_lis_new]
self.ref_table['m0'][idx_ref_new] = star_list_T['m'][idx_lis_new]
-
+
self.ref_table['name'] = update_old_and_new_names(self.ref_table, ii, idx_ref_new)
if self.use_ref_new == True:
self.ref_table['use_in_trans'][idx_ref_new] = True
else:
self.ref_table['use_in_trans'][idx_ref_new] = False
-
+
return
-
- def update_ref_table_aggregates(self, n_boot=0, weighting='var', use_scipy=True, absolute_sigma=False, show_progress=True):
- """
- Average positions or fit velocities.
+
+ def update_ref_table_aggregates(self, keep_orig=None, n_boot=0, seed=None, processes=1, chunksize=None, mp_star_threshold=100_000):
+ """ Average positions or fit velocities.
Average magnitudes.
Calculate bootstrap errors if desired.
- Update the use_in_trans values as needed.
+ Update the use_in_trans values as needed. TODO: ????.
Updates aggregate columns in self.ref_table in place.
+
+
+ Parameters
+ ----------
+ keep_orig : array-like of bool, optional
+ Boolean array indicating which stars to keep original values for, by default None
+ n_boot : int, optional
+ Number of bootstrap iterations, by default 0
+ seed : int, optional
+ Random seed for reproducible bootstrap results, by default None
+
"""
# Keep track of the original reference values.
# In certain cases, we will NOT update these.
- if not self.update_ref_orig:
- ref_orig_idx = np.where(self.ref_table['ref_orig'] == True)[0]
- x0_orig = self.ref_table['x0'][ref_orig_idx]
- y0_orig = self.ref_table['y0'][ref_orig_idx]
- m0_orig = self.ref_table['m0'][ref_orig_idx]
- x0e_orig = self.ref_table['x0e'][ref_orig_idx]
- y0e_orig = self.ref_table['y0e'][ref_orig_idx]
- m0e_orig = self.ref_table['m0e'][ref_orig_idx]
-
- if self.use_vel:
- vx_orig = self.ref_table['vx'][ref_orig_idx]
- vy_orig = self.ref_table['vy'][ref_orig_idx]
- vxe_orig = self.ref_table['vxe'][ref_orig_idx]
- vye_orig = self.ref_table['vye'][ref_orig_idx]
- t0_orig = self.ref_table['t0'][ref_orig_idx]
-
- if self.use_vel:
- # Combine positions with a velocity fit.
- self.ref_table.fit_velocities(weighting=weighting, use_scipy=use_scipy, absolute_sigma=absolute_sigma, bootstrap=n_boot, verbose=self.verbose, show_progress=show_progress)
-
+ if (keep_orig is not None) and (np.count_nonzero(keep_orig) > 0):
+ vals_orig = {}
+ vals_orig['m0'] = self.ref_table['m0'][keep_orig]
+ vals_orig['m0_err'] = self.ref_table['m0_err'][keep_orig]
+ # Collect all motion model parameter names
+ motion_model_class_names = []
+ if 'motion_model_input' in self.ref_table.keys():
+ motion_model_class_names += self.ref_table['motion_model_input'].tolist()
+ if 'motion_model_used' in self.ref_table.keys():
+ motion_model_class_names += self.ref_table['motion_model_used'][keep_orig].tolist()
+ vals_orig['motion_model_used'] = self.ref_table['motion_model_used'][keep_orig]
+ vals_orig['n_params'] = self.ref_table['n_params'][keep_orig]
+ motion_model_col_names = motion_model.motion_model_param_names(motion_model_class_names, with_errors=True, with_fixed=True)
+ for mm in motion_model_col_names:
+ if f'{mm}_mm' in self.ref_table.keys():
+ vals_orig[mm] = self.ref_table[mm][keep_orig]
+ elif mm in self.ref_table.keys():
+ vals_orig[mm] = self.ref_table[mm][keep_orig]
+ fit_star_idxs = ~keep_orig
+ else:
+ fit_star_idxs = None
+
+ weighted_xy = ('xe' in self.ref_table.colnames) and ('ye' in self.ref_table.colnames)
+ weighted_m = ('me' in self.ref_table.colnames)
+
+ # Route each star to the fastest applicable fitting path instead of
+ # an all-or-nothing check on the *requested* motion_model_input. A
+ # star with at most 1 valid (finite x, y, xe, ye) epoch can only
+ # ever qualify for the Empty or Fixed motion models -- and
+ # combine_lists_xym already produces identical output for both (0
+ # valid epochs -> nan/inf, matching Empty; >=1 -> weighted average,
+ # matching Fixed) -- so it's safe to route those stars straight to
+ # the fast vectorized combine_lists_xym, regardless of whether
+ # *other* stars need something more complex. This is a conservative
+ # (never-wrong) check: the raw count here is always >= the
+ # deduplicated-unique-times count fit_motion_models itself uses, so
+ # a star this flags as "<=1" can never actually qualify for a model
+ # needing more. Only stars with >=2 valid epochs (which MIGHT
+ # qualify for Linear/Parallax/etc, depending on
+ # self.motion_models/fixed_params_dict) go through
+ # fit_motion_models's fuller (and more expensive) classification.
+ # Previously, a single star needing something other than Fixed
+ # forced ALL stars -- including a huge Fixed/Empty majority -- through
+ # the slower fit_motion_models.
+ valid_epoch = np.isfinite(self.ref_table['x']) & np.isfinite(self.ref_table['y'])
+ if weighted_xy:
+ valid_epoch &= np.isfinite(self.ref_table['xe']) & np.isfinite(self.ref_table['ye'])
+ guaranteed_simple = valid_epoch.sum(axis=1) <= 1
+
+ if weighted_xy:
+ # fit_motion_models falls back to a unit weight (xe=ye=1) for a
+ # star whose xe/ye are invalid (or ~0) across *every* epoch, so
+ # it still gets a position instead of being dropped -- mirrored
+ # here from startables.py's fill_with_one logic. combine_lists
+ # has no such fallback and would produce nan/inf for these
+ # stars instead of the same weighted-by-1 result, so keep them
+ # out of the "simple" bucket and let fit_motion_models handle
+ # them regardless of how few epochs they have.
+ xe_bad = ~np.isfinite(self.ref_table['xe']) | np.isclose(self.ref_table['xe'], 0)
+ ye_bad = ~np.isfinite(self.ref_table['ye']) | np.isclose(self.ref_table['ye'], 0)
+ needs_error_fallback = xe_bad.all(axis=1) & ye_bad.all(axis=1)
+ guaranteed_simple &= ~needs_error_fallback
+
+ need_update = fit_star_idxs if fit_star_idxs is not None else np.ones(len(self.ref_table), dtype=bool)
+ simple_idxs = guaranteed_simple & need_update
+ complex_idxs = (~guaranteed_simple) & need_update
+
+ if np.any(simple_idxs):
+ # Only (re)average the rows that actually changed this round
+ # (fit_star_idxs) -- for a mosaic that keeps growing across many
+ # starlists, recomputing every already-settled row every time
+ # this is called would make the total cost grow quadratically in
+ # the number of starlists.
+ if self.verbose > 0:
+ print(f'Fixed/Empty motion model: combining lists for {np.count_nonzero(simple_idxs)} stars.')
+ self.ref_table.combine_lists_xym(weighted_xy=weighted_xy, weighted_m=weighted_m, select_stars=simple_idxs)
+
+ if np.any(complex_idxs):
+ self.ref_table.fit_motion_models(
+ motion_models=self.motion_models,
+ fixed_params_dict=self.fixed_params_dict,
+ weighting=self.vel_weighting,
+ use_scipy=self.use_scipy,
+ absolute_sigma=self.absolute_sigma,
+ method=self.scipy_method,
+ select_stars=complex_idxs,
+ bootstrap=n_boot,
+ seed=seed,
+ processes=processes,
+ chunksize=chunksize,
+ mp_star_threshold=mp_star_threshold,
+ verbose=self.verbose
+ )
# Combine (transformed) magnitudes
if 'me' in self.ref_table.colnames:
- weights_col = None
- else:
weights_col = 'me'
-
- self.ref_table.combine_lists('m', weights_col=weights_col, ismag=True)
+ else:
+ weights_col = None
+ self.ref_table.combine_lists('m', weights_col=weights_col, ismag=True, select_stars=complex_idxs)
+
+ # if (keep_orig is not None) and (sum(keep_orig) > 0):
+ # Determine motion_model_used for keep_orig stars
+ # Filter possible motion models based on available columns
+ # Only take the selective path if these columns already exist -- on
+ # the very first call they don't, so every row needs a value
+ # regardless of fit_star_idxs.
+ mm_cols_exist = ('motion_model_used' in self.ref_table.colnames) and ('n_params' in self.ref_table.colnames)
+ if (fit_star_idxs is not None) and mm_cols_exist:
+ # As above: only re-classify the rows that changed this round.
+ motion_model_used_new, n_params_new = determine_motion_models(
+ self.ref_table[fit_star_idxs], self.motion_models, self.fixed_params_dict, processes, chunksize, self.verbose > 0
+ )
+ motion_model_used = np.array(self.ref_table['motion_model_used'], dtype=object)
+ n_params = np.array(self.ref_table['n_params'])
+ motion_model_used[fit_star_idxs] = motion_model_used_new
+ n_params[fit_star_idxs] = n_params_new
else:
- weighted_xy = ('xe' in self.ref_table.colnames) and ('ye' in self.ref_table.colnames)
- weighted_m = ('me' in self.ref_table.colnames)
-
- self.ref_table.combine_lists_xym(weighted_xy=weighted_xy, weighted_m=weighted_m)
+ motion_model_used, n_params = determine_motion_models(self.ref_table, self.motion_models, self.fixed_params_dict, processes, chunksize, self.verbose > 0)
+
+ # Assign the determined motion models
+ self.ref_table['motion_model_used'] = Column(motion_model_used, name='motion_model_used', dtype='U20')
+ self.ref_table['n_params'] = Column(n_params, name='n_params', dtype=int)
# Replace the originals if we are supposed to keep them fixed.
- if not self.update_ref_orig:
- self.ref_table['x0'][ref_orig_idx] = x0_orig
- self.ref_table['y0'][ref_orig_idx] = y0_orig
- self.ref_table['m0'][ref_orig_idx] = m0_orig
- self.ref_table['x0e'][ref_orig_idx] = x0e_orig
- self.ref_table['y0e'][ref_orig_idx] = y0e_orig
- self.ref_table['m0e'][ref_orig_idx] = m0e_orig
-
- if self.use_vel:
- self.ref_table['vx'][ref_orig_idx] = vx_orig
- self.ref_table['vy'][ref_orig_idx] = vy_orig
- self.ref_table['vxe'][ref_orig_idx] = vxe_orig
- self.ref_table['vye'][ref_orig_idx] = vye_orig
- self.ref_table['t0'][ref_orig_idx] = t0_orig
+ if (keep_orig is not None) and (np.count_nonzero(keep_orig) > 0):
+ for val in vals_orig.keys():
+ self.ref_table[val][keep_orig] = vals_orig[val]
return
-
+
def get_weights_for_lists(self, ref_list, star_list):
if 'xe' in ref_list.colnames:
var_xref = ref_list['xe']**2
@@ -910,7 +1390,7 @@ def get_weights_for_lists(self, ref_list, star_list):
else:
var_xref = 0.0
var_yref = 0.0
-
+
if 'xe' in star_list.colnames:
var_xlis = star_list['xe']**2
var_ylis = star_list['ye']**2
@@ -918,19 +1398,24 @@ def get_weights_for_lists(self, ref_list, star_list):
var_xlis = 0.0
var_ylis = 0.0
- if self.weights != None:
- if self.weights == 'both,var':
- weight = 1.0 / (var_xref + var_xlis + var_yref + var_ylis)
- if self.weights == 'both,std':
- weight = 1.0 / np.sqrt(var_xref + var_xlis + var_yref + var_ylis)
- if self.weights == 'ref,var':
- weight = 1.0 / (var_xref + var_yref)
- if self.weights == 'ref,std':
- weight = 1.0 / np.sqrt(var_xref + var_yref)
- if self.weights == 'list,var':
- weight = 1.0 / (var_xlis + var_ylis)
- if self.weights == 'list,std':
- weight = 1.0 / np.sqrt(var_xlis, var_ylis)
+ if self.trans_weighting is not None:
+ # A star with zero variance here (e.g. xe=ye=0) deliberately
+ # produces inf, which the isfinite check right below this block
+ # already catches and zeroes out -- this is expected, not a bug,
+ # so silence the warning numpy would otherwise raise for it.
+ with np.errstate(divide='ignore'):
+ if self.trans_weighting == 'both,var':
+ weight = 1.0 / (var_xref + var_xlis + var_yref + var_ylis)
+ if self.trans_weighting == 'both,std':
+ weight = 1.0 / np.sqrt(var_xref + var_xlis + var_yref + var_ylis)
+ if self.trans_weighting == 'ref,var':
+ weight = 1.0 / (var_xref + var_yref)
+ if self.trans_weighting == 'ref,std':
+ weight = 1.0 / np.sqrt(var_xref + var_yref)
+ if self.trans_weighting == 'list,var':
+ weight = 1.0 / (var_xlis + var_ylis)
+ if self.trans_weighting == 'list,std':
+ weight = 1.0 / np.sqrt(var_xlis + var_ylis)
else:
weight = None
@@ -940,8 +1425,8 @@ def get_weights_for_lists(self, ref_list, star_list):
weight = None
if weight is not None:
- bad = np.where(np.isfinite(weight) == False)[0]
- if len(bad) == len(weight):
+ bad = np.isfinite(weight) == False
+ if sum(bad) == len(weight):
# Catch the case where we had no positional errors at all...
# The fit should be unweighted.
weight = None
@@ -949,46 +1434,58 @@ def get_weights_for_lists(self, ref_list, star_list):
# Fix bad weights:
weight[bad] = 0.0
+ if weight is not None and np.all(weight == 0.0):
+ # Catch the case where all weights were bad.
+ weight = None
+
return weight
-
- def match_lists(self, dr_tol, dm_tol):
+
+ def match_lists(self, dr_tol, dm_tol, workers=1):
"""
Using the existing trans objects, match all the starlists to the
- reference starlist (self.ref_table), propogated to the appropriate epoch.
+ reference starlist (self.ref_table), propogated to the appropriate epoch.
No trimming of stars.
- No new transformations derived.
+ No new transformations derived.
The resulting matched values will be used to update self.ref_table
+
+ Parameters
+ ----------
+ workers : int, optional
+ Number of worker threads scipy uses for the KDTree neighbor search
+ inside match.match(). By default 1. See MosaicSelfRef.fit for details.
"""
for ii in range(self.N_lists):
# Apply the XY transformation to a new copy of the starlist and
# do one final match between the two (now transformed) lists.
- star_list_T = copy.deepcopy(self.star_lists[ii])
+ star_list_T = StarList(self.star_lists[ii], copy=True)
if self.mag_trans:
star_list_T.transform_xym(self.trans_list[ii])
else:
star_list_T.transform_xy(self.trans_list[ii])
-
- xref, yref = get_pos_at_time(star_list_T['t'][0], self.ref_table, use_vel=self.use_vel) # optional velocity propogation.
+
+ xref, yref = infer_positions(star_list_T.meta['list_time'], self.ref_table, self.motion_models, self.fixed_params_dict)
mref = self.ref_table['m0']
idx_lis, idx_ref, dr, dm = match.match(star_list_T['x'], star_list_T['y'], star_list_T['m'],
xref, yref, mref,
- dr_tol=dr_tol, dm_tol=dm_tol, verbose=self.verbose)
+ dr_tol=dr_tol, dm_tol=dm_tol, workers=workers,
+ verbose=self.verbose)
+
if self.verbose > 0:
- fmt = 'Matched {0:5d} out of {1:5d} stars in list {2:2d} [dr = {3:7.4f} +/- {4:6.4f}, dm = {5:5.2f} +/- {6:4.2f}'
+ fmt = 'Matched {0:5d} out of {1:5d} stars in list {2:2d} [dr = {3:7.4f} ± {4:6.4f}, dm = {5:5.2f} ± {6:4.2f}]'
print(fmt.format(len(idx_lis), len(star_list_T), ii, dr.mean(), dr.std(), dm.mean(), dm.std()))
copy_over_values(self.ref_table, self.star_lists[ii], star_list_T, ii, idx_ref, idx_lis)
return
- def get_ref_list_from_table(self, epoch):
+ def get_ref_list_from_table(self, epoch, processes=1, chunksize=None):
"""
Convert the averaged quantites in self.ref_table into a StarList object
- appropriate for the specified epoch.
+ appropriate for the specified epoch.
Columns in resulting reference list will include:
name
@@ -1000,39 +1497,21 @@ def get_ref_list_from_table(self, epoch):
me (optional)
use_in_trans (optional)
"""
- # Reference stars will be named.
+ # Reference stars will be named.
name = self.ref_table['name']
+ # Calculate x, y, xe, ye
- if self.use_vel and ('vx' in self.ref_table.colnames):
- # First check if we should use velocities and if they exist.
- dt = epoch - self.ref_table['t0']
- x = self.ref_table['x0'] + (self.ref_table['vx'] * dt)
- y = self.ref_table['y0'] + (self.ref_table['vy'] * dt)
-
- xe = np.hypot(self.ref_table['x0e'], self.ref_table['vxe']*dt)
- ye = np.hypot(self.ref_table['y0e'], self.ref_table['vye']*dt)
-
- idx = np.where(np.isfinite(self.ref_table['vx']) == False)[0]
- x[idx] = self.ref_table['x0'][idx]
- y[idx] = self.ref_table['y0'][idx]
- xe[idx] = self.ref_table['x0e'][idx]
- ye[idx] = self.ref_table['y0e'][idx]
- else:
- # No velocities... just used average positions.
- x = self.ref_table['x0']
- y = self.ref_table['y0']
-
- if 'x0e' in self.ref_table.colnames:
- xe = self.ref_table['x0e']
- ye = self.ref_table['y0e']
- else:
- xe = None
- ye = None
+ if 'motion_model_used' not in self.ref_table.colnames:
+ motion_model_used, n_params = determine_motion_models(self.ref_table, self.motion_models, self.fixed_params_dict, processes, chunksize, self.verbose > 0)
+ self.ref_table['motion_model_used'] = Column(motion_model_used, name='motion_model_used', dtype='U20')
+ self.ref_table['n_params'] = Column(n_params, name='n_params', dtype=int)
+
+ x, y, xe, ye = self.ref_table.infer_positions(epoch, fixed_params_dict=self.fixed_params_dict)
m = self.ref_table['m0']
-
- if 'm0e' in self.ref_table.colnames:
- me = self.ref_table['m0e']
+
+ if 'm0_err' in self.ref_table.colnames:
+ me = self.ref_table['m0_err']
else:
me = None
@@ -1060,32 +1539,32 @@ def reset_ref_values(self, exclude=None):
"""
Reset all the 2D arrays in the reference table. This is the action
we take at the beginning of each new iteration. We don't preserve matching
- results from the prior iterations.
+ results from the prior iterations.
"""
# All 2D columns should be reset.
for col_name in self.ref_table.colnames:
- if (exclude != None) and (col_name in exclude):
+ if (exclude is not None) and (col_name in exclude):
continue
-
+
if len(self.ref_table[col_name].data.shape) == 2: # Find the 2D columns
# Loop through epochs for this array.
for cc in range(self.ref_table[col_name].shape[1]):
self.ref_table._set_invalid_list_values(col_name, cc)
return
-
- def calc_bootstrap_errors(self, n_boot=100, boot_epochs_min=-1, calc_vel_in_bootstrap=True, weighting='var', use_scipy=True, absolute_sigma=False, show_progress=True):
+
+ def calc_bootstrap_errors(self, n_boot=100, seed=None, boot_epochs_min=-1, calc_vel_in_bootstrap=True, update_errors=False, processes=1, chunksize=None, mp_star_threshold=100_000, verbose=True):
"""
Function to calculate bootstrap errors for the transformations as well
as the proper motions. For each iteration, this will:
- 1) Draw full-size bootstrap w/replacement sample from reference stars in
+ 1) Draw full-size bootstrap w/replacement sample from reference stars in
ref_table and re-calculate the transformations for each epoch
2) Apply transformation to all stars in each epoch
- If calc_vel_in_bootstraps:
+ If calc_vel_in_bootstrap:
3) For each star, draw full-size boostrap sample w/replacement from epochs
4) Calculate proper motion for each star using resampled epochs
-
+
The saved outputs will be: x_trans, y_trans, m_trans (transformed postions/mags),
as well as the proper motion fit parameters.
@@ -1095,155 +1574,183 @@ def calc_bootstrap_errors(self, n_boot=100, boot_epochs_min=-1, calc_vel_in_boot
Parameters:
----------
- mosaic_object: MosaicToRef object
+ mosaic_object : MosaicToRef object
MosaicToRef object after the complete match_and_transform process
- n_boot: int, must be greater than 0
- Number of bootstrap iterations when calculating transformations and the proper motion.
- PM bootstrap is only done for final proper motion
- calculation (e.g., not for each iteration of the starlist for matching)
+ n_boot : int, optional
+ Number of bootstrap iterations when calculating transformations and the proper motion.
+ PM bootstrap is only done for final proper motion calculation
+ (e.g., not for each iteration of the starlist for matching), by default 100
+
+ seed : int, optional
+ Random seed for reproducible bootstrap results.
- boot_epochs_min: int or -1
- In order to be included in bootstrap analysis, non-reference stars must be detected in
- at least boot_epochs_min epochs. If boot_epochs_min = -1, then all stars will
+ boot_epochs_min : int, optional
+ In order to be included in bootstrap analysis, non-reference stars must be detected in
+ at least boot_epochs_min epochs. If boot_epochs_min = -1, then all stars will
be included in the analysis, regardless of the number of epochs detected.
- For stars that fail boot_epochs_min criteria, np.nan is used
+ For stars that fail boot_epochs_min criteria, np.nan is used, by default -1
- calc_vel_in_bootstrap: boolean
- If true, do bootstrap sample w/ replacement over the epochs and calculate
+ calc_vel_in_bootstrap : boolean, optional
+ If true, do bootstrap sample w/ replacement over the epochs and calculate
stellar proper motions, as well as the bootstrap over reference stars
- to calculate positional alignment errors. If false, only
- calculate position alignment errors.
-
- weighting: str
- 'var' or 'std' weighting for velocity fitting, by default 'var'. If 'var', use the variance of the residuals to weight the fit.
- If 'std', use the standard deviation of the residuals to weight the fit.
-
- use_scipy: boolean
- If True, use scipy.optimize.curve_fit to fit the velocity. If False, use flystar.fit_velocity.linear_fit, by default True.
-
- absolute_sigma: boolean
- If True, use the absolute sigma in the velocity fitting. If False, use the relative sigma, by default False.
-
-
+ to calculate positional alignment errors. If false, only
+ calculate position alignment errors, by default True
+
+ update_errors : boolean
+ If True, save the starlist errors as xe_list, bootstrap errors as xe_boot, and their quad sum as xe (and likewise for ye and me). If False (default), leave the starlist errors in place as xe and bootstrap errors as xe_boot.
+
+ processes : int, optional
+ Number of processes to use for parallel processing, maximum os.cpu_count(), by default 1 (no multiprocessing)
+
+ chunksize : int, optional
+ Chunk size for multiprocessing, by default None (auto)
+
+ verbose : boolean, optional
+ Print verbose information or not, by default True
+
Output:
------
- Seven new columns will be added to self.ref_table:
+ New columns will be added to self.ref_table:
'xe_boot', 2D column: bootstrap x pos uncertainties due to transformation for each epoch
'ye_boot', 2D column: bootstrap y pos uncertainties due to transformation for each epoch
'me_boot', 2D column: bootstrap mag uncertainties due to transformation for each epoch
-
+
If calc_vel_in_bootstrap:
- 'x0e_boot', 1D column: bootstrap uncertainties in x0 for PM fit
- 'y0e_boot', 1D column: bootstrap uncertainties in y0 for PM fit
- 'vxe_boot', 1D column: bootstrap uncertainties in vx for PM fit
- 'vye_boot', 1D column: bootstrap uncertainties in vy for PM fit
+ '_err_boot', 1D column: bootstrap uncertainties in for motion model fit
For stars that fail boot_epochs_min criteria, np.nan is used
"""
# First, assert than n_boot > 0
- assert n_boot > 0
+ assert n_boot > 0, f'{n_boot=} is not possive!'
- ref_table = copy.deepcopy(self.ref_table)
+ ref_table = StarTable(self.ref_table, copy=True)
n_epochs = len(ref_table['x'][0])
- t_arr = get_all_epochs(ref_table)
- #t_arr = ref_table['t'][np.where(ref_table['n_detect'] == np.max(ref_table['n_detect']))[0][0]]
+ t_arr = np.array(ref_table.meta['list_times'])
t0_arr = ref_table['t0']
# Identify reference stars. If desired, trim ref_table to only stars to only
# reference stars and those that pass boot_epochs_min criteria
if boot_epochs_min > 0:
- idx_good = np.where( (ref_table['n_detect'] >= boot_epochs_min) | (ref_table['use_in_trans']) )
+ idx_good = (ref_table['n_detect'] >= boot_epochs_min) | (ref_table['use_in_trans'])
ref_table = ref_table[idx_good]
t0_arr = t0_arr[idx_good]
else:
- idx_good = np.arange(0, len(ref_table), 1)
- idx_ref = np.where(ref_table['use_in_trans'] == True)
-
- # Initialize output arrays
- x_trans_arr = np.ones((len(ref_table['x']), n_boot, n_epochs)) * -999
- y_trans_arr = np.ones((len(ref_table['x']), n_boot, n_epochs)) * -999
- m_trans_arr = np.ones((len(ref_table['x']), n_boot, n_epochs)) * -999
- xe_trans_arr = np.ones((len(ref_table['x']), n_boot, n_epochs)) * -999
- ye_trans_arr = np.ones((len(ref_table['x']), n_boot, n_epochs)) * -999
- me_trans_arr = np.ones((len(ref_table['x']), n_boot, n_epochs)) * -999
+ idx_good = np.ones(len(ref_table), dtype=bool)
+
+ # Initialize sums for output
+ x_boot_sum = np.zeros((len(ref_table['x']), n_epochs))
+ x2_boot_sum = np.zeros((len(ref_table['x']), n_epochs))
+ y_boot_sum = np.zeros((len(ref_table['x']), n_epochs))
+ y2_boot_sum = np.zeros((len(ref_table['x']), n_epochs))
+ m_boot_sum = np.zeros((len(ref_table['x']), n_epochs))
+ m2_boot_sum = np.zeros((len(ref_table['x']), n_epochs))
+
+ # Set up motion model parameters
+ if 'motion_model_used' in ref_table.keys():
+ motion_model_list = np.unique(ref_table['motion_model_used']).tolist()
+ elif 'motion_model_input' in ref_table.keys():
+ motion_model_list = np.unique(ref_table['motion_model_input']).tolist()
+
+ if 'Empty' not in motion_model_list:
+ motion_model_list.append('Empty')
+ if 'Fixed' not in motion_model_list:
+ motion_model_list.append('Fixed')
+
+ motion_col_list = motion_model.motion_model_param_names(motion_model_list, with_errors=False, with_fixed=False)
if calc_vel_in_bootstrap:
- x0_arr = np.ones((len(ref_table['x']), n_boot)) * -999
- y0_arr = np.ones((len(ref_table['x']), n_boot)) * -999
- vx_arr = np.ones((len(ref_table['x']), n_boot)) * -999
- vy_arr = np.ones((len(ref_table['x']), n_boot)) * -999
+ motion_boot_sum = {}
+ motion2_boot_sum = {}
+ for col in motion_col_list:
+ motion_boot_sum[col] = np.zeros((len(ref_table['x'])))
+ motion2_boot_sum[col] = np.zeros((len(ref_table['x'])))
+
+ all_mm_map = motion_model.motion_model_map()
+ motion_model_list = [all_mm_map[mm_name] for mm_name in motion_model_list]
+ motion_boot_min_epochs = np.max([mm.n_params for mm in motion_model_list])
### IF MEMORY PROBLEMS HERE:
### DEFINE MEAN, STD VARIABLES AND BUILD THEM RATHER THAN SAVING FULL ARRAY
### DECREASE PRECISION ON ARRAYS (32 bit instead of 64: dtype=np.float32)
### AT SOME POINT, NEED TO CONVERT BACK (LOOK UP HOW TO DO THIS CAREFULLY)
- t1 = time.time()
- for ii in range(n_boot):
+ rng = np.random.default_rng(seed)
+ for ii in tqdm(range(n_boot), desc='Bootstrap iterations', disable=not verbose):
# Recalculate transformations using bootstrap sample of
# reference stars. Use a loop for each epoch here, so we
# can handle case where different reference stars are used
# in different epochs
+
+ # Initialize data arrays
+ x_trans_arr = np.ones((len(ref_table['x']), n_epochs)) * -999
+ y_trans_arr = np.ones((len(ref_table['x']), n_epochs)) * -999
+ m_trans_arr = np.ones((len(ref_table['x']), n_epochs)) * -999
+ xe_trans_arr = np.ones((len(ref_table['x']), n_epochs)) * -999
+ ye_trans_arr = np.ones((len(ref_table['x']), n_epochs)) * -999
+ me_trans_arr = np.ones((len(ref_table['x']), n_epochs)) * -999
+
for jj in range(n_epochs):
- # Extract bootstrap sample of matched reference stars, using only ref stars
- # used in this epoch
- good = np.where( (ref_table['used_in_trans'][idx_ref][:,jj] == True) &
- (~np.isnan(ref_table['x_orig'][idx_ref][:,jj])) )
- #good = np.where(~np.isnan(ref_table['x_orig'][idx_ref][:,jj]))
- samp_idx = np.random.choice(good[0], len(good[0]), replace=True)
-
+ # Extract bootstrap sample of matched reference stars for this epoch
+ good = np.where((ref_table['used_in_trans'][:,jj] == True) & (~np.isnan(ref_table['x_orig'][:,jj])))[0]
+ samp_idx = rng.choice(good, len(good), replace=True)
+
# Get reference star positions in particular epoch from ref_list.
t_epoch = t_arr[jj]
- ref_orig = self.get_ref_list_from_table(t_epoch)
-
- # Get idx of reference stars in bootstrap sample in the ref_orig.
- # Then, use these to build reference starlist for the alignment
- idx_tmp = []
- for ff in range(len(samp_idx)):
- name_tmp = ref_table['name'][samp_idx[ff]]
- foo = np.where(ref_orig['name'] == name_tmp)[0][0]
- idx_tmp.append(foo)
-
- ref_boot = StarList(name=ref_orig['name'][idx_tmp],
- x=ref_orig['x'][idx_tmp],
- y=ref_orig['y'][idx_tmp],
- m=ref_orig['m'][idx_tmp],
- xe=ref_orig['xe'][idx_tmp],
- ye=ref_orig['ye'][idx_tmp],
- me=ref_orig['me'][idx_tmp])
+ ref_orig = self.get_ref_list_from_table(t_epoch, processes=processes, chunksize=chunksize)[idx_good]
+
+ ## Get idx of reference stars in bootstrap sample in the ref_orig.
+ ## Then, use these to build reference starlist for the alignment
+ #idx_tmp = []
+ #for ff in range(len(samp_idx)):
+ # name_tmp = ref_table['name'][idx_ref][samp_idx[ff]]
+ # foo = np.where(ref_orig['name'] == name_tmp)[0][0]
+ # idx_tmp.append(foo)
+
+ ref_boot = StarList(name=ref_orig['name'][samp_idx],
+ x=ref_orig['x'][samp_idx],
+ y=ref_orig['y'][samp_idx],
+ m=ref_orig['m'][samp_idx],
+ xe=ref_orig['xe'][samp_idx],
+ ye=ref_orig['ye'][samp_idx],
+ me=ref_orig['me'][samp_idx])
# Now build star list with original positions of the reference stars
# in the bootstrap sample
- starlist_boot = StarList(name=ref_table['name'][idx_ref][samp_idx],
- x=ref_table['x_orig'][:,jj][idx_ref][samp_idx],
- y=ref_table['y_orig'][:,jj][idx_ref][samp_idx],
- m=ref_table['m_orig'][:,jj][idx_ref][samp_idx],
- xe=ref_table['xe_orig'][:,jj][idx_ref][samp_idx],
- ye=ref_table['ye_orig'][:,jj][idx_ref][samp_idx],
- me=ref_table['me_orig'][:,jj][idx_ref][samp_idx])
-
+ starlist_boot = StarList(name=ref_table['name'][samp_idx],
+ x=ref_table['x_orig'][:,jj][samp_idx],
+ y=ref_table['y_orig'][:,jj][samp_idx],
+ m=ref_table['m_orig'][:,jj][samp_idx],
+ xe=ref_table['xe_orig'][:,jj][samp_idx],
+ ye=ref_table['ye_orig'][:,jj][samp_idx],
+ me=ref_table['me_orig'][:,jj][samp_idx])
+
+ # Sanity check: makes sure names match between ref_boot and starlist_boot,
+ # since they need to line up
+ assert np.all(ref_boot['name'] == starlist_boot['name'])
+
# Calculate weights based on weights keyword. If weights desired, will need to
# make starlist objects for this
- if self.weights != None:
+ if self.trans_weighting is not None:
# In order for weights calculation to work, we need to apply a transformation
# to the star_list_T so it is in the same units as ref_boot. So, we'll apply
# the final transformation for the epoch to get close enough for the
# purposes of the bootstrap calculation
- starlist_boot_T = copy.deepcopy(starlist_boot)
+ starlist_boot_T = StarList(starlist_boot, copy=True)
if self.mag_trans:
starlist_boot_T.transform_xym(self.trans_list[jj])
else:
starlist_boot_T.transform_xy(self.trans_list[jj])
-
+
weight = self.get_weights_for_lists(ref_boot, starlist_boot_T)
else:
weight = None
-
+
# Recalculate transformation
trans = self.trans_class.derive_transform(starlist_boot['x'], starlist_boot['y'],
ref_boot['x'], ref_boot['y'],
self.trans_args[0]['order'],
m=starlist_boot['m'], mref=ref_boot['m'],
weights=weight, mag_trans=self.mag_trans)
+ #print(jj)
# Apply transformation to *all* orig positions in this epoch. Need to make a new
# FLYSTAR starlist object with the original positions for this. We don't
@@ -1255,54 +1762,82 @@ def calc_bootstrap_errors(self, n_boot=100, boot_epochs_min=-1, calc_vel_in_boot
xe=ref_table['xe_orig'][:,jj],
ye=ref_table['ye_orig'][:,jj],
me=ref_table['me_orig'][:,jj])
- starlist_T = copy.deepcopy(starlist)
+ starlist_T = StarList(starlist, copy=True)
if self.mag_trans:
starlist_T.transform_xym(trans)
else:
starlist_T.transform_xy(trans)
-
+
# Add output to pos arrays
- x_trans_arr[:,ii,jj] = starlist_T['x']
- y_trans_arr[:,ii,jj] = starlist_T['y']
- m_trans_arr[:,ii,jj] = starlist_T['m']
- xe_trans_arr[:,ii,jj] = starlist_T['xe']
- ye_trans_arr[:,ii,jj] = starlist_T['ye']
- me_trans_arr[:,ii,jj] = starlist_T['me']
-
- t2 = time.time()
+ x_trans_arr[:,jj] = starlist_T['x']
+ y_trans_arr[:,jj] = starlist_T['y']
+ m_trans_arr[:,jj] = starlist_T['m']
+ xe_trans_arr[:,jj] = starlist_T['xe']
+ ye_trans_arr[:,jj] = starlist_T['ye']
+ me_trans_arr[:,jj] = starlist_T['me']
+
+ x_boot_sum += x_trans_arr
+ x2_boot_sum += x_trans_arr**2
+ y_boot_sum += y_trans_arr
+ y2_boot_sum += y_trans_arr**2
+ if self.mag_trans:
+ m_boot_sum += m_trans_arr
+ m2_boot_sum += m_trans_arr**2
+
+ # t2 = time.time()
#print('=================================================')
#print('Time to do {0} epochs: {1}s'.format(n_epochs, t2-t1))
#print('=================================================')
-
+
# Finally, calculate proper motions for this bootstrap iteration
# for each star, if desired. Draw a full-sample bootstrap over the epochs
# for each star, and then run it through the startable fit_velocities machinery
if calc_vel_in_bootstrap:
- boot_idx = np.random.choice(np.arange(0, n_epochs, 1), size=n_epochs)
+ boot_idx = rng.choice(np.arange(0, n_epochs, 1), size=n_epochs)
+ while len(np.unique(boot_idx)) < motion_boot_min_epochs:
+ boot_idx = rng.choice(np.arange(0, n_epochs, 1), size=n_epochs)
t_boot = t_arr[boot_idx]
-
+
star_table = StarTable(name=ref_table['name'],
- x=x_trans_arr[:,ii,boot_idx],
- y=y_trans_arr[:,ii,boot_idx],
- m=m_trans_arr[:,ii,boot_idx],
- xe=xe_trans_arr[:,ii,boot_idx],
- ye=ye_trans_arr[:,ii,boot_idx],
- me=me_trans_arr[:,ii,boot_idx],
- t=np.tile(t_boot, (len(ref_table),1)) )
+ x=x_trans_arr[:,boot_idx],
+ y=y_trans_arr[:,boot_idx],
+ m=m_trans_arr[:,boot_idx],
+ xe=xe_trans_arr[:,boot_idx],
+ ye=ye_trans_arr[:,boot_idx],
+ me=me_trans_arr[:,boot_idx],
+ t=np.tile(t_boot, (len(ref_table),1)))
+ if 'motion_model_used' in ref_table.columns:
+ star_table['motion_model_input'] = ref_table['motion_model_used']
# Now, do proper motion calculation, making sure to fix t0 to the
# orig value (so we can get a reasonable error on x0, y0)
- star_table.fit_velocities(weighting=weighting, use_scipy=use_scipy, absolute_sigma=absolute_sigma, fixed_t0=t0_arr, show_progress=show_progress)
+ if self.fixed_params_dict is None:
+ fixed_params_dict = {'t0': t0_arr}
+ elif 't0' not in self.fixed_params_dict.keys():
+ fixed_params_dict = self.fixed_params_dict.copy()
+ fixed_params_dict['t0'] = t0_arr
+
+ star_table.fit_motion_models(
+ motion_models=self.motion_models,
+ fixed_params_dict=fixed_params_dict,
+ weighting=self.vel_weighting,
+ use_scipy=self.use_scipy,
+ absolute_sigma=self.absolute_sigma,
+ method=self.scipy_method,
+ processes=processes,
+ chunksize=chunksize,
+ mp_star_threshold=mp_star_threshold,
+ verbose=False
+ )
# Save proper motion fit results to output arrays
- x0_arr[:,ii] = star_table['x0']
- y0_arr[:,ii] = star_table['y0']
- vx_arr[:,ii] = star_table['vx']
- vy_arr[:,ii] = star_table['vy']
+ for col in motion_col_list:
+ motion_boot_sum[col] += star_table[col]
+ motion2_boot_sum[col] += star_table[col]**2
# Quick check to make sure bootstrap calc was valid: output t0 should be
# same as input t0_arr, since we used fixed_t0 option
- assert np.sum(abs(star_table['t0'] - t0_arr) == 0)
+ np.testing.assert_array_equal(star_table['t0'], t0_arr)
#t3 = time.time()
#print('=================================================')
@@ -1310,75 +1845,154 @@ def calc_bootstrap_errors(self, n_boot=100, boot_epochs_min=-1, calc_vel_in_boot
#print('=================================================')
# Calculate the bootstrap error values.
- x_err_b = np.std(x_trans_arr, ddof=1, axis=1)
- y_err_b = np.std(y_trans_arr, ddof=1, axis=1)
- m_err_b = np.std(m_trans_arr, ddof=1, axis=1)
-
+ x_boot_mean = x_boot_sum/n_boot
+ x_err_b = np.sqrt((x2_boot_sum - 2*x_boot_mean*x_boot_sum + n_boot*x_boot_mean**2)/n_boot)
+ y_boot_mean = y_boot_sum/n_boot
+ y_err_b = np.sqrt((y2_boot_sum - 2*y_boot_mean*y_boot_sum + n_boot*y_boot_mean**2)/n_boot)
+ m_boot_mean = m_boot_sum/n_boot
+ m_err_b = np.sqrt((m2_boot_sum - 2*m_boot_mean*m_boot_sum + n_boot*m_boot_mean**2)/n_boot)
+
+ motion_data_err = {}
if calc_vel_in_bootstrap:
- x0_err_b = np.std(x0_arr, ddof=1, axis=1)
- y0_err_b = np.std(y0_arr, ddof=1, axis=1)
- vx_err_b = np.std(vx_arr, ddof=1, axis=1)
- vy_err_b = np.std(vy_arr, ddof=1, axis=1)
+ for col in motion_col_list:
+ mot_boot_mean = motion_boot_sum[col]/n_boot
+ motion_data_err[col] = np.sqrt((motion2_boot_sum[col] -
+ 2*mot_boot_mean*motion_boot_sum[col] + n_boot*mot_boot_mean**2)/n_boot)
else:
- x0_err_b = np.nan
- y0_err_b = np.nan
- vx_err_b = np.nan
- vy_err_b = np.nan
+ for col in motion_col_list:
+ motion_data_err[col] = np.nan
# Add summary statistics to *original* ref_table, i.e. ref_table
# hanging off of mosaic object.
col_heads_2D = ['xe_boot', 'ye_boot', 'me_boot']
- data_dict = {'xe_boot': x_err_b, 'ye_boot': y_err_b, 'me_boot': m_err_b,
- 'x0e_boot': x0_err_b, 'y0e_boot': y0_err_b,
- 'vxe_boot': vx_err_b, 'vye_boot': vy_err_b}
-
+ data_dict = {'xe_boot': x_err_b, 'ye_boot': y_err_b, 'me_boot': m_err_b}
+ for col in motion_col_list:
+ data_dict[col+'_err_boot'] = motion_data_err[col]
+
for ff in col_heads_2D:
col = Column(np.ones((len(self.ref_table), n_epochs)), name=ff)
col.fill(np.nan)
-
+
col[idx_good] = data_dict[ff]
self.ref_table.add_column(col)
+ # # Calculate chi^2 with bootstrap positional errors
+ # # Determine which motion model to use:
+ # motion_model_list = sorted(motion_model_list, key=lambda mm: mm.n_params)
+ # mm_n_params = np.sort([mm.n_params for mm in motion_model_list])
+
+ # required_params = [all_mm_map[mm_name].n_params for mm_name in self.ref_table['motion_model_input']]
+ # mm_digitized = np.digitize(
+ # x=np.minimum(np.array(self.ref_table['n_detect']), required_params),
+ # bins=mm_n_params
+ # ) - 1
+ # self.ref_table['motion_model_used'] = np.array([motion_model_list[d].name for d in mm_digitized], dtype='U20')
+
+
+ x_pred, y_pred, _, _ = self.ref_table.infer_positions(t_arr, fixed_params_dict=self.fixed_params_dict)
+ if np.ndim(x_pred) == 1:
+ x_pred = x_pred[:, np.newaxis]
+ if np.ndim(y_pred) == 1:
+ y_pred = y_pred[:, np.newaxis]
+ xe_comb = np.hypot(self.ref_table['xe'], self.ref_table['xe_boot'])
+ ye_comb = np.hypot(self.ref_table['ye'], self.ref_table['ye_boot'])
+ data_dict['chi2_x_boot'] = np.nansum((self.ref_table['x'] - x_pred)**2 / xe_comb**2, axis=1)
+ data_dict['chi2_y_boot'] = np.nansum((self.ref_table['y'] - y_pred)**2 / ye_comb**2, axis=1)
+ for ff in ['chi2_x_boot', 'chi2_y_boot']:
+ col = Column(np.ones(len(self.ref_table)), name=ff)
+ col.fill(np.nan)
+
+ col[idx_good] = data_dict[ff][idx_good]
+ self.ref_table.add_column(col)
+
# Now handle the velocities, if they were calculated
if calc_vel_in_bootstrap:
- col_heads_1D = [ 'x0e_boot', 'y0e_boot', 'vxe_boot', 'vye_boot']
-
+ col_heads_1D = [col+'_err_boot' for col in motion_col_list]
+
for ff in col_heads_1D:
col = Column(np.ones(len(self.ref_table)), name=ff)
col.fill(np.nan)
-
+
col[idx_good] = data_dict[ff]
self.ref_table.add_column(col)
- print('===============================')
- print('Done with bootstrap')
- print('===============================')
-
+ if verbose:
+ print('===================================')
+ print('======= Done with bootstrap =======')
+ print('===================================')
+
+ if update_errors:
+ self.ref_table['xe_list'] = self.ref_table['xe']
+ self.ref_table['ye_list'] = self.ref_table['ye']
+ self.ref_table['me_list'] = self.ref_table['me']
+ self.ref_table['xe'] = np.hypot(self.ref_table['xe_list'], self.ref_table['xe_boot'])
+ self.ref_table['ye'] = np.hypot(self.ref_table['ye_list'], self.ref_table['ye_boot'])
+ self.ref_table['me'] = np.hypot(self.ref_table['me_list'], self.ref_table['me_boot'])
+ print("Saved starlist errors to xe_list and added xe_boot to xe in quadrature.")
+ print("The same was done for ye and me.")
+
+ if self.save_path is not None:
+ suppress_meta_warnings(self.ref_table)
+ with open(os.path.join(self.save_path, self.prefix_name+'_bootstrap.pkl'), 'wb') as file:
+ pickle.dump(self, file)
+ with open(os.path.join(self.save_path, self.prefix_name+'_ref_table_bootstrap.pkl'), 'wb') as file:
+ pickle.dump(self.ref_table, file)
+ self.save_path = os.path.join(self.save_path, self.prefix_name+'_ref_table_bootstrap.fits')
+
return
-
+
class MosaicToRef(MosaicSelfRef):
- def __init__(self, ref_list, list_of_starlists, iters=2,
- dr_tol=[1, 1], dm_tol=[2, 1],
- outlier_tol=[None, None],
- trans_args=[{'order': 2}, {'order': 2}],
- init_order=1,
- mag_trans=True, mag_lim=None, ref_mag_lim=None,
- weights=None,
- trans_input=None,
- trans_class=transforms.PolyTransform,
- calc_trans_inverse=False,
- use_ref_new=False,
- use_vel=False, update_ref_orig=False,
- init_guess_mode='miracle',
- iter_callback=None,
- verbose=True):
+ def __init__(
+ self,
+ ref_list,
+ list_of_starlists,
+ reflist_vertex=None,
+ starlist_vertices=None,
+ # Alignment parameters
+ iters=1,
+ dr_tol=[1.],
+ dm_tol=[1.],
+ outlier_tol=None,
+ # Reference behavior (MosiacToRef specific)
+ use_ref_new=False,
+ update_ref_orig=False,
+ # Transformation parameters
+ trans_class=transforms.PolyTransform,
+ trans_args=[{'order': 1}],
+ trans_input=None,
+ trans_weights=None,
+ init_order=1,
+ init_guess_mode='miracle',
+ briteN=None,
+ calc_trans_inverse=False,
+ # Magnitude parameters
+ mag_trans=True,
+ mag_lim=None,
+ ref_mag_lim=None,
+ # Motion model parameters
+ motion_models=['Empty', 'Fixed'],
+ fixed_params_dict=None,
+ vel_weights='var',
+ use_scipy=True,
+ absolute_sigma=True,
+ scipy_method=None,
+ # Advanced options
+ inherit_n_detect=True,
+ iter_callback=None,
+ save_path=None,
+ prefix_name='mtr',
+ verbose=True
+ ):
"""
Required Parameters
- ----------
+ -------------------
ref_list : StarList object
- Can optionally have velocities. All starlists will be aligned to this one.
+ All starlists will be aligned to this one.
+ Must have columns (x, y, m, xe, ye, me) or (x0, y0, m0, x0_err, y0_err, m0_err).
+ May have t or t0 columns.
+ May have motion model parameters
list_of_starlists : array of StarList objects
An array or list of flystar.starlists.StarList objects (which are Astropy Tables).
@@ -1387,20 +2001,28 @@ def __init__(self, ref_list, list_of_starlists, iters=2,
Note that there is an optional weights column called 'w'. If this column exists
in any of the lists, it will be queried to determine if an individual star can be
used to derive the transformations between starlists. This is the most flexible way
- to allow you to determine, as a function of time and star, which ones are good enough
- in the transformation. Note that just because it can be used (i.e. w_in=1),
- doesn't meant that it will be used. The mag limits and outliers still take precedence.
- Note also that the weights that go into the transformation are
+ to allow you to determine, as a function of time and star, which ones are good enough
+ in the transformation. Note that just because it can be used (i.e. w_in=1),
+ doesn't meant that it will be used. The mag limits and outliers still take precedence.
+ Note also that the weights that go into the transformation are
star_list['w'] * ref_list['w'] * weight_from_keyword (see the weights parameter)
- for those stars not trimmed out by the other criteria.
+ for those stars not trimmed out by the other criteria.
Optional Parameters
----------
+ reflist_vertex : array
+ An array of polygon vertices coordinates for the reference starlist. Initial guess will only use stars in overlapping regions defined by these polygons.
+ Shape of (N_vertices, 2) in the format of [[x1, y1], [x2, y2], ..., [xN, yN]] for the reference starlist, by default None
+
+ starlist_vertices : list or array
+ A list or array of polygon vertices coordinates for each starlist. Initial guess will only use stars in overlapping regions defined by these polygons.
+ Shape of (N_lists, N_vertices, 2) in the format of [[x1, y1], [x2, y2], ..., [xN, yN]] for each starlist, by default None
+
iters : int
- The number of iterations used in the matching and transformation. TO DO: INNER/OUTER?
+ The number of iterations used in the matching and transformation. TO DO: INNER/OUTER?
dr_tol : list or array
The delta-radius (dr) tolerance for matching in units of the reference coordinate system.
@@ -1408,172 +2030,253 @@ def __init__(self, ref_list, list_of_starlists, iters=2,
dm_tol : list or array
The delta-magnitude (dm) tolerance for matching in units of the reference coordinate system.
- This is a list of dm values, one for each iteration of matching/transformation.
+ This is a list of dm values, one for each iteration of matching/transformation.
outlier_tol : list or array
- The outlier tolerance (in units of sigma) for rejecting outlier stars.
+ The outlier tolerance (in units of sigma) for rejecting outlier stars.
This is a list of tol values, one for each iteration of matching/transformation.
- mag_trans : boolean
- If true, this will also calculate and (temporarily) apply a zeropoint offset to
- magnitudes in each list to bring them into a common magnitude system. This is
- essential for matching (with finite dm_tol) starlists of different filters or
- starlists that are not photometrically calibrated. Note that the final_table columns
- of 'm', 'm0', and 'm0e' will contain the transformed magnitudes while the
- final_table column 'm_orig' will contain the original un-transformed magnitudes.
- If mag_trans = False, then no such zeropoint offset it applied at any point.
-
- mag_lim : array
- If different from None, it indicates the minimum and maximum magnitude
- on the catalogs for finding the transformations. Note, if you want specify the mag_lim
- separately for each list and each iteration, you need to pass in a 2D array that
- has shape (N_lists, 2).
+ use_ref_new : boolean
+ Each pass, new stars are matched and added to the ref_table. However, we don't
+ necessarily want to use these in the reference frame in subsequent passes.
+ If True, then the new stars will be used in later passes/iterations.
+ If False, then the new stars will be carried, but not used in the transformation.
+ We determine which stars to use through setting a boolean use_in_trans flag.
- ref_mag_lim : array
- If different from None, it indicates the minimum and maximum magnitude
- on the reference catalog for finding the transformations.
+ update_ref_orig : boolean or str
+ Should we update the reference values (position, velocity, t0) after each starlist
+ is transformed in each iteration?
- weights : str
- Either None (def), 'both,var', 'list,var', or 'ref,var' depending on whether you want
- to weight by the positional uncertainties (variances) in the individual starlists, or also with
- the uncertainties in the reference frame itself. Note weighting only works when there
- are positional uncertainties availabe. Other options include 'both,std', 'list,std', 'list,var'.
+ False if you want to get into an absolute reference frame and are using Gaia data.
+ True if you want to use the reference list as more of an initial guess.
+ 'periter' if you want to align all the starlists, then calculate the velocity.
- trans_input : array or list of transform objects
- def = None. If not None, then this should contain an array or list of transform
- objects that will be used as the initial guess in the alignment and matching.
+ Note that this only impacts the stars that are in the original reference list... the
+ newly identified stars that end up in ref_table will always be updated; but not always
+ used for transformation fitting.
trans_class : transforms.Transform2D object (or subclass)
The transform class that will be used to when deriving the optimal
- transformation parameters between each list and the reference list.
+ transformation parameters between each list and the reference list.
trans_args : dictionary
- A dictionary (or a list of dictionaries) containing any extra keywords that are needed
- in the transformation object. For instance, "order". Note that if a list is passed in,
+ A dictionary (or a list of dictionaries) containing any extra keywords that are needed
+ in the transformation object. For instance, "order". Note that if a list is passed in,
then the transformation argument (i.e. order) will be changed for every iteration in
iters.
+ trans_input : array or list of transform objects
+ def = None. If not None, then this should contain an array or list of transform
+ objects that will be used as the initial guess in the alignment and matching.
+
+ trans_weights : str
+ Either None (def), 'both,var', 'list,var', or 'ref,var' depending on whether you want
+ to weight by the positional uncertainties (variances) in the individual starlists, or also with
+ the uncertainties in the reference frame itself. Note weighting only works when there
+ are positional uncertainties availabe. Other options include 'both,std', 'list,std', 'list,var'.
+
init_order: int
Polynomial transformation order to use for initial guess transformation.
Order=1 should be used in most cases, but sometimes higher order is needed
+ init_guess_mode : string
+ If no initial transformations are passed in via the trans_input keyword, then we have
+ to make the initial transformation and matching blindly. We can do this in a couple of
+ different ways. Options are 'miracle' or 'name' (see trans_initial_guess() for more details).
+
+ briteN : int
+ If init_guess_mode is 'miracle', this is the number of brightest stars to use in the miracle match.
+ Default is min(50, len(star_list)).
+
calc_trans_inverse: boolean
If true, then calculate the inverse transformation (from reference to starlist)
in addition to the normal transformation (from starlist to reference). The inverse
calculation is calculated by switching the order to the positions in match_and_transform.
The inverse transformations are saved in self.trans_list_inverse.
-
self.trans_list_inverse doesn't exist if calc_trans_inverse == False
- update_ref_orig : boolean or str
- Should we update the reference values (position, velocity, t0) after each starlist
- is transformed in each iteration?
+ mag_trans : boolean
+ If true, this will also calculate and (temporarily) apply a zeropoint offset to
+ magnitudes in each list to bring them into a common magnitude system. This is
+ essential for matching (with finite dm_tol) starlists of different filters or
+ starlists that are not photometrically calibrated. Note that the final_table columns
+ of 'm', 'm0', and 'm0_err' will contain the transformed magnitudes while the
+ final_table column 'm_orig' will contain the original un-transformed magnitudes.
+ If mag_trans = False, then no such zeropoint offset it applied at any point.
- False if you want to get into an absolute reference frame and are using Gaia data.
- True if you want to use the reference list as more of an initial guess.
- 'periter' if you want to align all the starlists, then calculate the velocity.
+ mag_lim : array
+ If different from None, it indicates the minimum and maximum magnitude
+ on the starlists for finding the transformations BEFORE mag trans.
+ Note, if you want specify the mag_lim separately for each list,
+ you need to pass in a 2D array that has shape (N_lists, 2).
- Note that this only impacts the stars that are in the original reference list... the
- newly identified stars that end up in ref_table will always be updated; but not always
- used for transformation fitting.
+ ref_mag_lim : array
+ If different from None, it indicates the minimum and maximum magnitude
+ on the reference catalog for finding the transformations.
- use_ref_new : boolean
- Each pass, new stars are matched and added to the ref_table. However, we don't
- necessarily want to use these in the reference frame in subsequent passes.
- If True, then the new stars will be used in later passes/iterations.
- If False, then the new stars will be carried, but not used in the transformation.
- We determine which stars to use through setting a boolean use_in_trans flag.
+ motion_models : list of str or MotionModel objects
+ List of motion model names (strings) or MotionModel objects to use
- use_vel : boolean
- If velocities are present in the reference list and use_vel == True, then during
- each iteration of the alignment, the reference list will be propogated in time
- using the velocity information. So all transformations will be derived w.r.t.
- the propogated positions. See also update_vel.
+ motion_model_for_new_star : str or MotionModel, optional
+ Motion model or its name for newly added stars in the ref table. Used in add_rows_for_new_stars().
+ If None, the most complex motion model in motion_models will be used, by default None.
- init_guess_mode : string
- If no initial transformations are passed in via the trans_input keyword, then we have
- to make the initial transformation and matching blindly. We can do this in a couple of
- different ways. Options are 'miracle' or 'name' (see trans_initial_guess() for more details).
+ fixed_params_dict : None or dict
+ Dictionary of fixed parameters for motion models
+
+ vel_weights : str
+ Either 'var' (def) or 'std', depending on whether you want to weight the motion model
+ fits by the variance or standard deviation of the position data
+
+ use_scipy : bool, optional
+ If True, use scipy.optimize.curve_fit for velocity fitting. If False, use linear algebra fitting, by default True.
+
+ absolute_sigma : bool, optional
+ If True, the velocity fit will use absolute errors in the data. If False, relative errors will be used, by default False.
+
+ scipy_method : str, optional
+ Method of scipy.curve_fit, {'lm', 'trf', 'dogbox'}, by default None
+
+ inherit_n_detect : bool, optional
+ If True, and an input starlist already has its own 'n_detect' column
+ (e.g. it is itself the output of a previous, lower-level align pass),
+ use that starlist's own n_detect value -- instead of counting 1 --
+ as the contribution from that starlist when computing this mosaic's
+ n_detect. So a star's final n_detect reflects the total number of
+ raw detections it represents, however many alignment layers deep.
+ Starlists without their own 'n_detect' still contribute 1 per
+ detection, same as when this is False. By default True.
iter_callback : None or function
A function to call (that accepts a StarTable object and an iteration number)
- at the end of every iteration. This can be used for plotting or printing state.
+ at the end of every iteration. This can be used for plotting or printing state.
+
+ save_path : str, optional
+ Path to save the MosaicToRef object as a pickle file.
+
+ verbose : bool or int (0 to 9, inclusive)
+ Controls the verbosity of print statements. (0 least, 9 most verbose).
+ For backwards compatibility, 0 = False, 9 = True.
+ (Note: technically right now no checks on whether the number is an integer or not...)
Example
- ----------
- msc = align.MosaicToRef(my_gaia, list_of_starlists, iters=1,
+ -------
+ mtr = align.MosaicToRef(my_gaia, list_of_starlists, iters=1,
dr_tol=[0.1], dm_tol=[5],
outlier_tol=[None], mag_lim=[13, 21],
trans_class=transforms.PolyTransform,
trans_args=[{'order': 1}],
- use_vel=True,
use_ref_new=False,
update_ref_orig=False,
mag_trans=False,
weights='both,std',
init_guess_mode='miracle', verbose=False)
- msc.fit()
+ mtr.fit()
# Access a list of all the transformation parameters:
- trans_list = msc.trans_list
+ trans_list = mtr.trans_list
# Access the fully-combined reference table.
- stars_table = msc.ref_table
+ stars_table = mtr.ref_table
# Plot the magnitude of the first star vs. time:
- # Overplot the mean magnitude.
+ # Overplot the mean magnitude.
plt.plot(stars_table['t'][0, :], stars_table['m'][0, :], 'k.')
- plt.axhline(stars_table['m0'][0])
+ plt.axhline(stars_table['m0'][0])
# Plot the X position of the first star vs. time:
# Overplot the best-fit proper motion.
times = stars_table['t'][0, :]
plt.errorbar(times, stars_table['x'][0, :], yerr=stars_table['xe'][0, :])
- plt.axhline(stars_table['x0'][0] + stars_table['vx'][0]*(times - stars_table['t0'][0]))
+ plt.axhline(stars_table['x0'][0] + stars_table['vx'][0]*(times - stars_table['t0'][0]))
"""
- super().__init__(list_of_starlists, ref_index=-1, iters=iters,
- dr_tol=dr_tol, dm_tol=dm_tol,
- outlier_tol=outlier_tol, trans_args=trans_args,
- init_order=init_order,
- mag_trans=mag_trans, mag_lim=mag_lim, weights=weights,
- trans_input=trans_input, trans_class=trans_class,
- calc_trans_inverse=calc_trans_inverse, use_vel=use_vel,
- init_guess_mode=init_guess_mode,
- iter_callback=iter_callback,
- verbose=verbose)
-
- self.ref_list = copy.deepcopy(ref_list)
+ super().__init__(
+ list_of_starlists,
+ # Alignment parameters
+ ref_index=-1,
+ dr_tol=dr_tol,
+ dm_tol=dm_tol,
+ outlier_tol=outlier_tol,
+ # Transformation parameters
+ trans_class=trans_class,
+ trans_args=trans_args,
+ trans_input=trans_input,
+ trans_weights=trans_weights,
+ init_order=init_order,
+ init_guess_mode=init_guess_mode,
+ briteN=briteN,
+ calc_trans_inverse=calc_trans_inverse,
+ # Magnitude parameters
+ mag_trans=mag_trans,
+ mag_lim=mag_lim,
+ # Motion model parameters
+ motion_models=motion_models,
+ # motion_model_for_new_star=motion_model_for_new_star,
+ fixed_params_dict=fixed_params_dict,
+ vel_weights=vel_weights,
+ use_scipy=use_scipy,
+ absolute_sigma=absolute_sigma,
+ scipy_method=scipy_method,
+ # Advanced options
+ inherit_n_detect=inherit_n_detect,
+ iter_callback=iter_callback,
+ save_path=save_path,
+ prefix_name=prefix_name,
+ verbose=verbose
+ )
+
+ self.starlist_vertices = starlist_vertices
+ self.ref_list = StarList(ref_list, copy=True)
self.ref_mag_lim = ref_mag_lim
self.update_ref_orig = update_ref_orig
self.use_ref_new = use_ref_new
+ if reflist_vertex is not None:
+ import shapely
+ self.reflist_polygon = shapely.make_valid(shapely.Polygon(reflist_vertex))
+ else:
+ self.reflist_polygon = None
+
+ # If motion_model_used in columns but params columns are missing, raise a warning and remove motion_model_used column to avoid confusion.
+ # if 'motion_model_used' in self.ref_list.colnames:
+ # motion_model_params = motion_model.motion_model_param_names(np.unique(self.ref_list['motion_model_used']), with_errors=False, with_fixed=True)
+ # missing_params = [param for param in motion_model_params if (param not in self.ref_list.colnames) and (f'{param}_err' not in self.ref_list.colnames) and (param not in self.fixed_params_dict.keys())]
+ # if len(missing_params) > 0:
+ # warnings.warn("Warning: 'motion_model_used' column found in ref_list, but the following motion model parameter columns are missing: " + ", ".join(missing_params) + ". Removing 'motion_model_used' column to avoid confusion.")
+ # self.ref_list.remove_column('motion_model_used')
+
+ # If motion_model_used in columns, remove it and raise a warning, since it will only be determined after the fit.
+ if 'motion_model_used' in self.ref_list.colnames:
+ warnings.warn("Warning: 'motion_model_used' column found in ref_list. This column will be determined after the fit, so it is being removed from the input ref_list to avoid confusion.")
+ self.ref_list.remove_column('motion_model_used')
+
# Do some temporary clean up of the reference list.
if ('x' not in self.ref_list.colnames) and ('x0' in self.ref_list.colnames):
self.ref_list['x'] = self.ref_list['x0']
self.ref_list['y'] = self.ref_list['y0']
- if ('xe' not in self.ref_list.colnames) and ('x0e' in self.ref_list.colnames):
- self.ref_list['xe'] = self.ref_list['x0e']
- self.ref_list['ye'] = self.ref_list['y0e']
+ if ('xe' not in self.ref_list.colnames) and ('x0_err' in self.ref_list.colnames):
+ self.ref_list['xe'] = self.ref_list['x0_err']
+ self.ref_list['ye'] = self.ref_list['y0_err']
if ('m' not in self.ref_list.colnames) and ('m0' in self.ref_list.colnames):
self.ref_list['m'] = self.ref_list['m0']
- if ('me' not in self.ref_list.colnames) and ('m0e' in self.ref_list.colnames):
- self.ref_list['me'] = self.ref_list['m0e']
+ if ('me' not in self.ref_list.colnames) and ('m0_err' in self.ref_list.colnames):
+ self.ref_list['me'] = self.ref_list['m0_err']
if ('t' not in self.ref_list.colnames) and ('t0' in self.ref_list.colnames):
self.ref_list['t'] = self.ref_list['t0']
return
-
- def fit(self):
+
+ def fit(self, processes=1, chunksize=None, match_workers=1, mp_star_threshold=100_000):
"""
Using the current parameter settings, match and transform all the lists
to a reference position. Note in the first pass, the reference position
is just the specified input reference starlist. In subsequent iterations,
- this is (optionally) updated.
+ this is (optionally) updated.
The ultimate outcome is the creation of self.ref_table. This reference
- table will contain "averaged" quantites as well as a big 2D array of all
- the matched original and transformed quantities.
+ table will contain "averaged" quantities as well as a big 2D array of all
+ the matched original and transformed quantities.
Averaged columns on ref_table:
x0
@@ -1582,34 +2285,72 @@ def fit(self):
x0e
y0e
m0e
- vx (only if use_vel=True)
- vy (only if use_vel=True)
- vxe (only if use_vel=True)
- vye (only if use_vel=True)
+ addl. motion_model parameters
+ Parameters
+ ----------
+ processes : int, optional
+ Number of processes to use for parallel processing, maximum os.cpu_count(), by default 1 (no multiprocessing)
+ chunksize : int, optional
+ Chunk size for multiprocessing, by default None (auto)
+ match_workers : int, optional
+ Number of worker threads scipy uses for the KDTree neighbor search inside
+ match.match(). Default is 1 (single-threaded), which is the safe choice on
+ shared/multi-tenant machines where grabbing all cores would step on other
+ users' jobs. Set to -1 to use all available CPU cores (measurably faster on
+ large starlists, with no change in matching results). See MosaicSelfRef.fit
+ for details.
+ mp_star_threshold : int, optional
+ Minimum number of stars actually requiring the per-star motion-model
+ fitting path before a multiprocessing Pool is used for fitting, even
+ if processes > 1. See StarTable.fit_motion_models for details.
+ By default 100_000.
"""
# Create a log file of the parameters used in the fit.
- with open('MosaicToRef_input_params.log', 'w',) as _log:
- logger(_log, 'Parameters used for fit: ', self.verbose)
- logger(_log, '------------------------- ', self.verbose)
- logger(_log, ' dr_tol = ' + str(self.dr_tol), self.verbose)
- logger(_log, ' dm_tol = ' + str(self.dm_tol), self.verbose)
- logger(_log, ' outlier_tol = ' + str(self.outlier_tol), self.verbose)
- logger(_log, ' trans_args = ' + str(self.trans_args), self.verbose)
- logger(_log, ' mag_trans = ' + str(self.mag_trans), self.verbose)
- logger(_log, ' mag_lim = ' + str(self.mag_lim), self.verbose)
- logger(_log, ' ref_mag_lim = ' + str(self.ref_mag_lim), self.verbose)
- logger(_log, ' weights = ' + str(self.weights), self.verbose)
- logger(_log, ' trans_input = ' + str(self.trans_input), self.verbose)
- logger(_log, ' trans_class = ' + str(self.trans_class), self.verbose)
- logger(_log, ' calc_trans_inverse = ' + str(self.calc_trans_inverse), self.verbose)
- logger(_log, ' use_ref_new = ' + str(self.use_ref_new), self.verbose)
- logger(_log, ' use_vel = ' + str(self.use_vel), self.verbose)
- logger(_log, ' update_ref_orig = ' + str(self.update_ref_orig), self.verbose)
- logger(_log, ' init_guess_mode = ' + str(self.init_guess_mode), self.verbose)
- logger(_log, ' iter_callback = ' + str(self.iter_callback), self.verbose)
- logger(_log, '-------------------------\n', self.verbose)
-
+ # Setup save_path:
+ if self.save_path:
+ if not os.path.exists(os.path.dirname(self.save_path)):
+ os.makedirs(os.path.dirname(self.save_path))
+
+ # Save input params
+ input_filename = f'{self.prefix_name}_input.txt'
+ input_dict = {
+ 'iters': self.iters,
+ 'dr_tol': self.dr_tol,
+ 'dm_tol': self.dm_tol,
+ 'outlier_tol': self.outlier_tol,
+ 'use_ref_new': self.use_ref_new,
+ 'update_ref_orig': self.update_ref_orig,
+ 'trans_class': self.trans_class,
+ 'trans_args': self.trans_args,
+ 'trans_input': self.trans_input,
+ 'trans_weights': self.trans_weighting,
+ 'init_order': self.init_order,
+ 'init_guess_mode': self.init_guess_mode,
+ 'calc_trans_inverse': self.calc_trans_inverse,
+ 'mag_trans': self.mag_trans,
+ 'mag_lim': self.mag_lim,
+ 'ref_mag_lim': self.ref_mag_lim,
+ 'motion_models': self.motion_models,
+ 'fixed_params_dict': self.fixed_params_dict,
+ 'vel_weights': self.vel_weighting,
+ 'use_scipy': self.use_scipy,
+ 'absolute_sigma': self.absolute_sigma,
+ 'iter_callback': self.iter_callback,
+ 'save_path': self.save_path,
+ 'prefix_name': self.prefix_name,
+ 'verbose': self.verbose
+ }
+ if self.save_path is not None:
+ if not os.path.exists(self.save_path):
+ os.makedirs(self.save_path)
+ with open(os.path.join(self.save_path, input_filename), 'w') as file:
+ for key, value in input_dict.items():
+ file.write(f'{key}:\t{value}\n')
+
+ if self.ref_mag_lim is not None:
+ self.ref_mag_lim[0] = self.ref_mag_lim[0] if self.ref_mag_lim[0] is not None else -np.inf
+ self.ref_mag_lim[1] = self.ref_mag_lim[1] if self.ref_mag_lim[1] is not None else np.inf
##########
# Setup a reference table to store data. It will contain:
@@ -1618,26 +2359,15 @@ def fit(self):
# x_orig, y_orig, m_orig, (opt. errors) -- the transformed errors for the lists: 2D
# w, w_orig (optiona) -- the input and output weights of stars in transform: 2D
##########
+ if 't0' in self.ref_list.colnames: self.t0_provided = True
+ else: self.t0_provided = False
self.ref_table = self.setup_ref_table_from_starlist(self.ref_list)
-
- # copy over velocities if they exist in the reference list
- if 'vx' in self.ref_list.colnames:
- self.ref_table['vx'] = self.ref_list['vx']
- self.ref_table['vy'] = self.ref_list['vy']
- self.ref_table['t0'] = self.ref_list['t0']
- if 'vxe' in self.ref_list.colnames:
- self.ref_table['vxe'] = self.ref_list['vxe']
- self.ref_table['vye'] = self.ref_list['vye']
-
##########
- #
# Repeat transform + match of all the starlists several times.
- #
##########
for nn in range(self.iters):
-
- # If we are on subsequent iterations, remove matching results from the
+ # If we are on subsequent iterations, remove matching results from the
# prior iteration. This leaves aggregated (1D) columns alone.
if nn > 0:
self.reset_ref_values()
@@ -1649,69 +2379,356 @@ def fit(self):
print('Starting iter {0:d} with ref_table shape:'.format(nn), self.ref_table['x'].shape)
print("**********")
print("**********")
-
+
# ALL the action is in here. Match and transform the stack of starlists.
- # This updates trans objects and the ref_table.
- self.match_and_transform(self.ref_mag_lim,
- self.dr_tol[nn], self.dm_tol[nn], self.outlier_tol[nn],
- self.trans_args[nn])
+ # This updates trans objects and the ref_table.
+ self.match_and_transform(
+ self.ref_mag_lim,
+ self.dr_tol[nn],
+ self.dm_tol[nn],
+ self.outlier_tol[nn],
+ self.trans_args[nn],
+ nn,
+ processes=processes,
+ chunksize=chunksize,
+ match_workers=match_workers,
+ mp_star_threshold=mp_star_threshold
+ )
# Clean up the reference table
# Find where stars are detected.
- self.ref_table.detections()
+ self.ref_table.detections(weight_col='n_detect_list' if self.inherit_n_detect else None)
### Drop all stars that have 0 detections.
- idx = np.where((self.ref_table['n_detect'] == 0) & (self.ref_table['ref_orig'] == False))[0]
+ idx = np.where((self.ref_table['n_detect'] == 0))[0] # & (self.ref_table['ref_orig'] == False))[0]
if self.verbose > 0:
- print(' *** Getting rid of {0:d} out of {1:d} junk sources'.format(len(idx), len(self.ref_table)))
+ print(' *** Getting rid of {0:d} out of {1:d} junk sources'.format(len(idx), len(self.ref_table)))
self.ref_table.remove_rows(idx)
- if self.iter_callback != None:
+ if self.iter_callback is not None:
self.iter_callback(self.ref_table, nn)
##########
- #
# Re-do all matching given final transformations.
- # No trimming this time.
- # First rest the reference table 2D values.
+ # No trimming this time.
+ # First reset the reference table 2D values.
##########
self.reset_ref_values(exclude=['used_in_trans'])
-
+
if self.verbose > 0:
print("**********")
print("Final Matching")
print("**********")
- self.match_lists(self.dr_tol[-1], self.dm_tol[-1])
- self.update_ref_table_aggregates()
+ self.match_lists(self.dr_tol[-1], self.dm_tol[-1], workers=match_workers)
+ if self.update_ref_orig:
+ keep_orig=None
+ else:
+ keep_orig = self.ref_table['ref_orig']
+ self.update_ref_table_aggregates(keep_orig=keep_orig, processes=processes, chunksize=chunksize, mp_star_threshold=mp_star_threshold)
##########
# Clean up output table.
- #
##########
# Find where stars are detected.
if self.verbose > 0:
- print('')
- print(' Preparing the reference table...')
-
- self.ref_table.detections()
+ print(' Preparing the reference table...')
+
+ self.ref_table.detections(weight_col='n_detect_list' if self.inherit_n_detect else None)
### Drop all stars that have 0 detections.
- idx = np.where(self.ref_table['n_detect'] == 0)[0]
- print(' *** Getting rid of {0:d} out of {1:d} junk sources'.format(len(idx), len(self.ref_table)))
+ idx = np.where((self.ref_table['n_detect'] == 0))[0] # & (self.ref_table['ref_orig'] == False))[0]
+ if self.verbose:
+ print(' *** Getting rid of {0:d} out of {1:d} junk sources'.format(len(idx), len(self.ref_table)))
self.ref_table.remove_rows(idx)
- if self.iter_callback != None:
+ if self.iter_callback is not None:
self.iter_callback(self.ref_table, nn)
+ # Add times into ref_table meta data
+ all_epochs = [s.meta['list_time'] for s in self.star_lists]
+ self.ref_table.meta['list_times'] = all_epochs
+
+ # Update chi2 values in ref table, as motion_model_used may have changed
+ x_inferred, y_inferred, _, _ = self.ref_table.infer_positions(all_epochs, fixed_params_dict=self.fixed_params_dict)
+ # Convert x_inferred and y_inferred to 2D arrays if they are 1D (i.e. if only one epoch), so that the chi2 calculation works correctly.
+ if x_inferred.ndim == 1:
+ x_inferred = x_inferred[:, np.newaxis]
+ if y_inferred.ndim == 1:
+ y_inferred = y_inferred[:, np.newaxis]
+ weighted_xy = ('xe' in self.ref_table.colnames) and ('ye' in self.ref_table.colnames)
+ if weighted_xy:
+ chi2_x_2d = ((self.ref_table['x'] - x_inferred) / self.ref_table['xe'])**2
+ chi2_y_2d = ((self.ref_table['y'] - y_inferred) / self.ref_table['ye'])**2
+ else:
+ chi2_x_2d = (self.ref_table['x'] - x_inferred)**2
+ chi2_y_2d = (self.ref_table['y'] - y_inferred)**2
+ chi2_x = np.nansum(chi2_x_2d, axis=1)
+ chi2_y = np.nansum(chi2_y_2d, axis=1)
+ chi2_x[~np.isfinite(chi2_x_2d).any(axis=1)] = np.nan
+ chi2_y[~np.isfinite(chi2_y_2d).any(axis=1)] = np.nan
+ self.ref_table['chi2_x'] = chi2_x
+ self.ref_table['chi2_y'] = chi2_y
+
+ # Update t0 and n_fit when no fitting is run because all motion_model_input==Fixed.
+ # 't0' may already exist as a column (e.g. supplied by the input
+ # reference list) without being populated for every row -- newly
+ # added stars get a NaN placeholder when their row is created (see
+ # add_rows_for_new_stars), and nothing else ever fills it in for the
+ # all-Fixed case. So the check has to be "which rows still need a
+ # value", not just "does the column exist".
+ needs_t0 = (
+ np.ones(len(self.ref_table), dtype=bool) if 't0' not in self.ref_table.colnames
+ else ~np.isfinite(self.ref_table['t0'])
+ )
+ needs_n_fit = 'n_fit' not in self.ref_table.colnames
+
+ if needs_t0.any() or needs_n_fit:
+ x_data = np.ma.masked_invalid(self.ref_table['x'].data, copy=True)
+ y_data = np.ma.masked_invalid(self.ref_table['y'].data, copy=True)
+ if weighted_xy:
+ xe_data = np.ma.masked_invalid(self.ref_table['xe'].data, copy=True)
+ ye_data = np.ma.masked_invalid(self.ref_table['ye'].data, copy=True)
+ xe_data.mask[np.isclose(xe_data, 0.)] = True
+ ye_data.mask[np.isclose(ye_data, 0.)] = True
+ fill_with_one = np.all(xe_data.mask, axis=1) & np.all(ye_data.mask, axis=1)
+ xe_data[fill_with_one] = 1.
+ ye_data[fill_with_one] = 1.
+ else:
+ xe_data = None
+ ye_data = None
+
+ if np.ndim(x_data) == 1:
+ x_data = x_data[:, np.newaxis]
+ if np.ndim(y_data) == 1:
+ y_data = y_data[:, np.newaxis]
+ if weighted_xy:
+ if np.ndim(xe_data) == 1:
+ xe_data = xe_data[:, np.newaxis]
+ if np.ndim(ye_data) == 1:
+ ye_data = ye_data[:, np.newaxis]
+
+ if 't' in self.ref_table.colnames:
+ t_data = self.ref_table['t'].data
+ else:
+ t_data = np.array(self.ref_table.meta['list_times'])
+ t_data = np.broadcast_to(t_data, xe_data.shape)
+
+ # Update t0, adapted from startables.fit_motion_models. Only the
+ # rows that need it are written -- rows that already have a
+ # valid t0 (e.g. from the input reference list) are left alone.
+ if needs_t0.any():
+ weights = 1. / np.hypot(xe_data, ye_data) if weighted_xy else None
+ # t_data must be masked (not just weights) and np.ma.average
+ # (not plain np.average) must be used here: for the
+ # fill_with_one rows above (no usable xe/ye anywhere at all),
+ # the substitute weight is uniform/unmasked, but t can still
+ # be genuinely NaN in undetected epochs. Plain np.average's
+ # weight-sum denominator doesn't respect t's own mask in that
+ # case, silently corrupting the result. np.ma.average does,
+ # and with a uniform weight that's equivalent to
+ # combine_lists()'s plain (unweighted) mean of just the valid
+ # epochs -- i.e. these stars' t0 still reflects their real
+ # detections, it's just not astrometric-error-weighted.
+ t0_new = np.ma.average(np.ma.masked_invalid(t_data), axis=1, weights=weights).filled(np.nan)
+ if 't0' not in self.ref_table.colnames:
+ self.ref_table['t0'] = t0_new
+ else:
+ self.ref_table['t0'][needs_t0] = t0_new[needs_t0]
+
+ # Update n_fit: unique epochs with valid data
+ if needs_n_fit:
+ xy_mask = ~ (x_data.mask | y_data.mask)
+ if weighted_xy:
+ xy_mask &= ~ (xe_data.mask | ye_data.mask)
+
+ self.ref_table['n_fit'] = np.array([
+ len(set(t_data[i][xy_mask[i]]))
+ for i in range(len(self.ref_table))
+ ])
+
+ if self.save_path is not None:
+ suppress_meta_warnings(self.ref_table)
+ with open(os.path.join(self.save_path, f'{self.prefix_name}.pkl'), 'wb') as file:
+ pickle.dump(self, file)
+ # Using pickle here because nan in a fits file is auto-converted to a masked value in astropy.io.fits.open()
+ with open(os.path.join(self.save_path, f'{self.prefix_name}_ref_table.pkl'), 'wb') as file:
+ pickle.dump(self.ref_table, file)
+ self.ref_table.write(os.path.join(self.save_path, f'{self.prefix_name}_ref_table.fits'), overwrite=True)
+
+ if self.verbose > 0:
+ print('===================================')
+ print('========== Done with fit ==========')
+ print('===================================')
return
+# TODO: This is sometimes run on a startable, not a starlist, at least as currently used
+def infer_positions(t, startable, motion_models=None, fixed_params_dict=None, return_errors=False):
+ """
+ Take a startable, check to see if it has motion/velocity columns.
+ If it does, then propagate the positions forward in time
+ to the desired epoch. If no motion/velocities exist, then just
+ use ['x0', 'y0'] or ['x', 'y']
+
+ Parameters
+ ----------
+ t : float
+ The time to propagate to. Usually in decimal years;
+ but it should be in the same units
+ as the 't0' column in starlist.
+ startable : StarTable
+ Startable that needs to be inferred.
+ motion_models : list of MotionModel classes or strings
+ The motion models to check for in the startable
+ return_errors : boolean
+ Whether to return the inferred position errors. If True, then the function returns x, y, xe, ye. If False, then it just returns x, y, by default False.
+
+ Returns
+ -------
+ x, y, (xe, ye) : tuple
+ Inferred position (and errors) at time t
+ """
+ if ('motion_model_used' in startable.colnames):
+ x, y, xe, ye = startable.infer_positions(t, fixed_params_dict=fixed_params_dict)
+ if return_errors:
+ return x, y, xe, ye
+ else:
+ return x, y
+
+ # Convert motion_models from strings to MotionModel classes if needed.
+ if motion_models is None:
+ # Setting the default to None to avoid mutable default argument issue
+ # See https://stackoverflow.com/questions/15189245/assigning-class-variable-as-default-value-to-class-method-argument
+ motion_models = [motion_model.Empty, motion_model.Fixed]
+ all_mm_map = motion_model.motion_model_map()
+ if all(isinstance(mm, str) for mm in motion_models):
+ mm_names = motion_models
+ motion_models = [all_mm_map[mm] for mm in motion_models]
+ else:
+ mm_names = [mm.name for mm in motion_models]
+
+ # Always add Empty and Fixed in motion models
+ if 'Fixed' not in mm_names:
+ motion_models.insert(0, motion_model.Fixed)
+ if 'Empty' not in mm_names:
+ motion_models.insert(0, motion_model.Empty)
+
+ # Otherwise, infer positions using the most complex motion model with the existing columns, until it reaches Fixed or Empty
+ # Sort motion models inversely by mm.n_params
+ motion_models = sorted(motion_models, key=lambda mm: mm.n_params, reverse=True)
+ for mm in motion_models:
+ if mm.name == 'Empty':
+ x = startable['x']
+ y = startable['y']
+ return x, y
+
+ required_columns = mm.fit_param_names + mm.fixed_param_names
+ if all([param in startable.colnames for param in required_columns]):
+ # Check if the values are finite for non-string columns in the required columns for this motion model. If not, skip to the next motion model.
+ if not all([np.isfinite(startable[param]).all() for param in required_columns if startable[param].dtype.kind in 'if']):
+ continue
+
+ # If we have error columns for all fit parameters, then use them in the model inference. Otherwise, just use the fit parameters without errors.
+ x, y = mm().model(
+ t=t,
+ fit_params=np.array([startable[param] for param in mm.fit_param_names]).T,
+ fixed_params_dict={param: startable[param] for param in mm.fixed_param_names}
+ )
+ break
+
+ return x, y
+
+
+def determine_motion_models(startable, motion_models=None, fixed_params_dict=None, processes=1, chunksize=None, verbose=True):
+ """Determine motion model used in star table based on the finite model parameter columns
+
+ Parameters
+ ----------
+ startable : startable
+ Startable with motion model parameter columns
+ motion_models : list of MotionModel or str, optional
+ List of motion model classes or their names to select from.
+ If None, all available motion models will be considered, by default None
+ fixed_params_dict : dict, optional
+ Dictionary of fixed parameters, by default None
+ verbose : bool, optional
+ Show progress bar or not
+
+ Returns
+ -------
+ motion_model_used : list
+ List of motion model used for each star
+ n_params : list
+ List of n parameters per direction for each star
+ """
+
+ if motion_models is None:
+ motion_models = motion_model.MotionModel.__subclasses__()
+ elif all(isinstance(mm, str) for mm in motion_models):
+ all_mm_map = motion_model.motion_model_map()
+ motion_models = [all_mm_map[mm] for mm in motion_models]
+
+ if fixed_params_dict is None:
+ fixed_params_dict = {}
+
+ motion_models_possible = []
+ for mm in motion_models:
+ required_columns = mm.fit_param_names + mm.fixed_param_names
+ req_col_in_table = [col for col in required_columns if (col in startable.colnames)]
+ req_col_in_dict = [col for col in required_columns if (col in fixed_params_dict.keys())]
+ req_cols = startable[req_col_in_table]
+ if all((col in startable.colnames) or (col in fixed_params_dict.keys()) for col in required_columns):
+ motion_models_possible.append((mm, req_col_in_table, req_cols, req_col_in_dict))
+
+ # Vectorized replacement for the old per-star Python loop (which called
+ # np.isfinite/np.issubdtype once per star per required column -- millions
+ # of times for large mosaics). For each candidate motion model, checked in
+ # the same priority order as before (last-declared model first), compute a
+ # whole-table boolean mask of which stars have all of that model's required
+ # *numeric* columns finite, then assign that model to every not-yet-assigned
+ # star the mask covers. Whether the fixed_params_dict entries are finite
+ # doesn't depend on the star, so it's checked once per model instead of once
+ # per star. This makes the `processes`/`chunksize` arguments unnecessary for
+ # this function; they are kept in the signature for backward compatibility.
+ n_stars = len(startable)
+ motion_model_used = np.empty(n_stars, dtype=object)
+ n_params = np.empty(n_stars, dtype=int)
+ assigned = np.zeros(n_stars, dtype=bool)
+
+ for mm, req_col_in_table, req_cols, req_col_in_dict in motion_models_possible[::-1]:
+ fixed_ok = all(
+ np.isfinite(fixed_params_dict[col])
+ for col in req_col_in_dict
+ if np.issubdtype(np.array(fixed_params_dict[col]).dtype, np.number)
+ )
+ if not fixed_ok:
+ continue
+
+ satisfies = np.ones(n_stars, dtype=bool)
+ for col in req_col_in_table:
+ col_data = req_cols[col]
+ if np.issubdtype(col_data.dtype, np.number):
+ satisfies &= np.isfinite(col_data)
+
+ newly_assigned = satisfies & ~assigned
+ motion_model_used[newly_assigned] = mm.name
+ n_params[newly_assigned] = mm.n_params
+ assigned |= newly_assigned
+
+ # Stars that matched no motion model are dropped, matching the old
+ # behavior of simply never appending an entry for them.
+ motion_model_used = motion_model_used[assigned].tolist()
+ n_params = n_params[assigned].tolist()
+
+ return motion_model_used, n_params
+
+
def get_all_epochs(t):
"""
Helper function to get times of all epochs from a ref table.
- This is required because our previous approach
- of simply taking the time array of the star with the most detections
- fails for mosaicked catalogs, because it is then possible that
+ This is required because our previous approach
+ of simply taking the time array of the star with the most detections
+ fails for mosaicked catalogs, because it is then possible that
no star is detected in all fields.
"""
nepochs = len(t['t'][0])
@@ -1728,16 +2745,17 @@ def get_all_epochs(t):
all_epochs = np.array(all_epochs)
return all_epochs
-
-def setup_ref_table_from_starlist(star_list):
- """
+
+def setup_ref_table_from_starlist(star_list, motion_models):
+ """
Start with the reference list.... this will change and grow
over time, so make a copy that we will keep updating.
The reference table will contain one columne for every named
array in the original reference star list.
"""
col_arrays = {}
+ motion_model_col_names = motion_model.motion_model_param_names(motion_models, with_errors=True)
for col_name in star_list.colnames:
if col_name == 'name':
# The "name" column will be 1D; but we will also add a "name_in_list" column.
@@ -1745,7 +2763,7 @@ def setup_ref_table_from_starlist(star_list):
new_col_name = "name_in_list"
else:
new_col_name = col_name
-
+
# Make every column's 2D arrays except "name" and those
# columns used for the motion model.
if col_name in motion_model_col_names:
@@ -1759,7 +2777,7 @@ def setup_ref_table_from_starlist(star_list):
# Make new columns to hold original values. These will be copies
# of the old columns and will only include x, y, m, xe, ye, me.
- # The columns we have already created will hold transformed values.
+ # The columns we have already created will hold transformed values.
trans_col_names = ['x', 'y', 'm', 'xe', 'ye', 'me', 'w']
for tt in range(len(trans_col_names)):
old_name = trans_col_names[tt]
@@ -1771,32 +2789,30 @@ def setup_ref_table_from_starlist(star_list):
# Make sure ref_table has the necessary x0, y0, m0 and associated
# error columns. If they don't exist, then add them as a copy of
- # the original x,y,m etc columns.
- new_cols_arr = ['x0', 'x0e', 'y0', 'y0e', 'm0', 'm0e']
+ # the original x,y,m etc columns.
+ new_cols_arr = ['x0', 'x0_err', 'y0', 'y0_err', 'm0', 'm0_err']
orig_cols_arr = ['x', 'xe', 'y', 'ye', 'm', 'me']
assert len(new_cols_arr) == len(orig_cols_arr)
ref_cols = ref_table.keys()
- for ii in range(len(new_cols_arr)):
- if not new_cols_arr[ii] in ref_cols:
+ for new_col, orig_col in zip(new_cols_arr, orig_cols_arr):
+ if new_col not in ref_cols:
# Some munging to convert data shape from (N,1) to (N,),
# since these are all 1D cols
- vals = np.transpose(np.array(ref_table[orig_cols_arr[ii]]))[0]
+ vals = np.array(ref_table[orig_col]).flatten()
# Now add to ref_table
- new_col = Column(vals, name=new_cols_arr[ii])
- ref_table.add_column(new_col)
-
+ ref_table.add_column(vals, name=new_col)
+
if 'use_in_trans' not in ref_table.colnames:
- new_col = Column(np.ones(len(ref_table), dtype=bool), name='use_in_trans')
- ref_table.add_column(new_col)
+ ref_table.add_column(np.ones(len(ref_table), dtype=bool), name='use_in_trans')
# Now reset the original values to invalids... they will be filled in
# at later times. Preserve content only in the columns: name, x0, y0, m0 (and 0e).
- # Note that these are all the 1D columsn.
+ # Note that these are all the 1D columns.
for col_name in ref_table.colnames:
- if len(ref_table[col_name].data.shape) == 2: # Find the 2D columns
- ref_table._set_invalid_list_values(col_name, -1)
+ if np.ndim(ref_table[col_name].data) == 2: # Find the 2D columns
+ ref_table._set_invalid_list_values(col_name, -1)
return ref_table
@@ -1806,14 +2822,14 @@ def copy_over_values(ref_table, star_list, star_list_T, idx_epoch, idx_ref, idx_
into the reference table we carry around and that is the final output product.
Copy only those values for stars that match.
- Copy all columns that are in both ref_table and star_list_T.
+ Copy all columns that are in both ref_table and star_list_T.
Copy all columns that are also in star_list but copy them into
_orig.
Parameters
----------
ref_table : StarTable
The table we will be copying values into. Note the columns with the appropriate
- names and dimensions must already exist.
+ names and dimensions must already exist.
star_list : StarList
The astropy table to copy values from. These should be untransformed (orig) values.
star_list_T : StarList
@@ -1821,18 +2837,56 @@ def copy_over_values(ref_table, star_list, star_list_T, idx_epoch, idx_ref, idx_
idx_ref : list or array
The indices into the ref_table where values are copied to.
idx_lis : list or array
- The indices into the star_list or star_lsit_T where values are copied from.
+ The indices into the star_list or star_list_T where values are copied from.
"""
+ idx_lis = np.array(idx_lis)
for col_name in ref_table.colnames:
+ if col_name == 'n_detect':
+ # 'n_detect' in ref_table is the 1D aggregate computed by
+ # detections()/update_n_detect(), not a per-list column -- a
+ # starlist's own 'n_detect' (used by inherit_n_detect) is
+ # handled separately below via 'n_detect_list', never here.
+ continue
if col_name in star_list_T.colnames:
if col_name == 'name':
- ref_table['name_in_list'][idx_ref, idx_epoch] = star_list_T[col_name][list(idx_lis)]
+ # name_in_list's dtype width is set once, from whichever
+ # names it saw first (e.g. the reference list's, at
+ # ref_table construction time). Other starlists' names can
+ # be longer, so widen the column here rather than silently
+ # truncating them.
+ incoming_names = star_list_T[col_name][idx_lis]
+ incoming_width = np.asarray(incoming_names).dtype.itemsize // np.dtype('U1').itemsize
+ current_width = ref_table['name_in_list'].dtype.itemsize // np.dtype('U1').itemsize
+ if incoming_width > current_width:
+ ref_table['name_in_list'] = ref_table['name_in_list'].astype(f'U{incoming_width}')
+ ref_table['name_in_list'][idx_ref, idx_epoch] = incoming_names
else:
- ref_table[col_name][idx_ref, idx_epoch] = star_list_T[col_name][list(idx_lis)]
+ ref_table[col_name][idx_ref, idx_epoch] = star_list_T[col_name][idx_lis]
orig_col_name = col_name + '_orig'
if orig_col_name in ref_table.colnames:
- ref_table[orig_col_name][idx_ref, idx_epoch] = star_list[col_name][list(idx_lis)]
+ ref_table[orig_col_name][idx_ref, idx_epoch] = star_list[col_name][idx_lis]
+
+ # Special case for n_detect_list (used by inherit_n_detect): the source
+ # column is named 'n_detect' (not 'n_detect_list'), so the by-name loop
+ # above never touches it -- copy it explicitly here. A starlist that's
+ # itself the output of a previous, lower-level align pass has its own
+ # 'n_detect'; one without it still contributes a weight of 1 per
+ # detection.
+ if 'n_detect_list' in ref_table.colnames:
+ if 'n_detect' in star_list.colnames:
+ ref_table['n_detect_list'][idx_ref, idx_epoch] = star_list['n_detect'][idx_lis]
+ else:
+ ref_table['n_detect_list'][idx_ref, idx_epoch] = 1
+
+ # Special case for list_time
+ if 't' not in star_list.colnames:
+ ref_table['t'][idx_ref, idx_epoch] = star_list.meta['list_time']
+ # Add list_times in meta
+ if 'list_times' not in ref_table.meta:
+ ref_table.meta['list_times'] = [star_list.meta['list_time']]
+ else:
+ ref_table.meta['list_times'].append(star_list.meta['list_time'])
return
@@ -1840,453 +2894,137 @@ def reset_ref_values(ref_table):
"""
Reset all the 2D arrays in the reference table. This is the action
we take at the beginning of each new iteration. We don't preserve matching
- results from the prior iterations.
+ results from the prior iterations.
"""
# All 2D columns should be reset.
for col_name in ref_table.colnames:
- if len(ref_table[col_name].data.shape) == 2: # Find the 2D columns
+ if np.ndim(ref_table[col_name].data) == 2: # Find the 2D columns
# Loop through epochs for this array.
for cc in range(ref_table[col_name].shape[1]):
- ref_table._set_invalid_list_values(col_name, cc)
-
- return
-
-def add_rows_for_new_stars(ref_table, star_list, idx_lis):
- """
- For each star that is in star_list and NOT in idx_list, make a
- new row in the reference table. The values will be empty (None, NAN, etc.).
-
- Parameters
- ----------
- ref_table : StarTable
- The reference table that the rows will be added to.
-
- star_list : StarList
- The starlist that will be used to estimate how many new stars there are.
-
- idx_lis : array or list
- The indices of the non-new stars (those that matched already). The complement
- of this array will be used as the new stars.
-
- Returns
- ----------
- ref_table : StarTable
- The reference table with rows added into.
- idx_lis_new : list
- The list of indices into the star_list object for the "new" stars.
- idx_ref_new : list
- The list of indices into the ref_table object for the "new" stars.
-
- """
- last_star_idx = len(ref_table)
-
- idx_lis_orig = np.arange(len(star_list))
- idx_lis_new = np.array(list(set(idx_lis_orig) - set(idx_lis)))
-
- if len(idx_lis_new) > 0:
- col_arrays = {}
-
- for col_name in ref_table.colnames:
- new_col_name = col_name
-
- if ref_table[col_name].dtype == np.dtype('float'):
- new_col_empty = np.nan
- elif ref_table[col_name].dtype == np.dtype('int'):
- new_col_empty = -1
- elif ref_table[col_name].dtype == np.dtype('bool'):
- new_col_empty = False
- else:
- new_col_empty = np.nan
-
- if len(ref_table[col_name].shape) == 1:
- new_col_shape = len(idx_lis_new)
- else:
- new_col_shape = [len(idx_lis_new), ref_table[col_name].shape[1]]
-
- new_col_data = Column(data=np.tile(new_col_empty, new_col_shape),
- name=col_name, dtype=ref_table[col_name].dtype)
- col_arrays[new_col_name] = new_col_data
-
- ref_table_new = StarTable(**col_arrays)
- ref_table_nstars = ref_table.meta['n_stars'] + ref_table_new.meta['n_stars']
- ref_table.meta['n_stars'] = ref_table_nstars
- ref_table_new.meta['n_stars'] = ref_table_nstars
- ref_table_new.meta['ref_list'] = ref_table.meta['ref_list']
- ref_table = vstack([ref_table, ref_table_new])
-
- idx_ref_new = np.arange(last_star_idx, len(ref_table))
-
- return ref_table, idx_lis_new, idx_ref_new
-
-
-def run_align_iter(catalog, trans_order=1, poly_deg=1, ref_mag_lim=19, ref_radius_lim=300):
- # Load up data with matched stars.
- d = Table.read(catalog)
-
- # Determine how many epochs there are.
- N_epochs = len([n for n, c in enumerate(d.colnames) if c.startswith('name')])
-
- # Determine how many stars there are.
- N_stars = len(d)
-
- # Determine the reference epoch
- ref = d.meta['L_REF']
-
- # Figure out the number of free parameters for the specified
- # poly2d order.
- poly2d = models.Polynomial2D(trans_order)
- N_par_trans_per_epoch = 2.0 * poly2d.get_num_coeff(2) # one poly2d for each dimension (X, Y)
- N_par_trans = N_par_trans_per_epoch * N_epochs
-
- ##########
- # First iteration -- align everything to REF epoch with zero velocities.
- ##########
- print('ALIGN_EPOCHS: run_align_iter() -- PASS 1')
- ee_ref = d.meta['L_REF']
-
- target_name = 'OB120169'
-
- trans1, used1 = calc_transform_ref_epoch(d, target_name, ee_ref, ref_mag_lim, ref_radius_lim)
-
- ##########
- # Derive the velocity of each stars using the round 1 transforms.
- ##########
- calc_polyfit_all_stars(d, poly_deg, init_fig_idx=0)
-
- calc_mag_avg_all_stars(d)
-
- tdx = np.where((d['name_0'] == 'OB120169') | (d['name_0'] == 'OB120169_L'))[0]
- print(d[tdx]['name_0', 't0', 'mag', 'x0', 'vx', 'x0e', 'vxe', 'chi2x', 'y0', 'vy', 'y0e', 'vye', 'chi2y', 'dof'])
-
- ##########
- # Second iteration -- align everything to reference positions derived from iteration 1
- ##########
- print('ALIGN_EPOCHS: run_align_iter() -- PASS 2')
- target_name = 'OB120169'
-
- trans2, used2 = calc_transform_ref_poly(d, target_name, poly_deg, ref_mag_lim, ref_radius_lim)
-
- ##########
- # Derive the velocity of each stars using the round 1 transforms.
- ##########
- calc_polyfit_all_stars(d, poly_deg, init_fig_idx=4)
-
- ##########
- # Save output
- ##########
- d.write(catalog.replace('.fits', '_aln.fits'), overwrite=True)
-
- return
-
-def calc_transform_ref_epoch(d, target_name, ee_ref, ref_mag_lim, ref_radius_lim):
- # Determine how many epochs there are.
- N_epochs = len([n for n, c in enumerate(d.colnames) if c.startswith('name')])
-
- # output array
- trans = []
- used = []
-
- # Find the target
- tdx = np.where(d['name_0'] == 'OB120169')[0][0]
-
- # Reference values
- t_ref = d['t_{0:d}'.format(ee_ref)]
- m_ref = d['m_{0:d}'.format(ee_ref)]
- x_ref = d['x_{0:d}'.format(ee_ref)]
- y_ref = d['y_{0:d}'.format(ee_ref)]
- xe_ref = d['xe_{0:d}'.format(ee_ref)]
- ye_ref = d['ye_{0:d}'.format(ee_ref)]
-
- # Calculate some quanitites we use for selecting reference stars.
- r_ref = np.hypot(x_ref - x_ref[tdx], y_ref - y_ref[tdx])
-
- # Loop through and align each epoch to the reference epoch.
- for ee in range(N_epochs):
- # Pull out the X, Y positions (and errors) for the two
- # starlists we are going to align.
- x_epo = d['x_{0:d}'.format(ee)]
- y_epo = d['y_{0:d}'.format(ee)]
- t_epo = d['t_{0:d}'.format(ee)]
- xe_epo = d['xe_{0:d}'.format(ee)]
- ye_epo = d['ye_{0:d}'.format(ee)]
-
- # Figure out the set of stars detected in both epochs.
- idx = np.where((t_ref != 0) & (t_epo != 0) & (xe_ref != 0) & (xe_epo != 0))[0]
-
- # Find those in both epochs AND reference stars. This is [idx][rdx]
- rdx = np.where((r_ref[idx] < ref_radius_lim) & (m_ref[idx] < ref_mag_lim))[0]
-
- # Average the positional errors together to get one weight per star.
- xye_ref = (xe_ref + ye_ref) / 2.0
- xye_epo = (xe_epo + ye_epo) / 2.0
- xye_wgt = (xye_ref**2 + xye_epo**2)**0.5
-
- # Calculate transform based on the matched stars
- trans_tmp = transforms.PolyTransform(x_epo[idx][rdx], y_epo[idx][rdx], x_ref[idx][rdx], y_ref[idx][rdx],
- weights=xye_wgt[idx][rdx], order=2)
-
- trans.append(trans_tmp)
-
-
- # Apply thte transformation to the stars positions and errors:
- xt_epo = np.zeros(len(d), dtype=float)
- yt_epo = np.zeros(len(d), dtype=float)
- xet_epo = np.zeros(len(d), dtype=float)
- yet_epo = np.zeros(len(d), dtype=float)
-
- xt_epo[idx], xet_epo[idx], yt_epo[idx], yet_epo[idx] = trans_tmp.evaluate_errors(x_epo[idx], xe_epo[idx],
- y_epo[idx], ye_epo[idx],
- nsim=100)
-
- d['xt_{0:d}'.format(ee)] = xt_epo
- d['yt_{0:d}'.format(ee)] = yt_epo
- d['xet_{0:d}'.format(ee)] = xet_epo
- d['yet_{0:d}'.format(ee)] = yet_epo
-
- # Record which stars we used in the transform.
- used_tmp = np.zeros(len(d), dtype=bool)
- used_tmp[idx[rdx]] = True
-
- used.append(used_tmp)
-
- if True:
- plot_quiver_residuals(xt_epo, yt_epo, x_ref, y_ref, idx, rdx, 'Epoch: ' + str(ee))
-
- used = np.array(used)
-
- return trans, used
+ ref_table._set_invalid_list_values(col_name, cc)
+ return
-def calc_transform_ref_poly(d, target_name, poly_deg, ref_mag_lim, ref_radius_lim):
- # Determine how many epochs there are.
- N_epochs = len([n for n, c in enumerate(d.colnames) if c.startswith('name')])
+def add_rows_for_new_stars(ref_table, star_list, idx_list, motion_model_name='Fixed', fixed_params_dict=None):
+ """
+ For each star that is in star_list and NOT in idx_list, make a
+ new row in the reference table. The values will be empty (None, NAN, etc.).
- # output array
- trans = []
- used = []
+ Parameters
+ ----------
+ ref_table : StarTable
+ The reference table that the rows will be added to.
+ star_list : StarList
+ The starlist that will be used to estimate how many new stars there are.
+ idx_list : array or list
+ The indices of the non-new stars (those that matched already). The complement
+ of this array will be used as the new stars.
+ motion_model_name : str
+ The motion model name to assign to the new stars.
+ fixed_params_dict : dict
+ The default fixed parameters to assign to the new stars.
- # Find the target
- tdx = np.where(d['name_0'] == 'OB120169')[0][0]
+ Returns
+ ----------
+ ref_table : StarTable
+ The reference table with rows added into.
+ idx_lis_new : list
+ The list of indices into the star_list object for the "new" stars.
+ idx_ref_new : list
+ The list of indices into the ref_table object for the "new" stars.
- # Temporary Reference values
- t_ref = d['t0']
- m_ref = d['mag']
- x_ref = d['x0']
- y_ref = d['y0']
- xe_ref = d['x0e']
- ye_ref = d['y0e']
-
- # Calculate some quanitites we use for selecting reference stars.
- r_ref = np.hypot(x_ref - x_ref[tdx], y_ref - y_ref[tdx])
+ """
+ last_star_idx = len(ref_table)
- for ee in range(N_epochs):
- # Pull out the X, Y positions (and errors) for the two
- # starlists we are going to align.
- x_epo = d['x_{0:d}'.format(ee)]
- y_epo = d['y_{0:d}'.format(ee)]
- t_epo = d['t_{0:d}'.format(ee)]
- xe_epo = d['xe_{0:d}'.format(ee)]
- ye_epo = d['ye_{0:d}'.format(ee)]
-
- # Shift the reference position by the polyfit for each star.
- dt = t_epo - t_ref
- if poly_deg >= 0:
- x_ref_ee = x_ref
- y_ref_ee = y_ref
- xe_ref_ee = x_ref
- ye_ref_ee = y_ref
-
- if poly_deg >= 1:
- x_ref_ee += d['vx'] * dt
- y_ref_ee += d['vy'] * dt
- xe_ref_ee = np.hypot(xe_ref_ee, d['vxe'] * dt)
- ye_ref_ee = np.hypot(ye_ref_ee, d['vye'] * dt)
-
- if poly_deg >= 2:
- x_ref_ee += d['ax'] * dt
- y_ref_ee += d['ay'] * dt
- xe_ref_ee = np.hypot(xe_ref_ee, d['axe'] * dt)
- ye_ref_ee = np.hypot(ye_ref_ee, d['aye'] * dt)
-
- # Figure out the set of stars detected in both.
- idx = np.where((t_ref != 0) & (t_epo != 0) & (xe_ref != 0) & (xe_epo != 0))[0]
-
- # Find those in both AND reference stars. This is [idx][rdx]
- rdx = np.where((r_ref[idx] < ref_radius_lim) & (m_ref[idx] < ref_mag_lim))[0]
-
- # Average the positional errors together to get one weight per star.
- xye_ref = (xe_ref_ee + ye_ref_ee) / 2.0
- xye_epo = (xe_epo + ye_epo) / 2.0
- xye_wgt = (xye_ref**2 + xye_epo**2)**0.5
-
- # Calculate transform based on the matched stars
- trans_tmp = transforms.PolyTransform(x_epo[idx][rdx], y_epo[idx][rdx], x_ref_ee[idx][rdx], y_ref_ee[idx][rdx],
- weights=xye_wgt[idx][rdx], order=2)
- trans.append(trans_tmp)
-
- # Apply thte transformation to the stars positions and errors:
- xt_epo = np.zeros(len(d), dtype=float)
- yt_epo = np.zeros(len(d), dtype=float)
- xet_epo = np.zeros(len(d), dtype=float)
- yet_epo = np.zeros(len(d), dtype=float)
-
- xt_epo[idx], xet_epo[idx], yt_epo[idx], yet_epo[idx] = trans_tmp.evaluate_errors(x_epo[idx], xe_epo[idx],
- y_epo[idx], ye_epo[idx],
- nsim=100)
- d['xt_{0:d}'.format(ee)] = xt_epo
- d['yt_{0:d}'.format(ee)] = yt_epo
- d['xet_{0:d}'.format(ee)] = xet_epo
- d['yet_{0:d}'.format(ee)] = yet_epo
+ idx_lis_orig = np.arange(len(star_list))
+ idx_lis_new = np.array(list(set(idx_lis_orig) - set(idx_list)))
+ N_newstars = len(idx_lis_new)
- # Record which stars we used in the transform.
- used_tmp = np.zeros(len(d), dtype=bool)
- used_tmp[idx[rdx]] = True
+ mm_map = motion_model.motion_model_map()
+ mm = mm_map[motion_model_name]
- used.append(used_tmp)
+ # Add optional fixed params default values into fixed params dict, prioritizing values in fixed_params_dict
+ if fixed_params_dict is not None:
+ fixed_params_dict.update({k: v for k, v in mm.optional_fixed_params.items() if k not in fixed_params_dict})
+ else:
+ fixed_params_dict = mm.optional_fixed_params.copy()
+
+ if N_newstars > 0:
+ # Build each column's new rows and concatenate them onto the
+ # existing column data one column at a time, dropping the old
+ # column's reference immediately afterward -- instead of building a
+ # whole parallel StarTable for the new rows and then vstack()-ing
+ # it onto ref_table, which transiently holds the old table, the new
+ # (parallel) table, AND vstack's own freshly-concatenated result all
+ # in memory simultaneously (every column, all at once). That
+ # transient roughly doubles peak memory on every single "add new
+ # stars" step, which dominates total memory use for a mosaic that
+ # grows into the millions of rows across many starlists. Building
+ # concatenated arrays directly (and letting each old column's array
+ # be freed as soon as it's replaced) avoids ever needing a second
+ # full copy of the whole table at once.
+ colnames = list(ref_table.colnames)
+ new_col_arrays = {}
+ for col_name in colnames:
+ old_col = ref_table[col_name]
+ dtype = old_col.dtype
+
+ if col_name in fixed_params_dict.keys():
+ new_col_empty = fixed_params_dict[col_name]
+ elif col_name=='n_params':
+ new_col_empty = mm.n_params
+ elif col_name=='motion_model_input':
+ new_col_empty = motion_model_name
+ elif col_name=='motion_model_used':
+ new_col_empty = 'Empty'
+ elif col_name in ['xe', 'ye', 'me'] or col_name.endswith('_err'):
+ new_col_empty = np.inf
+ elif dtype == np.dtype('float'):
+ new_col_empty = np.nan
+ elif dtype == np.dtype('int'):
+ new_col_empty = -1
+ elif dtype == np.dtype('bool'):
+ new_col_empty = False
+ else:
+ new_col_empty = np.nan
- if True:
- plot_quiver_residuals(xt_epo, yt_epo, x_ref_ee, y_ref_ee, idx, rdx, 'Epoch: ' + str(ee))
+ if np.ndim(old_col.data) == 1:
+ new_col_shape = N_newstars
+ else:
+ new_col_shape = (N_newstars, old_col.shape[1])
+
+ new_rows = np.full(new_col_shape, new_col_empty, dtype=dtype)
+ new_col_arrays[col_name] = np.concatenate([old_col.data, new_rows], axis=0)
+
+ # Drop ref_table's reference to the old column now, before
+ # moving on to the next one, so it can be freed immediately
+ # rather than staying alive until every column has been
+ # processed.
+ del ref_table[col_name]
+ del old_col, new_rows
+
+ ref_table_nstars = ref_table.meta['n_stars'] + N_newstars
+ ref_table_meta = dict(ref_table.meta)
+ ref_table_meta['n_stars'] = ref_table_nstars
+ del ref_table
+
+ # Build the new table directly from the already-concatenated,
+ # already-correctly-shaped/typed arrays with copy=False, so
+ # StarTable.__init__ uses them as-is instead of silently copying
+ # the whole (now full-size) table all over again right at the end.
+ ref_table = StarTable(**new_col_arrays, copy=False)
+ ref_table.meta.update(ref_table_meta)
- used = np.array(used)
-
- return trans, used
+ idx_ref_new = np.arange(last_star_idx, len(ref_table))
-def calc_polyfit_all_stars(d, poly_deg, init_fig_idx=0):
- # Determine how many stars there are.
- N_stars = len(d)
+ return ref_table, idx_lis_new, idx_ref_new
- # Determine how many epochs there are.
- N_epochs = len([n for n, c in enumerate(d.colnames) if c.startswith('name')])
-
- # Setup some variables to save the results
- t0_all = []
- px_all = []
- py_all = []
- pxe_all = []
- pye_all = []
- chi2x_all = []
- chi2y_all = []
- dof_all = []
-
- # Get the time array, which is the same for all stars.
- # Also, sort the time indices.
- t = np.array([d['t_{0:d}'.format(ee)][0] for ee in range(N_epochs)])
- tdx = t.argsort()
- t_sorted = t[tdx]
-
- # Run polyfit on each star.
- for ss in range(N_stars):
- # Get the x, y, xe, ye, and t arrays for this star.
- xt = np.array([d['xt_{0:d}'.format(ee)][ss] for ee in range(N_epochs)])
- yt = np.array([d['yt_{0:d}'.format(ee)][ss] for ee in range(N_epochs)])
- xet = np.array([d['xet_{0:d}'.format(ee)][ss] for ee in range(N_epochs)])
- yet = np.array([d['yet_{0:d}'.format(ee)][ss] for ee in range(N_epochs)])
- t_tmp = np.array([d['t_{0:d}'.format(ee)][ss] for ee in range(N_epochs)])
-
- # Sort these arrays.
- xt_sorted = xt[tdx]
- yt_sorted = yt[tdx]
- xet_sorted = xet[tdx]
- yet_sorted = yet[tdx]
- t_tmp_sorted = t_tmp[tdx]
-
- # Get only the detected epochs.
- edx = np.where(t_tmp_sorted != 0)[0]
-
- # Calculate the weighted t0 (using the transformed errors).
- weight_for_t0 = 1.0 / np.hypot(xet_sorted, yet_sorted)
- t0 = np.average(t_sorted[edx], weights=weight_for_t0[edx])
-
- # for ee in edx:
- # print('{0:8.3f} {1:10.5f} {2:10.5f} {3:8.5f} {4:8.5f}'.format(t[ee], xt[ee], yt[ee], xet[ee], yet[ee]))
- # pdb.set_trace()
-
- # Run polyfit
- dt = t_sorted - t0
- px, covx = np.polyfit(dt[edx], xt_sorted[edx], poly_deg, w=1./xet_sorted[edx], cov=True)
- py, covy = np.polyfit(dt[edx], yt_sorted[edx], poly_deg, w=1./yet_sorted[edx], cov=True)
-
- pxe = np.sqrt(np.diag(covx))
- pye = np.sqrt(np.diag(covy))
-
-
- x_mod = np.polyval(px, dt[edx])
- y_mod = np.polyval(py, dt[edx])
- chi2x = np.sum( ((x_mod - xt_sorted[edx]) / xet_sorted[edx])**2 )
- chi2y = np.sum( ((y_mod - yt_sorted[edx]) / yet_sorted[edx])**2 )
- dof = len(edx) - (poly_deg + 1)
-
- # Save results:
- t0_all.append(t0)
- px_all.append(px)
- py_all.append(py)
- pxe_all.append(pxe)
- pye_all.append(pye)
- chi2x_all.append(chi2x)
- chi2y_all.append(chi2y)
- dof_all.append(dof)
-
- if d[ss]['name_0'] in ['OB120169', 'OB120169_L']:
- gs = GridSpec(3, 2) # 3 rows, 1 column
- fig = plt.figure(ss + 1 + init_fig_idx, figsize=(12, 8))
- a0 = fig.add_subplot(gs[0:2, 0])
- a1 = fig.add_subplot(gs[2, 0])
- a2 = fig.add_subplot(gs[0:2, 1])
- a3 = fig.add_subplot(gs[2, 1])
-
- a0.errorbar(t_sorted[edx], xt_sorted[edx], yerr=xet_sorted[edx], fmt='ro')
- a0.plot(t_sorted[edx], x_mod, 'k-')
- a0.set_title(d[ss]['name_0'] + ' X')
- a1.errorbar(t_sorted[edx], xt_sorted[edx] - x_mod, yerr=xet_sorted[edx], fmt='ro')
- a1.axhline(0, linestyle='--')
- a1.set_xlabel('Time (yrs)')
- a2.errorbar(t_sorted[edx], yt_sorted[edx], yerr=yet_sorted[edx], fmt='ro')
- a2.plot(t_sorted[edx], y_mod, 'k-')
- a2.set_title(d[ss]['name_0'] + ' Y')
- a3.errorbar(t_sorted[edx], yt_sorted[edx] - y_mod, yerr=yet_sorted[edx], fmt='ro')
- a3.axhline(0, linestyle='--')
- a3.set_xlabel('Time (yrs)')
-
-
-
- t0_all = np.array(t0_all)
- px_all = np.array(px_all)
- py_all = np.array(py_all)
- pxe_all = np.array(pxe_all)
- pye_all = np.array(pye_all)
- chi2x_all = np.array(chi2x_all)
- chi2y_all = np.array(chi2y_all)
- dof_all = np.array(dof_all)
-
- # Done with all the stars... recast as numpy arrays and save to output table.
- d['t0'] = t0_all
- d['chi2x'] = chi2x_all
- d['chi2y'] = chi2y_all
- d['dof'] = dof_all
- if poly_deg >= 0:
- d['x0'] = px_all[:, -1]
- d['y0'] = py_all[:, -1]
- d['x0e'] = pxe_all[:, -1]
- d['y0e'] = pye_all[:, -1]
-
- if poly_deg >= 1:
- d['vx'] = px_all[:, -2]
- d['vy'] = py_all[:, -2]
- d['vxe'] = pxe_all[:, -2]
- d['vye'] = pye_all[:, -2]
-
- if poly_deg >= 2:
- d['ax'] = px_all[:, -3]
- d['ay'] = py_all[:, -3]
- d['axe'] = pxe_all[:, -3]
- d['aye'] = pye_all[:, -3]
-
- pdb.set_trace()
-
- return
+"""
+Functions specific to OB120169 moved to align_old_functions,py
+"""
def calc_mag_avg_all_stars(d):
- # Determine how many stars there are.
+ # Determine how many stars there are.
N_stars = len(d)
# Determine how many epochs there are.
@@ -2310,8 +3048,7 @@ def calc_mag_avg_all_stars(d):
-def initial_align(table1, table2, briteN=100,
- transformModel=transforms.PolyTransform, order=1, req_match=5):
+def initial_align(table1, table2, briteN=100, transformModel=transforms.PolyTransform, order=1):
"""
Calculates an initial (unweighted) transformation from table1 starlist into
table2 starlist (i.e., table2 is the reference starlist). Matching is done using
@@ -2328,7 +3065,7 @@ def initial_align(table1, table2, briteN=100,
y: y position
xe: error in x position
ye: error in y position
-
+
vx: proper motion in x direction
vy proper motion in y direction
vxe: error in x proper motion
@@ -2336,11 +3073,11 @@ def initial_align(table1, table2, briteN=100,
m: magnitude
me: magnitude error
-
+
t0: linear motion time zero point
use: specify use in transformation
-
+
Parameters:
----------
@@ -2362,13 +3099,10 @@ def initial_align(table1, table2, briteN=100,
-order: int
Order of the transformation. Not relevant for 4 parameter or spline fit
- -req_match: int
- Number of required matches of the input catalog to the total reference
-
Output:
------
Transformation object
-
+
"""
# Extract necessary information from tables (x, y, m)
x1 = table1['x']
@@ -2394,7 +3128,7 @@ def initial_align(table1, table2, briteN=100,
-def transform_and_match(table1, table2, transform, dr_tol=1.0, dm_tol=None, verbose=True):
+def transform_and_match(table1, table2, transform, dr_tol=1.0, dm_tol=None, workers=1, verbose=True):
"""
apply transformation to starlist1 and
match stars to given radius and magnitude tolerance.
@@ -2415,8 +3149,12 @@ def transform_and_match(table1, table2, transform, dr_tol=1.0, dm_tol=None, verb
The search radius for the matching algorithm, in the same units as the
starlist file positions.
+ -workers: int (default=1)
+ Number of worker threads for the KDTree neighbor search. -1 uses all
+ available CPU cores. See match.match() for details.
+
-transform: transformation object
-
+
-verbose: bool, optional
Prints on screen information on the matching
@@ -2435,12 +3173,11 @@ def transform_and_match(table1, table2, transform, dr_tol=1.0, dm_tol=None, verb
y2 = table2['y']
m2 = table2['m']
-
# Transform x, y coordinates from starlist 1 into starlist 2
x1t, y1t = transform.evaluate(x1, y1)
# Match starlist 1 and 2
- idx1, idx2, dr, dm = match.match(x1t, y1t, m1, x2, y2, m2, dr_tol, dm_tol, verbose=verbose)
+ idx1, idx2, dr, dm = match.match(x1t, y1t, m1, x2, y2, m2, dr_tol, dm_tol, workers=workers, verbose=verbose)
if verbose:
print(( '{0} of {1} stars matched'.format(len(idx1), len(x1t))))
@@ -2488,7 +3225,7 @@ def find_transform(table1, table1_trans, table2, transModel=transforms.PolyTrans
if weights=='starlist', we only use postion error in transformed starlist.
if weights=='reference', we only use position error in reference starlist.
if weights==None, we don't use weights.
-
+
verbose: bool (default=True)
Prints on screen information on the matching
@@ -2504,7 +3241,7 @@ def find_transform(table1, table1_trans, table2, transModel=transforms.PolyTrans
(transModel != transforms.LegTransform) ):
print(( '{0} not supported yet!'.format(transModel)))
return
-
+
# Extract *untransformed* coordinates from starlist 1
# and the matching coordinates from starlist 2
x1 = table1['x']
@@ -2516,7 +3253,7 @@ def find_transform(table1, table1_trans, table2, transModel=transforms.PolyTrans
# calculate weights from *transformed* coords. This is where we use the
# transformation object
- if (table1_trans != None) and ('xe' in table1_trans.colnames):
+ if (table1_trans is not None) and ('xe' in table1_trans.colnames):
x1e = table1_trans['xe']
y1e = table1_trans['ye']
@@ -2582,7 +3319,7 @@ def find_transform_new(table1_mat, table2_mat,
if weights = 'both' or 'starlist' then the positions in table 1 are first transformed
using the transInit object. This is necessary if the plate scales are very different
between the table 1 and the reference list.
-
+
verbose: bool (default=True)
Prints on screen information on the matching
@@ -2595,7 +3332,7 @@ def find_transform_new(table1_mat, table2_mat,
if ( (transModel != transforms.four_paramNW) & (transModel != transforms.PolyTransform) ):
print(( '{0} not supported yet!'.format(transModel)))
return
-
+
# Extract *untransformed* coordinates from starlist 1
# and the matching coordinates from starlist 2
x1 = table1_mat['x']
@@ -2604,18 +3341,18 @@ def find_transform_new(table1_mat, table2_mat,
y2 = table2_mat['y']
# Get the uncertainties (if needed) and calculate the weights.
- if weights != None:
+ if weights is not None:
x1e = table1_mat['xe']
y1e = table1_mat['ye']
x2e = table2_mat['xe']
y2e = table2_mat['ye']
- if transInit != None:
+ if transInit is not None:
table1T_mat = table1_mat.copy()
- table1T_mat = transform_by_object(table1T_mat, transInit)
+ table1T_mat = transform_from_object(table1T_mat, transInit)
- x1e = table1T_mag['xe']
- y1e = table1T_mag['ye']
+ x1e = table1T_mat['xe']
+ y1e = table1T_mat['ye']
# Calculate weights as to user specification
if weights == 'both':
@@ -2683,7 +3420,7 @@ def write_transform(transform, starlist, reference, N_trans, deltaMag=0, restric
outFile: string (default: 'outTrans.txt')
Name of output text file
-
+
Output:
------
txt file with the file name outFile
@@ -2691,7 +3428,7 @@ def write_transform(transform, starlist, reference, N_trans, deltaMag=0, restric
# Extract info about transformation
trans_name = transform.__class__.__name__
trans_order = transform.order
-
+
# Extract X, Y coefficients from transform
if trans_name == 'four_paramNW':
Xcoeff = transform.px
@@ -2700,12 +3437,11 @@ def write_transform(transform, starlist, reference, N_trans, deltaMag=0, restric
Xcoeff = transform.px.parameters
Ycoeff = transform.py.parameters
else:
- print(( '{0} not yet supported!'.format(transType)))
- return
-
+ raise Exception(f'{trans_name} not yet supported!')
+
# Write output
_out = open(outFile, 'w')
-
+
# Write the header. DO NOT CHANGE, HARDCODED IN JAVA ALIGN
_out.write('## Date: {0}\n'.format(datetime.date.today()) )
_out.write('## File: {0}, Reference: {1}\n'.format(starlist, reference) )
@@ -2718,7 +3454,7 @@ def write_transform(transform, starlist, reference, N_trans, deltaMag=0, restric
_out.write('## N_trans: {0}\n'.format(N_trans))
_out.write('## Delta Mag: {0}\n'.format(deltaMag))
_out.write('{0:16s} {1:16s}\n'.format('# Xcoeff', 'Ycoeff'))
-
+
# Write the coefficients such that the orders are together as defined in
# documentation. This is a pain because PolyTransform output is weird.
# (see astropy Polynomial2D documentation)
@@ -2729,12 +3465,12 @@ def write_transform(transform, starlist, reference, N_trans, deltaMag=0, restric
# CODE TO GET INDICIES
N = trans_order - 1
idx_list = list()
-
+
# when trans_order=1, N=0
idx_list.append(0)
idx_list.append(1)
idx_list.append(N+2)
-
+
if trans_order >= 2:
for k in range(2, N+2):
idx_list.append(k)
@@ -2743,22 +3479,17 @@ def write_transform(transform, starlist, reference, N_trans, deltaMag=0, restric
idx_list.append(int(2*N +2 +j + (2*N+2-i)*(i-1)/2.))
idx_list.append(N+1+k)
- #_out.write('{0:16.6e} {1:16.6e}\n'.format(Xcoeff[0], Ycoeff[0]) )
- #_out.write('{0:16.6e} {1:16.6e}\n'.format(Xcoeff[1], Ycoeff[1]) )
- #_out.write('{0:16.6e} {1:16.6e}\n'.format(Xcoeff[3], Ycoeff[3]) )
- #_out.write('{0:16.6e} {1:16.6e}\n'.format(Xcoeff[2], Ycoeff[2]) )
- #_out.write('{0:16.6e} {1:16.6e}\n'.format(Xcoeff[5], Ycoeff[5]) )
- #_out.write('{0:16.6e} {1:16.6e}'.format(Xcoeff[4], Ycoeff[4]) )
-
for i in idx_list:
_out.write('{0:16.6e} {1:16.6e}\n'.format(Xcoeff[i], Ycoeff[i]) )
_out.close()
-
+
return
+# Transform_from_file original version moved to align_old_functions.py
+# This version makes the transFile an object and uses transform_from_object
def transform_from_file(starlist, transFile):
"""
Apply transformation from transFile to starlist. Returns astropy table with
@@ -2766,9 +3497,8 @@ def transform_from_file(starlist, transFile):
positions/position errors, plus velocities and velocity errors if they
are present in starlist.
- WARNING: THIS CODE WILL NOT WORK FOR LEGENDRE POLYNOMIAL
- TRANSFORMS
-
+ WARNING: THIS CODE WORKS FOR POLYTRANSFORM
+
Parameters:
----------
starlist: astropy table
@@ -2783,154 +3513,32 @@ def transform_from_file(starlist, transFile):
------
Copy of starlist astropy table with transformed coordinates.
"""
- # Make a copy of starlist. This is what we will eventually modify with
- # the transformed coordinates
- starlist_f = copy.deepcopy(starlist)
-
- # Check to see if velocities are present in starlist. If so, we will
- # need to transform these as well as positions
- vel = False
- keys = list(starlist.keys())
- if 'vx' in keys:
- vel = True
-
- # Extract needed information from starlist
- x_orig = starlist['x']
- y_orig = starlist['y']
- xe_orig = starlist['xe']
- ye_orig = starlist['ye']
-
- if vel:
- x0_orig = starlist['x0']
- y0_orig = starlist['y0']
- x0e_orig = starlist['x0e']
- y0e_orig = starlist['y0e']
-
- vx_orig = starlist['vx']
- vy_orig = starlist['vy']
- vxe_orig = starlist['vxe']
- vye_orig = starlist['vye']
-
- # Read transFile
- trans = Table.read(transFile, format='ascii.commented_header', header_start=-1)
- Xcoeff = trans['Xcoeff']
- Ycoeff = trans['Ycoeff']
-
- #-----------------------------------------------#
- # General equation for applying the transform
- #-----------------------------------------------#
- #"""
+ # Make transform object
+ trans_table = Table.read(transFile, format='ascii.commented_header', header_start=-1)
+ Xcoeff = trans_table['Xcoeff']
+ Ycoeff = trans_table['Ycoeff']
# First determine the order based on the number of terms
# Comes from Nterms = (N+1)*(N+2) / 2.
order = (np.sqrt(1 + 8*len(Xcoeff)) - 3) / 2.
-
if order%1 != 0:
print( 'Incorrect number of coefficients for polynomial')
print( 'Stopping')
return
order = int(order)
+ # Do transform
+ transform = transforms.PolyTransform(order, Xcoeff, Ycoeff)
+ return transform_from_object(starlist, transform)
- # Position transformation
- x_new, y_new = transform_pos_from_file(Xcoeff, Ycoeff, order, x_orig,
- y_orig)
-
- if vel:
- x0_new, y0_new = transform_pos_from_file(Xcoeff, Ycoeff, order, x0_orig,
- y0_orig)
-
- # Position error transformation
- xe_new, ye_new = transform_poserr_from_file(Xcoeff, Ycoeff, order, xe_orig,
- ye_orig, x_orig, y_orig)
-
- if vel:
- x0e_new, y0e_new = transform_poserr_from_file(Xcoeff, Ycoeff, order, x0e_orig,
- y0e_orig, x0_orig, y0_orig)
-
- if vel:
- # Velocity transformation
- vx_new, vy_new = transform_vel_from_file(Xcoeff, Ycoeff, order, vx_orig,
- vy_orig, x_orig, y_orig)
-
- # Velocity error transformation
- vxe_new, vye_new = transform_velerr_from_file(Xcoeff, Ycoeff, order,
- vxe_orig, vye_orig,
- vx_orig, vy_orig,
- xe_orig, ye_orig,
- x_orig, y_orig)
-
- #----------------------------------------#
- # Hard coded example: old but functional
- #----------------------------------------#
- """
- # How the transformation is applied depends on the type of transform.
- # This can be determined by the length of Xcoeff, Ycoeff
- if len(Xcoeff) == 3:
- x_new = Xcoeff[0] + Xcoeff[1] * x_orig + Xcoeff[2] * y_orig
- y_new = Ycoeff[0] + Ycoeff[1] * x_orig + Ycoeff[2] * y_orig
- xe_new = np.sqrt( (Xcoeff[1] * xe_orig)**2 + (Xcoeff[2] * ye_orig)**2 )
- ye_new = np.sqrt( (Ycoeff[1] * xe_orig)**2 + (Ycoeff[2] * ye_orig)**2 )
-
- if vel:
- vx_new = Xcoeff[1] * vx_orig + Xcoeff[2] * vy_orig
- vy_new = Ycoeff[1] * vx_orig + Ycoeff[2] * vy_orig
- vxe_new = np.sqrt( (Xcoeff[1] * vxe_orig)**2 + (Xcoeff[2] * vye_orig)**2 )
- vye_new = np.sqrt( (Ycoeff[1] * vxe_orig)**2 + (Ycoeff[2] * vye_orig)**2 )
-
- elif len(Xcoeff) == 6:
- x_new = Xcoeff[0] + Xcoeff[1]*x_orig + Xcoeff[3]*x_orig**2 + Xcoeff[2]*y_orig + \
- Xcoeff[5]*y_orig**2. + Xcoeff[4]*x_orig*y_orig
-
- y_new = Ycoeff[0] + Ycoeff[1]*x_orig + Ycoeff[3]*x_orig**2 + Ycoeff[2]*y_orig + \
- Ycoeff[5]*y_orig**2. + Ycoeff[4]*x_orig*y_orig
-
- xe_new = np.sqrt( (Xcoeff[1] + 2*Xcoeff[3]*x_orig + Xcoeff[4]*y_orig)**2 * xe_orig**2 + \
- (Xcoeff[2] + 2*Xcoeff[5]*y_orig + Xcoeff[4]*x_orig)**2 * ye_orig**2 )
-
- ye_new = np.sqrt( (Ycoeff[1] + 2*Ycoeff[3]*x_orig + Ycoeff[4]*y_orig)**2 * xe_orig**2 + \
- (Ycoeff[2] + 2*Ycoeff[5]*y_orig + Ycoeff[4]*x_orig)**2 * ye_orig**2 )
-
- if vel:
- vx_new = Xcoeff[1]*vx_orig + 2*Xcoeff[3]*x_orig*vx_orig + Xcoeff[2]*vy_orig + \
- 2.*Xcoeff[5]*y_orig*vy_orig + Xcoeff[4]*(x_orig*vy_orig + vx_orig*y_orig)
-
- vy_new = Ycoeff[1]*vx_orig + 2*Ycoeff[3]*x_orig*vx_orig + Ycoeff[2]*vy_orig + \
- 2.*Ycoeff[5]*y_orig*vy_orig + Ycoeff[4]*(x_orig*vy_orig + vx_orig*y_orig)
-
- vxe_new = np.sqrt( (Xcoeff[1] + 2*Xcoeff[3]*x_orig + Xcoeff[4]*y_orig)**2 * vxe_orig**2 + \
- (Xcoeff[2] + 2*Xcoeff[5]*y_orig + Xcoeff[4]*x_orig)**2 * vye_orig**2 + \
- (2*Xcoeff[3]*vx_orig + Xcoeff[4]*vy_orig)**2 * xe_orig**2 + \
- (2*Xcoeff[5]*vy_orig + Xcoeff[4]*vx_orig)**2 * ye_orig**2 )
-
- vye_new = np.sqrt( (Ycoeff[1] + 2*Ycoeff[3]*x_orig + Ycoeff[4]*y_orig)**2 * vxe_orig**2 + \
- (Ycoeff[2] + 2*Ycoeff[5]*y_orig + Ycoeff[4]*x_orig)**2 * vye_orig**2 + \
- (2*Ycoeff[3]*vx_orig + Ycoeff[4]*vy_orig)**2 * xe_orig**2 + \
- (2*Ycoeff[5]*vy_orig + Ycoeff[4]*vx_orig)**2 * ye_orig**2 )
- """
- #Update transformed coords to copy of astropy table
- starlist_f['x'] = x_new
- starlist_f['y'] = y_new
- starlist_f['xe'] = xe_new
- starlist_f['ye'] = ye_new
-
- if vel:
- starlist_f['x0'] = x0_new
- starlist_f['y0'] = y0_new
- starlist_f['x0e'] = x0e_new
- starlist_f['y0e'] = y0e_new
- starlist_f['vx'] = vx_new
- starlist_f['vy'] = vy_new
- starlist_f['vxe'] = vxe_new
- starlist_f['vye'] = vye_new
-
- return starlist_f
def transform_from_object(starlist, transform):
"""
Apply transformation to starlist. Returns astropy table with
transformed positions/position errors, velocities and velocity errors
- if they are present in starlits
-
+ if they are present in starlits. If a more complex motion_model is
+ implemented, the motion parameters are set to nan, as we need the full time
+ series to refit.
+
Parameters:
----------
starlist: astropy table
@@ -2948,14 +3556,27 @@ def transform_from_object(starlist, transform):
"""
# Make a copy of starlist. This is what we will eventually modify with
# the transformed coordinates
- starlist_f = copy.deepcopy(starlist)
+ starlist_f = StarList(starlist, copy=True)
keys = list(starlist.keys())
- # Check to see if velocities are present in starlist. If so, we will
- # need to transform these as well as positions
- vel = 'vx' in keys
+ # Check to see if velocities or motion_model are present in starlist.
+ vel = ('vx' in keys) and ("motion_model_input" not in keys)
+ mot = ("motion_model_input" in keys)
+ # If the only motion models used are Fixed and Linear, we can still transform velocities.
+ if mot:
+ motion_models_unique = list(np.unique(starlist_f['motion_model_input']))
+ if 'Linear' in motion_models_unique:
+ motion_models_unique.remove('Linear')
+ if 'Fixed' in motion_models_unique:
+ motion_models_unique.remove('Fixed')
+ if len(motion_models_unique)==0:
+ vel=True
+ mot=False
+
+ # Prior code before motion_model implementation
+ # Can still be used as shortcut for Linear+Fixed motion_model only
err = 'xe' in keys
-
+
# Extract needed information from starlist
x = starlist_f['x']
y = starlist_f['y']
@@ -2963,49 +3584,50 @@ def transform_from_object(starlist, transform):
if err:
xe = starlist_f['xe']
ye = starlist_f['ye']
+ else:
+ xe = np.zeros(len(starlist_f))
+ ye = np.zeros(len(starlist_f))
if vel:
x0 = starlist_f['x0']
y0 = starlist_f['y0']
- x0e = starlist_f['x0e']
- y0e = starlist_f['y0e']
+ x0e = starlist_f['x0_err']
+ y0e = starlist_f['y0_err']
vx = starlist_f['vx']
vy = starlist_f['vy']
- vxe = starlist_f['vxe']
- vye = starlist_f['vye']
-
+ vxe = starlist_f['vx_err']
+ vye = starlist_f['vy_err']
+
# calculate the transformed position and velocity
-
- # (x_new, y_new, xe_new, ye_new) in (x,y)
x_new, y_new, xe_new, ye_new = position_transform_from_object(x, y, xe, ye, transform)
-
- if vel:
- # (x0_new, y0_new, x0e_new, y0e_new) in (x0, y0, x0e, y0e)
- x0_new, y0_new, x0e_new, y0e_new = position_transform_from_object(x0, y0, x0e, y0e, transform)
- # (vx_new, vy_new, vxe_new, vye_new) in (x0, y0, x0e, y0e, vx, vy, vxe, vye)
- vx_new, vy_new, vxe_new, vye_new = velocity_transform_from_object(x0, y0, x0e, y0e, vx, vy, vxe, vye, transform)
-
# update transformed coords to copy of astropy table
starlist_f['x'] = x_new
starlist_f['y'] = y_new
starlist_f['xe'] = xe_new
starlist_f['ye'] = ye_new
-
+
if vel:
+ x0_new, y0_new, x0e_new, y0e_new = position_transform_from_object(x0, y0, x0e, y0e, transform)
+ vx_new, vy_new, vxe_new, vye_new = velocity_transform_from_object(x0, y0, x0e, y0e, vx, vy, vxe, vye, transform)
starlist_f['x0'] = x0_new
starlist_f['y0'] = y0_new
- starlist_f['x0e'] = x0e_new
- starlist_f['y0e'] = y0e_new
+ starlist_f['x0_err'] = x0e_new
+ starlist_f['y0_err'] = y0e_new
starlist_f['vx'] = vx_new
starlist_f['vy'] = vy_new
- starlist_f['vxe'] = vxe_new
- starlist_f['vye'] = vye_new
-
- return starlist_f
-
+ starlist_f['vx_err'] = vxe_new
+ starlist_f['vy_err'] = vye_new
+ # For more complicated motion_models,
+ # we can't easily transform them, set the values to nans and refit later.
+ if mot:
+ motion_model_params = motion_model.motion_model_param_names()
+ for param in motion_model_params:
+ if param in keys:
+ starlist_f[param] = np.nan
+ return starlist_f
def position_transform_from_object(x, y, xe, ye, transform):
@@ -3017,7 +3639,7 @@ def position_transform_from_object(x, y, xe, ye, transform):
- x, y: original position
- xe, ye: original position error
- transform: transformation object from astropy.modeling.models.polynomial2D
-
+
Outpus:
- x_new, y_new: transformed position
- xe_new, ye_new: transformed position error
@@ -3034,8 +3656,8 @@ def position_transform_from_object(x, y, xe, ye, transform):
order = transform.order
else:
txt = 'Transform not yet supported by position_transform_from_object'
- raise StandardError(txt)
-
+ raise Exception(txt)
+
# How the transformation is applied depends on the type of transform.
# This can be determined by the length of Xcoeff, Ycoeff
N = order - 1
@@ -3060,9 +3682,8 @@ def position_transform_from_object(x, y, xe, ye, transform):
sub = int(2*N + 2 + j + (2*N+2-i) * (i-1)/2.)
y_new += Ycoeff[sub] * (x**i) * (y**j)
-
"""
- THIS IS WRONG BELOW!
+ THIS IS WRONG BELOW! - NOTE: I don't think this is wrong any more
Currently doing:
((A + B + C) * xe)**2
@@ -3070,7 +3691,7 @@ def position_transform_from_object(x, y, xe, ye, transform):
Should be doing:
((A**2 + B**2 + C**2) * xe**2)
"""
-
+
# xe_new & ye_new in (x,y,xe,ye)
xe_new = 0
temp1 = 0
@@ -3118,11 +3739,11 @@ def velocity_transform_from_object(x0, y0, x0e, y0e, vx, vy, vxe, vye, transform
- x0, y0, x0e, y0e: original position and position error
- vx, vy, vxe, vye: original velocity and velocity error
- transform: transformation object from astropy.modeling.models.polynomial2D
-
+
Outpus:
- vx_new, vy_new, vxe_new, vye_new: transformed velocity and velocity error
"""
-
+
# Read transformation: Extract X, Y coefficients from transform
if transform.__class__.__name__ == 'four_paramNW':
Xcoeff = transform.px
@@ -3134,8 +3755,8 @@ def velocity_transform_from_object(x0, y0, x0e, y0e, vx, vy, vxe, vye, transform
order = transform.order
else:
txt = 'Transform not yet supported by velocity_transform_from_object'
- raise StandardError(txt)
-
+ raise Exception(txt)
+
# How the transformation is applied depends on the type of transform.
# This can be determined by the length of Xcoeff, Ycoeff
N = order - 1
@@ -3196,7 +3817,7 @@ def velocity_transform_from_object(x0, y0, x0e, y0e, vx, vy, vxe, vye, transform
for i in range(1, N+1):
for j in range(1, N+2-i):
sub = 2*N + 2 + j + (2*N+2-i) * (i-1)/2.
- temp3 += i * Xcoeff[int(sub)] * (x0**(i-1)) * (y0**j)
+ temp3 += i * Xcoeff[int(sub)] * (x0**(i-1)) * (y0**j)
for j in range(1, N+2):
temp4 += j * Xcoeff[N+1+j] * (y0**(j-1))
@@ -3207,7 +3828,6 @@ def velocity_transform_from_object(x0, y0, x0e, y0e, vx, vy, vxe, vye, transform
vxe_new = np.sqrt((temp1*x0e)**2 + (temp2*y0e)**2 + (temp3*vxe)**2 + (temp4*vye)**2)
-
vye_new = 0
temp1 = 0
temp2 = 0
@@ -3240,7 +3860,7 @@ def velocity_transform_from_object(x0, y0, x0e, y0e, vx, vy, vxe, vye, transform
for i in range(1, N+1):
for j in range(1, N+2-i):
sub = 2*N + 2 + j + (2*N+2-i) * (i-1)/2.
- temp3 += i * Ycoeff[int(sub)] * (x0**(i-1)) * (y0**j)
+ temp3 += i * Ycoeff[int(sub)] * (x0**(i-1)) * (y0**j)
for j in range(1, N+2):
temp4 += j * Ycoeff[N+1+j] * (y0**(j-1))
@@ -3254,344 +3874,67 @@ def velocity_transform_from_object(x0, y0, x0e, y0e, vx, vy, vxe, vye, transform
return vx_new, vy_new, vxe_new, vye_new
-def transform_pos_from_file(Xcoeff, Ycoeff, order, x_orig, y_orig):
- """
- Given the read-in coefficients from transform_from_file, apply the
- transformation to the observed positions. This is generalized to
- work with any order polynomial transform.
-
- WARNING: THIS CODE WILL NOT WORK FOR LEGENDRE POLYNOMIAL
- TRANSFORMS
-
- Parameters:
- ----------
- Xcoeff: Array
- Array with the coefficients of the X pos transformation
-
- Ycoeff: Array
- Array with the coefficients of the Y pos transformation
-
- order: int
- Order of transformation
-
- x_orig: array
- Array with the original X positions
-
- y_orig: array
- Array with the original Y positions
-
- Output:
- ------
- x_new: array
- Transformed X positions
-
- y_new: array
- Transformed Y positions
-
- """
- idx = 0 # coeff index
- x_new = 0.0
- y_new = 0.0
- for i in range(order+1):
- for j in range(i+1):
- x_new += Xcoeff[idx] * x_orig**(i-j) * y_orig**j
- y_new += Ycoeff[idx] * x_orig**(i-j) * y_orig**j
-
- idx += 1
-
- return x_new, y_new
-
-def transform_poserr_from_file(Xcoeff, Ycoeff, order, xe_orig, ye_orig, x_orig, y_orig):
- """
- Given the read-in coefficients from transform_from_file, apply the
- transformation to the observed position errors. This is generalized to
- work with any order transform.
-
- WARNING: THIS CODE WILL NOT WORK FOR LEGENDRE POLYNOMIAL
- TRANSFORMS
-
- Parameters:
- ----------
- Xcoeff: Array
- Array with the coefficients of the X pos transformation
-
- Ycoeff: Array
- Array with the coefficients of the Y pos transformation
-
- order: int
- Order of transformation
-
- xe_orig: array
- Array with the original X position errs
-
- ye_orig: array
- Array with the original Y position errs
-
- x_orig: array
- Array with the original X positions
-
- y_orig: array
- Array with the original Y positions
-
- Output:
- ------
- xe_new: array
- Transformed X position errs
-
- ye_new: array
- Transformed Y position errs
- """
- idx = 0 # coeff index
- xe_new_tmp1 = 0.0
- ye_new_tmp1 = 0.0
- xe_new_tmp2 = 0.0
- ye_new_tmp2 = 0.0
-
- # First loop: dx'/dx
- for i in range(order+1):
- for j in range(i+1):
- xe_new_tmp1 += Xcoeff[idx] * (i - j) * x_orig**(i-j-1) * y_orig**j
- ye_new_tmp1 += Ycoeff[idx] * (i - j) * x_orig**(i-j-1) * y_orig**j
-
- idx += 1
-
- # Second loop: dy'/dy
- idx = 0 # coeff index
- for i in range(order+1):
- for j in range(i+1):
- xe_new_tmp2 += Xcoeff[idx] * (j) * x_orig**(i-j) * y_orig**(j-1)
- ye_new_tmp2 += Ycoeff[idx] * (j) * x_orig**(i-j) * y_orig**(j-1)
-
- idx += 1
- # Take square root for xe/ye_new
- xe_new = np.sqrt((xe_new_tmp1 * xe_orig)**2 + (xe_new_tmp2 * ye_orig)**2)
- ye_new = np.sqrt((ye_new_tmp1 * ye_orig)**2 + (ye_new_tmp2 * ye_orig)**2)
-
- return xe_new, ye_new
-
-def transform_vel_from_file(Xcoeff, Ycoeff, order, vx_orig, vy_orig, x_orig, y_orig):
- """
- Given the read-in coefficients from transform_from_file, apply the
- transformation to the observed proper motions. This is generalized to
- work with any order transform.
-
- WARNING: THIS CODE WILL NOT WORK FOR LEGENDRE POLYNOMIAL
- TRANSFORMS
-
- Parameters:
- ----------
- Xcoeff: Array
- Array with the coefficients of the X pos transformation
-
- Ycoeff: Array
- Array with the coefficients of the Y pos transformation
-
- order: int
- Order of transformation
-
- vx_orig: array
- Array with the original X proper motions
-
- vy_orig: array
- Array with the original Y proper motions
-
- x_orig: array
- Array with the original X positions
-
- y_orig: array
- Array with the original Y positions
-
- Output:
- ------
- vx_new: array
- Transformed X proper motions
-
- vy_new: array
- Transformed Y proper motions
- """
- idx = 0 # coeff index
- vx_new = 0.0
- vy_new = 0.0
- # First loop: dx'/dx
- for i in range(order+1):
- for j in range(i+1):
- vx_new += Xcoeff[idx] * (i - j) * x_orig**(i-j-1) * y_orig**j * vx_orig
- vy_new += Ycoeff[idx] * (i - j) * x_orig**(i-j-1) * y_orig**j * vx_orig
-
- idx += 1
- # Second loop: dy'/dy
- idx = 0 # coeff index
- for i in range(order+1):
- for j in range(i+1):
- vx_new += Xcoeff[idx] * (j) * x_orig**(i-j) * y_orig**(j-1) * vy_orig
- vy_new += Ycoeff[idx] * (j) * x_orig**(i-j) * y_orig**(j-1) * vy_orig
-
- idx += 1
-
- return vx_new, vy_new
-
-def transform_velerr_from_file(Xcoeff, Ycoeff, order, vxe_orig, vye_orig, vx_orig,
- vy_orig, xe_orig, ye_orig, x_orig, y_orig):
- """
- Given the read-in coefficients from transform_from_file, apply the
- transformation to the observed proper motion errors. This is generalized to
- work with any order transform.
-
- WARNING: THIS CODE WILL NOT WORK FOR LEGENDRE POLYNOMIAL
- TRANSFORMS
-
- Parameters:
- ----------
- Xcoeff: Array
- Array with the coefficients of the X pos transformation
-
- Ycoeff: Array
- Array with the coefficients of the Y pos transformation
-
- order: int
- Order of transformation
-
- vxe_orig: array
- Array with the original X proper motion errs
-
- vye_orig: array
- Array with the original Y proper motion errs
-
- vx_orig: array
- Array with the original X proper motions
-
- vy_orig: array
- Array with the original Y proper motions
-
- xe_orig: array
- Array with the original X position errs
-
- ye_orig: array
- Array with the original Y position errs
-
- x_orig: array
- Array with the original X positions
-
- y_orig: array
- Array with the original Y positions
-
- Output:
- ------
- vxe_new: array
- Transformed X proper motion errs
-
- vye_new: array
- Transformed Y proper motion errs
- """
- idx = 0
- vxe_new_tmp1 = 0.0
- vye_new_tmp1 = 0.0
- vxe_new_tmp2 = 0.0
- vye_new_tmp2 = 0.0
- vxe_new_tmp3 = 0.0
- vye_new_tmp3 = 0.0
- vxe_new_tmp4 = 0.0
- vye_new_tmp4 = 0.0
-
-
- # First loop: dvx' / dx
- for i in range(order+1):
- for j in range(i+1):
- vxe_new_tmp1 += Xcoeff[idx] * (i-j) * (i-j-1) * x_orig**(i-j-2) * y_orig**j * vx_orig
- vxe_new_tmp1 += Xcoeff[idx] * (j) * (i-j) * x_orig**(i-j-1) * y_orig**(j-1) * vy_orig
- vye_new_tmp1 += Ycoeff[idx] * (i-j) * (i-j-1) * x_orig**(i-j-2) * y_orig**j * vx_orig
- vye_new_tmp1 += Ycoeff[idx] * (j) * (i-j) * x_orig**(i-j-1) * y_orig**(j-1) * vy_orig
-
- idx += 1
-
- # Second loop: dvx' / dy
- idx = 0
- for i in range(order+1):
- for j in range(i+1):
- vxe_new_tmp2 += Xcoeff[idx] * (i-j) * (j) * x_orig**(i-j-1) * y_orig**(j-1) * vx_orig
- vxe_new_tmp2 += Xcoeff[idx] * (j) * (j-1) * x_orig**(i-j-1) * y_orig**(j-2) * vy_orig
- vye_new_tmp2 += Ycoeff[idx] * (i-j) * (j) * x_orig**(i-j-1) * y_orig**(j-1) * vx_orig
- vye_new_tmp2 += Ycoeff[idx] * (j) * (j-1) * x_orig**(i-j-1) * y_orig**(j-2) * vy_orig
-
- idx += 1
-
- # Third loop: dvx' / dvx
- idx = 0
- for i in range(order+1):
- for j in range(i+1):
- vxe_new_tmp3 += Xcoeff[idx] * (i-j) * x_orig**(i-j-1) * y_orig**j
- vye_new_tmp3 += Ycoeff[idx] * (i-j) * x_orig**(i-j-1) * y_orig**j
-
- idx += 1
-
- # Fourth loop: dvx' / dvy
- idx = 0
- for i in range(order+1):
- for j in range(i+1):
- vxe_new_tmp4 += Xcoeff[idx] * (j) * x_orig**(i-j) * y_orig**(j-1)
- vye_new_tmp4 += Ycoeff[idx] * (j) * x_orig**(i-j) * y_orig**(j-1)
-
- idx += 1
-
- vxe_new = np.sqrt((vxe_new_tmp1 * xe_orig)**2 + (vxe_new_tmp2 * ye_orig)**2 + \
- (vxe_new_tmp3 * vxe_orig)**2 + (vxe_new_tmp4 * vye_orig)**2)
- vye_new = np.sqrt((vye_new_tmp1 * xe_orig)**2 + (vye_new_tmp2 * ye_orig)**2 + \
- (vye_new_tmp3 * vxe_orig)**2 + (vye_new_tmp4 * vye_orig)**2)
-
- return vxe_new, vye_new
-
-
-def check_iter_tolerances(iters, dr_tol, dm_tol, outlier_tol):
- # iteration tolerances must match the number of iterations requested.
- assert iters == len(dr_tol)
- assert iters == len(dm_tol)
- assert iters == len(outlier_tol)
-
- return
-
def check_trans_input(list_of_starlists, trans_input, mag_trans):
# Check trans_input
# If we are transforming magnitudes and their are input transformations,
# then they need to have a mag_offset on them.
- if trans_input != None:
- assert len(trans_input) == len(list_of_starlists)
+ if trans_input is not None:
+ assert len(trans_input) == len(list_of_starlists), f'trans_input (len={len(trans_input)}) must have the same length as list_of_starlists (len={len(list_of_starlists)})!'
- if mag_trans:
+ if mag_trans:
for ii in range(len(trans_input)):
- if trans_input[ii] != None:
+ if trans_input[ii] is not None:
try:
trans_input[ii].mag_offset
except NameError:
print('Missing trans.mag_offset on trans_input[{0:d}].'.format(ii))
print('Setting mag_offset = 0 and dm_tol[0] = 100 and hoping for the best!!')
trans_input[ii].mag_offset = 0.0
-
+
return
-def trans_initial_guess(ref_list, star_list, trans_args, mode='miracle',
- ignore_contains='star', verbose=True, n_req_match=3,
- mag_trans=True, order=1):
+def trans_initial_guess(
+ ref_list,
+ star_list,
+ trans_args,
+ mode='miracle',
+ indices=None,
+ order=1,
+ briteN=None,
+ n_req_match=3,
+ polygon_reflist=None,
+ polygon_starlist=None,
+ buffer=0,
+ motion_models=None,
+ fixed_params_dict=None,
+ ignore_contains='star',
+ mag_trans=True,
+ verbose=True
+):
"""
Take two starlists and perform an initial matching and transformation.
This function will grow with time to handle difference types of initial
guess transformations (triangle matching, match by name, etc.). For now it
- is just blind triangle matching on the brightest 50 stars.
+ is just blind triangle matching on the brightest 50 stars.
"""
warnings.filterwarnings('ignore', category=AstropyUserWarning)
-
+ if motion_models is None:
+ motion_models = []
+
+ # Match by name
if mode == 'name':
# First trim the two lists down to only those that don't contain
# the "ignore_contains" string.
- idx_r = np.flatnonzero(np.char.find(ref_list['name'], ignore_contains) == -1)
- idx_s = np.flatnonzero(np.char.find(star_list['name'], ignore_contains) == -1)
+ idx_r = np.flatnonzero(np.char.find(ref_list['name'].astype(str), ignore_contains) == -1)
+ idx_s = np.flatnonzero(np.char.find(star_list['name'].astype(str), ignore_contains) == -1)
# Match the star names
name_matches, ndx_r, ndx_s = np.intersect1d(ref_list['name'][idx_r],
star_list['name'][idx_s],
assume_unique=True,
return_indices=True)
-
+
x1m = star_list['x'][idx_s][ndx_s]
y1m = star_list['y'][idx_s][ndx_s]
m1m = star_list['m'][idx_s][ndx_s]
@@ -3600,31 +3943,64 @@ def trans_initial_guess(ref_list, star_list, trans_args, mode='miracle',
m2m = ref_list['m'][idx_r][ndx_r]
N = len(x1m)
- else:
- # Default is miracle match.
- briteN = min(50, len(star_list))
+ # Default is miracle match.
+ elif mode == 'miracle':
+ if briteN is None:
+ briteN = min(50, len(star_list))
+ else:
+ assert (type(briteN) == int) and (briteN > 0), f'briteN must be a positive integer, but got {briteN}.'
# If there are velocities in the reference list, use them.
# We assume velocities are in the same units as the positions.
- xref, yref = get_pos_at_time(star_list['t'][0], ref_list)
+ if 't' in ref_list.colnames:
+ epoch = star_list['t'][0]
+ elif 'list_time' in star_list.meta:
+ epoch = star_list.meta['list_time']
+ else:
+ raise ValueError('star_list must have either a "t" column or a "list_time" meta key to use miracle matching.')
+
+ xref, yref = infer_positions(epoch, ref_list, motion_models, fixed_params_dict=fixed_params_dict)
if 'm' in ref_list.colnames:
mref = ref_list['m']
else:
mref = ref_list['m0']
-
- N, x1m, y1m, m1m, x2m, y2m, m2m = match.miracle_match_briteN(star_list['x'],
- star_list['y'],
- star_list['m'],
- xref,
- yref,
- mref,
- briteN)
-
- err_msg = 'Failed to find more than '+str(n_req_match)
- err_msg += ' (only ' + str(len(x1m)) + ') matches, giving up.'
- assert len(x1m) >= n_req_match, err_msg
+
+ N, x1m, y1m, m1m, x2m, y2m, m2m = match.miracle_match_briteN(
+ star_list['x'],
+ star_list['y'],
+ star_list['m'],
+ xref,
+ yref,
+ mref,
+ briteN,
+ polygon_reflist,
+ polygon_starlist,
+ buffer=buffer
+ )
+ elif mode == 'indices':
+ idx_r, idx_s = indices
+ x1m = star_list['x'][idx_s]
+ y1m = star_list['y'][idx_s]
+ m1m = star_list['m'][idx_s]
+ x2m = ref_list['x'][idx_r]
+ y2m = ref_list['y'][idx_r]
+ m2m = ref_list['m'][idx_r]
+ N = len(indices)
+
+ else:
+ raise ValueError(f'flystar.align.trans_initial_guess: Unknown mode: {mode}. Must be one of ["name", "miracle"].')
+
+ if len(x1m) < n_req_match:
+ fig, ax = plt.subplots()
+ ax.scatter(star_list['x'], star_list['y'], s=1, label='star_list')
+ ax.scatter(xref, yref, s=1, label='ref_list')
+ ax.legend()
+ ax.set_aspect('equal')
+ plt.show()
+ raise AssertionError(f'Failed to find more than {n_req_match} (only {len(x1m)}) matches, giving up.')
+
if verbose > 1:
- print('initial_guess: {0:d} stars matched between starlist and reference list'.format(N))
+ print('Initial_guess: {0:d} stars matched between starlist and reference list'.format(N))
# Calculate position transformation based on matches
if ('order' in trans_args) and (trans_args['order'] == 0):
@@ -3641,42 +4017,44 @@ def trans_initial_guess(ref_list, star_list, trans_args, mode='miracle',
trans.mag_offset = np.mean(m2m - m1m)
else:
trans.mag_offset = 0
-
+
if verbose > 1:
- print('init guess: ', trans.px.parameters, trans.py.parameters)
+ print('Initial guess:')
+ print(f'{trans.px.parameters=}')
+ print(f'{trans.py.parameters=}')
+ print(f'{trans.mag_offset=}')
warnings.filterwarnings('default', category=AstropyUserWarning)
-
+
return trans
def update_old_and_new_names(ref_table, list_index, idx_ref_new):
# Make new ref_list names for the new stars.
new_names = []
- new_name_len_max = 0
- for ss in idx_ref_new:
- new_name = '{0:3d}_{1:s}'.format(list_index, ref_table['name_in_list'][ss, list_index])
- new_names.append(new_name)
- new_name_len_max = max(new_name_len_max, len(new_name))
+ new_names = [f"{list_index:3d}_{name}" for name in ref_table['name_in_list'][idx_ref_new, list_index]]
+ new_name_len_max = np.max([len(new_name) for new_name in new_names])
old_names = ref_table['name']
- old_name_len = [len(old_name) for old_name in old_names]
- old_name_len_max = np.max(old_name_len)
+ # old_names is a fixed-width numpy unicode array, so its dtype already
+ # encodes the longest string it can hold without truncation -- no need to
+ # loop over every element (up to millions of rows) to find the max length.
+ old_name_len_max = old_names.dtype.itemsize // np.dtype('U1').itemsize
if new_name_len_max > old_name_len_max:
all_names = old_names.astype('U{0:d}'.format(new_name_len_max))
else:
all_names = old_names
-
+
all_names[idx_ref_new] = new_names
-
+
return all_names
def copy_and_rename_for_ref(star_list):
"""
Make a deep copy of the starlist and rename the columns to include
- "0". This only applies to x, y, m and xe, ye, me (if they exist)
+ "0". This only applies to x, y, m and xe, ye, me (if they exist)
columns.
Input
@@ -3689,69 +4067,69 @@ def copy_and_rename_for_ref(star_list):
if 'xe' in star_list.colnames:
old_cols += ['xe']
- new_cols += ['x0e']
+ new_cols += ['x0_err']
if 'ye' in star_list.colnames:
old_cols += ['ye']
- new_cols += ['y0e']
+ new_cols += ['y0_err']
if 'me' in star_list.colnames:
old_cols += ['me']
- new_cols += ['m0e']
+ new_cols += ['m0_err']
if 'w' in star_list.colnames:
old_cols += ['w']
new_cols += ['w']
-
- ref_list = copy.deepcopy(star_list)
+
+ ref_list = StarList(star_list, copy=True)
for ii in range(len(old_cols)):
ref_list.rename_column(old_cols[ii], new_cols[ii])
return ref_list
-def outlier_rejection_indices(star_list, ref_list, outlier_tol, verbose=True):
+def outlier_rejection_indices(star_list, ref_list, outlier_tol, motion_models, fixed_params_dict=None, verbose=True):
"""
Determine the outliers based on the residual positions between two different
- starlists and some threshold (in sigma). Return the indices of the stars
- to keep (that shouldn't be rejected as outliers).
+ starlists and some threshold (in sigma). Return the indices of the stars
+ to keep (that shouldn't be rejected as outliers).
Note that we assume that the star_list and ref_list are already transformed and
- matched.
+ matched.
Parameters
----------
star_list : StarList
starlist with 'x', 'y'
-
ref_list : StarList
starlist with 'x0', 'y0'
-
outlier_tol : float
- Number of sigma inside which we keep stars and outside of which we
- reject stars as outliers.
-
- Optional Parameters
- --------------------
- verbose : boolean
+ Number of sigma inside which we keep stars and outside of which we
+ reject stars as outliers.
+ motion_models : list of motion_model objects
+ The motion models to use in the star_list
+ fixed_params_dict : dict or None, optional
+ Dictionary of fixed parameters for motion models, by default None
+ verbose : bool, optional
+ If True, print information about the outlier rejection process, by default True
Returns
----------
- keepers : nd.array
- The indicies of the stars to keep.
+ keepers : bool array
+ The boolean array of the stars to keep.
"""
# Optionally propogate the reference positions forward in time.
- xref, yref = get_pos_in_time(star_list['t'][0], ref_list)
-
+ xref, yref = infer_positions(star_list['t'][0], ref_list, motion_models, fixed_params_dict=fixed_params_dict)
+
# Residuals
x_resid_on_old_trans = star_list['x'] - xref
y_resid_on_old_trans = star_list['y'] - yref
resid_on_old_trans = np.hypot(x_resid_on_old_trans, y_resid_on_old_trans)
threshold = outlier_tol * resid_on_old_trans.std()
- keepers = np.where(resid_on_old_trans < threshold)[0]
+ keepers = resid_on_old_trans < threshold
if verbose > 0:
msg = ' Outlier Rejection: Keeping {0:d} of {1:d}'
- print(msg.format(len(keepers), len(resid_on_old_trans)))
-
+ print(msg.format(sum(keepers), len(resid_on_old_trans)))
+
return keepers
def setup_trans_info(trans_input, trans_args, N_lists, iters):
@@ -3763,7 +4141,7 @@ def setup_trans_info(trans_input, trans_args, N_lists, iters):
iters : int
"""
trans_list = [None for ii in range(N_lists)]
- if trans_input != None:
+ if trans_input is not None:
trans_list = [trans_input[ii] for ii in range(N_lists)]
# Keep a list of trans_args, one for each starlist. If only
@@ -3771,12 +4149,12 @@ def setup_trans_info(trans_input, trans_args, N_lists, iters):
if type(trans_args) == dict:
tmp = trans_args
trans_args = [tmp for ii in range(iters)]
-
+
return trans_list, trans_args
def apply_mag_lim(star_list, mag_lim):
- """ Apply a magnitude limit to the list. If no magnitude limit is
- specified, then return a copy of the list. This works on a
+ """ Apply a magnitude limit to the list. If no magnitude limit is
+ specified, then return a copy of the list. This works on a
reference list (with 'm0') or a star_list ('m') with 'm0' taking
priority.
@@ -3785,7 +4163,7 @@ def apply_mag_lim(star_list, mag_lim):
no magnitude cut is applied.
"""
- star_list_T = copy.deepcopy(star_list)
+ star_list_T = StarList(star_list, copy=True)
if (mag_lim is not None):
# Support 'm0' (primary) or 'm' column name.
@@ -3795,7 +4173,7 @@ def apply_mag_lim(star_list, mag_lim):
mcol = 'm'
conditions = {}
-
+
cond_key = '{0:s}_min'.format(mcol)
conditions[cond_key] = mag_lim[0]
@@ -3813,7 +4191,7 @@ def get_weighting_scheme(weights, ref_list, star_list):
else:
var_xref = 0.0
var_yref = 0.0
-
+
if 'xe' in star_list.colnames:
var_xlis = star_list['xe']**2
var_ylis = star_list['ye']**2
@@ -3821,7 +4199,7 @@ def get_weighting_scheme(weights, ref_list, star_list):
var_xlis = 0.0
var_ylis = 0.0
- if weights != None:
+ if weights is not None:
if weights == 'both,var':
weight = 1.0 / (var_xref + var_xlis + var_yref + var_ylis)
if weights == 'both,std':
@@ -3844,36 +4222,217 @@ def get_weighting_scheme(weights, ref_list, star_list):
return weight
-def get_pos_at_time(t, starlist, use_vel=True):
- """
- Take a starlist, check to see if it has velocity columns.
- If it does, then propogate the positions forward in time
- to the desired epoch. If no velocities exist, then just
- use ['x0', 'y0'] or ['x', 'y']
-
- Inputs
- ----------
- t_array : float
- The time to propogate to. Usually in decimal years;
- but it should be in the same units
- as the 't0' column in starlist.
- """
- if use_vel and ('vx' in starlist.colnames) and ('vy' in starlist.colnames):
- dt = t - starlist['t0']
- x = starlist['x0'] + (starlist['vx'] * dt)
- y = starlist['y0'] + (starlist['vy'] * dt)
- else:
- if ('x0' in starlist.colnames) and ('y0' in starlist.colnames):
- x = starlist['x0']
- y = starlist['y0']
- else:
- x = starlist['x']
- y = starlist['y']
-
- return (x, y)
def logger(logfile, message, verbose = 9):
if verbose > 4:
print(message)
logfile.write(message + '\n')
return
+
+
+def generic_match(sl1, sl2, init_mode='triangle',
+ model=transforms.PolyTransform, order_dr=(1, 1.0),
+ dr_final=1.0,
+ xy_match=(None, None, None, None, None, None, None, None),
+ m_match=(None, None, None, None), sigma_match=None,
+ n_bright=100, verbose=True, **kwargs):
+ """
+ Finds the transformation between two starlists using the first one
+ as reference frame. Different matching methods can be used. If no
+ transformation is found, it returns an error message.
+
+
+ Parameters
+ sl1 : StarList
+ starlist used for reference frame
+ sl2 : StarList
+ starlist transformed
+ init_mode : str
+ Initial matching method.
+ If 'triangle', uses the blind triangle method.
+ If 'match_name', uses match by name
+ If 'load', uses the transformation from a loaded file
+ model : str
+ Transformation model to be used with the 'triangle' initial mode
+ poly_order : int
+ Order of the transformation model
+ order_dr : int, float [n, 2]
+ Combinations of polinomial order (first column) and search radius
+ (second column) to refine the transformation. Rows are executed in
+ orders
+ dr_final: float
+ Search radius used for the final matching
+ n_bright : int
+ Number of bright stars used in the initial blind triangles matching
+ xy_match : array
+ Area of the images to remove in the matching [reference catalog min x,
+ reference catalog max x, reference catalog min y, reference catalog max y,
+ transformed catalog min x, transformed catalog max x,
+ transformed catalog min y, transformed catalog max y]. Use None for values not used.
+ m_match : array
+ Magnitude limits of matching stars used to find transformations
+ [reference catalog min mag, reference catalog max mag, transformed
+ catalog min mag, transformed catalog max mag]. Use None for values not
+ used
+ sigma_match : array
+ Number of Deltap movement sigmas [0] used for sigma-cutting matched
+ stars for a number of times [1]. Use None for no sigma-cut. The last
+ polynomial order and search radius in 'order_dr' are used
+ transf_file : str
+ File name and path of the transformation file used with the 'load'
+ init_mode
+ verbose : bool, optional
+ Prints on screen information on the matching
+
+ Returns
+ -------
+ transf : Transform2D
+ Transformation of the second starlist respect to the first
+ st : StarTable
+ Startable of the two matched catalogs
+
+ """
+ from flystar import starlists, startables
+ # Check the input StarLists and transform them into astropy Tables
+ if not isinstance(sl1, starlists.StarList):
+ raise TypeError("The first catalog has to be a StarList")
+ if not isinstance(sl2, starlists.StarList):
+ raise TypeError("The second catalog has to be a StarList")
+
+ # Find the initial transformation
+ if init_mode == 'triangle': # Blind triangles method
+
+ # Prepare the reduced starlists for matching
+ sl1_cut = StarList(sl1, copy=True)
+ sl2_cut = StarList(sl2, copy=True)
+ sl1_cut.restrict_by_value(x_min=xy_match[0], x_max=xy_match[1],
+ y_min=xy_match[2], y_max=xy_match[3])
+ sl2_cut.restrict_by_value(x_min=xy_match[4], x_max=xy_match[5],
+ y_min=xy_match[6], y_max=xy_match[7])
+ sl1_cut.restrict_by_value(m_min=m_match[0], m_max=m_match[1])
+ sl2_cut.restrict_by_value(m_min=m_match[2], m_max=m_match[3])
+
+ # Find the transformation
+ # TODO: test 'initial_align' with StarList input
+ transf = initial_align(sl1_cut, sl2_cut, briteN=n_bright, transformModel=model, order=order_dr[0]) #order_dr[i_loop][0] ?
+
+ elif init_mode == 'match_name': # Name match
+ sl1_idx_init, sl2_idx_init, _ = starlists.restrict_by_name(sl1, sl2)
+ transf = model(sl2['x'][sl2_idx_init], sl2['y'][sl2_idx_init],
+ sl1['x'][sl1_idx_init], sl1['y'][sl1_idx_init],
+ order=int(order_dr[0][0]))
+
+ elif init_mode == 'load': # Load a transformation file
+ transf = transforms.Transform2D.from_file(kwargs['transf_file'])
+
+ else: # None of the above
+ raise TypeError("Unrecognized initial matching method")
+
+ # Restrict the matching catalogs
+ sl1_match = StarList(sl1, copy=True)
+ sl2_match = StarList(sl2, copy=True)
+ sl1_match.restrict_by_value(m_min=m_match[0], m_max=m_match[1])
+ sl2_match.restrict_by_value(m_min=m_match[2], m_max=m_match[3])
+
+ # Refine the transformation
+ if sigma_match:
+ order_dr_len = len(order_dr)
+
+ for i_loop in range(sigma_match[1]):
+ order_dr = np.vstack((np.array(order_dr), np.array(order_dr[-1])))
+
+ for i_loop in range(len(order_dr)):
+
+ # Transform and match the catalog to the reference frame
+ sl2_idx, sl1_idx = transform_and_match(sl2_match, sl1_match, transf,
+ dr_tol=order_dr[1],
+ verbose=verbose)
+
+ # Transform the catalog to the reference frame
+ sl2_transf_match = transform_from_object(sl2_match, transf)
+
+ # Sigma-rejection
+ if sigma_match and (i_loop >= order_dr_len):
+ resid = np.sqrt((sl1_match['x'][sl1_idx] -
+ sl2_transf_match['x'][sl2_idx])**2 +
+ (sl1_match['y'][sl1_idx] -
+ sl2_transf_match['y'][sl2_idx])**2)
+ sl1_idx = sl1_idx[resid <= (sigma_match[0] * np.std(resid))]
+ sl2_idx = sl2_idx[resid <= (sigma_match[0] * np.std(resid))]
+
+ # Test section to observe the matching catalogs before refining the transformation
+ """
+ from matplotlib import pyplot
+
+ _, axarr = pyplot.subplots(nrows=1, ncols=1, figsize=(10,10))
+ axarr.scatter(sl1_match['x'][sl1_idx], sl1_match['y'][sl1_idx])
+ xlim = axarr.get_xlim()
+ ylim = axarr.get_ylim()
+
+ _, axarr = pyplot.subplots(nrows=1, ncols=1, figsize=(10, 10))
+ axarr.scatter(sl2_transf_match['x'][sl2_idx], sl2_transf_match['y'][sl2_idx])
+ axarr.set_xlim(xlim)
+ axarr.set_ylim(ylim)
+ """
+
+ # Find a better transformation
+ transf, _ = find_transform(
+ sl2_match[sl2_idx],
+ sl2_transf_match[sl2_idx],
+ sl1_match[sl1_idx], transModel=model,
+ order=order_dr[0], verbose=verbose
+ )
+
+ # This section was used for testing transformations with normalized
+ # coordinates. Only several catalogs had reduced residuals when using
+ # high order polynomials (>3), some of them became unstable
+ """sl1_match_norm = sl1_match[sl1_idx]
+ sl2_match_norm = sl2_match[sl2_idx]
+ sl2_transf_match_norm = sl2_transf_match[sl2_idx]
+ mm = max(max(sl1_match_norm['x']), max(sl1_match_norm['y']),
+ max(sl2_transf_match_norm['x']), max(sl2_transf_match_norm['y']))
+ sl1_match_norm['x'] = sl1_match_norm['x'] / mm
+ sl1_match_norm['y'] = sl1_match_norm['y'] / mm
+ sl2_match_norm['x'] = sl2_match_norm['x'] / mm
+ sl2_match_norm['y'] = sl2_match_norm['y'] / mm
+ sl2_transf_match_norm['x'] = sl2_transf_match_norm['x'] / mm
+ sl2_transf_match_norm['y'] = sl2_transf_match_norm['y'] / mm
+ transf, _ = align.find_transform(sl2_match_norm, sl2_transf_match_norm,
+ sl1_match_norm, transModel=model,
+ order=poly_order, verbose=verbose)
+ c_exp = np.zeros(len(transf.px._parameters))
+
+ for i_c in range(len(transf.px._parameters)):
+ c_exp[i_c] = int(transf.px._param_names[i_c][1:].split('_')[0]) +\
+ int(transf.px._param_names[i_c][1:].split('_')[1])
+
+ c_corr = mm ** (1 - c_exp)
+ transf.px._parameters = transf.px._parameters * c_corr
+ transf.py._parameters = transf.py._parameters * c_corr"""
+
+ # Do the final transformation and matching using
+ sl2_idx, sl1_idx = transform_and_match(sl2, sl1, transf, dr_tol=dr_final, verbose=verbose)
+ # StarTable output
+ sl2_transf = transform_from_object(sl2, transf)
+ unames = np.array(range(len(sl1_idx)))
+ st = startables.StarTable(name=unames,
+ x=np.column_stack((np.array(sl1['x'][sl1_idx]), np.array(sl2_transf['x'][sl2_idx]))),
+ y=np.column_stack((np.array(sl1['y'][sl1_idx]), np.array(sl2_transf['y'][sl2_idx]))),
+ m=np.column_stack((np.array(sl1['m'][sl1_idx]), np.array(sl2_transf['m'][sl2_idx]))),
+ ep_name=np.column_stack((np.array(sl1['name'][sl1_idx]), np.array(sl2_transf['name'][sl2_idx])))
+ )
+
+ for col in sl1.colnames:
+ if col in sl2.colnames:
+ if col not in ['name', 'x', 'y', 'm']:
+ st.add_column(Column(np.column_stack((np.array(sl1[col][sl1_idx]),np.array(sl2_transf[col][sl2_idx]))), name=col))
+
+ return transf, st
+
+
+def suppress_meta_warnings(table):
+ table.meta = {
+ (f'HIERARCH {k}' if len(k) > 8 else k): v
+ for k, v in table.meta.items()
+ }
+ return
\ No newline at end of file
diff --git a/flystar/align_old_functions.py b/flystar/align_old_functions.py
new file mode 100755
index 0000000..9bae670
--- /dev/null
+++ b/flystar/align_old_functions.py
@@ -0,0 +1,828 @@
+"""
+Old functions that are only referenced in examples and template
+"""
+def transform_from_file(starlist, transFile):
+ """
+ Apply transformation from transFile to starlist. Returns astropy table with
+ added columns with the transformed coordinates. NOTE: Transforms
+ positions/position errors, plus velocities and velocity errors if they
+ are present in starlist.
+
+ WARNING: THIS CODE WILL NOT WORK FOR LEGENDRE POLYNOMIAL
+ TRANSFORMS
+
+ Parameters:
+ ----------
+ starlist: astropy table
+ Starlist we want to apply the transformation too. Must already
+ have standard column headers
+
+ transFile: ascii file
+ File with the transformation coefficients. Assumed to be output of
+ write_transform, with coefficients specified as code documents
+
+ Output:
+ ------
+ Copy of starlist astropy table with transformed coordinates.
+ """
+ # Make a copy of starlist. This is what we will eventually modify with
+ # the transformed coordinates
+ starlist_f = copy.deepcopy(starlist)
+
+ # Check to see if velocities are present in starlist. If so, we will
+ # need to transform these as well as positions
+ vel = False
+ keys = list(starlist.keys())
+ if 'vx' in keys:
+ vel = True
+
+ # Extract needed information from starlist
+ x_orig = starlist['x']
+ y_orig = starlist['y']
+ xe_orig = starlist['xe']
+ ye_orig = starlist['ye']
+
+ if vel:
+ x0_orig = starlist['x0']
+ y0_orig = starlist['y0']
+ x0e_orig = starlist['x0_err']
+ y0e_orig = starlist['y0_err']
+
+ vx_orig = starlist['vx']
+ vy_orig = starlist['vy']
+ vxe_orig = starlist['vx_err']
+ vye_orig = starlist['vy_err']
+
+ # Read transFile
+ trans = Table.read(transFile, format='ascii.commented_header', header_start=-1)
+ Xcoeff = trans['Xcoeff']
+ Ycoeff = trans['Ycoeff']
+
+ #-----------------------------------------------#
+ # General equation for applying the transform
+ #-----------------------------------------------#
+ #"""
+ # First determine the order based on the number of terms
+ # Comes from Nterms = (N+1)*(N+2) / 2.
+ order = (np.sqrt(1 + 8*len(Xcoeff)) - 3) / 2.
+
+ if order%1 != 0:
+ print( 'Incorrect number of coefficients for polynomial')
+ print( 'Stopping')
+ return
+ order = int(order)
+
+ # Position transformation
+ x_new, y_new = transform_pos_from_file(Xcoeff, Ycoeff, order, x_orig,
+ y_orig)
+
+ if vel:
+ x0_new, y0_new = transform_pos_from_file(Xcoeff, Ycoeff, order, x0_orig,
+ y0_orig)
+
+ # Position error transformation
+ xe_new, ye_new = transform_poserr_from_file(Xcoeff, Ycoeff, order, xe_orig,
+ ye_orig, x_orig, y_orig)
+
+ if vel:
+ x0e_new, y0e_new = transform_poserr_from_file(Xcoeff, Ycoeff, order, x0e_orig,
+ y0e_orig, x0_orig, y0_orig)
+
+ if vel:
+ # Velocity transformation
+ vx_new, vy_new = transform_vel_from_file(Xcoeff, Ycoeff, order, vx_orig,
+ vy_orig, x_orig, y_orig)
+
+ # Velocity error transformation
+ vxe_new, vye_new = transform_velerr_from_file(Xcoeff, Ycoeff, order,
+ vxe_orig, vye_orig,
+ vx_orig, vy_orig,
+ xe_orig, ye_orig,
+ x_orig, y_orig)
+
+ #----------------------------------------#
+ # Hard coded example: old but functional
+ #----------------------------------------#
+ """
+ # How the transformation is applied depends on the type of transform.
+ # This can be determined by the length of Xcoeff, Ycoeff
+ if len(Xcoeff) == 3:
+ x_new = Xcoeff[0] + Xcoeff[1] * x_orig + Xcoeff[2] * y_orig
+ y_new = Ycoeff[0] + Ycoeff[1] * x_orig + Ycoeff[2] * y_orig
+ xe_new = np.sqrt( (Xcoeff[1] * xe_orig)**2 + (Xcoeff[2] * ye_orig)**2 )
+ ye_new = np.sqrt( (Ycoeff[1] * xe_orig)**2 + (Ycoeff[2] * ye_orig)**2 )
+
+ if vel:
+ vx_new = Xcoeff[1] * vx_orig + Xcoeff[2] * vy_orig
+ vy_new = Ycoeff[1] * vx_orig + Ycoeff[2] * vy_orig
+ vxe_new = np.sqrt( (Xcoeff[1] * vxe_orig)**2 + (Xcoeff[2] * vye_orig)**2 )
+ vye_new = np.sqrt( (Ycoeff[1] * vxe_orig)**2 + (Ycoeff[2] * vye_orig)**2 )
+
+ elif len(Xcoeff) == 6:
+ x_new = Xcoeff[0] + Xcoeff[1]*x_orig + Xcoeff[3]*x_orig**2 + Xcoeff[2]*y_orig + \
+ Xcoeff[5]*y_orig**2. + Xcoeff[4]*x_orig*y_orig
+
+ y_new = Ycoeff[0] + Ycoeff[1]*x_orig + Ycoeff[3]*x_orig**2 + Ycoeff[2]*y_orig + \
+ Ycoeff[5]*y_orig**2. + Ycoeff[4]*x_orig*y_orig
+
+ xe_new = np.sqrt( (Xcoeff[1] + 2*Xcoeff[3]*x_orig + Xcoeff[4]*y_orig)**2 * xe_orig**2 + \
+ (Xcoeff[2] + 2*Xcoeff[5]*y_orig + Xcoeff[4]*x_orig)**2 * ye_orig**2 )
+
+ ye_new = np.sqrt( (Ycoeff[1] + 2*Ycoeff[3]*x_orig + Ycoeff[4]*y_orig)**2 * xe_orig**2 + \
+ (Ycoeff[2] + 2*Ycoeff[5]*y_orig + Ycoeff[4]*x_orig)**2 * ye_orig**2 )
+
+ if vel:
+ vx_new = Xcoeff[1]*vx_orig + 2*Xcoeff[3]*x_orig*vx_orig + Xcoeff[2]*vy_orig + \
+ 2.*Xcoeff[5]*y_orig*vy_orig + Xcoeff[4]*(x_orig*vy_orig + vx_orig*y_orig)
+
+ vy_new = Ycoeff[1]*vx_orig + 2*Ycoeff[3]*x_orig*vx_orig + Ycoeff[2]*vy_orig + \
+ 2.*Ycoeff[5]*y_orig*vy_orig + Ycoeff[4]*(x_orig*vy_orig + vx_orig*y_orig)
+
+ vxe_new = np.sqrt( (Xcoeff[1] + 2*Xcoeff[3]*x_orig + Xcoeff[4]*y_orig)**2 * vxe_orig**2 + \
+ (Xcoeff[2] + 2*Xcoeff[5]*y_orig + Xcoeff[4]*x_orig)**2 * vye_orig**2 + \
+ (2*Xcoeff[3]*vx_orig + Xcoeff[4]*vy_orig)**2 * xe_orig**2 + \
+ (2*Xcoeff[5]*vy_orig + Xcoeff[4]*vx_orig)**2 * ye_orig**2 )
+
+ vye_new = np.sqrt( (Ycoeff[1] + 2*Ycoeff[3]*x_orig + Ycoeff[4]*y_orig)**2 * vxe_orig**2 + \
+ (Ycoeff[2] + 2*Ycoeff[5]*y_orig + Ycoeff[4]*x_orig)**2 * vye_orig**2 + \
+ (2*Ycoeff[3]*vx_orig + Ycoeff[4]*vy_orig)**2 * xe_orig**2 + \
+ (2*Ycoeff[5]*vy_orig + Ycoeff[4]*vx_orig)**2 * ye_orig**2 )
+ """
+ #Update transformed coords to copy of astropy table
+ starlist_f['x'] = x_new
+ starlist_f['y'] = y_new
+ starlist_f['xe'] = xe_new
+ starlist_f['ye'] = ye_new
+
+ if vel:
+ starlist_f['x0'] = x0_new
+ starlist_f['y0'] = y0_new
+ starlist_f['x0_err'] = x0e_new
+ starlist_f['y0_err'] = y0e_new
+ starlist_f['vx'] = vx_new
+ starlist_f['vy'] = vy_new
+ starlist_f['vx_err'] = vxe_new
+ starlist_f['vy_err'] = vye_new
+
+ return starlist_f
+
+def transform_pos_from_file(Xcoeff, Ycoeff, order, x_orig, y_orig):
+ """
+ Given the read-in coefficients from transform_from_file, apply the
+ transformation to the observed positions. This is generalized to
+ work with any order polynomial transform.
+
+ WARNING: THIS CODE WILL NOT WORK FOR LEGENDRE POLYNOMIAL
+ TRANSFORMS
+
+ Parameters:
+ ----------
+ Xcoeff: Array
+ Array with the coefficients of the X pos transformation
+
+ Ycoeff: Array
+ Array with the coefficients of the Y pos transformation
+
+ order: int
+ Order of transformation
+
+ x_orig: array
+ Array with the original X positions
+
+ y_orig: array
+ Array with the original Y positions
+
+ Output:
+ ------
+ x_new: array
+ Transformed X positions
+
+ y_new: array
+ Transformed Y positions
+
+ """
+ idx = 0 # coeff index
+ x_new = 0.0
+ y_new = 0.0
+ for i in range(order+1):
+ for j in range(i+1):
+ x_new += Xcoeff[idx] * x_orig**(i-j) * y_orig**j
+ y_new += Ycoeff[idx] * x_orig**(i-j) * y_orig**j
+
+ idx += 1
+
+ return x_new, y_new
+
+def transform_poserr_from_file(Xcoeff, Ycoeff, order, xe_orig, ye_orig, x_orig, y_orig):
+ """
+ Given the read-in coefficients from transform_from_file, apply the
+ transformation to the observed position errors. This is generalized to
+ work with any order transform.
+
+ WARNING: THIS CODE WILL NOT WORK FOR LEGENDRE POLYNOMIAL
+ TRANSFORMS
+
+ Parameters:
+ ----------
+ Xcoeff: Array
+ Array with the coefficients of the X pos transformation
+
+ Ycoeff: Array
+ Array with the coefficients of the Y pos transformation
+
+ order: int
+ Order of transformation
+
+ xe_orig: array
+ Array with the original X position errs
+
+ ye_orig: array
+ Array with the original Y position errs
+
+ x_orig: array
+ Array with the original X positions
+
+ y_orig: array
+ Array with the original Y positions
+
+ Output:
+ ------
+ xe_new: array
+ Transformed X position errs
+
+ ye_new: array
+ Transformed Y position errs
+ """
+ idx = 0 # coeff index
+ xe_new_tmp1 = 0.0
+ ye_new_tmp1 = 0.0
+ xe_new_tmp2 = 0.0
+ ye_new_tmp2 = 0.0
+
+ # First loop: dx'/dx
+ for i in range(order+1):
+ for j in range(i+1):
+ xe_new_tmp1 += Xcoeff[idx] * (i - j) * x_orig**(i-j-1) * y_orig**j
+ ye_new_tmp1 += Ycoeff[idx] * (i - j) * x_orig**(i-j-1) * y_orig**j
+
+ idx += 1
+
+ # Second loop: dy'/dy
+ idx = 0 # coeff index
+ for i in range(order+1):
+ for j in range(i+1):
+ xe_new_tmp2 += Xcoeff[idx] * (j) * x_orig**(i-j) * y_orig**(j-1)
+ ye_new_tmp2 += Ycoeff[idx] * (j) * x_orig**(i-j) * y_orig**(j-1)
+
+ idx += 1
+ # Take square root for xe/ye_new
+ xe_new = np.sqrt((xe_new_tmp1 * xe_orig)**2 + (xe_new_tmp2 * ye_orig)**2)
+ ye_new = np.sqrt((ye_new_tmp1 * ye_orig)**2 + (ye_new_tmp2 * ye_orig)**2)
+
+ return xe_new, ye_new
+
+def transform_vel_from_file(Xcoeff, Ycoeff, order, vx_orig, vy_orig, x_orig, y_orig):
+ """
+ Given the read-in coefficients from transform_from_file, apply the
+ transformation to the observed proper motions. This is generalized to
+ work with any order transform.
+
+ WARNING: THIS CODE WILL NOT WORK FOR LEGENDRE POLYNOMIAL
+ TRANSFORMS
+
+ Parameters:
+ ----------
+ Xcoeff: Array
+ Array with the coefficients of the X pos transformation
+
+ Ycoeff: Array
+ Array with the coefficients of the Y pos transformation
+
+ order: int
+ Order of transformation
+
+ vx_orig: array
+ Array with the original X proper motions
+
+ vy_orig: array
+ Array with the original Y proper motions
+
+ x_orig: array
+ Array with the original X positions
+
+ y_orig: array
+ Array with the original Y positions
+
+ Output:
+ ------
+ vx_new: array
+ Transformed X proper motions
+
+ vy_new: array
+ Transformed Y proper motions
+ """
+ idx = 0 # coeff index
+ vx_new = 0.0
+ vy_new = 0.0
+ # First loop: dx'/dx
+ for i in range(order+1):
+ for j in range(i+1):
+ vx_new += Xcoeff[idx] * (i - j) * x_orig**(i-j-1) * y_orig**j * vx_orig
+ vy_new += Ycoeff[idx] * (i - j) * x_orig**(i-j-1) * y_orig**j * vx_orig
+
+ idx += 1
+ # Second loop: dy'/dy
+ idx = 0 # coeff index
+ for i in range(order+1):
+ for j in range(i+1):
+ vx_new += Xcoeff[idx] * (j) * x_orig**(i-j) * y_orig**(j-1) * vy_orig
+ vy_new += Ycoeff[idx] * (j) * x_orig**(i-j) * y_orig**(j-1) * vy_orig
+
+ idx += 1
+
+ return vx_new, vy_new
+
+def transform_velerr_from_file(Xcoeff, Ycoeff, order, vxe_orig, vye_orig, vx_orig,
+ vy_orig, xe_orig, ye_orig, x_orig, y_orig):
+ """
+ Given the read-in coefficients from transform_from_file, apply the
+ transformation to the observed proper motion errors. This is generalized to
+ work with any order transform.
+
+ WARNING: THIS CODE WILL NOT WORK FOR LEGENDRE POLYNOMIAL
+ TRANSFORMS
+
+ Parameters:
+ ----------
+ Xcoeff: Array
+ Array with the coefficients of the X pos transformation
+
+ Ycoeff: Array
+ Array with the coefficients of the Y pos transformation
+
+ order: int
+ Order of transformation
+
+ vxe_orig: array
+ Array with the original X proper motion errs
+
+ vye_orig: array
+ Array with the original Y proper motion errs
+
+ vx_orig: array
+ Array with the original X proper motions
+
+ vy_orig: array
+ Array with the original Y proper motions
+
+ xe_orig: array
+ Array with the original X position errs
+
+ ye_orig: array
+ Array with the original Y position errs
+
+ x_orig: array
+ Array with the original X positions
+
+ y_orig: array
+ Array with the original Y positions
+
+ Output:
+ ------
+ vxe_new: array
+ Transformed X proper motion errs
+
+ vye_new: array
+ Transformed Y proper motion errs
+ """
+ idx = 0
+ vxe_new_tmp1 = 0.0
+ vye_new_tmp1 = 0.0
+ vxe_new_tmp2 = 0.0
+ vye_new_tmp2 = 0.0
+ vxe_new_tmp3 = 0.0
+ vye_new_tmp3 = 0.0
+ vxe_new_tmp4 = 0.0
+ vye_new_tmp4 = 0.0
+
+
+ # First loop: dvx' / dx
+ for i in range(order+1):
+ for j in range(i+1):
+ vxe_new_tmp1 += Xcoeff[idx] * (i-j) * (i-j-1) * x_orig**(i-j-2) * y_orig**j * vx_orig
+ vxe_new_tmp1 += Xcoeff[idx] * (j) * (i-j) * x_orig**(i-j-1) * y_orig**(j-1) * vy_orig
+ vye_new_tmp1 += Ycoeff[idx] * (i-j) * (i-j-1) * x_orig**(i-j-2) * y_orig**j * vx_orig
+ vye_new_tmp1 += Ycoeff[idx] * (j) * (i-j) * x_orig**(i-j-1) * y_orig**(j-1) * vy_orig
+
+ idx += 1
+
+ # Second loop: dvx' / dy
+ idx = 0
+ for i in range(order+1):
+ for j in range(i+1):
+ vxe_new_tmp2 += Xcoeff[idx] * (i-j) * (j) * x_orig**(i-j-1) * y_orig**(j-1) * vx_orig
+ vxe_new_tmp2 += Xcoeff[idx] * (j) * (j-1) * x_orig**(i-j-1) * y_orig**(j-2) * vy_orig
+ vye_new_tmp2 += Ycoeff[idx] * (i-j) * (j) * x_orig**(i-j-1) * y_orig**(j-1) * vx_orig
+ vye_new_tmp2 += Ycoeff[idx] * (j) * (j-1) * x_orig**(i-j-1) * y_orig**(j-2) * vy_orig
+
+ idx += 1
+
+ # Third loop: dvx' / dvx
+ idx = 0
+ for i in range(order+1):
+ for j in range(i+1):
+ vxe_new_tmp3 += Xcoeff[idx] * (i-j) * x_orig**(i-j-1) * y_orig**j
+ vye_new_tmp3 += Ycoeff[idx] * (i-j) * x_orig**(i-j-1) * y_orig**j
+
+ idx += 1
+
+ # Fourth loop: dvx' / dvy
+ idx = 0
+ for i in range(order+1):
+ for j in range(i+1):
+ vxe_new_tmp4 += Xcoeff[idx] * (j) * x_orig**(i-j) * y_orig**(j-1)
+ vye_new_tmp4 += Ycoeff[idx] * (j) * x_orig**(i-j) * y_orig**(j-1)
+
+ idx += 1
+
+ vxe_new = np.sqrt((vxe_new_tmp1 * xe_orig)**2 + (vxe_new_tmp2 * ye_orig)**2 + \
+ (vxe_new_tmp3 * vxe_orig)**2 + (vxe_new_tmp4 * vye_orig)**2)
+ vye_new = np.sqrt((vye_new_tmp1 * xe_orig)**2 + (vye_new_tmp2 * ye_orig)**2 + \
+ (vye_new_tmp3 * vxe_orig)**2 + (vye_new_tmp4 * vye_orig)**2)
+
+ return vxe_new, vye_new
+
+
+
+
+
+
+"""
+Old functions with things hard-coded for OB120169
+"""
+
+def run_align_iter(catalog, trans_order=1, poly_deg=1, ref_mag_lim=19, ref_radius_lim=300):
+ # Load up data with matched stars.
+ d = Table.read(catalog)
+
+ # Determine how many epochs there are.
+ N_epochs = len([n for n, c in enumerate(d.colnames) if c.startswith('name')])
+
+ # Determine how many stars there are.
+ N_stars = len(d)
+
+ # Determine the reference epoch
+ ref = d.meta['L_REF']
+
+ # Figure out the number of free parameters for the specified
+ # poly2d order.
+ poly2d = models.Polynomial2D(trans_order)
+ N_par_trans_per_epoch = 2.0 * poly2d.get_num_coeff(2) # one poly2d for each dimension (X, Y)
+ N_par_trans = N_par_trans_per_epoch * N_epochs
+
+ ##########
+ # First iteration -- align everything to REF epoch with zero velocities.
+ ##########
+ print('ALIGN_EPOCHS: run_align_iter() -- PASS 1')
+ ee_ref = d.meta['L_REF']
+
+ target_name = 'OB120169'
+
+ trans1, used1 = calc_transform_ref_epoch(d, target_name, ee_ref, ref_mag_lim, ref_radius_lim)
+
+ ##########
+ # Derive the velocity of each stars using the round 1 transforms.
+ ##########
+ calc_polyfit_all_stars(d, poly_deg, init_fig_idx=0)
+
+ calc_mag_avg_all_stars(d)
+
+ tdx = np.where((d['name_0'] == 'OB120169') | (d['name_0'] == 'OB120169_L'))[0]
+ print(d[tdx]['name_0', 't0', 'mag', 'x0', 'vx', 'x0_err', 'vx_err', 'chi2x', 'y0', 'vy', 'y0_err', 'vy_err', 'chi2y', 'dof'])
+
+ ##########
+ # Second iteration -- align everything to reference positions derived from iteration 1
+ ##########
+ print('ALIGN_EPOCHS: run_align_iter() -- PASS 2')
+ target_name = 'OB120169'
+
+ trans2, used2 = calc_transform_ref_poly(d, target_name, poly_deg, ref_mag_lim, ref_radius_lim)
+
+ ##########
+ # Derive the velocity of each stars using the round 1 transforms.
+ ##########
+ calc_polyfit_all_stars(d, poly_deg, init_fig_idx=4)
+
+ ##########
+ # Save output
+ ##########
+ d.write(catalog.replace('.fits', '_aln.fits'), overwrite=True)
+
+ return
+
+def calc_transform_ref_epoch(d, target_name, ee_ref, ref_mag_lim, ref_radius_lim):
+ # Determine how many epochs there are.
+ N_epochs = len([n for n, c in enumerate(d.colnames) if c.startswith('name')])
+
+ # output array
+ trans = []
+ used = []
+
+ # Find the target
+ tdx = np.where(d['name_0'] == 'OB120169')[0][0]
+
+ # Reference values
+ t_ref = d['t_{0:d}'.format(ee_ref)]
+ m_ref = d['m_{0:d}'.format(ee_ref)]
+ x_ref = d['x_{0:d}'.format(ee_ref)]
+ y_ref = d['y_{0:d}'.format(ee_ref)]
+ xe_ref = d['xe_{0:d}'.format(ee_ref)]
+ ye_ref = d['ye_{0:d}'.format(ee_ref)]
+
+ # Calculate some quanitites we use for selecting reference stars.
+ r_ref = np.hypot(x_ref - x_ref[tdx], y_ref - y_ref[tdx])
+
+ # Loop through and align each epoch to the reference epoch.
+ for ee in range(N_epochs):
+ # Pull out the X, Y positions (and errors) for the two
+ # starlists we are going to align.
+ x_epo = d['x_{0:d}'.format(ee)]
+ y_epo = d['y_{0:d}'.format(ee)]
+ t_epo = d['t_{0:d}'.format(ee)]
+ xe_epo = d['xe_{0:d}'.format(ee)]
+ ye_epo = d['ye_{0:d}'.format(ee)]
+
+ # Figure out the set of stars detected in both epochs.
+ idx = np.where((t_ref != 0) & (t_epo != 0) & (xe_ref != 0) & (xe_epo != 0))[0]
+
+ # Find those in both epochs AND reference stars. This is [idx][rdx]
+ rdx = np.where((r_ref[idx] < ref_radius_lim) & (m_ref[idx] < ref_mag_lim))[0]
+
+ # Average the positional errors together to get one weight per star.
+ xye_ref = (xe_ref + ye_ref) / 2.0
+ xye_epo = (xe_epo + ye_epo) / 2.0
+ xye_wgt = (xye_ref**2 + xye_epo**2)**0.5
+
+ # Calculate transform based on the matched stars
+ trans_tmp = transforms.PolyTransform(x_epo[idx][rdx], y_epo[idx][rdx], x_ref[idx][rdx], y_ref[idx][rdx],
+ weights=xye_wgt[idx][rdx], order=2)
+
+ trans.append(trans_tmp)
+
+
+ # Apply thte transformation to the stars positions and errors:
+ xt_epo = np.zeros(len(d), dtype=float)
+ yt_epo = np.zeros(len(d), dtype=float)
+ xet_epo = np.zeros(len(d), dtype=float)
+ yet_epo = np.zeros(len(d), dtype=float)
+
+ xt_epo[idx], xet_epo[idx], yt_epo[idx], yet_epo[idx] = trans_tmp.evaluate_errors(x_epo[idx], xe_epo[idx],
+ y_epo[idx], ye_epo[idx],
+ nsim=100)
+
+ d['xt_{0:d}'.format(ee)] = xt_epo
+ d['yt_{0:d}'.format(ee)] = yt_epo
+ d['xet_{0:d}'.format(ee)] = xet_epo
+ d['yet_{0:d}'.format(ee)] = yet_epo
+
+ # Record which stars we used in the transform.
+ used_tmp = np.zeros(len(d), dtype=bool)
+ used_tmp[idx[rdx]] = True
+
+ used.append(used_tmp)
+
+ if True:
+ plot_quiver_residuals(xt_epo, yt_epo, x_ref, y_ref, idx, rdx, 'Epoch: ' + str(ee))
+
+ used = np.array(used)
+
+ return trans, used
+
+def calc_transform_ref_poly(d, target_name, poly_deg, ref_mag_lim, ref_radius_lim):
+ # Determine how many epochs there are.
+ N_epochs = len([n for n, c in enumerate(d.colnames) if c.startswith('name')])
+
+ # output array
+ trans = []
+ used = []
+
+ # Find the target
+ tdx = np.where(d['name_0'] == 'OB120169')[0][0]
+
+ # Temporary Reference values
+ t_ref = d['t0']
+ m_ref = d['mag']
+ x_ref = d['x0']
+ y_ref = d['y0']
+ xe_ref = d['x0_err']
+ ye_ref = d['y0_err']
+
+ # Calculate some quanitites we use for selecting reference stars.
+ r_ref = np.hypot(x_ref - x_ref[tdx], y_ref - y_ref[tdx])
+
+ for ee in range(N_epochs):
+ # Pull out the X, Y positions (and errors) for the two
+ # starlists we are going to align.
+ x_epo = d['x_{0:d}'.format(ee)]
+ y_epo = d['y_{0:d}'.format(ee)]
+ t_epo = d['t_{0:d}'.format(ee)]
+ xe_epo = d['xe_{0:d}'.format(ee)]
+ ye_epo = d['ye_{0:d}'.format(ee)]
+
+ # Shift the reference position by the polyfit for each star.
+ dt = t_epo - t_ref
+ if poly_deg >= 0:
+ x_ref_ee = x_ref
+ y_ref_ee = y_ref
+ xe_ref_ee = x_ref
+ ye_ref_ee = y_ref
+
+ if poly_deg >= 1:
+ x_ref_ee += d['vx'] * dt
+ y_ref_ee += d['vy'] * dt
+ xe_ref_ee = np.hypot(xe_ref_ee, d['vx_err'] * dt)
+ ye_ref_ee = np.hypot(ye_ref_ee, d['vy_err'] * dt)
+
+ if poly_deg >= 2:
+ x_ref_ee += d['ax'] * dt
+ y_ref_ee += d['ay'] * dt
+ xe_ref_ee = np.hypot(xe_ref_ee, d['axe'] * dt)
+ ye_ref_ee = np.hypot(ye_ref_ee, d['aye'] * dt)
+
+ # Figure out the set of stars detected in both.
+ idx = np.where((t_ref != 0) & (t_epo != 0) & (xe_ref != 0) & (xe_epo != 0))[0]
+
+ # Find those in both AND reference stars. This is [idx][rdx]
+ rdx = np.where((r_ref[idx] < ref_radius_lim) & (m_ref[idx] < ref_mag_lim))[0]
+
+ # Average the positional errors together to get one weight per star.
+ xye_ref = (xe_ref_ee + ye_ref_ee) / 2.0
+ xye_epo = (xe_epo + ye_epo) / 2.0
+ xye_wgt = (xye_ref**2 + xye_epo**2)**0.5
+
+ # Calculate transform based on the matched stars
+ trans_tmp = transforms.PolyTransform(x_epo[idx][rdx], y_epo[idx][rdx], x_ref_ee[idx][rdx], y_ref_ee[idx][rdx],
+ weights=xye_wgt[idx][rdx], order=2)
+ trans.append(trans_tmp)
+
+ # Apply thte transformation to the stars positions and errors:
+ xt_epo = np.zeros(len(d), dtype=float)
+ yt_epo = np.zeros(len(d), dtype=float)
+ xet_epo = np.zeros(len(d), dtype=float)
+ yet_epo = np.zeros(len(d), dtype=float)
+
+ xt_epo[idx], xet_epo[idx], yt_epo[idx], yet_epo[idx] = trans_tmp.evaluate_errors(x_epo[idx], xe_epo[idx],
+ y_epo[idx], ye_epo[idx],
+ nsim=100)
+ d['xt_{0:d}'.format(ee)] = xt_epo
+ d['yt_{0:d}'.format(ee)] = yt_epo
+ d['xet_{0:d}'.format(ee)] = xet_epo
+ d['yet_{0:d}'.format(ee)] = yet_epo
+
+ # Record which stars we used in the transform.
+ used_tmp = np.zeros(len(d), dtype=bool)
+ used_tmp[idx[rdx]] = True
+
+ used.append(used_tmp)
+
+ if True:
+ plot_quiver_residuals(xt_epo, yt_epo, x_ref_ee, y_ref_ee, idx, rdx, 'Epoch: ' + str(ee))
+
+ used = np.array(used)
+
+ return trans, used
+
+def calc_polyfit_all_stars(d, poly_deg, init_fig_idx=0):
+ # Determine how many stars there are.
+ N_stars = len(d)
+
+ # Determine how many epochs there are.
+ N_epochs = len([n for n, c in enumerate(d.colnames) if c.startswith('name')])
+
+ # Setup some variables to save the results
+ t0_all = []
+ px_all = []
+ py_all = []
+ pxe_all = []
+ pye_all = []
+ chi2x_all = []
+ chi2y_all = []
+ dof_all = []
+
+ # Get the time array, which is the same for all stars.
+ # Also, sort the time indices.
+ t = np.array([d['t_{0:d}'.format(ee)][0] for ee in range(N_epochs)])
+ tdx = t.argsort()
+ t_sorted = t[tdx]
+
+ # Run polyfit on each star.
+ for ss in range(N_stars):
+ # Get the x, y, xe, ye, and t arrays for this star.
+ xt = np.array([d['xt_{0:d}'.format(ee)][ss] for ee in range(N_epochs)])
+ yt = np.array([d['yt_{0:d}'.format(ee)][ss] for ee in range(N_epochs)])
+ xet = np.array([d['xet_{0:d}'.format(ee)][ss] for ee in range(N_epochs)])
+ yet = np.array([d['yet_{0:d}'.format(ee)][ss] for ee in range(N_epochs)])
+ t_tmp = np.array([d['t_{0:d}'.format(ee)][ss] for ee in range(N_epochs)])
+
+ # Sort these arrays.
+ xt_sorted = xt[tdx]
+ yt_sorted = yt[tdx]
+ xet_sorted = xet[tdx]
+ yet_sorted = yet[tdx]
+ t_tmp_sorted = t_tmp[tdx]
+
+ # Get only the detected epochs.
+ edx = np.where(t_tmp_sorted != 0)[0]
+
+ # Calculate the weighted t0 (using the transformed errors).
+ weight_for_t0 = 1.0 / np.hypot(xet_sorted, yet_sorted)
+ t0 = np.average(t_sorted[edx], weights=weight_for_t0[edx])
+
+ # for ee in edx:
+ # print('{0:8.3f} {1:10.5f} {2:10.5f} {3:8.5f} {4:8.5f}'.format(t[ee], xt[ee], yt[ee], xet[ee], yet[ee]))
+ # pdb.set_trace()
+
+ # Run polyfit
+ dt = t_sorted - t0
+ px, covx = np.polyfit(dt[edx], xt_sorted[edx], poly_deg, w=1./xet_sorted[edx], cov=True)
+ py, covy = np.polyfit(dt[edx], yt_sorted[edx], poly_deg, w=1./yet_sorted[edx], cov=True)
+
+ pxe = np.sqrt(np.diag(covx))
+ pye = np.sqrt(np.diag(covy))
+
+
+ x_mod = np.polyval(px, dt[edx])
+ y_mod = np.polyval(py, dt[edx])
+ chi2x = np.sum( ((x_mod - xt_sorted[edx]) / xet_sorted[edx])**2 )
+ chi2y = np.sum( ((y_mod - yt_sorted[edx]) / yet_sorted[edx])**2 )
+ dof = len(edx) - (poly_deg + 1)
+
+ # Save results:
+ t0_all.append(t0)
+ px_all.append(px)
+ py_all.append(py)
+ pxe_all.append(pxe)
+ pye_all.append(pye)
+ chi2x_all.append(chi2x)
+ chi2y_all.append(chi2y)
+ dof_all.append(dof)
+
+ if d[ss]['name_0'] in ['OB120169', 'OB120169_L']:
+ gs = GridSpec(3, 2) # 3 rows, 1 column
+ fig = plt.figure(ss + 1 + init_fig_idx, figsize=(12, 8))
+ a0 = fig.add_subplot(gs[0:2, 0])
+ a1 = fig.add_subplot(gs[2, 0])
+ a2 = fig.add_subplot(gs[0:2, 1])
+ a3 = fig.add_subplot(gs[2, 1])
+
+ a0.errorbar(t_sorted[edx], xt_sorted[edx], yerr=xet_sorted[edx], fmt='ro')
+ a0.plot(t_sorted[edx], x_mod, 'k-')
+ a0.set_title(d[ss]['name_0'] + ' X')
+ a1.errorbar(t_sorted[edx], xt_sorted[edx] - x_mod, yerr=xet_sorted[edx], fmt='ro')
+ a1.axhline(0, linestyle='--')
+ a1.set_xlabel('Time (yrs)')
+ a2.errorbar(t_sorted[edx], yt_sorted[edx], yerr=yet_sorted[edx], fmt='ro')
+ a2.plot(t_sorted[edx], y_mod, 'k-')
+ a2.set_title(d[ss]['name_0'] + ' Y')
+ a3.errorbar(t_sorted[edx], yt_sorted[edx] - y_mod, yerr=yet_sorted[edx], fmt='ro')
+ a3.axhline(0, linestyle='--')
+ a3.set_xlabel('Time (yrs)')
+
+
+
+ t0_all = np.array(t0_all)
+ px_all = np.array(px_all)
+ py_all = np.array(py_all)
+ pxe_all = np.array(pxe_all)
+ pye_all = np.array(pye_all)
+ chi2x_all = np.array(chi2x_all)
+ chi2y_all = np.array(chi2y_all)
+ dof_all = np.array(dof_all)
+
+ # Done with all the stars... recast as numpy arrays and save to output table.
+ d['t0'] = t0_all
+ d['chi2x'] = chi2x_all
+ d['chi2y'] = chi2y_all
+ d['dof'] = dof_all
+ if poly_deg >= 0:
+ d['x0'] = px_all[:, -1]
+ d['y0'] = py_all[:, -1]
+ d['x0_err'] = pxe_all[:, -1]
+ d['y0_err'] = pye_all[:, -1]
+
+ if poly_deg >= 1:
+ d['vx'] = px_all[:, -2]
+ d['vy'] = py_all[:, -2]
+ d['vx_err'] = pxe_all[:, -2]
+ d['vy_err'] = pye_all[:, -2]
+
+ if poly_deg >= 2:
+ d['ax'] = px_all[:, -3]
+ d['ay'] = py_all[:, -3]
+ d['axe'] = pxe_all[:, -3]
+ d['aye'] = pye_all[:, -3]
+
+ pdb.set_trace()
+
+ return
+
diff --git a/flystar/analysis.py b/flystar/analysis.py
index 953461b..429eab7 100644
--- a/flystar/analysis.py
+++ b/flystar/analysis.py
@@ -1,27 +1,19 @@
+import copy
import numpy as np
import pylab as plt
-from flystar import starlists
-from flystar import startables
-from flystar import align
-from flystar import match
-from flystar import transforms
+from scipy.stats import f
from astropy import table
from astropy.table import Table, Column
from astropy.coordinates import SkyCoord
from astropy import units as u
-from astropy.wcs import WCS
-from astroquery.gaia import Gaia
-from astroquery.mast import Observations, Catalogs
-import pdb, copy
-import math
-from scipy.stats import f
+from flystar import starlists, match
##################################################
# New codes for velocity support in FlyStar and using
-# the new StarTable and StarList format.
+# the new StarTable and StarList format.
##################################################
-def query_gaia(ra, dec, search_radius=30.0, table_name='gaiadr2'):
+def query_gaia(ra, dec, search_radius=30.0, table_name='gaiadr3'):
"""
Query the Gaia database at the specified location
and with the specified search radius
@@ -35,13 +27,14 @@ def query_gaia(ra, dec, search_radius=30.0, table_name='gaiadr2'):
Dec. in degrees in the format such as '-29:00:28.0'
search_radius : float
- The search radius in arcseconds.
+ The search radius in arcseconds.
Optional Input
--------------
table_name : string
Options are 'gaiadr2' or 'gaiaedr3'
"""
+ from astroquery.gaia import Gaia
target_coords = SkyCoord(ra, dec, unit=(u.hourangle, u.deg), frame='icrs')
ra = target_coords.ra.degree
dec = target_coords.dec.degree
@@ -49,20 +42,72 @@ def query_gaia(ra, dec, search_radius=30.0, table_name='gaiadr2'):
search_radius *= u.arcsec
Gaia.ROW_LIMIT = 50000
- gaia_job = Gaia.cone_search_async(target_coords, search_radius, table_name = table_name + '.gaia_source')
+ gaia_job = Gaia.cone_search_async(target_coords, radius=search_radius, table_name=table_name + '.gaia_source')
gaia = gaia_job.get_results()
#Change new 'SOURCE_ID' column header back to lowercase 'source_id' so all subsequent functions still work:
- gaia['SOURCE_ID'].name = 'source_id'
+ if 'SOURCE_ID' in gaia.colnames:
+ gaia.rename_column('SOURCE_ID', 'source_id')
return gaia
+def check_gaia_parallaxes(ra,dec,search_radius=10.0,table_name='gaiadr3',target='(unnamed)',
+ file_ext=''):
+ """
+ Query the Gaia database at the specified location
+ and with the specified search radius, and plot
+ parallaxes.
-def prepare_gaia_for_flystar(gaia, ra, dec, targets_dict=None, match_dr_max=0.2):
+ Input
+ ----------
+ ra : string
+ R.A. in hours in the format such as '17:45:40.3'
+
+ dec : string
+ Dec. in degrees in the format such as '-29:00:28.0'
+
+ search_radius : float
+ The search radius in arcseconds.
+
+ Optional Input
+ --------------
+ table_name : string
+ Options are 'gaiadr2' or 'gaiadr3'
+ """
+ # Query Gaia
+ gaia = query_gaia(ra,dec,search_radius=search_radius,table_name=table_name)
+ # Set up reasonable histogram bins
+ plim0,plim1 = np.min(gaia['parallax']),np.max(gaia['parallax'])
+ pplim0,pplim1 = np.min(gaia['parallax']/gaia['parallax_error']),np.max(gaia['parallax']/gaia['parallax_error'])
+ binwidth = 1
+ pbins = np.arange(np.floor(plim0),np.ceil(plim1)+binwidth,binwidth)
+ ppbins = np.arange(np.floor(pplim0),np.ceil(pplim1)+binwidth,binwidth)
+ # Find number where plx/plx_err>3
+ p_perr = (gaia['parallax']/gaia['parallax_error']).compressed()
+ nppe3 = sum((p_perr>3).astype(int))
+ nppen3 = sum((p_perr<-3).astype(int))
+ print(table_name,'stars within',search_radius,'\" with plx/plx_err>3: ', nppe3, ' of ', len(gaia['parallax']))
+ print(table_name,'stars within',search_radius,'\" with plx/plx_err<-3: ', nppen3, ' of ', len(gaia['parallax']))
+ # Plot
+ plt.subplots(nrows=1,ncols=2,figsize=(12,6))
+ plt.subplot(121)
+ plt.xlabel('parallax (mas)'); plt.ylabel('N stars')
+ plt.hist(gaia['parallax'],bins=pbins)
+ plt.yscale('log')
+ plt.title(table_name+' parallax histograms, '+str(search_radius)+'\" radius around '+target, loc='left')
+ plt.subplot(122)
+ plt.xlabel('parallax/parallax_error')
+ plt.hist(gaia['parallax']/gaia['parallax_error'],bins=ppbins)
+ plt.yscale('log')
+ plt.tight_layout()
+ plt.savefig('gaiaplx'+file_ext+'.png')
+
+
+def prepare_gaia_for_flystar(gaia, ra, dec, targets_dict=None, match_dr_max=0.2, pi_err_limit=0.4, default_motion_model='Linear'):
"""
Take a Gaia table (from astroquery) and produce a new table with a tangential projection
- and shift such that the origin is centered on the target of interest.
- Convert everything into arcseconds and name columns such that they are
+ and shift such that the origin is centered on the target of interest.
+ Convert everything into arcseconds and name columns such that they are
ready for FlyStar input.
Inputs
@@ -79,7 +124,7 @@ def prepare_gaia_for_flystar(gaia, ra, dec, targets_dict=None, match_dr_max=0.2)
target_coords = SkyCoord(ra, dec, unit=(u.hourangle, u.deg), frame='icrs')
ra = target_coords.ra.degree # in decimal degrees
dec = target_coords.dec.degree # in decimal degrees
-
+
cos_dec = np.cos(np.radians(dec))
x = (gaia['ra'] - ra) * cos_dec * 3600.0 # arcsec
y = (gaia['dec'] - dec) * 3600.0 # arcsec
@@ -90,15 +135,15 @@ def prepare_gaia_for_flystar(gaia, ra, dec, targets_dict=None, match_dr_max=0.2)
gaia_new['x0'] = x * -1.0
gaia_new['y0'] = y
- gaia_new['x0e'] = xe
- gaia_new['y0e'] = ye
+ gaia_new['x0_err'] = xe
+ gaia_new['y0_err'] = ye
# Also convert the velocities. Note that Gaia PM are already * cos(dec)
gaia_new['vx'] = gaia['pmra'].data * -1.0 / 1e3 # asec/yr
gaia_new['vy'] = gaia['pmdec'].data / 1e3
- gaia_new['vxe'] = gaia['pmra_error'].data / 1e3
- gaia_new['vye'] = gaia['pmdec_error'].data / 1e3
-
+ gaia_new['vx_err'] = gaia['pmra_error'].data / 1e3
+ gaia_new['vy_err'] = gaia['pmdec_error'].data / 1e3
+
gaia_new['t0'] = gaia['ref_epoch'].data
gaia_new['source_id'] = gaia['source_id'].data.astype('S19')
@@ -106,40 +151,84 @@ def prepare_gaia_for_flystar(gaia, ra, dec, targets_dict=None, match_dr_max=0.2)
idx = np.where(gaia['pmdec'].mask == True)[0]
gaia_new['vx'][idx] = 0.0
gaia_new['vy'][idx] = 0.0
- gaia_new['vxe'][idx] = 0.0
- gaia_new['vye'][idx] = 0.0
-
+ gaia_new['vx_err'][idx] = 0.0
+ gaia_new['vy_err'][idx] = 0.0
+
gaia_new['m'] = gaia['phot_g_mean_mag']
gaia_new['me'] = 1.09/gaia['phot_g_mean_flux_over_error']
- gaia_new['parallax'] = gaia['parallax']
- gaia_new['parallax_error'] = gaia['parallax_error']
+ gaia_new['pi'] = gaia['parallax'].data*1e-3
+ gaia_new['pi_err'] = gaia['parallax_error'].data*1e-3
# Set the velocities (and uncertainties) to zero if they aren't measured.
idx = np.where(np.isnan(gaia_new['vx']) == True)[0]
gaia_new['vx'][idx] = 0.0
- gaia_new['vxe'][idx] = 0.0
+ gaia_new['vx_err'][idx] = 0.0
gaia_new['vy'][idx] = 0.0
- gaia_new['vye'][idx] = 0.0
+ gaia_new['vy_err'][idx] = 0.0
+
+ # Cut out stars with high plx error and set motion models
+ idx = np.where((gaia_new['pi_err']>(pi_err_limit/1e3)) | (gaia['parallax'].mask == True))[0]
+ gaia_new['pi'][idx] = 0.0
+ gaia_new['pi_err'][idx] = 0.0
+ if default_motion_model=='Parallax':
+ gaia_new['motion_model_input'] = 'Parallax'
+ gaia_new['motion_model_used'] = 'Parallax'
+ gaia_new['motion_model_used'][idx] = 'Linear'
+ gaia_new['n_params'] = 3
+ gaia_new['n_params'][idx] = 2
+ elif default_motion_model=='Linear':
+ gaia_new['motion_model_input'] = 'Linear'
+ gaia_new['motion_model_used'] = 'Linear'
+ gaia_new['n_params'] = 2
+ elif default_motion_model=='Fixed':
+ gaia_new['motion_model_input'] = 'Fixed'
+ gaia_new['motion_model_used'] = 'Fixed'
+ gaia_new['n_params'] = 1
+ elif default_motion_model=='Empty':
+ gaia_new['motion_model_input'] = 'Empty'
+ gaia_new['motion_model_used'] = 'Empty'
+ gaia_new['n_params'] = 0
+ else:
+ print("Invalid motion model",default_motion_model,"- none assigned")
+
+ #macy additions to try to fix wild magnitude values
+ #gaia_new['ruwe'] = gaia['ruwe']
+ #try:
+ # gaia_new = gaia_new[~gaia_new['m'].mask]
+ #except:
+ # print('no invalig mags')
gaia_new = gaia_new.filled() #convert masked colunms to regular columns
if targets_dict != None:
- for targ_name, targ_coo in targets_dict.items():
- dx = gaia_new['x0'] - (targ_coo[0] * -1.0)
- dy = gaia_new['y0'] - targ_coo[1]
+# for targ_name, targ_coo in targets_dict.items():
+# dx = gaia_new['x0'] - (targ_coo[0] * -1.0)
+# dy = gaia_new['y0'] - targ_coo[1]
+# dr = np.hypot(dx, dy)
+#
+# idx = dr.argmin()
+#
+# if dr[idx] < match_dr_max:
+# gaia_new['name'][idx] = targ_name
+# print('Found match for: ', targ_name, ' - ',gaia_new['source_id'][idx])
+ targ_names = [x for x in targets_dict]
+ targ_xs = np.array([targets_dict[x][0] for x in targets_dict])
+ targ_ys = np.array([targets_dict[x][1] for x in targets_dict])
+ for i_gaia in range(len(gaia_new)):
+ dx = gaia_new['x0'][i_gaia] - (targ_xs * -1.0)
+ dy = gaia_new['y0'][i_gaia] - targ_ys
dr = np.hypot(dx, dy)
idx = dr.argmin()
if dr[idx] < match_dr_max:
- gaia_new['name'][idx] = targ_name
- print('Found match for: ', targ_name)
+ gaia_new['name'][i_gaia] = targ_names[idx]
+ print('Found match for: ', targ_names[idx], ' - ',gaia_new['source_id'][i_gaia])
return gaia_new
-
def run_flystar():
-
+
test_file = '/u/jlu/work/microlens/OB150211/a_2018_10_19/a_ob150211_2018_10_19/lis/stars_matched2.fits'
t = Table.read(test_file)
@@ -171,39 +260,39 @@ def run_flystar():
ym_t = y0 + vy * (t - t0)
# Model distorted positions
-
-
+
+
return
def project_gaia(gaia, epoch, ra, dec):
"""
Take the Gaia measurements, forward them in time, and then convert them into a tangential projection.
-
+
Inputs
----------
epoch : float (year)
The decimal year to project the measurement to. Note that we use 365.25 days per year.
-
+
ra : float (deg)
The right ascension (J2000) in decimal degrees of the center of the field.
-
+
dec : float (deg)
The declination (J2000) in decimal degrees of the center of the field.
-
+
"""
t0 = gaia['ref_epoch']
x0 = (gaia['ra'] - ra) * np.cos(np.radians(dec)) * 3600.0 # Arcsec
y0 = (gaia['dec'] - dec) * 3600.0
x0e = gaia['ra_error'] / 1.0e3 # arcsec, already in alpha* (multiplied by cos(delta))
y0e = gaia['dec_error'] / 1.0e3 # arcsec
-
-
+
+
vx = gaia['pmra'] / 1.0e3 # arcsec / yr
- vy = gaia['pmdec'] / 1.0e3
+ vy = gaia['pmdec'] / 1.0e3
vxe = gaia['pmra_error'] / 1.0e3 # arcsec / yr
vye = gaia['pmdec_error'] / 1.0e3
-
+
# Modify any vx/vy, etc. that are zero and make a regular (unmasked) numpy array.
vx[vx.mask] = 0.0
vy[vy.mask] = 0.0
@@ -213,29 +302,29 @@ def project_gaia(gaia, epoch, ra, dec):
vy = np.array(vy)
vxe = np.array(vxe)
vye = np.array(vye)
-
+
dt = epoch - t0
x_now = (x0 + (vx * dt)) * -1.0 # Switch to a left-handed coordinate system, like detector pixels.
y_now = (y0 + (vy * dt))
xe_now = np.hypot(x0e, vxe*dt)
ye_now = np.hypot(y0e, vye*dt)
-
+
# Format as a starlist
- gaia_lis = starlists.StarList(name=gaia['source_id'],
+ gaia_lis = starlists.StarList(name=gaia['source_id'],
x=x_now, y=y_now, m=gaia['phot_g_mean_mag'],
xe=xe_now, ye=ye_now, me=1.0/gaia['phot_g_mean_flux_over_error'])
-
+
# Duplicate columns to 'x_avg', etc. Needed for initial guessing.
gaia_lis['x_avg'] = gaia_lis['x']
gaia_lis['y_avg'] = gaia_lis['y']
- gaia_lis['m_avg'] = gaia_lis['m']
-
+ gaia_lis['m_avg'] = gaia_lis['m']
+
return gaia_lis
def rename_after_flystar(star_tab, label_dat_file, new_copy=True, dr_tol=0.05, dm_tol=0.3, verbose=False):
"""
- Take a StarTable output from FlyStar MosaicToRef that has been
+ Take a StarTable output from FlyStar MosaicToRef that has been
aligned into R.A. and Dec. (usually by way of Gaia). Align
the output to a label.dat file for this source and rename
everything.
@@ -263,25 +352,28 @@ def rename_after_flystar(star_tab, label_dat_file, new_copy=True, dr_tol=0.05, d
x_lab[ndx_lab[ii]], star_tab['x0'][ndx_star[ii]],
y_lab[ndx_lab[ii]], star_tab['y0'][ndx_star[ii]],
m_lab[ndx_lab[ii]], star_tab['m0'][ndx_star[ii]]))
-
+
print('Temporary shift transformations: ')
print(' dm = {0:8.4f} +/- {1:8.4f}'.format(dm.mean(), dm.std()))
print(' dx = {0:8.4f} +/- {1:8.4f}'.format(dx.mean(), dx.std()))
print(' dy = {0:8.4f} +/- {1:8.4f}'.format(dy.mean(), dy.std()))
-
+
m_lab = label_tab['m'] + dm.mean()
x_lab += dx.mean()
y_lab += dy.mean()
-
+
# Now that we are in a common coordinate and magnitude
# system, lets match the whole lists by coordinates.
- idx_lab, idx_star, dr, dm = match.match(x_lab, y_lab, m_lab,
+ idx_lab, idx_star, dr, dm = match.match(x_lab, y_lab, m_lab,
star_tab['x0'], star_tab['y0'], star_tab['m0'],
dr_tol=dr_tol, dm_tol=dm_tol, verbose=verbose)
+ #print('idx_lab:')
+ #for iii in range(len(idx_lab)):
+ # print(label_tab["name"][idx_lab[iii]], star_tab["name"][idx_star[iii]])
print('Renaming {0:d} out of {1:d} stars'.format(len(idx_lab), len(star_tab)))
-
+
# Make a copy of the table, UNLESS, the user specifies.
if new_copy:
new_tab = copy.deepcopy(star_tab)
@@ -291,9 +383,9 @@ def rename_after_flystar(star_tab, label_dat_file, new_copy=True, dr_tol=0.05, d
# copy over the original names... don't overwrite (this could mean data loss)
if 'name_orig' not in new_tab.colnames:
new_tab.add_column(Column(star_tab['name'].data, name='name_orig'))
-
+
new_tab['name'][idx_star] = label_tab[idx_lab]['name']
-
+
return new_tab
def pick_good_ref_stars(star_tab, r_cut=None, m_cut=None, p_err_cut=None, pm_err_cut=None, name_cut=None, reset=True):
@@ -317,12 +409,12 @@ def pick_good_ref_stars(star_tab, r_cut=None, m_cut=None, p_err_cut=None, pm_err
print('pick_good_ref_stars: Use {0:d} stars after m<{1:.2f}.'.format(use.sum(), m_cut))
if p_err_cut is not None:
- p_err = np.mean((star_tab['x0e'], star_tab['y0e']), axis=0)
+ p_err = np.mean((star_tab['x0_err'], star_tab['y0_err']), axis=0)
use = use & (p_err < p_err_cut)
print('pick_good_ref_stars: Use {0:d} stars after p_err<{1:.5f}.'.format(use.sum(), p_err_cut))
if pm_err_cut is not None:
- pm_err = np.mean((star_tab['vxe'], star_tab['vye']), axis=0)
+ pm_err = np.mean((star_tab['vx_err'], star_tab['vy_err']), axis=0)
use = use & (pm_err < pm_err_cut)
print('pick_good_ref_stars: Use {0:d} stars after pm_err<{1:.5f}.'.format(use.sum(), pm_err_cut))
@@ -338,44 +430,24 @@ def pick_good_ref_stars(star_tab, r_cut=None, m_cut=None, p_err_cut=None, pm_err
def startable_subset(tab, idx, mag_trans=True, mag_trans_orig=False):
"""
- Input is MosaicToRef table from alignment of multiple filters,
+ Input is MosaicToRef table from alignment of multiple filters,
such that the astrometry is combined but the photometry is not.
- This function is used to separate out a selected filter from the
+ This function is used to separate out a selected filter from the
combined astrometry + uncombined photometry table.
"""
# Multiples: ['x', 'y', 'm', 'name_in_list', 'xe', 'ye', 'me', 't',
- # 'x_orig', 'y_orig', 'm_orig', 'xe_orig', 'ye_orig', 'me_orig', 'used_in_trans']
- # Single: ['name', 'm0', 'm0e', 'use_in_trans', 'ref_orig', 'n_detect',
- # 'x0', 'vx', 'y0', 'vy', 'x0e', 'vxe', 'y0e', 'vye', 't0']
+ # 'x_orig', 'y_orig', 'm_orig', 'xe_orig', 'ye_orig', 'me_orig', 'used_in_trans',
+ # 'xe_boot','ye_boot','me_boot']
+ # Single: ['name', 'm0', 'm0_err', 'use_in_trans', 'ref_orig', 'n_detect',
+ # 'x0', 'vx', 'y0', 'vy', 'x0_err', 'vx_err', 'y0_err', 'vy_err', 't0']
# Don't include n_vfit
- new_tab = startables.StarTable(name=tab['name'].data,
- x=tab['x'][:,idx].data,
- y=tab['y'][:,idx].data,
- m=tab['m'][:,idx].data,
- xe=tab['xe'][:,idx].data,
- ye=tab['ye'][:,idx].data,
- me=tab['me'][:,idx].data,
- t=tab['t'][:,idx].data,
- x_orig=tab['x_orig'][:,idx].data,
- y_orig=tab['y_orig'][:,idx].data,
- m_orig=tab['m_orig'][:,idx].data,
- xe_orig=tab['xe_orig'][:,idx].data,
- ye_orig=tab['ye_orig'][:,idx].data,
- me_orig=tab['me_orig'][:,idx].data,
- used_in_trans=tab['used_in_trans'][:,idx].data,
- m0=tab['m0'].data,
- m0e=tab['m0e'].data,
- use_in_trans=tab['use_in_trans'].data,
- x0=tab['x0'].data,
- vx=tab['vx'].data,
- y0=tab['y0'].data,
- vy=tab['vy'].data,
- x0e=tab['x0e'].data,
- vxe=tab['vxe'].data,
- y0e=tab['y0e'].data,
- vye=tab['vye'].data,
- t0=tab['t0'].data)
+ new_tab = copy.deepcopy(tab)
+ #new_tab.remove_column('n_fit')
+ new_tab.remove_column('n_detect')
+ for col in ['x','y','m','name_in_list','xe','ye','me','t','x_orig','y_orig','m_orig',
+ 'xe_orig','ye_orig','me_orig','used_in_trans','xe_boot','ye_boot','me_boot']:
+ new_tab[col] = tab[col][:,idx]
new_tab.combine_lists('m', weights_col='me', sigma=3, ismag=True)
@@ -392,7 +464,7 @@ def startable_subset(tab, idx, mag_trans=True, mag_trans_orig=False):
# Update the original table.
if mag_trans_orig:
tab['m'][:,idx[ii]] += mag_offset
-
+
return new_tab
@@ -400,86 +472,6 @@ def startable_subset(tab, idx, mag_trans=True, mag_trans_orig=False):
# Old codes.
##################################################
-def calc_chi2(ref_mat, starlist_mat, transform, errs='both'):
- """
- calculate the chi2 and reduced chi2 of the position
- between two matched starlists.
- Input:
- ref_mat: astropy table
- Reference starlist only containing matched stars that were used in the
- transformation. Standard column headers are assumed.
-
- starlist_mat: astropy table
- Transformed starlist only containing the matched stars used in
- the transformation. Standard column headers are assumed.
-
- transform: transformation object
- Transformation object of final transform. Used in chi-square
- determination
-
- errs: string; 'both', 'reference', or 'starlist'
- If both, add starlist errors in quadrature with reference errors.
-
- If reference, only consider reference errors. This should be used if the starlist
- does not have valid errors
-
- If starlist, only consider starlist errors. This should be used if the reference
- does not have valid errors
-
- Output:
- chi_sq: float
- chi2 = sum (diff_x**2 / xerr**2 + diff_y**2 /yerr**2)
- chi_sq_red: float
- reduced chi2 = chi2/ degree of freedom
- deg_freedom: int
- degree of freedom
-
- """
- diff_x = ref_mat['x'] - starlist_mat['x']
- diff_y = ref_mat['y'] - starlist_mat['y']
-
- # Set errors as per user input
- if errs == 'both':
- xerr = np.hypot(ref_mat['xe'], starlist_mat['xe'])
- yerr = np.hypot(ref_mat['ye'], starlist_mat['ye'])
- elif errs == 'reference':
- xerr = ref_mat['xe']
- yerr = ref_mat['ye']
- elif errs == 'starlist':
- xerr = starlist_mat['xe']
- yerr = starlist_mat['ye']
-
-
- # For both X and Y, calculate chi-square. Combine arrays to get combined
- # chi-square
- chi_sq_x = diff_x**2. / xerr**2.
- chi_sq_y = diff_y**2. / yerr**2.
-
- chi_sq = np.append(chi_sq_x, chi_sq_y)
-
- # Calculate degrees of freedom in transformation
- num_mod_params = calc_nparam(transform)
- deg_freedom = len(chi_sq) - num_mod_params
-
- # Calculate reduced chi-square
- chi_sq = np.sum(chi_sq)
- chi_sq_red = chi_sq / deg_freedom
-
- return chi_sq, chi_sq_red, deg_freedom
-
-
-def calc_nparam(transformation):
- """
- calculate the degree of freedom for a transformation
- """
- # Read transformation: Extract X, Y coefficients from transform
- if transformation.__class__.__name__ == 'four_paramNW':
- nparam = 4
- elif transformation.__class__.__name__ == 'PolyTransform':
- order = transformation.order
- nparam = (order+1) * (order+2)
- return nparam
-
def calc_F(red_chi2_1, red_chi2_2, v1, v2):
"""
compare two different models to get the proper polynomial fitting order
@@ -498,24 +490,24 @@ def calc_F(red_chi2_1, red_chi2_2, v1, v2):
for 1st order polynomial fitting:
x' = a0 + a1*x + a2*y
y' = b0 + b1*x + b2*y
- v1 = 2*N1 - 2*3 (2*: because x and y direction)
+ v1 = 2*N1 - 2*3 (2*: because x and y direction)
red_chi2_1 = chi2/v1
for 2nd order polynomial fitting:
x' = a0 + a1*x + a2*y + a3*x**2 + a4*y**2 + a5*x*y
y' = b0 + b1*x + b2*y + b3*x**2 + b4*y**2 + b5*x*y
- v1 = 2*N1 - 2*6
+ v1 = 2*N1 - 2*6
red_chi2_2 = chi2/v2
calc_F(red_chi2_1, red_chi2_2, v1, v2)
-
+
***Note***
- * make sure the first model is the simple model
+ * make sure the first model is the simple model
and the second model is the more complicated model
- * the return value represents the probability that
+ * the return value represents the probability that
the first model is better than the second model, in other words,
the small P means the more colicated model is needed.
the large P means the simple model is good enough.
- * normally, the P value will increase from model1->model2, to
- model2->model3, to model3->model4. The user can decide a
+ * normally, the P value will increase from model1->model2, to
+ model2->model3, to model3->model4. The user can decide a
critical value (eg, 0.7) to find the proper model.
"""
diff --git a/flystar/archive_io.py b/flystar/archive_io.py
index 88de5cb..2177e40 100755
--- a/flystar/archive_io.py
+++ b/flystar/archive_io.py
@@ -1,9 +1,9 @@
import pickle
-# Need to add these functions to a utility .py file rather than storing them in general structure.
+# Need to add these functions to a utility .py file rather than storing them in general structure.
def open_archive(file_name):
"""
- Helper function to open archived files.
+ Helper function to open archived files.
"""
with open(file_name, 'rb') as file_archive:
file_dict = pickle.load(file_archive)
@@ -11,7 +11,7 @@ def open_archive(file_name):
def save_archive(file_name, save_data):
"""
- Helper function to archive a file.
+ Helper function to archive a file.
"""
with open(file_name, 'wb') as outfile:
pickle.dump(save_data, outfile, protocol=pickle.HIGHEST_PROTOCOL)
diff --git a/flystar/conftest.py b/flystar/conftest.py
index 672b273..da164b5 100644
--- a/flystar/conftest.py
+++ b/flystar/conftest.py
@@ -31,9 +31,9 @@ def pytest_configure(config):
PYTEST_HEADER_MODULES.pop('Pandas', None)
PYTEST_HEADER_MODULES['scikit-image'] = 'skimage'
- from . import __version__
+ #from . import __version__
packagename = os.path.basename(os.path.dirname(__file__))
- TESTED_VERSIONS[packagename] = __version__
+ #TESTED_VERSIONS[packagename] = __version__
# Uncomment the last two lines in this block to treat all DeprecationWarnings as
# exceptions. For Astropy v2.0 or later, there are 2 additional keywords,
diff --git a/flystar/examples.py b/flystar/examples.py
index 8059562..d70a880 100644
--- a/flystar/examples.py
+++ b/flystar/examples.py
@@ -1,11 +1,5 @@
-from flystar import transforms
-from flystar import match
-from flystar import align
-from flystar import starlists
-from flystar import plots
import numpy as np
-import copy
-import pdb
+from flystar import transforms, match, align, starlists, plots
def align_example(labelFile, reference, transModel=transforms.four_paramNW, order=1, N_loop=2,
@@ -38,7 +32,7 @@ def align_example(labelFile, reference, transModel=transforms.four_paramNW, orde
dr_tol: float (default = 1.0)
The search radius for the matching algorithm, in the same units as the
starlist file positions.
-
+
dm_tol: float or None
If float, sets the maximum magnitude difference allowed in matching
between label.dat and starlist. Note that this should be set to
@@ -54,10 +48,10 @@ def align_example(labelFile, reference, transModel=transforms.four_paramNW, orde
outFile: string (default = 'outTrans.txt')
Name of output ascii file which contains the transform parameters.
-
+
Output:
------
-
+
"""
# Read in label.dat file and reference starlist, changing columns to their
# standard column headers/epochs/orientations
@@ -72,7 +66,7 @@ def align_example(labelFile, reference, transModel=transforms.four_paramNW, orde
# Apply intial transformation to label.dat (for error weighting purposes below)
label_trans = align.transform_from_object(label, trans)
-
+
# Use transformation to match starlists, then recalculate transformation.
# Iterate on this as many times as desired
for i in range(N_loop):
@@ -80,10 +74,10 @@ def align_example(labelFile, reference, transModel=transforms.four_paramNW, orde
trans,
dr_tol=dr_tol,
dm_tol=dm_tol)
-
+
trans, N_trans = align.find_transform(label[idx_label],
label_trans[idx_label],
- starlist_mat[idx_starlist],
+ starlist[idx_starlist],
transModel=transModel,
order=order, weights=weights)
@@ -91,14 +85,14 @@ def align_example(labelFile, reference, transModel=transforms.four_paramNW, orde
# Write final transform in java align format
print('Write transform to {0}'.format(outFile))
align.write_transform(trans, labelFile, reference, N_trans, outFile=outFile)
-
+
# Test transform: apply final transformation to label.dat
label_trans2 = align.transform(label, outFile)
# Make diagnostic plots
-
+
return
-
+
def align_Arches(labelFile, reference, transModel=transforms.four_paramNW, order=1, N_loop=2,
dr_tol=1.0, dm_tol=None, briteN=100, weights=None, restrict=False,
@@ -131,7 +125,7 @@ def align_Arches(labelFile, reference, transModel=transforms.four_paramNW, order
dr_tol: float (default = 1.0)
The search radius for the matching algorithm, in the same units as the
starlist file positions.
-
+
dm_tol: float or None (default = None)
If float, sets the maximum magnitude difference allowed in matching
between label.dat and starlist. Note that this should be set to
@@ -143,7 +137,7 @@ def align_Arches(labelFile, reference, transModel=transforms.four_paramNW, order
weights: string (default=None)
if weights=='both', we use both position error and velocity error in transformed
- starlist and reference starlist as uncertanties. And weights is the reciprocal
+ starlist and reference starlist as uncertanties. And weights is the reciprocal
of this uncertanty.
if weights=='starlist', we only use postion error and velocity error in transformed
starlist as uncertainty.
@@ -156,7 +150,7 @@ def align_Arches(labelFile, reference, transModel=transforms.four_paramNW, order
outFile: string (default = 'outTrans.txt')
Name of output ascii file which contains the transform parameters.
-
+
Output:
------
outFile is written containing the tranformation coefficients
@@ -170,11 +164,11 @@ def align_Arches(labelFile, reference, transModel=transforms.four_paramNW, order
positions and the label.dat positions after transformation.
-Positions_quiver.png: Quiver plot showing the difference between reference
- positions and transformed label.dat positions as a function of location.
-
+ positions and transformed label.dat positions as a function of location.
+
-Magnitude_hist.png: Histogram of the difference between the reference list
magnitude and label.dat magnitude for matched stars.
-
+
"""
# Read in label.dat file and reference starlist, changing columns to their
# standard column headers/epochs/orientations
@@ -192,10 +186,10 @@ def align_Arches(labelFile, reference, transModel=transforms.four_paramNW, order
# Perform blind matching of 100 brightest stars and calculate initial transform
trans = align.initial_align(label_r, starlist, briteN, transformModel=transModel,
order=order)
-
+
# Apply transformation to label.dat file, for weighting purposes.
label_trans = align.transform_from_object(label, trans)
-
+
# Use transformation to match starlists, then recalculate transformation.
# Iterate on this as many times as desired
for i in range(N_loop):
@@ -223,7 +217,7 @@ def align_Arches(labelFile, reference, transModel=transforms.four_paramNW, order
print('Write transform to {0}'.format(outFile))
align.write_transform(trans, labelFile, reference, N_trans, deltaMag=delta_m,
restrict=restrict, weights=weights, outFile=outFile)
-
+
# Test transform: apply to label.dat, make diagnostic plots
label_trans2 = align.transform_from_file(label, outFile)
@@ -241,7 +235,7 @@ def align_Arches(labelFile, reference, transModel=transforms.four_paramNW, order
label_trans2[idx_label], xlim=xlim, ylim=ylim)
# Histogram of difference in transformed and reference positions for
- # matched stars
+ # matched stars
plots.pos_diff_hist(starlist[idx_starlist], label_trans2[idx_label])
# Histogram of difference in transformed and reference positions for
@@ -250,7 +244,7 @@ def align_Arches(labelFile, reference, transModel=transforms.four_paramNW, order
plots.pos_diff_err_hist(starlist[idx_starlist], label_trans2[idx_label],
trans, errs='both', bin_width=0.5, xlim=[-6,6])
- # Histogram of difference in the magnitudes for the matched stars
+ # Histogram of difference in the magnitudes for the matched stars
plots.mag_diff_hist(starlist[idx_starlist], label_trans2[idx_label])
# Quiver plot showing difference between transformed and reference
@@ -260,7 +254,7 @@ def align_Arches(labelFile, reference, transModel=transforms.four_paramNW, order
ylim=ylim, outlier_reject=None)
print('Done with plots')
- print('Done with plots')
+ print('Done with plots')
return
@@ -274,7 +268,7 @@ def align_gc(starFile, refFile, transModel=transforms.PolyTransform, order=1, N_
Parameters:
-----------
starFile: string
- Starlist we would like to transform into the reference frame, eg:label.dat
+ Starlist we would like to transform into the reference frame, eg:label.dat
refFile: string
Starlist that defines the reference frame.
@@ -312,7 +306,7 @@ def align_gc(starFile, refFile, transModel=transforms.PolyTransform, order=1, N_
"""
#----------------------------------------------
- # Read in starlist and reference
+ # Read in starlist and reference
#----------------------------------------------
# starlist has postion & postion err
ref = starlists.read_starlist(refFile, error=True)
@@ -400,7 +394,7 @@ def align_starlists(starlist, ref, transModel=transforms.PolyTransform, order=2,
Parameters:
-----------
starlist: Table
- Starlist we would like to transform into the reference frame, eg:label.dat
+ Starlist we would like to transform into the reference frame, eg:label.dat
ref: Table
Starlist that defines the reference frame.
@@ -433,7 +427,7 @@ def align_starlists(starlist, ref, transModel=transforms.PolyTransform, order=2,
outFile: string('outTrans.txt')
the name of the output transformation file
"""
-
+
#--------------------------------------------------
# Initial transformation with brightest briteN stars
#--------------------------------------------------
diff --git a/flystar/fit_velocity.py b/flystar/fit_velocity.py
deleted file mode 100755
index 0317322..0000000
--- a/flystar/fit_velocity.py
+++ /dev/null
@@ -1,205 +0,0 @@
-from tqdm import tqdm
-import numpy as np
-import pandas as pd
-
-def linear(x, k, b):
- return k*x + b
-
-def linear_fit(x, y, sigma=None, absolute_sigma=True):
- """Weighted linear regression (See https://en.wikipedia.org/wiki/Weighted_least_squares#Solution). Recommended for low-dimension, non-degenerate data. Otherwise, please use scipy.curve_fit.
-
- Parameters
- ----------
- x : array-like
- x data
- y : array-like
- y data
- sigma : array-like, optional
- Weighted by 1/sigma**2. If not provided, weight = 1, by default None
- absolute_sigma : bool, optional
- If True (default), sigma is used in an absolute sense and the estimated parameter uncertainty reflects these absolute values. If False, only the relative magnitudes of the sigma values matter, by default True
-
- Returns
- -------
- result : dictionary
- Dictionary with keys 'slope', 'e_slope', 'intercept', 'e_intercept', and 'chi2' if return_chi2=True.
- """
- x = np.array(x)
- y = np.array(y)
- if sigma is None:
- sigma = np.ones_like(x)
- else:
- sigma = np.array(sigma)
-
- X = np.vander(x, 2)
- W = np.diag(1/sigma**2)
- XTWX = X.T @ W @ X
- pcov = np.linalg.inv(XTWX) # Covariance Matrix
- popt = pcov @ X.T @ W @ y # Linear Solution
- perr = np.sqrt(np.diag(pcov)) # Uncertainty of Linear Solution
-
- residual = y - X @ popt
- chi2 = residual.T @ W @ residual
-
- if not absolute_sigma:
- reduced_chi2 = chi2/(len(x) - 2)
- perr *= reduced_chi2**0.5
-
- result = {
- 'slope': popt[0],
- 'intercept': popt[1],
- 'e_slope': perr[0],
- 'e_intercept': perr[1],
- 'chi2': chi2
- }
-
- return result
-
-
-def calc_chi2(x, y, sigma, slope, intercept):
- popt = np.array([slope, intercept])
- X = np.vander(x, 2)
- W = np.diag(1/sigma**2)
- residual = y - X @ popt
- return residual.T @ W @ residual
-
-
-def fit_velocity(startable, weighting='var', use_scipy=False, absolute_sigma=True, epoch_cols='all', art_star=False):
- """Fit proper motion with weighted linear regression equations (see https://en.wikipedia.org/wiki/Weighted_least_squares#Solution).
- Assumes that all data are valid.
-
- Parameters
- ----------
- startable : StarTable
- StarTable object
- weighting : str, optional
- Weighting by variance (1/ye**2) or standard deviation (1/ye), by default 'var'
- use_scipy : bool, optional
- Use scipy.curve_fit or flystar.fit_velocity.linear_fit, by default False
- absolute_sigma : bool, optional
- If True (default), sigma is used in an absolute sense and the estimated parameter uncertainty reflects these absolute values. If False, only the relative magnitudes of the sigma values matter, by default True
- epoch_cols : str or list of intergers, optional
- List of indicies of columns to use. If 'all', use all columns, by default 'all'
- art_star : bool, optional
- Artificial star catalog or not. If True, use startable['x'][:, epoch_ols, 1] as the location, by default False.
-
- Returns
- -------
- result : pd.DataFrame
- Proper motion dataframe with keys vx, vxe, vy, vye, x0, x0e, y0, y0e
-
- Raises
- ------
- ValueError
- If weighting is neither 'std' nor 'var'
- """
- if weighting not in ['std', 'var']:
- raise ValueError(f"Weighting must be either 'std' or 'var', not '{weighting}'.")
- if epoch_cols is None:
- epoch_cols = np.arange(len(startable.meta['YEARS'])) # use all cols if not specified
-
- N = len(startable)
- vx = np.zeros(N)
- vy = np.zeros(N)
- vxe = np.zeros(N)
- vye = np.zeros(N)
- x0 = np.zeros(N)
- y0 = np.zeros(N)
- x0e = np.zeros(N)
- y0e = np.zeros(N)
- chi2_vx = np.zeros(N)
- chi2_vy = np.zeros(N)
- t0 = np.zeros(N)
-
- time = np.array(startable.meta['YEARS'])[epoch_cols]
-
- if not art_star:
- x_arr = startable['x'][:, epoch_cols]
- y_arr = startable['y'][:, epoch_cols]
- else:
- x_arr = startable['x'][:, epoch_cols, 1]
- y_arr = startable['y'][:, epoch_cols, 1]
-
- xe_arr = startable['xe'][:, epoch_cols]
- ye_arr = startable['ye'][:, epoch_cols]
-
- if weighting=='std':
- sigma_x_arr = np.abs(xe_arr)**0.5
- sigma_y_arr = np.abs(ye_arr)**0.5
- elif weighting=='var':
- sigma_x_arr = xe_arr
- sigma_y_arr = ye_arr
-
- # For each star
- for i in tqdm(range(len(startable))):
- x = x_arr[i]
- y = y_arr[i]
- xe = xe_arr[i]
- ye = ye_arr[i]
- sigma_x = sigma_x_arr[i]
- sigma_y = sigma_y_arr[i]
-
- t_weight = 1. / np.hypot(xe, ye)
- t0[i] = np.average(time, weights=t_weight)
- dt = time - t0[i]
-
- if use_scipy:
- p0x = np.array([0., x.mean()])
- p0y = np.array([0., y.mean()])
-
- # Use scipy.curve_fit to fit for velocity
- vx_opt, vx_cov = curve_fit(linear, dt, x, p0=p0x, sigma=sigma_x, absolute_sigma=absolute_sigma)
- vy_opt, vy_cov = curve_fit(linear, dt, y, p0=p0y, sigma=sigma_y, absolute_sigma=absolute_sigma)
-
- vx[i] = vx_opt[0]
- vy[i] = vy_opt[0]
- x0[i] = vx_opt[1]
- y0[i] = vy_opt[1]
- vxe[i], x0e[i] = np.sqrt(vx_cov.diagonal())
- vye[i], y0e[i] = np.sqrt(vy_cov.diagonal())
- chi2_vx[i] = calc_chi2(dt, x, sigma_x, *vx_opt)
- chi2_vy[i] = calc_chi2(dt, y, sigma_y, *vy_opt)
-
- else:
- vx_result = linear_fit(dt, x, sigma=sigma_x, absolute_sigma=absolute_sigma)
- vy_result = linear_fit(dt, y, sigma=sigma_y, absolute_sigma=absolute_sigma)
-
- vx[i] = vx_result['slope']
- vxe[i] = vx_result['e_slope']
- x0[i] = vx_result['intercept']
- x0e[i] = vx_result['e_intercept']
- chi2_vx[i] = vx_result['chi2']
-
- vy[i] = vy_result['slope']
- vye[i] = vy_result['e_slope']
- y0[i] = vy_result['intercept']
- y0e[i] = vy_result['e_intercept']
- chi2_vy[i] = vy_result['chi2']
-
- result = pd.DataFrame({
- 'vx': vx, 'vy': vy,
- 'vxe': vxe, 'vye': vye,
- 'x0': x0, 'y0': y0,
- 'x0e': x0e, 'y0e': y0e,
- 'chi2_vx': chi2_vx,
- 'chi2_vy': chi2_vy,
- 't0': t0
- })
- return result
-
-
-# Test
-if __name__=='__main__':
- from scipy.optimize import curve_fit
-
- x = np.array([1,2,3,4])
- y = np.array([1,2,5,6])
- sigma = np.array([.4,.2,.1,.3])
-
- for absolute_sigma in [True, False]:
- result = linear_fit(x, y, sigma=sigma, absolute_sigma=absolute_sigma)
- popt, pcov = curve_fit(linear, x, y, sigma=sigma, absolute_sigma=absolute_sigma)
- perr = np.sqrt(np.diag(pcov))
- print(f'Absolute Sigma = {absolute_sigma}')
- print(f"linear_fit: slope = {result['slope']:.3f} ± {result['e_slope']:.3f}, intercept = {result['intercept']:.3f} ± {result['e_intercept']:.3f}, chi2={result['chi2']:.3f}")
- print(f'curve_fit: slope = {popt[0]:.3f} ± {perr[0]:.3f}, intercept = {popt[1]:.3f} ± {perr[1]:.3f}, chi2={calc_chi2(x, y, sigma, *popt):.3f}\n')
\ No newline at end of file
diff --git a/flystar/match.py b/flystar/match.py
index e989579..3162e38 100644
--- a/flystar/match.py
+++ b/flystar/match.py
@@ -1,21 +1,14 @@
+import itertools
import numpy as np
-from flystar import starlists, transforms, startables, align
from collections import Counter
-from scipy.spatial import cKDTree as KDT
-from astropy.table import Column, Table
-import itertools
-import copy
-import scipy.signal
-from scipy.spatial import distance
-import math
-import pdb
+from scipy.spatial import KDTree as KDT
def miracle_match_briteN(xin1, yin1, min1, xin2, yin2, min2, Nbrite,
- Nbins_vmax=200, Nbins_angle=360,verbose=False):
+ polygon1=None, polygon2=None, buffer=0, Nbins_vmax=200, Nbins_angle=360,verbose=False):
"""
Take two input starlists and select the brightest stars from
- each. Then performa a triangle matching algorithm along the lines of
+ each. Then perform a triangle matching algorithm along the lines of
Groth 1986.
For every possible triangle (combination of 3 stars) in a starlist,
@@ -30,23 +23,115 @@ def miracle_match_briteN(xin1, yin1, min1, xin2, yin2, min2, Nbrite,
and brightness uncertainties, the more bigger the bin sizes should really
be. But this isn't well tested.
"""
-
+
if verbose:
print( '')
print( ' miracle_match_briteN: use brightest {0}'.format(Nbrite))
print( ' miracle_match_briteN: ')
print( ' miracle_match_briteN: ')
+ xin1 = np.array(xin1)
+ yin1 = np.array(yin1)
+ min1 = np.array(min1)
+ xin2 = np.array(xin2)
+ yin2 = np.array(yin2)
+ min2 = np.array(min2)
+
+ if (polygon1 is not None) and (polygon2 is not None):
+ import shapely
+ points1 = shapely.points(xin1, yin1)
+ points2 = shapely.points(xin2, yin2)
+ overlap = polygon1.intersection(polygon2).buffer(buffer)
+ in_poly1 = shapely.contains(overlap, points1)
+ in_poly2 = shapely.contains(overlap, points2)
+ xin1 = xin1[in_poly1]
+ yin1 = yin1[in_poly1]
+ min1 = min1[in_poly1]
+ xin2 = xin2[in_poly2]
+ yin2 = yin2[in_poly2]
+ min2 = min2[in_poly2]
+ # else:
+ # # Only look for matches within overlapping minimum-bounding-boxes of the 2 lists
+ # valid1 = (np.isfinite(xin1)) & (np.isfinite(yin1)) & (np.isfinite(min1))
+ # valid2 = (np.isfinite(xin2)) & (np.isfinite(yin2)) & (np.isfinite(min2))
+ # if (sum(valid1) < Nbrite) or (sum(valid2) < Nbrite):
+ # raise ValueError(
+ # f'Not enough valid stars to find matches! Need at least {Nbrite} valid stars.\n' +
+ # f'Valid stars in list 1: {sum(valid1)}\n' +
+ # f'Valid stars in list 2: {sum(valid2)}\n'
+ # )
+
+ # xin1 = xin1[valid1]
+ # yin1 = yin1[valid1]
+ # min1 = min1[valid1]
+ # xin2 = xin2[valid2]
+ # yin2 = yin2[valid2]
+ # min2 = min2[valid2]
+
+ # xmin1, xmax1 = np.min(xin1), np.max(xin1)
+ # ymin1, ymax1 = np.min(yin1), np.max(yin1)
+ # xmin2, xmax2 = np.min(xin2), np.max(xin2)
+ # ymin2, ymax2 = np.min(yin2), np.max(yin2)
+
+ # # Find the overlapping minimum bounding box
+ # x_overlap = (max(xmin1, xmin2), min(xmax1, xmax2))
+ # y_overlap = (max(ymin1, ymin2), min(ymax1, ymax2))
+ # if x_overlap[0] >= x_overlap[1] or y_overlap[0] >= y_overlap[1]:
+ # fig, ax = plt.subplots()
+ # ax.scatter(xin1, yin1, s=1, label='List 1')
+ # ax.scatter(xin2, yin2, s=1, label='List 2')
+ # ax.set_aspect('equal')
+ # ax.legend()
+ # plt.show()
+ # raise ValueError('The two star lists do not have an overlapping region!')
+
+ # # Select overlapping regions
+ # in_overlap1 = (xin1 >= x_overlap[0]) & (xin1 <= x_overlap[1]) & (yin1 >= y_overlap[0]) & (yin1 <= y_overlap[1])
+ # in_overlap2 = (xin2 >= x_overlap[0]) & (xin2 <= x_overlap[1]) & (yin2 >= y_overlap[0]) & (yin2 <= y_overlap[1])
+ # if sum(in_overlap1) < Nbrite or sum(in_overlap2) < Nbrite:
+ # raise ValueError(
+ # 'Not enough stars in the overlapping region to find matches!\n' +
+ # f'Stars in overlap for list 1: {sum(in_overlap1)}\n' +
+ # f'Stars in overlap for list 2: {sum(in_overlap2)}\n'
+ # )
+
+ # from matplotlib.patches import Rectangle
+ # fig, ax = plt.subplots()
+ # polygon1 = Rectangle((xmin1, ymin1), xmax1-xmin1, ymax1-ymin1, fill=True, edgecolor='C0', facecolor='C0', alpha=0.5, label='MBB List 1')
+ # polygon2 = Rectangle((xmin2, ymin2), xmax2-xmin2, ymax2-ymin2, fill=True, edgecolor='C2', facecolor='C2', alpha=0.5, label='MBB List 2')
+ # polygon_overlap = Rectangle((x_overlap[0], y_overlap[0]), x_overlap[1]-x_overlap[0], y_overlap[1]-y_overlap[0], fill=True, edgecolor='red', facecolor='C3', alpha=0.5, label='Overlap Region')
+ # ax.scatter(xin1, yin1, s=1, label='List 1')
+ # ax.scatter(xin2, yin2, s=1, label='List 2')
+ # ax.add_patch(polygon1)
+ # ax.add_patch(polygon2)
+ # ax.add_patch(polygon_overlap)
+ # ax.set_aspect('equal')
+ # ax.legend()
+ # plt.show()
+
+ # xin1 = xin1[in_overlap1]
+ # yin1 = yin1[in_overlap1]
+ # min1 = min1[in_overlap1]
+ # xin2 = xin2[in_overlap2]
+ # yin2 = yin2[in_overlap2]
+ # min2 = min2[in_overlap2]
+
# Get/check the lengths of the two starlists
nin1 = len(xin1)
nin2 = len(xin2)
if (nin1 < Nbrite) or (nin2 < Nbrite):
- print(( 'You need at least {0} to '.format(Nbrite)))
- print( 'find the matches...')
- print(( 'NIN1: ', nin1))
- print(( 'NIN2: ', nin2))
- return (0, None, None, None, None, None, None)
+ raise ValueError(
+ f'Not enough stars in the overlapping region to find matches! Need at least {Nbrite} valid stars.\n' +
+ f'Stars in overlap for list 1: {nin1}\n' +
+ f'Stars in overlap for list 2: {nin2}\n'
+ )
+ # print(f'WARNING: You need at least {Nbrite} to find the matches...')
+ # print(f'NIN1: {nin1}')
+ # print(f'NIN2: {nin2}')
+ # # Nbrite = min(nin1, nin2)
+ # # print(f'Updating Nbrite to {Nbrite}...')
+ # return (0, None, None, None, None, None, None)
# Take the Nbrite brightest stars from each list and order by brightness.
if verbose:
@@ -55,7 +140,7 @@ def miracle_match_briteN(xin1, yin1, min1, xin2, yin2, min2, Nbrite,
print( ' miracle_match_briteN: ')
x1, y1, m1 = order_by_brite(xin1, yin1, min1, Nbrite, verbose=verbose)
x2, y2, m2 = order_by_brite(xin2, yin2, min2, Nbrite, verbose=verbose)
-
+
####################
#
# Triangle Matching
@@ -111,7 +196,6 @@ def miracle_match_briteN(xin1, yin1, min1, xin2, yin2, min2, Nbrite,
idx2_vmax_hist = idx2_vmax_hist[good_idx2]
idx2_angl_hist = idx2_angl_hist[good_idx2]
-
##########
# Possible Matches
##########
@@ -125,7 +209,7 @@ def miracle_match_briteN(xin1, yin1, min1, xin2, yin2, min2, Nbrite,
# Now vote for all stars in the triangles that have possible matches (same vmax, angle)
# between the first and second lists.
votes = np.zeros((Nbrite, Nbrite))
-
+
matches = np.where(stars_in1_matches2[:,0] >= 0)[0]
match_stars1 = stars_in1_matches2[matches,:]
match_stars2 = stars_in_tri2[matches,:]
@@ -138,7 +222,7 @@ def miracle_match_briteN(xin1, yin1, min1, xin2, yin2, min2, Nbrite,
add_votes(votes, match_stars1[:,0], match_stars2[:,0])
add_votes(votes, match_stars1[:,1], match_stars2[:,1])
add_votes(votes, match_stars1[:,2], match_stars2[:,2])
-
+
##########
# Find matching triangles with most votes (and that pass threshold)
##########
@@ -166,7 +250,6 @@ def miracle_match_briteN(xin1, yin1, min1, xin2, yin2, min2, Nbrite,
x1_mat = x1[votes_sdx[0, good]]
y1_mat = y1[votes_sdx[0, good]]
m1_mat = m1[votes_sdx[0, good]]
-
return len(x1_mat), x1_mat, y1_mat, m1_mat, x2_mat, y2_mat, m2_mat
@@ -196,7 +279,7 @@ def order_by_brite(xi, yi, mi, Nout, verbose=True):
return xo, yo, mo
-def match(x1, y1, m1, x2, y2, m2, dr_tol, dm_tol=None, verbose=True):
+def match(x1, y1, m1, x2, y2, m2, dr_tol, dm_tol=None, workers=1, verbose=True):
"""
Finds matches between two different catalogs. No transformations are done and it
is assumed that the two catalogs are already on the same coordinate system
@@ -205,11 +288,12 @@ def match(x1, y1, m1, x2, y2, m2, dr_tol, dm_tol=None, verbose=True):
For two stars to be matched, they must be within a specified radius (dr_tol) and
delta-magnitude (dm_tol). For stars with more than 1 neighbor (within the tolerances),
if one is found that is the best match in both brightness and positional offsets
- (closest in both), then the match is made. Otherwise,
- their is a conflict and no match is returned for the star.
-
-
+ (closest in both), then the match is made.
+ Otherwise, their is a conflict and no match is returned for the star.
+
+
Parameters
+ ----------
x1 : array-like
X coordinate in the first catalog
y1 : array-like
@@ -229,10 +313,12 @@ def match(x1, y1, m1, x2, y2, m2, dr_tol, dm_tol=None, verbose=True):
dm_tol : float or None, optional
How close in delta-magnitude a match has to be to count as a match.
If None, then any delta-magnitude is allowed.
+ workers : int, optional
+ Number of jobs to schedule for parallel processing. If -1 is given all processors are used. Default: 1.
verbose : bool or int, optional
- Prints on screen information on the matching. Higher verbose values
+ Prints on screen information on the matching. Higher verbose values
(up to 9) provide more detail.
-
+
Returns
-------
idx1 : int array
@@ -245,27 +331,34 @@ def match(x1, y1, m1, x2, y2, m2, dr_tol, dm_tol=None, verbose=True):
Distance between the matches.
dm : float array
Delta-mag between the matches. (m1 - m2)
-
+
+ Raises
+ ------
+ ValueError
+ If the input arrays do not have the same shape or if they do not contain any finite values.
+ Or when no match is found between the two catalogs.
"""
-
+
x1 = np.array(x1, copy=False)
y1 = np.array(y1, copy=False)
m1 = np.array(m1, copy=False)
x2 = np.array(x2, copy=False)
y2 = np.array(y2, copy=False)
m2 = np.array(m2, copy=False)
-
- if x1.shape != y1.shape:
- raise ValueError('x1 and y1 do not match!')
- if x2.shape != y2.shape:
- raise ValueError('x2 and y2 do not match!')
-
+
+ for val, name in zip([x1, y1, m1, x2, y2, m2], ['x1', 'y1', 'm1', 'x2', 'y2', 'm2']):
+ if not np.isfinite(val).any():
+ raise ValueError(f'{name} does not contain any finite values!')
+
+ assert x1.shape == y1.shape, 'x1 and y1 do not match!'
+ assert x2.shape == y2.shape, 'x2 and y2 do not match!'
+
# Setup coords1 pairs and coords 2 pairs
# this is equivalent to, but faster than just doing np.array([x1, y1])
coords1 = np.empty((x1.size, 2))
coords1[:, 0] = x1
coords1[:, 1] = y1
-
+
# this is equivalent to, but faster than just doing np.array([x1, y1])
coords2 = np.empty((x2.size, 2))
coords2[:, 0] = x2
@@ -279,18 +372,20 @@ def match(x1, y1, m1, x2, y2, m2, dr_tol, dm_tol=None, verbose=True):
idxs2 = np.ones(x1.size, dtype=int) * -1
# The matching will be done using a KDTree.
- kdt = KDT(coords2, balanced_tree=False)
+ #kdt = KDT(coords2, balanced_tree=False)
+ #KDTree handling of NaNs throws error in scipy v1.10.1 and newer.
+ #Replace NaNs in coords2 with zero (0). -SKT
+ kdt = KDT(np.where(np.isfinite(coords2), coords2, 0), balanced_tree=False)
# This returns the number of neighbors within the specified
# radius. We will use this to find those stars that have no or one
# match and deal with them easily. The more complicated conflict
# cases will be dealt with afterward.
- i2_match = kdt.query_ball_point(coords1, dr_tol)
+ i2_match = kdt.query_ball_point(coords1, dr_tol, workers=workers)
Nmatch = np.array([len(idxs) for idxs in i2_match])
# What is the largest number of matches we have for a given star?
Nmatch_max = Nmatch.max()
-
# Loop through and handle all the different numbers of matches.
# This turns out to be the most efficient so we can use numpy
# array operations. Remember, skip the Nmatch=0 objects... they
@@ -303,7 +398,7 @@ def match(x1, y1, m1, x2, y2, m2, dr_tol, dm_tol=None, verbose=True):
if nn == 1:
i2_nn = np.array([i2_match[mm][0] for mm in i1_nn])
- if dm_tol != None:
+ if dm_tol is not None:
dm = np.abs(m1[i1_nn] - m2[i2_nn])
keep = dm < dm_tol
idxs1[i1_nn[keep]] = i1_nn[keep]
@@ -314,20 +409,18 @@ def match(x1, y1, m1, x2, y2, m2, dr_tol, dm_tol=None, verbose=True):
else:
i2_tmp = np.array([i2_match[mm] for mm in i1_nn])
- # Repeat star list 1 positions and magnitudes
- # for nn times (tile then transpose)
- x1_nn = np.tile(x1[i1_nn], (nn, 1)).T
- y1_nn = np.tile(y1[i1_nn], (nn, 1)).T
- m1_nn = np.tile(m1[i1_nn], (nn, 1)).T
+ x1_nn = x1[i1_nn]
+ y1_nn = y1[i1_nn]
+ m1_nn = m1[i1_nn]
# Get out star list 2 positions and magnitudes
x2_nn = x2[i2_tmp]
y2_nn = y2[i2_tmp]
m2_nn = m2[i2_tmp]
- dr = np.abs(x1_nn - x2_nn, y1_nn - y2_nn)
- dm = np.abs(m1_nn - m2_nn)
+ dr = np.hypot(x2_nn - x1_nn[:, np.newaxis], y2_nn - y1_nn[:, np.newaxis])
+ dm = np.abs(m2_nn - m1_nn[:, np.newaxis])
- if dm_tol != None:
+ if dm_tol is not None:
# Don't even consider stars that exceed our
# delta-mag threshold.
dr_msk = np.ma.masked_where(dm > dm_tol, dr)
@@ -342,7 +435,7 @@ def match(x1, y1, m1, x2, y2, m2, dr_tol, dm_tol=None, verbose=True):
# Double check that "min" choice is still within our
# detla-mag tolerence.
- dm_tmp = np.array([dm.T[dm_min[I]][I] for I in np.lib.index_tricks.ndindex(dm_min.shape)])
+ dm_tmp = np.array([dm.T[dm_min[I]][I] for I in np.ndindex(dm_min.shape)])
keep = (dm_min == dr_min) & (dm_tmp < dm_tol)
else:
@@ -361,8 +454,8 @@ def match(x1, y1, m1, x2, y2, m2, dr_tol, dm_tol=None, verbose=True):
idxs1 = idxs1[idxs1 >= 0]
idxs2 = idxs2[idxs2 >= 0]
- dr = np.hypot(x1[idxs1] - x2[idxs2], y1[idxs1] - y2[idxs2])
- dm = m1[idxs1] - m2[idxs2]
+ dr = np.hypot(x2[idxs2] - x1[idxs1], y2[idxs2] - y1[idxs1])
+ dm = m2[idxs2] - m1[idxs1]
# Deal with duplicates
duplicates = [item for item, count in list(Counter(idxs2).items()) if count > 1]
@@ -373,36 +466,29 @@ def match(x1, y1, m1, x2, y2, m2, dr_tol, dm_tol=None, verbose=True):
# Index into the idxs1, idxs2 array of this duplicate.
dups = np.where(idxs2 == duplicates[dd])[0]
- # Assume the duplicates are confused first... see if we
- # can resolve the confusion below.
+ # Assume the duplicates are confused first... see if we can resolve the confusion below.
keep[dups] = False
-
- dm_dups = m1[idxs1[dups]] - m2[idxs2[dups]]
- dr_dups = np.hypot(x1[idxs1[dups]] - x2[idxs2[dups]], y1[idxs1[dups]] - y2[idxs2[dups]])
-
- dm_min = np.abs(dm_dups).argmin()
- dr_min = np.abs(dr_dups).argmin()
+ best_dm = np.abs(m2[idxs2[dups]] - m1[idxs1[dups]]).argmin()
+ best_dr = np.hypot(x2[idxs2[dups]] - x1[idxs1[dups]], y2[idxs2[dups]] - y1[idxs1[dups]]).argmin()
# If there is a clearly preferred match (closest in distance and brightness), then
- # keep it and dump the other duplicates.
- if dm_min == dr_min:
- keep[dups[dm_min]] = True
- else:
- if verbose > 8:
- print(' confused, dropping')
-
+ # keep it and dump the other duplicates. Otherwise, drop the match as confused.
+ if best_dm == best_dr:
+ keep[dups[best_dm]] = True
+ elif verbose > 3:
+ print(' confused, dropping star at',x2[idxs2[dups]][0],y2[idxs2[dups]][0])
# Clean up the duplicates
idxs1 = idxs1[keep]
idxs2 = idxs2[keep]
dr = dr[keep]
dm = dm[keep]
-
+
return idxs1, idxs2, dr, dm
def calc_triangles_vmax_angle(x, y):
idx = np.arange(len(x), dtype=np.int16)
-
+
# Option 1 -- this takes 0.217 seconds for 50 objects
# t1 = time.time()
# combo_iter1 = itertools.combinations(idx1, 3)
@@ -411,258 +497,51 @@ def calc_triangles_vmax_angle(x, y):
# print( 'Finished Option 1: ', t2 - t1)
# print( combo_idx1_1.shape)
# print( combo_idx1_1)
-
+
# Option 2 -- this takes 0.016 seconds for 50 objects
combo_iter = itertools.combinations(idx, 3)
combo_dt = np.dtype('i2,i2,i2')
combo_idx_tmp = np.fromiter(combo_iter, dtype=combo_dt)
combo_idx = combo_idx_tmp.view(np.int16).reshape(-1, 3)
-
+
ii0 = combo_idx[:,0]
ii1 = combo_idx[:,1]
ii2 = combo_idx[:,2]
-
+
dxab = x[ii1] - x[ii0]
dyab = y[ii1] - y[ii0]
dxac = x[ii2] - x[ii0]
dyac = y[ii2] - y[ii0]
-
+
dab = np.hypot(dxab, dyab)
dac = np.hypot(dxac, dyac)
-
+
dmax = np.max([dab, dac], axis=0)
dmin = np.min([dab, dac], axis=0)
-
+
vmax = dmin ** 2 / dmax ** 2
vmax[dab < dac] *= -1
-
+
vdprod = dxab * dxac + dyab * dyac
vcprod = dxab * dyac - dyab * dxac
-
+
angle = np.degrees( np.arctan2( vdprod, vcprod) )
angle[angle < 0] += 360.0
angle[angle > 360] -= 360.0
-
+
return combo_idx, vmax, angle
def add_votes(votes, match1, match2):
# Construct a histogram of how often a bin is matched... then add the delta
flat_idx = np.ravel_multi_index((match1, match2), dims=votes.shape)
-
+
# extract the unique indices and their position
unique_idx, idx_idx = np.unique(flat_idx, return_inverse=True)
-
+
# aggregate the repeated indices
deltas = np.bincount(idx_idx)
-
+
# Sum them to the array
votes.flat[unique_idx] += deltas
-
- return
-
-
-def generic_match(sl1, sl2, init_mode='triangle',
- model=transforms.PolyTransform, order_dr=(1, 1.0),
- dr_final=1.0,
- xy_match=(None, None, None, None, None, None, None, None),
- m_match=(None, None, None, None), sigma_match=None,
- n_bright=100, verbose=True, **kwargs):
- """
- Finds the transformation between two starlists using the first one
- as reference frame. Different matching methods can be used. If no
- transformation is found, it returns an error message.
-
- Parameters
- sl1 : StarList
- starlist used for reference frame
- sl2 : StarList
- starlist transformed
- init_mode : str
- Initial matching method.
- If 'triangle', uses the blind triangle method.
- If 'match_name', uses match by name
- If 'load', uses the transformation from a loaded file
- model : str
- Transformation model to be used with the 'triangle' initial mode
- poly_order : int
- Order of the transformation model
- order_dr : int, float [n, 2]
- Combinations of polinomial order (first column) and search radius
- (second column) to refine the transformation. Rows are executed in
- orders
- dr_final: float
- Search radius used for the final matching
- n_bright : int
- Number of bright stars used in the initial blind triangles matching
- xy_match : array
- Area of the images to remove in the matching [reference catalog min x,
- reference catalog max x, reference catalog min y, reference catalog max y,
- transformed catalog min x, transformed catalog max x,
- transformed catalog min y, transformed catalog max y]. Use None for values not used.
- m_match : array
- Magnitude limits of matching stars used to find transformations
- [reference catalog min mag, reference catalog max mag, transformed
- catalog min mag, transformed catalog max mag]. Use None for values not
- used
- sigma_match : array
- Number of Deltap movement sigmas [0] used for sigma-cutting matched
- stars for a number of times [1]. Use None for no sigma-cut. The last
- polynomial order and search radius in 'order_dr' are used
- transf_file : str
- File name and path of the transformation file used with the 'load'
- init_mode
- verbose : bool, optional
- Prints on screen information on the matching
-
- Returns
- -------
- transf : Transform2D
- Transformation of the second starlist respect to the first
- st : StarTable
- Startable of the two matched catalogs
-
- """
-
- # Check the input StarLists and transform them into astropy Tables
- if not isinstance(sl1, starlists.StarList):
- raise TypeError("The first catalog has to be a StarList")
- if not isinstance(sl2, starlists.StarList):
- raise TypeError("The second catalog has to be a StarList")
-
- # Find the initial transformation
- if init_mode == 'triangle': # Blind triangles method
-
- # Prepare the reduced starlists for matching
- sl1_cut = copy.deepcopy(sl1)
- sl2_cut = copy.deepcopy(sl2)
- sl1_cut.restrict_by_value(x_min=xy_match[0], x_max=xy_match[1],
- y_min=xy_match[2], y_max=xy_match[3])
- sl2_cut.restrict_by_value(x_min=xy_match[4], x_max=xy_match[5],
- y_min=xy_match[6], y_max=xy_match[7])
- sl1_cut.restrict_by_value(m_min=m_match[0], m_max=m_match[1])
- sl2_cut.restrict_by_value(m_min=m_match[2], m_max=m_match[3])
-
- # Find the transformation
- # TODO: test 'initial_align' with StarList input
- transf = align.initial_align(sl1_cut, sl2_cut, briteN=n_bright,
- transformModel=model, order=order_dr[0]) #order_dr[i_loop][0] ?
-
- elif init_mode == 'match_name': # Name match
- sl1_idx_init, sl2_idx_init, _ = starlists.restrict_by_name(sl1, sl2)
- transf = model(sl2['x'][sl2_idx_init], sl2['y'][sl2_idx_init],
- sl1['x'][sl1_idx_init], sl1['y'][sl1_idx_init],
- order=int(order_dr[0][0]))
-
- elif init_mode == 'load': # Load a transformation file
- transf = transforms.Transform2D.from_file(kwargs['transf_file'])
-
- else: # None of the above
- raise TypeError("Unrecognized initial matching method")
-
- # Restrict the matching catalogs
- sl1_match = copy.deepcopy(sl1)
- sl2_match = copy.deepcopy(sl2)
- sl1_match.restrict_by_value(m_min=m_match[0], m_max=m_match[1])
- sl2_match.restrict_by_value(m_min=m_match[2], m_max=m_match[3])
-
- # Refine the transformation
- if sigma_match:
- order_dr_len = len(order_dr)
-
- for i_loop in range(sigma_match[1]):
- order_dr = np.vstack((np.array(order_dr), np.array(order_dr[-1])))
-
- for i_loop in range(len(order_dr)):
-
- # Transform and match the catalog to the reference frame
-# sl2_idx, sl1_idx = align.transform_and_match(sl2_match, sl1_match, transf,
-# dr_tol=order_dr[i_loop][1],
-# verbose=verbose)
-
- sl2_idx, sl1_idx = align.transform_and_match(sl2_match, sl1_match, transf,
- dr_tol=order_dr[1],
- verbose=verbose)
-
- # Transform the catalog to the reference frame
- sl2_transf_match = align.transform_from_object(sl2_match, transf)
-
- # Sigma-rejection
- if sigma_match and (i_loop >= order_dr_len):
- resid = np.sqrt((sl1_match['x'][sl1_idx] -
- sl2_transf_match['x'][sl2_idx])**2 +
- (sl1_match['y'][sl1_idx] -
- sl2_transf_match['y'][sl2_idx])**2)
- sl1_idx = sl1_idx[resid <= (sigma_match[0] * np.std(resid))]
- sl2_idx = sl2_idx[resid <= (sigma_match[0] * np.std(resid))]
-
- # Test section to observe the matching catalogs before refining the transformation
- """
- from matplotlib import pyplot
-
- _, axarr = pyplot.subplots(nrows=1, ncols=1, figsize=(10,10))
- axarr.scatter(sl1_match['x'][sl1_idx], sl1_match['y'][sl1_idx])
- xlim = axarr.get_xlim()
- ylim = axarr.get_ylim()
-
- _, axarr = pyplot.subplots(nrows=1, ncols=1, figsize=(10, 10))
- axarr.scatter(sl2_transf_match['x'][sl2_idx], sl2_transf_match['y'][sl2_idx])
- axarr.set_xlim(xlim)
- axarr.set_ylim(ylim)
- """
-
- # Find a better transformation
- transf, _ = align.find_transform(sl2_match[sl2_idx],
- sl2_transf_match[sl2_idx],
- sl1_match[sl1_idx], transModel=model,
- order=order_dr[0], verbose=verbose)
-# order=int(order_dr[i_loop][0]), verbose=verbose)
-
- # This section was used for testing transformations with normalized
- # coordinates. Only several catalogs had reduced residuals when using
- # high order polynomials (>3), some of them became unstable
- """sl1_match_norm = sl1_match[sl1_idx]
- sl2_match_norm = sl2_match[sl2_idx]
- sl2_transf_match_norm = sl2_transf_match[sl2_idx]
- mm = max(max(sl1_match_norm['x']), max(sl1_match_norm['y']),
- max(sl2_transf_match_norm['x']), max(sl2_transf_match_norm['y']))
- sl1_match_norm['x'] = sl1_match_norm['x'] / mm
- sl1_match_norm['y'] = sl1_match_norm['y'] / mm
- sl2_match_norm['x'] = sl2_match_norm['x'] / mm
- sl2_match_norm['y'] = sl2_match_norm['y'] / mm
- sl2_transf_match_norm['x'] = sl2_transf_match_norm['x'] / mm
- sl2_transf_match_norm['y'] = sl2_transf_match_norm['y'] / mm
- transf, _ = align.find_transform(sl2_match_norm, sl2_transf_match_norm,
- sl1_match_norm, transModel=model,
- order=poly_order, verbose=verbose)
- c_exp = np.zeros(len(transf.px._parameters))
-
- for i_c in range(len(transf.px._parameters)):
- c_exp[i_c] = int(transf.px._param_names[i_c][1:].split('_')[0]) +\
- int(transf.px._param_names[i_c][1:].split('_')[1])
-
- c_corr = mm ** (1 - c_exp)
- transf.px._parameters = transf.px._parameters * c_corr
- transf.py._parameters = transf.py._parameters * c_corr"""
-
- # Do the final transformation and matching using
- sl2_idx, sl1_idx = align.transform_and_match(sl2, sl1, transf, dr_tol=dr_final,
- verbose=verbose)
- # StarTable output
- sl2_transf = align.transform_from_object(sl2, transf)
- unames = np.array(range(len(sl1_idx)))
- st = startables.StarTable(name=unames,
- x=np.column_stack((np.array(sl1['x'][sl1_idx]), np.array(sl2_transf['x'][sl2_idx]))),
- y=np.column_stack((np.array(sl1['y'][sl1_idx]), np.array(sl2_transf['y'][sl2_idx]))),
- m=np.column_stack((np.array(sl1['m'][sl1_idx]), np.array(sl2_transf['m'][sl2_idx]))),
- ep_name=np.column_stack((np.array(sl1['name'][sl1_idx]), np.array(sl2_transf['name'][sl2_idx]))))
-# ep_name=np.column_stack((np.array(sl1['name'][sl1_idx]), np.array(sl2_transf['name'][sl2_idx]))),
-# list_times=[sl1.meta['list_time'], sl2.meta['list_time']],
-# list_names=[sl1.meta['list_name'], sl2.meta['list_name']])
-
- for col in sl1.colnames:
- if col in sl2.colnames:
- if col not in ['name', 'x', 'y', 'm']:
- st.add_column(Column(np.column_stack((np.array(sl1[col][sl1_idx]),np.array(sl2_transf[col][sl2_idx]))), name=col))
-
- return transf, st
+ return
diff --git a/flystar/motion_model.py b/flystar/motion_model.py
new file mode 100644
index 0000000..7cff0b6
--- /dev/null
+++ b/flystar/motion_model.py
@@ -0,0 +1,1690 @@
+import warnings
+import numpy as np
+from abc import ABC
+from flystar import parallax
+from astropy.time import Time
+from scipy.optimize import curve_fit, OptimizeWarning
+
+
+def weight_from_sigma(sigma, valid=None):
+ """
+ Convert an uncertainty (sigma) array into a safe inverse-variance
+ weight (1/sigma**2), for use in a weighted sum/average.
+
+ A point with no real uncertainty information should contribute
+ nothing to a weighted sum -- but naively computing 1/sigma**2 can
+ instead produce an infinite or NaN weight (sigma is NaN/inf/exactly
+ zero, or so small that squaring it underflows to zero), which would
+ corrupt rather than exclude that point. This handles all of those
+ cases uniformly: any sigma that doesn't produce a finite weight, or
+ any point explicitly marked invalid via `valid`, gets a weight of
+ exactly 0.
+
+ This does NOT handle the "every point has weight 0" case for you --
+ a weighted average built from these weights still needs its own
+ explicit fallback for that (see combine_lists/fit_motion_models),
+ since there's no single value this function could return that fixes
+ an otherwise-undefined 0/0 average.
+
+ Parameters
+ ----------
+ sigma : array-like
+ Uncertainty values (any invalid/zero/overflow-inducing value is
+ safely handled).
+ valid : array-like of bool, optional
+ If given, points where this is False also get weight 0,
+ regardless of sigma.
+
+ Returns
+ -------
+ weight : ndarray
+ Same shape as sigma.
+ """
+ sigma = np.asarray(sigma, dtype=float)
+ with np.errstate(divide='ignore', invalid='ignore'):
+ weight = 1. / sigma**2
+ if valid is not None:
+ weight = np.where(valid, weight, 0.0)
+ weight[~np.isfinite(weight)] = 0.0
+ return weight
+
+
+class MotionModel(ABC):
+ name = "MotionModel"
+
+ # Fit paramters: Shared fit parameters
+ fit_param_names = []
+ n_fit_params = len(fit_param_names)
+ # Number of fit parameters/required observations in each direction
+ n_params = int((n_fit_params + 1) / 2)
+
+ # Fixed parameters: These are parameters that are required for the model, but are not
+ # fit quantities. For example, RA and Dec in a parallax model.
+ fixed_param_names = []
+ required_fixed_param_names = []
+ optional_fixed_params = {}
+
+ fixed_meta_data = []
+
+ # Non-fit paramters: Custom paramters that will not be fit.
+ # These parameters should be derived from the fit parameters and
+ # they must exist as a variable on the model object
+
+ def __init__(self, *args, **kwargs):
+ """
+ Make a motion model object. This object defines the fit and fixed parameters,
+ and contains functions to fit the model to data and infer positions at given times.
+ Each instance corresponds to a given motion model, not an individual star,
+ and thus the fit values are only input/returned in functions, not stored in the object.
+ """
+ return
+
+ def _check_param_dimensions(self, fit_params, fit_params_errs, fixed_params_dict):
+ """Check that parameters is either a scalar or length of N_stars
+
+ Parameters
+ ----------
+ fit_params: array-like
+ Fit parameters, shape (N_fit_params,) or (n_stars, N_fit_params)
+ fit_params_errs: array-like
+ Errors of fit parameters, shape (N_fit_params,) or (n_stars, N_fit_params)
+ fixed_params_dict : dict
+ Dictionary of fixed parameters
+ """
+ N_stars = fit_params.shape[0] if fit_params.ndim > 1 else 1
+ if fit_params_errs is not None:
+ assert fit_params_errs.shape == fit_params.shape, "fit_params and fit_params_errs must have the same shape!"
+
+ if fixed_params_dict is not None:
+ for key, value in fixed_params_dict.items():
+ # assert key in fixed_params_dict, f"Missing fixed parameter {key} in fixed_params_dict!"
+ value = fixed_params_dict[key]
+ if np.isscalar(value):
+ continue
+ else:
+ assert len(value) == N_stars, f"Length of fixed parameter {key} must be either 1 or N_stars={N_stars}!"
+
+ def model_fit(self, dt):
+ return np.full_like(dt, np.nan)
+
+ def model(self, t, fit_params, fit_param_errs=None, fixed_params_dict=None):
+ self._check_param_dimensions(fit_params, fit_param_errs, fixed_params_dict)
+ if fit_param_errs is None:
+ return np.full_like(t, np.nan), np.full_like(t, np.nan)
+ return np.full_like(t, np.nan), np.full_like(t, np.nan), np.full_like(t, np.inf), np.full_like(t, np.inf)
+
+ def run_fit(
+ self, t, x, y, xe, ye,
+ fixed_params_dict=None,
+ weighting='var',
+ use_scipy=True,
+ absolute_sigma=True,
+ params_guess=None,
+ fill_value=np.nan,
+ return_chi2=False,
+ method=None,
+ verbose=True
+ ):
+ # Run a single fit (used both for overall fit + bootstrap iterations)
+ if return_chi2:
+ return np.full(self.n_fit_params, fill_value), np.full(self.n_fit_params, np.inf), np.nan, np.nan
+ return np.full(self.n_fit_params, fill_value), np.full(self.n_fit_params, np.inf)
+
+ def calc_sigma(self, xe, ye, weighting='var'):
+ if weighting=='std':
+ return np.sqrt(np.abs(xe)), np.sqrt(np.abs(ye))
+ elif weighting=='var':
+ return np.abs(xe), np.abs(ye)
+ else:
+ warnings.warn("Invalid weighting, using default weighting scheme var.", UserWarning)
+ return np.abs(xe), np.abs(ye)
+
+ def fit(
+ self, t, x, y, xe, ye,
+ fixed_params_dict=None,
+ weighting='var',
+ use_scipy=True,
+ absolute_sigma=True,
+ fill_value=np.nan,
+ params_guess=None,
+ return_chi2=False,
+ bootstrap=0,
+ seed=None,
+ method=None,
+ verbose=True
+ ):
+ """Fit stellar motion parameters
+
+ Parameters
+ ----------
+ t : array-like
+ Times of measurements
+ x : array-like
+ x-coordinates
+ y : array-like
+ y-coordinates
+ xe : array-like
+ Uncertainty of x
+ ye : array-like
+ Uncertainty of y
+ fixed_params_dict : dict, optional
+ Dictionary of fixed parameters, see each motion model's fixed_param_names for details, by default None
+ weighting : str, optional
+ Use standard error weighting ('std': w=1/xe, 1/ye) or variance weighting ('var': w=1/xe**2, 1/ye**2), by default 'var'
+ use_scipy : bool, optional
+ Use scipy for optimization. Otherwise, use linear algebraic solution (Linear model only), which is faster for < 300 epochs, by default True
+ absolute_sigma : bool, optional
+ Absolute sigma. See scipy.optimize.curve_fit for details, by default True
+ fill_value : float, optional
+ Fill value for parameters when not enough data points to fit model, by default np.nan
+ params_guess : array-like, optional
+ Initial guess for the fit parameters used in scipy curve_fit, by default None
+ return_chi2 : bool, optional
+ Return chi^2 values along with parameters and uncertainties in params, param_errs, chi2_x, chi2_y, by default False
+ bootstrap : int, optional
+ Bootstrapping uncertainties, by default 0
+ seed : int, optional
+ Seed for the random number generator, by default None
+ method : str, optional
+ Method of scipy.curve_fit, {'lm', 'trf', 'dogbox'}, by default None
+ verbose : bool, optional
+ Print warning messages, by default True
+
+ Returns
+ -------
+ params, param_errs(, chi2_x, chi2_y)
+ Parameters, uncertainties, and chi squares if return_chi2 is True. The corresponding parameter names are in self.fit_param_names.
+ """
+ for variable, name in zip([t, x, y, xe, ye], ['t', 'x', 'y', 'xe', 'ye']):
+ assert np.ndim(variable) == 1, f"Input {name} array must be 1D! Got shape {np.shape(variable)}"
+ if name != 't':
+ assert len(t) == len(variable), f'Input {name} must have the same length as t! Got len(t)={len(t)}, len({name})={len(variable)}'
+
+ if not verbose:
+ warnings.filterwarnings("ignore", category=OptimizeWarning)
+
+ fit_result = self.run_fit(
+ t, x, y, xe, ye,
+ fixed_params_dict=fixed_params_dict,
+ weighting=weighting,
+ use_scipy=use_scipy,
+ absolute_sigma=absolute_sigma,
+ fill_value=fill_value,
+ params_guess=params_guess,
+ return_chi2=return_chi2,
+ verbose=verbose
+ )
+
+ if return_chi2:
+ params, param_errs, chi2_x, chi2_y = fit_result
+ else:
+ params, param_errs = fit_result
+
+
+ # Bootstrap errors
+ n_obs = len(t)
+
+ if (bootstrap > 0) and (n_obs > self.n_params):
+ rng = np.random.default_rng(seed)
+ edx = np.arange(n_obs, dtype=int)
+ # Precompute All Bootstrap Draws at Once
+ # Ensure there are enough unique points in each bootstrap sample
+ bdx_unique = np.stack([
+ rng.choice(edx, size=self.n_params, replace=False)
+ for _ in range(bootstrap)
+ ])
+ # Draw with replacement for the rest
+ bdx_extra = np.stack([
+ rng.choice(edx, size=n_obs - self.n_params, replace=True)
+ for _ in range(bootstrap)
+ ])
+ bdx_all = np.hstack((bdx_unique, bdx_extra))
+
+ bb_params = []
+ bb_params_errs = []
+ for bdx in bdx_all:
+ params_bdx, param_errs_bdx = self.run_fit(
+ t[bdx], x[bdx], y[bdx], xe[bdx], ye[bdx],
+ fixed_params_dict=fixed_params_dict,
+ weighting=weighting,
+ use_scipy=use_scipy,
+ absolute_sigma=absolute_sigma,
+ params_guess=params,
+ fill_value=fill_value,
+ return_chi2=False,
+ method=method,
+ verbose=verbose
+ )
+ bb_params.append(params_bdx)
+ bb_params_errs.append(param_errs_bdx)
+
+ # Save the errors from the bootstrap
+ param_errs = np.std(bb_params, axis=0)
+
+ # Account for odd case
+ inf_errs = [np.all(arr==np.inf) for arr in np.transpose(np.array(bb_params_errs))]
+ param_errs[inf_errs] = 0.0
+
+ if not verbose:
+ warnings.resetwarnings()
+
+ if return_chi2:
+ return params, param_errs, chi2_x, chi2_y
+ else:
+ return params, param_errs
+
+
+ # def calc_chi2(self, dt, x, y, x_wt, y_wt, popt_x, popt_y, reduced=False, parallax=False):
+ # X_mat_t = np.vander(dt, 2)
+ # residual_x = x - X_mat_t @ popt_x
+ # residual_y = y - X_mat_t @ popt_y
+
+ # W_mat_x = np.diag(x_wt)
+ # W_mat_y = np.diag(y_wt)
+
+ # chi2_x = residual_x.T @ W_mat_x @ residual_x
+ # chi2_y = residual_y.T @ W_mat_y @ residual_y
+
+ # if reduced:
+ # if len(dt) == self.n_params:
+ # return np.inf, np.inf
+ # if not parallax:
+ # degree_of_freedom = len(x) - self.n_params
+ # else:
+ # degree_of_freedom = 2*len(x) - len(self.fit_param_names)
+ # chi2_x, chi2_y = chi2_x / degree_of_freedom, chi2_y / degree_of_freedom
+ # return chi2_x, chi2_y
+
+ def calc_chi2(self, t, x, y, xe, ye, fit_params, fixed_params_dict=None, reduced=False, parallax=False):
+ """
+ Get the chi^2 value for the input motion model parameters and data.
+ """
+ x_pred, y_pred = self.model(t, fit_params, fixed_params_dict=fixed_params_dict)
+ chi2x = np.sum((x - x_pred)**2 / xe**2)
+ chi2y = np.sum((y - y_pred)**2 / ye**2)
+ if reduced:
+ if len(t) == self.n_params:
+ return np.inf, np.inf
+ if parallax:
+ degree_of_freedom = 2*len(x) - len(self.fit_param_names)
+ else:
+ degree_of_freedom = len(x) - self.n_params
+ chi2x, chi2y = chi2x / degree_of_freedom, chi2y / degree_of_freedom
+ return chi2x, chi2y
+
+class Empty(MotionModel):
+ name = "Empty"
+ fit_param_names = []
+ fixed_param_names = []
+ required_fixed_param_names = []
+ optional_fixed_params = {}
+
+ n_fit_params = len(fit_param_names)
+ # Number of fit parameters/required observations in each direction
+ n_params = int((n_fit_params + 1) / 2)
+
+ def __init__(self, **kwargs):
+ """Empty motion model, returns nan for values and inf for uncertainties.
+ """
+ super().__init__()
+ return
+
+ def model_fit(self, dt):
+ return np.full_like(dt, np.nan)
+
+ def model(self, t, fit_params, fit_param_errs=None, fixed_params_dict=None):
+ """Predicted positions (and uncertainties, if fit_param_errs is provided) at time t of Empty model.
+
+ Parameters
+ ----------
+ t : float or array-like
+ Time array, shape (N_times,)
+ fit_params : array-like
+ Fit parameters, shape (N_fit_params,) or (N_stars, N_fit_params)
+ fit_param_errs : array-like, optional
+ Uncertainties for fit parameters, not applicable for Empty model, by default None
+ fixed_params_dict : dict, optional
+ Not applicable for Empty model, by default None
+
+ Returns
+ -------
+ x, y (, xe, ye)
+ Predicted position (and uncertainties) of Empty model, shape (N_times,)
+ """
+ self._check_param_dimensions(fit_params, fit_param_errs, fixed_params_dict)
+
+ t = np.atleast_1d(t)
+ fit_params = np.atleast_2d(fit_params) # (N_stars, N_fit_params)
+
+ N_stars = fit_params.shape[0]
+ N_times = len(t)
+
+ if N_times == N_stars or N_times == 1 or N_stars == 1:
+ # Assume each time corresponds to each star, so N_times = 1
+ x = np.full(N_stars, np.nan)
+ y = np.full(N_stars, np.nan)
+ else:
+ x = np.full((N_stars, N_times), np.nan)
+ y = np.full((N_stars, N_times), np.nan)
+
+ if fit_param_errs is None:
+ return x, y
+ return x, y, np.full_like(x, np.inf), np.full_like(y, np.inf)
+
+ def run_fit(
+ self, t, x, y, xe, ye,
+ fixed_params_dict=None,
+ weighting='var',
+ use_scipy=True,
+ absolute_sigma=True,
+ params_guess=None,
+ fill_value=np.nan,
+ return_chi2=False,
+ method=None,
+ verbose=True
+ ):
+ """Fit stellar motion parameters
+
+ Parameters
+ ----------
+ t : float or array-like
+ Time array, shape (N_times,)
+ x : array-like
+ Observed x positions, shape (N_times,)
+ y : array-like
+ Observed y positions, shape (N_times,)
+ xe : array-like
+ Observed uncertainties in x positions, shape (N_times,)
+ ye : array-like
+ Observed uncertainties in y positions, shape (N_times,)
+ fixed_params_dict : dict, optional
+ Dictionary of fixed parameters, not applicable for Empty model, by default None
+ weighting : str, optional
+ Weighting scheme to use, 'var' or 'std', by default 'var'
+ use_scipy : bool, optional
+ Whether to use scipy.optimize for fitting, by default True
+ absolute_sigma : bool, optional
+ Whether to treat sigma as absolute, by default True
+ fill_value : float, optional
+ Value to fill parameters with when fitting is not possible, by default np.nan
+ params_guess : array-like, optional
+ Initial guess for parameters, by default None
+ return_chi2 : bool, optional
+ Whether to return chi-squared value, by default False
+ method : str, optional
+ Method of scipy.curve_fit, {'lm', 'trf', 'dogbox'}, by default None
+ verbose : bool, optional
+ Whether to print verbose output, by default True
+
+ Returns
+ -------
+ params, param_errors (, chi2_x, chi2_y)
+ Fitted parameters, their uncertainties, and optionally chi-squared values
+ """
+ self.fixed_params_dict = fixed_params_dict
+ if verbose:
+ warnings.warn(f"Empty data cannot be fit. Setting parameters to {fill_value} and uncertainties to np.inf.", OptimizeWarning, stacklevel=2)
+ params = np.full(self.n_fit_params, fill_value)
+ param_errors = np.full(self.n_fit_params, np.inf)
+ if return_chi2:
+ return params, param_errors, np.nan, np.nan
+ else:
+ return params, param_errors
+
+ def run_fit_batch(self, t, x, y, xe, ye, valid, fixed_params_dict=None, weighting='var',
+ absolute_sigma=True, fill_value=np.nan, verbose=True):
+ """
+ Vectorized version of run_fit() for many stars at once. Empty's
+ "fit" never looks at any data -- it's always fill_value/inf
+ regardless of what's passed in -- so there's no actual computation
+ to batch. This exists purely so that a table containing some Empty
+ stars (there is almost always at least a handful, e.g. stars with
+ 0 valid epochs) doesn't force the caller to spin up a
+ multiprocessing pool -- and pay its real, fixed per-worker spawn
+ cost -- just to run this trivial, zero-cost case one star at a time.
+
+ Parameters
+ ----------
+ t, x, y, xe, ye, valid : array-like, shape (n_stars, n_epochs)
+ Unused -- accepted only for interface consistency with other
+ motion models' run_fit_batch.
+ fixed_params_dict, weighting, absolute_sigma : unused.
+ fill_value, verbose : as in run_fit().
+
+ Returns
+ -------
+ params : ndarray, shape (n_stars, 0)
+ param_errs : ndarray, shape (n_stars, 0)
+ chi2_x, chi2_y : ndarray, shape (n_stars,), all nan
+ """
+ n_stars = t.shape[0]
+ if verbose and n_stars > 0:
+ warnings.warn(f"Empty data cannot be fit. Setting parameters to {fill_value} and uncertainties to np.inf.", OptimizeWarning, stacklevel=2)
+ params = np.full((n_stars, self.n_fit_params), fill_value)
+ param_errs = np.full((n_stars, self.n_fit_params), np.inf)
+ chi2x = np.full(n_stars, np.nan)
+ chi2y = np.full(n_stars, np.nan)
+ return params, param_errs, chi2x, chi2y
+
+
+class Fixed(MotionModel):
+ """
+ A non-moving motion model for a star on the sky.
+ """
+ name = "Fixed"
+ fit_param_names = ['x0','y0']
+ fixed_param_names = []
+ required_fixed_param_names = []
+ optional_fixed_params = {}
+
+ n_fit_params = len(fit_param_names)
+ # Number of fit parameters/required observations in each direction
+ n_params = int((n_fit_params + 1) / 2)
+
+ def __init__(self, **kwargs):
+ # Must call after setting parameters.
+ # This checks for proper parameter formatting.
+ super().__init__()
+ return
+
+ def model_fit(self, dt, x0):
+ """Fit function for Fixed motion model
+
+ Parameters
+ ----------
+ dt : array-like
+ Time offset, shape (N_times,)
+ x0 : float or array-like
+ Average positions, scalar or shape (N_stars,)
+
+ Returns
+ -------
+ x : array-like
+ Predicted positions, shape (N_times,) if scalar x0, else (N_stars, N_times)
+ """
+ return x0 + np.zeros_like(x0) * dt
+
+ def model(self, t, fit_params, fit_param_errs=None, fixed_params_dict=None):
+ """Predicted positions (and uncertainties, if fit_param_errs is provided) at time t of Fixed model.
+
+ Parameters
+ ----------
+ t : float or array-like
+ Time array, shape (N_times,)
+ fit_params : array-like
+ x0, y0 in shape (N_fit_params,) or (N_stars, N_fit_params)
+ fit_param_errs : array-like, optional
+ Uncertainties for x0, y0 in shape (N_fit_params,) or (N_stars, N_fit_params), by default None
+ fixed_params_dict : dict, optional
+ Not applicable for Fixed, by default None
+
+
+ Returns
+ -------
+ x, y (, xe, ye)
+ Predicted position (and uncertainties) of Fixed model, shape (N_stars, N_times), or (N_times,) if N_stars=1, or (N_stars,) if N_times=1
+ """
+ self.fixed_params_dict = fixed_params_dict
+ t = np.atleast_1d(t)
+ fit_params = np.atleast_2d(fit_params) # (N_stars, N_fit_params)
+ self._check_param_dimensions(fit_params, fit_param_errs, fixed_params_dict)
+
+ N_stars = fit_params.shape[0]
+ N_times = len(t)
+ x0, y0 = fit_params.T # Each shape (N_stars,)
+
+ # FIXME: Do we want this assumption?
+ if N_times == N_stars:
+ # Assume each time corresponds to each star, so N_times = 1
+ dt = t[:, np.newaxis] # Shape (N_stars, 1)
+ N_times = 1
+ else:
+ # Else, calculate each time for each star
+ dt = t[np.newaxis, :] - np.zeros(N_stars)[:, np.newaxis] # Shape (N_stars, N_times)
+
+ # Return results in (N_stars, N_times) shape
+ x = self.model_fit(t, x0[:, np.newaxis]) # Shape (N_stars, N_times)
+ y = self.model_fit(t, y0[:, np.newaxis]) # Shape (N_stars, N_times)
+
+ if N_stars == 1 or N_times == 1:
+ # If only one star, return flattened arrays
+ x = x.flatten()
+ y = y.flatten()
+
+ if fit_param_errs is None:
+ return x, y
+
+ fit_param_errs = np.atleast_2d(fit_param_errs) # (N_stars, N_fit_params)
+ x0_err, y0_err = fit_param_errs.T
+
+ # Return results in (N_stars, N_times) shape
+ x_err = np.broadcast_to(x0_err[:, np.newaxis], (N_stars, N_times))
+ y_err = np.broadcast_to(y0_err[:, np.newaxis], (N_stars, N_times))
+
+ if N_stars == 1 or N_times == 1:
+ # If only one star, return flattened arrays
+ x_err = x_err.flatten()
+ y_err = y_err.flatten()
+
+ return x, y, x_err, y_err
+
+ def run_fit(
+ self, t, x, y, xe, ye,
+ fixed_params_dict=None,
+ weighting='var',
+ use_scipy=True,
+ absolute_sigma=True,
+ params_guess=None,
+ fill_value=np.nan,
+ return_chi2=False,
+ method=None,
+ verbose=True
+ ):
+ if verbose and (not use_scipy):
+ warnings.warn("Fixed model has no non-scipy fitter option. Running with scipy.")
+
+ n_obs = len(t)
+ degree_of_freedom = n_obs - self.n_params
+ # Not enough data points to fit model
+ if degree_of_freedom < 0:
+ warnings.warn(
+ f'Not enough data points to fit model. Setting parameters to {fill_value} and uncertainties to np.inf.',
+ OptimizeWarning, stacklevel=2
+ )
+ params = np.full(self.n_fit_params, fill_value)
+ param_errors = np.full(self.n_fit_params, np.inf)
+ return params, param_errors, np.nan, np.nan
+
+ # degree_of_freedom >= 0
+ # Calculate weighted average position
+ sigma_x, sigma_y = self.calc_sigma(xe, ye, weighting=weighting)
+ x_wt, y_wt = 1. / sigma_x**2, 1. / sigma_y**2
+ x0 = np.average(x, weights=x_wt)
+ # x0e = (np.sum(x_wt_norm**2 * xe**2))**0.5 # Error propagation
+ x0e = 1. / np.sum(x_wt)**0.5 # Error propagation
+ y0 = np.average(y, weights=y_wt)
+ # y0e = (np.sum(y_wt_norm**2 * ye**2))**0.5 # Error propagation
+ y0e = 1. / np.sum(y_wt)**0.5 # Error propagation
+
+ params = np.array([x0, y0])
+ param_errors = np.array([x0e, y0e])
+
+ if (not absolute_sigma) or return_chi2:
+ chi2x, chi2y = self.calc_chi2(t, x, y, xe, ye, params)
+
+ if not absolute_sigma:
+ if degree_of_freedom > 0:
+ reduced_chi2x = chi2x / degree_of_freedom
+ reduced_chi2y = chi2y / degree_of_freedom
+
+ param_errors[0] *= reduced_chi2x**0.5
+ param_errors[1] *= reduced_chi2y**0.5
+ else:
+ # degree_of_freedom == 0, as < 0 case already handled above
+ warnings.warn(
+ f'Degree of freedom < 0. Covariance of the parameters could not be estimated. Setting parameter uncertainties to np.inf.',
+ OptimizeWarning, stacklevel=2
+ )
+ # Set parameter uncertainties to np.inf, same behavior as scipy.optimize.curve_fit
+ param_errors = np.full_like(param_errors, np.inf)
+
+ if return_chi2:
+ return params, param_errors, chi2x, chi2y
+ else:
+ return params, param_errors
+
+ def run_fit_batch(self, t, x, y, xe, ye, valid, fixed_params_dict=None, weighting='var',
+ absolute_sigma=True, fill_value=np.nan, verbose=True):
+ """
+ Vectorized version of run_fit() for many stars at once. Fixed's fit
+ is closed-form (a weighted average -- no iterative optimizer), so
+ nothing about it actually requires fitting one star at a time; this
+ fits the whole batch in one pass instead of looping (or spinning up
+ multiprocessing for) each star individually.
+
+ Parameters
+ ----------
+ t, x, y, xe, ye : array-like, shape (n_stars, n_epochs)
+ Per-star, per-epoch data. Entries where `valid` is False are
+ ignored -- their content does not matter (e.g. they can be NaN
+ placeholders for undetected epochs).
+ valid : array-like of bool, shape (n_stars, n_epochs)
+ Which entries are usable for each star.
+ fixed_params_dict : dict, optional
+ Unused -- Fixed has no fixed params -- accepted only so callers
+ can call run_fit_batch() uniformly across motion models (e.g.
+ Linear requires fixed_params_dict={'t0': ...}).
+ weighting, absolute_sigma, fill_value, verbose : as in run_fit().
+
+ Returns
+ -------
+ params : ndarray, shape (n_stars, 2)
+ param_errs : ndarray, shape (n_stars, 2)
+ chi2_x, chi2_y : ndarray, shape (n_stars,)
+ """
+ n_valid = valid.sum(axis=1)
+ has_data = n_valid >= self.n_params # degree_of_freedom >= 0
+
+ if verbose and np.any(~has_data):
+ warnings.warn(
+ f'Not enough data points to fit model for {np.sum(~has_data)} star(s). '
+ f'Setting parameters to {fill_value} and uncertainties to np.inf.',
+ OptimizeWarning, stacklevel=2
+ )
+
+ sigma_x, sigma_y = self.calc_sigma(xe, ye, weighting=weighting)
+ x_wt = weight_from_sigma(sigma_x, valid)
+ y_wt = weight_from_sigma(sigma_y, valid)
+
+ x_wt_sum = x_wt.sum(axis=1)
+ y_wt_sum = y_wt.sum(axis=1)
+ x_masked = np.where(valid, x, 0.0)
+ y_masked = np.where(valid, y, 0.0)
+
+ with np.errstate(divide='ignore', invalid='ignore'):
+ x0 = (x_masked * x_wt).sum(axis=1) / x_wt_sum
+ y0 = (y_masked * y_wt).sum(axis=1) / y_wt_sum
+ x0e = 1. / np.sqrt(x_wt_sum)
+ y0e = 1. / np.sqrt(y_wt_sum)
+
+ params = np.column_stack([x0, y0])
+ param_errs = np.column_stack([x0e, y0e])
+
+ # chi2: Fixed's prediction is time-independent (x_pred == x0 for every epoch)
+ with np.errstate(divide='ignore', invalid='ignore'):
+ chi2x = np.where(valid, (x - x0[:, np.newaxis])**2 / xe**2, 0.0).sum(axis=1)
+ chi2y = np.where(valid, (y - y0[:, np.newaxis])**2 / ye**2, 0.0).sum(axis=1)
+
+ if not absolute_sigma:
+ dof = n_valid - self.n_params
+ dof_pos = dof > 0
+ with np.errstate(divide='ignore', invalid='ignore'):
+ reduced_chi2x = np.where(dof_pos, chi2x / np.where(dof_pos, dof, 1), 1.0)
+ reduced_chi2y = np.where(dof_pos, chi2y / np.where(dof_pos, dof, 1), 1.0)
+ param_errs[:, 0] = np.where(dof_pos, param_errs[:, 0] * np.sqrt(reduced_chi2x), np.inf)
+ param_errs[:, 1] = np.where(dof_pos, param_errs[:, 1] * np.sqrt(reduced_chi2y), np.inf)
+ if verbose and np.any(has_data & ~dof_pos):
+ warnings.warn(
+ 'Degree of freedom <= 0 for some star(s). Covariance of the parameters could not be '
+ 'estimated. Setting parameter uncertainties to np.inf.',
+ OptimizeWarning, stacklevel=2
+ )
+
+ # Not-enough-data stars: overwrite with fill_value/inf/nan regardless
+ # of whatever the (meaningless, e.g. 0/0) computation above produced.
+ params[~has_data] = fill_value
+ param_errs[~has_data] = np.inf
+ chi2x[~has_data] = np.nan
+ chi2y[~has_data] = np.nan
+
+ return params, param_errs, chi2x, chi2y
+
+class Linear(MotionModel):
+ """
+ A 2D linear motion model for a star on the sky.
+ """
+ name = "Linear"
+ fit_param_names = ['x0', 'vx', 'y0', 'vy']
+ required_fixed_param_names = ['t0']
+ optional_fixed_params = {}
+ fixed_param_names = required_fixed_param_names + list(optional_fixed_params.keys())
+
+ n_fit_params = len(fit_param_names)
+ # Number of fit parameters/required observations in each direction
+ n_params = int((n_fit_params + 1) / 2)
+
+ def __init__(self, **kwargs):
+ # Must call after setting parameters.
+ # This checks for proper parameter formatting.
+ super().__init__()
+ return
+
+ def model_fit(self, dt, x0, v):
+ """Linear motion model fit function
+
+ Parameters
+ ----------
+ dt : array-like
+ Time offset, shape (N_times,)
+ x0 : float or array-like
+ Initial position, shape (N_stars,) or scalar
+ v : float or array-like
+ Velocity, shape (N_stars,) or scalar
+
+ Returns
+ -------
+ x : array-like
+ Predicted position(s)
+ """
+ return x0 + v * dt
+
+ def model(self, t, fit_params, fit_param_errs=None, fixed_params_dict=None):
+ """Model positions (and uncertainties, if fit_param_errs is provided) at time t of Linear model.
+
+ Parameters
+ ----------
+ t : float or array-like
+ Time(s) at which to evaluate the model
+ fit_params : array-like
+ x0, vx, y0, vy in shape (N_fit_params,) or (N_stars, N_fit_params)
+ fit_param_errs : array-like, optional
+ Uncertainties of fit parameters in shape (N_fit_params,) or (N_stars, N_fit_params), by default None
+ fixed_params_dict : dict
+ t0, shape (1,) or (N_stars,)
+
+ Returns
+ -------
+ x, y (, xe, ye)
+ Predicted positions (and uncertainties, if fit_param_errs is provided) with shape (N_stars, N_times), or (N_times,) if N_stars=1, or (N_stars,) if N_times=1
+ """
+ if fixed_params_dict is None:
+ fixed_params_dict = self.fixed_params_dict
+ assert 't0' in fixed_params_dict, "Fixed parameter t0 is required for Linear model."
+ self._check_param_dimensions(fit_params, fit_param_errs, fixed_params_dict)
+
+ t = np.atleast_1d(t)
+ fit_params = np.atleast_2d(fit_params) # (N_stars, N_fit_params)
+
+ N_stars = fit_params.shape[0]
+ N_times = len(t)
+
+ x0, vx, y0, vy = fit_params.T # Each shape (N_stars,)
+ t0 = np.atleast_1d(fixed_params_dict['t0']) # Shape (N_stars,) or (1,)
+
+ if N_times == N_stars:
+ # Assume each time corresponds to each star, so N_times = 1
+ dt = t - t0 # Shape (N_stars,)
+ dt = dt[:, np.newaxis] # Shape (N_stars, 1)
+ N_times = 1
+ else:
+ dt = t[np.newaxis, :] - t0[:, np.newaxis] # Shape (N_stars, N_times)
+
+ x = self.model_fit(dt, x0[:, np.newaxis], vx[:, np.newaxis]) # Shape (N_stars, N_times)
+ y = self.model_fit(dt, y0[:, np.newaxis], vy[:, np.newaxis]) # Shape (N_stars, N_times)
+
+ if N_stars == 1 or N_times == 1:
+ # If only one star, return flattened arrays
+ x = x.flatten()
+ y = y.flatten()
+
+ if fit_param_errs is None:
+ return x, y
+
+ fit_param_errs = np.atleast_2d(fit_param_errs) # (N_stars, N_fit_params)
+ x0_err, vx_err, y0_err, vy_err = fit_param_errs.T # Each shape (N_stars,)
+ x_err = np.hypot(x0_err[:, np.newaxis], vx_err[:, np.newaxis] * dt) # Shape (N_stars, N_times)
+ y_err = np.hypot(y0_err[:, np.newaxis], vy_err[:, np.newaxis] * dt) # Shape (N_stars, N_times)
+
+ if N_stars == 1 or N_times == 1:
+ # If only one star, return flattened arrays
+ x_err = x_err.flatten()
+ y_err = y_err.flatten()
+ return x, y, x_err, y_err
+
+ def run_fit(
+ self, t, x, y, xe, ye,
+ fixed_params_dict=None,
+ weighting='var',
+ use_scipy=True,
+ absolute_sigma=True,
+ params_guess=None,
+ fill_value=np.nan,
+ return_chi2=False,
+ method=None,
+ verbose=True
+ ):
+ if fixed_params_dict is None:
+ fixed_params_dict = {}
+ if 't0' not in fixed_params_dict:
+ # Default t0 to weighted average time
+ fixed_params_dict['t0'] = np.average(t, weights=1./np.hypot(xe, ye))
+ self.fixed_params_dict = fixed_params_dict
+ t0 = np.atleast_1d(fixed_params_dict['t0'])
+ t = np.atleast_1d(t)
+ x = np.atleast_1d(x)
+ y = np.atleast_1d(y)
+ xe = np.atleast_1d(xe)
+ ye = np.atleast_1d(ye)
+
+ n_obs = len(t)
+ degree_of_freedom = n_obs - self.n_params
+ # Not enough data points to fit model
+ if degree_of_freedom < 0:
+ warnings.warn(
+ f'Not enough data points to fit model. Setting parameters to {fill_value} and uncertainties to np.inf.',
+ OptimizeWarning, stacklevel=2
+ )
+ params = np.full(self.n_fit_params, fill_value)
+ param_errors = np.full(self.n_fit_params, np.inf)
+ if return_chi2:
+ return params, param_errors, np.nan, np.nan
+ else:
+ return params, param_errors
+
+ # degree_of_freedom >= 0
+ dt = t - t0
+ sigma_x, sigma_y = self.calc_sigma(xe, ye, weighting=weighting)
+ x_wt, y_wt = 1. / sigma_x**2, 1. / sigma_y**2
+
+ if params_guess is None:
+ params_guess = [x.mean(), 0., y.mean(), 0.]
+
+ if use_scipy:
+ x_opt, x_cov, x_info, x_msg, x_ier = curve_fit(self.model_fit, dt, x, p0=np.array(params_guess[:2]), sigma=sigma_x, absolute_sigma=absolute_sigma, full_output=True, method=method)
+ y_opt, y_cov, y_info, y_msg, y_ier = curve_fit(self.model_fit, dt, y, p0=np.array(params_guess[2:]), sigma=sigma_y, absolute_sigma=absolute_sigma, full_output=True, method=method)
+ x0, vx = x_opt
+ y0, vy = y_opt
+ x0e, vxe = np.sqrt(x_cov.diagonal())
+ y0e, vye = np.sqrt(y_cov.diagonal())
+ params = np.array([x0, vx, y0, vy])
+ param_errors = np.array([x0e, vxe, y0e, vye])
+ if return_chi2:
+ # chi2_x, chi2_y = self.calc_chi2(t, x, y, xe, ye, params, fixed_params_dict)
+ chi2_x = np.sum(x_info['fvec']**2)
+ chi2_y = np.sum(y_info['fvec']**2)
+ return params, param_errors, chi2_x, chi2_y
+ else:
+ return params, param_errors
+
+ # Linear algebraic solution
+ # Use https://en.wikipedia.org/wiki/Weighted_least_squares#Solution_scheme
+ X_mat_t = np.vander(dt, 2)
+
+ # x calculation
+ W_mat_x = np.diag(x_wt)
+ XTWX_mat_x = X_mat_t.T @ W_mat_x @ X_mat_t # Shape (2, 2)
+ pcov_x = np.linalg.pinv(XTWX_mat_x) # Covariance Matrix
+ popt_x = pcov_x @ X_mat_t.T @ W_mat_x @ x # Linear Solution
+
+ # Singular matrix (not enough unique times): Fill uncertainty with Inf.
+ if np.linalg.matrix_rank(XTWX_mat_x) < 2:
+ warnings.warn(
+ f'Singular matrix. Covariance of the parameters could not be estimated. Setting parameter uncertainties to np.inf.',
+ OptimizeWarning, stacklevel=2
+ )
+ perr_x = np.full_like(popt_x, np.inf)
+ else:
+ perr_x = np.sqrt(np.diag(pcov_x)) # Uncertainty of Linear Solution
+
+ # y calculation
+ W_mat_y = np.diag(y_wt)
+ XTWX_mat_y = X_mat_t.T @ W_mat_y @ X_mat_t # Shape (2, 2)
+ pcov_y = np.linalg.pinv(XTWX_mat_y) # Covariance Matrix
+ popt_y = pcov_y @ X_mat_t.T @ W_mat_y @ y # Linear Solution
+
+ # Singular matrix (not enough unique times): Fill uncertainty with Inf.
+ if np.linalg.matrix_rank(XTWX_mat_y) < 2:
+ warnings.warn(
+ f'Singular matrix. Covariance of the parameters could not be estimated. Setting parameter uncertainties to np.inf.',
+ OptimizeWarning, stacklevel=2
+ )
+ perr_y = np.full_like(popt_y, np.inf)
+ else:
+ perr_y = np.sqrt(np.diag(pcov_y)) # Uncertainty of Linear Solution
+
+ # prepare values to return
+ vx, x0 = popt_x
+ vy, y0 = popt_y
+ vxe, x0e = perr_x
+ vye, y0e = perr_y
+
+ params = np.array([x0, vx, y0, vy])
+ param_errors = np.array([x0e, vxe, y0e, vye])
+
+ # Does not use get_chi2 to accelerate calculation
+ if return_chi2 or (not absolute_sigma):
+ residual_x = x - X_mat_t @ popt_x
+ residual_y = y - X_mat_t @ popt_y
+
+ chi2_x = residual_x.T @ W_mat_x @ residual_x
+ chi2_y = residual_y.T @ W_mat_y @ residual_y
+
+ if not absolute_sigma:
+ if degree_of_freedom > 0:
+ reduced_chi2_x = chi2_x / degree_of_freedom
+ reduced_chi2_y = chi2_y / degree_of_freedom
+
+ param_errors[0:2] *= reduced_chi2_x**0.5
+ param_errors[2:4] *= reduced_chi2_y**0.5
+
+ else:
+ # degree_of_freedom == 0, as < 0 case already handled above
+ warnings.warn(
+ f'Degree of freedom < 0. Covariance of the parameters could not be estimated. Setting parameter uncertainties to np.inf.',
+ OptimizeWarning, stacklevel=2
+ )
+ # Set parameter uncertainties to np.inf, same behavior as scipy.optimize.curve_fit
+ param_errors = np.full_like(param_errors, np.inf)
+
+ if return_chi2:
+ return params, param_errors, chi2_x, chi2_y
+ else:
+ return params, param_errors
+
+ def run_fit_batch(self, t, x, y, xe, ye, valid, fixed_params_dict=None, weighting='var',
+ absolute_sigma=True, fill_value=np.nan, verbose=True):
+ """
+ Vectorized version of run_fit(use_scipy=False) for many stars at
+ once. Linear's weighted least-squares fit is closed-form (the
+ normal equations, no iterative optimizer) -- so, like Fixed, it
+ doesn't actually need to run one star at a time. The per-star path
+ builds a full (n_epochs, n_epochs) diagonal weight matrix and calls
+ np.linalg.pinv/matrix_rank (SVD-based) on it for every single star,
+ which is wasteful work for what's always exactly a 2x2 system; this
+ instead computes the five weighted sums the 2x2 normal-equations
+ matrix needs via vectorized .sum(axis=1) calls across the whole
+ batch, and solves/inverts that 2x2 system with its closed-form
+ (adjugate-over-determinant) formula.
+
+ Parameters
+ ----------
+ t, x, y, xe, ye : array-like, shape (n_stars, n_epochs)
+ Per-star, per-epoch data. Entries where `valid` is False are
+ ignored -- their content does not matter (e.g. they can be NaN
+ placeholders for undetected epochs).
+ valid : array-like of bool, shape (n_stars, n_epochs)
+ Which entries are usable for each star.
+ fixed_params_dict : dict
+ Must contain 't0', either a scalar or shape (n_stars,).
+ weighting, absolute_sigma, fill_value, verbose : as in run_fit().
+
+ Returns
+ -------
+ params : ndarray, shape (n_stars, 4) -- [x0, vx, y0, vy]
+ param_errs : ndarray, shape (n_stars, 4)
+ chi2_x, chi2_y : ndarray, shape (n_stars,)
+ """
+ assert fixed_params_dict is not None and 't0' in fixed_params_dict, \
+ "Linear.run_fit_batch requires fixed_params_dict={'t0': ...}."
+
+ n_stars, n_epochs = t.shape
+ t0 = np.broadcast_to(np.atleast_1d(fixed_params_dict['t0']), (n_stars,)).astype(float)
+ dt = t - t0[:, np.newaxis]
+
+ n_valid = valid.sum(axis=1)
+ has_data = n_valid >= self.n_params # degree_of_freedom >= 0
+
+ if verbose and np.any(~has_data):
+ warnings.warn(
+ f'Not enough data points to fit model for {np.sum(~has_data)} star(s). '
+ f'Setting parameters to {fill_value} and uncertainties to np.inf.',
+ OptimizeWarning, stacklevel=2
+ )
+
+ sigma_x, sigma_y = self.calc_sigma(xe, ye, weighting=weighting)
+ x_wt = weight_from_sigma(sigma_x, valid)
+ y_wt = weight_from_sigma(sigma_y, valid)
+
+ dt_m = np.where(valid, dt, 0.0)
+ x_m = np.where(valid, x, 0.0)
+ y_m = np.where(valid, y, 0.0)
+
+ def solve(wt, val_m):
+ # Weighted normal-equations matrix for [v, x0] (matching
+ # np.vander(dt, 2)'s [dt, 1] column order in the per-star path):
+ # [[Swdt2, Swdt], [Swdt, Sw]] @ [v, x0] = [Swdtv, Swv]
+ # Solved and inverted in closed form (2x2 adjugate/det) rather
+ # than via np.linalg.pinv/matrix_rank.
+ Sw = wt.sum(axis=1)
+ Swdt = (wt * dt_m).sum(axis=1)
+ Swdt2 = (wt * dt_m**2).sum(axis=1)
+ Swv = (wt * val_m).sum(axis=1)
+ Swdtv = (wt * dt_m * val_m).sum(axis=1)
+
+ det = Swdt2 * Sw - Swdt**2
+ # Singular (e.g. every valid epoch at the same time): mirrors
+ # the per-star path's matrix_rank(XTWX) < 2 check, just via a
+ # direct determinant tolerance instead of an SVD-based rank.
+ scale = np.maximum(Sw * Swdt2, np.finfo(float).tiny)
+ singular = has_data & (np.abs(det) <= 1e-12 * scale)
+
+ with np.errstate(divide='ignore', invalid='ignore'):
+ v = (Sw * Swdtv - Swdt * Swv) / det
+ v0 = (Swdt2 * Swv - Swdt * Swdtv) / det
+ v_err = np.sqrt(Sw / det)
+ v0_err = np.sqrt(Swdt2 / det)
+
+ if verbose and np.any(singular):
+ warnings.warn(
+ 'Singular matrix. Covariance of the parameters could not be estimated. '
+ 'Setting parameter uncertainties to np.inf.',
+ OptimizeWarning, stacklevel=2
+ )
+ v_err[singular] = np.inf
+ v0_err[singular] = np.inf
+ # A singular system (e.g. every valid epoch at the same time) has
+ # no well-defined [v, x0] split -- only their particular combination
+ # is constrained -- so unlike np.linalg.pinv's arbitrary
+ # minimum-norm choice, report fill_value here rather than a
+ # specific-but-meaningless number. The error is inf either way,
+ # so nothing downstream should be trusting this value regardless.
+ v[singular] = fill_value
+ v0[singular] = fill_value
+
+ return v0, v, v0_err, v_err, singular
+
+ x0, vx, x0e, vxe, singular_x = solve(x_wt, x_m)
+ y0, vy, y0e, vye, singular_y = solve(y_wt, y_m)
+
+ params = np.column_stack([x0, vx, y0, vy])
+ param_errs = np.column_stack([x0e, vxe, y0e, vye])
+
+ # chi2, using the same (weighting-scheme) weights the fit itself
+ # used -- matches the per-star path's residual.T @ W @ residual.
+ with np.errstate(divide='ignore', invalid='ignore'):
+ chi2x = (x_wt * (x_m - (vx[:, np.newaxis] * dt_m + x0[:, np.newaxis]))**2).sum(axis=1)
+ chi2y = (y_wt * (y_m - (vy[:, np.newaxis] * dt_m + y0[:, np.newaxis]))**2).sum(axis=1)
+ # A singular fit has no real params to compute a residual from
+ # (regardless of what fill_value happens to be) -- nan them
+ # explicitly rather than relying on fill_value being nan.
+ chi2x[singular_x] = np.nan
+ chi2y[singular_y] = np.nan
+
+ if not absolute_sigma:
+ dof = n_valid - self.n_params
+ dof_pos = dof > 0
+ with np.errstate(divide='ignore', invalid='ignore'):
+ reduced_chi2x = np.where(dof_pos, chi2x / np.where(dof_pos, dof, 1), 1.0)
+ reduced_chi2y = np.where(dof_pos, chi2y / np.where(dof_pos, dof, 1), 1.0)
+ param_errs[:, 0] = np.where(dof_pos, param_errs[:, 0] * np.sqrt(reduced_chi2x), np.inf)
+ param_errs[:, 1] = np.where(dof_pos, param_errs[:, 1] * np.sqrt(reduced_chi2x), np.inf)
+ param_errs[:, 2] = np.where(dof_pos, param_errs[:, 2] * np.sqrt(reduced_chi2y), np.inf)
+ param_errs[:, 3] = np.where(dof_pos, param_errs[:, 3] * np.sqrt(reduced_chi2y), np.inf)
+ if verbose and np.any(has_data & ~dof_pos):
+ warnings.warn(
+ 'Degree of freedom <= 0 for some star(s). Covariance of the parameters could not be '
+ 'estimated. Setting parameter uncertainties to np.inf.',
+ OptimizeWarning, stacklevel=2
+ )
+
+ # Not-enough-data and singular stars: overwrite with fill_value/inf/nan
+ # regardless of whatever the (meaningless, e.g. 0/0, or inf*nan from
+ # the absolute_sigma=False rescaling above) computation produced.
+ # This must come last -- e.g. the rescaling above would otherwise
+ # silently turn a singular star's correct inf error into nan
+ # (inf * sqrt(nan) == nan, not inf).
+ params[~has_data] = fill_value
+ param_errs[~has_data] = np.inf
+ chi2x[~has_data] = np.nan
+ chi2y[~has_data] = np.nan
+ param_errs[singular_x, 0] = np.inf
+ param_errs[singular_x, 1] = np.inf
+ param_errs[singular_y, 2] = np.inf
+ param_errs[singular_y, 3] = np.inf
+
+ return params, param_errs, chi2x, chi2y
+
+class Acceleration(MotionModel):
+ """
+ A 2D accelerating motion model for a star on the sky.
+ """
+ name = "Acceleration"
+ fit_param_names = ['x0', 'vx0', 'ax', 'y0', 'vy0', 'ay']
+ required_fixed_param_names = ['t0']
+ optional_fixed_params = {}
+ fixed_param_names = required_fixed_param_names + list(optional_fixed_params.keys())
+
+ n_fit_params = len(fit_param_names)
+ # Number of required observations in each direction
+ n_params = int((n_fit_params + 1) / 2)
+
+ def __init__(self):
+ # Must call after setting parameters.
+ # This checks for proper parameter formatting.
+ super().__init__()
+ return
+
+ def model_fit(self, t, x0, v0, a):
+ """Model positions at time t of Acceleration model.
+
+ Parameters
+ ----------
+ t : float or array-like
+ Time(s) at which to evaluate the model
+ x0 : float or array-like
+ Initial position(s)
+ v0 : float or array-like
+ Initial velocity(ies)
+ a : float or array-like
+ Acceleration(s)
+
+ Returns
+ -------
+ float or array-like
+ Model positions at time t of Acceleration model
+ """
+ return x0 + v0*t + 0.5*a*t**2
+
+ def model(self, t, fit_params, fit_param_errs=None, fixed_params_dict=None):
+ """Model positions (and uncertainties, if fit_param_errs is provided) at time t of Acceleration model.
+
+ Parameters
+ ----------
+ t : float or array-like
+ Time(s) at which to evaluate the model
+ fit_params : array-like
+ x0, vx, ax, y0, vy, ay in shape (N_fit_params,) or (N_stars, N_fit_params)
+ fit_param_errs : array-like, optional
+ Fit parameter uncertainties with shape (N_stars, N_fit_params) or (N_fit_params,), by default None
+ fixed_params_dict : dict
+ t0, shape (1,) or (N_stars,)
+
+ Returns
+ -------
+ x, y (, xe, ye)
+ Predicted positions (and uncertainties, if fit_param_errs is provided) with shape (N_stars, N_times), or (N_times,) if N_stars=1, or (N_stars,) if N_times=1
+ """
+ if fixed_params_dict is None:
+ fixed_params_dict = self.fixed_params_dict
+ assert 't0' in fixed_params_dict, "Fixed parameter t0 is required for Acceleration model."
+ self._check_param_dimensions(fit_params, fit_param_errs, fixed_params_dict)
+
+ t = np.atleast_1d(t)
+ fit_params = np.atleast_2d(fit_params) # (N_stars, N_fit_params)
+
+ N_stars = fit_params.shape[0]
+ N_times = len(t)
+
+ x0, vx0, ax, y0, vy0, ay = fit_params.T # Each shape (N_stars,)
+ t0 = np.atleast_1d(fixed_params_dict['t0']) # Shape (N_stars,) or (1,)
+
+ if N_times == N_stars:
+ # Assume each time corresponds to each star, so N_times = 1
+ dt = t - t0 # Shape (N_stars,)
+ dt = dt[:, np.newaxis] # Shape (N_stars, 1)
+ N_times = 1
+ else:
+ dt = t[np.newaxis, :] - t0[:, np.newaxis] # Shape (N_stars, N_times)
+
+ x = self.model_fit(dt, x0[:, np.newaxis], vx0[:, np.newaxis], ax[:, np.newaxis]) # Shape (N_stars, N_times)
+ y = self.model_fit(dt, y0[:, np.newaxis], vy0[:, np.newaxis], ay[:, np.newaxis]) # Shape (N_stars, N_times)
+
+ if N_stars == 1 or N_times == 1:
+ # If only one star, return flattened arrays
+ x = x.flatten()
+ y = y.flatten()
+
+ if fit_param_errs is None:
+ return x, y
+
+ fit_param_errs = np.atleast_2d(fit_param_errs) # (N_stars, N_fit_params)
+ x0_err, vx0_err, ax_err, y0_err, vy0_err, ay_err = fit_param_errs.T
+ x_err = np.sqrt(x0_err[:, np.newaxis]**2 + (vx0_err[:, np.newaxis] * dt)**2 + (0.5 * ax_err[:, np.newaxis] * dt**2)**2) # Shape (N_stars, N_times)
+ y_err = np.sqrt(y0_err[:, np.newaxis]**2 + (vy0_err[:, np.newaxis] * dt)**2 + (0.5 * ay_err[:, np.newaxis] * dt**2)**2) # Shape (N_stars, N_times)
+
+ if N_stars == 1 or N_times == 1:
+ # If only one star, return flattened arrays
+ x_err = x_err.flatten()
+ y_err = y_err.flatten()
+
+ return x, y, x_err, y_err
+
+
+ def run_fit(
+ self, t, x, y, xe, ye,
+ fixed_params_dict=None,
+ weighting='var',
+ use_scipy=True,
+ absolute_sigma=True,
+ params_guess=None,
+ fill_value=np.nan,
+ return_chi2=False,
+ method=None,
+ verbose=True
+ ):
+ if fixed_params_dict is None:
+ fixed_params_dict = {}
+ if 't0' not in fixed_params_dict:
+ # Default t0 to weighted average time
+ fixed_params_dict['t0'] = np.average(t, weights=1./np.hypot(xe, ye))
+ self.fixed_params_dict = fixed_params_dict
+ t0 = np.atleast_1d(fixed_params_dict['t0'])
+ t = np.atleast_1d(t)
+ x = np.atleast_1d(x)
+ y = np.atleast_1d(y)
+ xe = np.atleast_1d(xe)
+ ye = np.atleast_1d(ye)
+
+ if not use_scipy:
+ if verbose:
+ warnings.warn("Acceleration model has no non-scipy fitter option. Running with scipy.")
+
+ n_obs = len(t)
+ degree_of_freedom = n_obs - self.n_params
+ # Not enough data points to fit model
+ if degree_of_freedom < 0:
+ warnings.warn(
+ f'Not enough data points to fit model. Setting parameters to {fill_value} and uncertainties to np.inf.',
+ OptimizeWarning, stacklevel=2
+ )
+ params = np.full(self.n_fit_params, fill_value)
+ param_errors = np.full(self.n_fit_params, np.inf)
+ if return_chi2:
+ return params, param_errors, np.nan, np.nan
+ else:
+ return params, param_errors
+
+ # degree_of_freedom >= 0
+ dt = t - t0
+ sigma_x, sigma_y = self.calc_sigma(xe, ye, weighting=weighting)
+ if params_guess is None:
+ # Initial guess for velocity:
+ idx_first, idx_last = np.argmin(t), np.argmax(t)
+ t_span = t[idx_last] - t[idx_first]
+ params_guess = [x.mean(), (x[idx_last] - x[idx_first]) / t_span, 0., y.mean(), (y[idx_last] - y[idx_first]) / t_span, 0.]
+
+ x_opt, x_cov, x_info, x_msg, x_ier = curve_fit(self.model_fit, dt, x, p0=np.array(params_guess[:3]), sigma=sigma_x, absolute_sigma=absolute_sigma, full_output=True, method=method)
+ y_opt, y_cov, y_info, y_msg, y_ier = curve_fit(self.model_fit, dt, y, p0=np.array(params_guess[3:]), sigma=sigma_y, absolute_sigma=absolute_sigma, full_output=True, method=method)
+ x0, vx0, ax = x_opt
+ y0, vy0, ay = y_opt
+ x0e, vx0e, axe = np.sqrt(x_cov.diagonal())
+ y0e, vy0e, aye = np.sqrt(y_cov.diagonal())
+
+ params = np.array([x0, vx0, ax, y0, vy0, ay])
+ param_errors = np.array([x0e, vx0e, axe, y0e, vy0e, aye])
+ if return_chi2:
+ # chi2_x, chi2_y = self.calc_chi2(t, x, y, xe, ye, params, fixed_params_dict)
+ chi2_x = np.sum(x_info['fvec']**2)
+ chi2_y = np.sum(y_info['fvec']**2)
+ return params, param_errors, chi2_x, chi2_y
+ else:
+ return params, param_errors
+
+class Parallax(MotionModel):
+ """
+ Motion model for linear proper motion + parallax
+
+ Requires RA and Dec J2000 (degrees) for parallax calculation.
+ Optional PA is counterclockwise offset of the image y-axis from North.
+ Optional obs parameter describes observer location, default is 'earth'.
+ """
+ name = "Parallax"
+ fit_param_names = ['x0', 'vx', 'y0', 'vy', 'pi']
+ required_fixed_param_names = ['t0', 'ra', 'dec']
+ optional_fixed_params = {'pa': 0., 'obsLocation': 'earth'}
+ fixed_param_names = required_fixed_param_names + list(optional_fixed_params.keys())
+
+
+ n_fit_params = len(fit_param_names)
+ # Number of required observations in each direction
+ n_params = int((n_fit_params + 1) / 2)
+
+ def __init__(self):
+ super().__init__()
+ self.pvec_cached = None # Cache for parallax vector
+ self.t_mjd_cached = None # Cache for times corresponding to cached parallax vector
+ return
+
+ def calc_parallax_vector(self, t_mjd, ra, dec, pa=0., obsLocation='earth'):
+ """Calculate parallax vector of shape (N_stars, 2, N_times)
+
+ Parameters
+ ----------
+ t_mjd : array-like
+ Time array in mjd
+ ra : float or array-like
+ Right ascension(s) in degrees
+ dec : float or array-like
+ Declination(s) in degrees
+ pa : float or array-like, optional
+ Position angle(s) of image y-axis from North in degrees, by default 0.
+ obsLocation : str, optional
+ Observer location, by default 'earth'
+
+ Returns
+ -------
+ pvec
+ Parallax vector of shape (N_stars, 2, N_times), where 2 corresponds to (x, y) components.
+ """
+ if self.pvec_cached is not None:
+ t_mjd = np.atleast_1d(t_mjd)
+ t_mjd_cached = self.t_mjd_cached
+ if np.array_equal(t_mjd, t_mjd_cached):
+ # If cached values match input times, return cached values
+ return self.pvec_cached
+
+ elif all(np.isin(t_mjd, t_mjd_cached)):
+ # If all input times are in cached values, return those
+ # Calculate pvec_idxs such that t_mjd_cached[ pvec_idxs ] == t_mjd
+ pvec_idxs = np.array([np.where(t_mjd_cached == t_mjd_i)[0][0] for t_mjd_i in t_mjd])
+ pvec = self.pvec_cached[:, :, pvec_idxs]
+ return pvec
+
+ pvec = parallax.parallax_in_direction(ra, dec, t_mjd, obsLocation=obsLocation, pa=pa) # Shape (N_stars, 2, N_times)
+ # self.plx_vector_cached = [t_mjd, pvec]
+ self.t_mjd_cached = t_mjd
+ self.pvec_cached = pvec
+ return pvec
+
+ def model_fit(self, dt, x0, vx, y0, vy, pi):
+ """Model positions at time t of Parallax model.
+
+ Parameters
+ ----------
+ dt : float or array-like
+ Time(s) at which to evaluate the model
+ x0 : float or array-like
+ Initial position(s)
+ vx : float or array-like
+ Velocity(ies)
+ y0 : float or array-like
+ Initial position(s)
+ vy : float or array-like
+ Velocity(ies)
+ pi : float or array-like
+ Parallax factor(s)
+
+ Returns
+ -------
+ x_result, y_result : array-like
+ Model positions at time t of Parallax model, shape (N_stars, N_times)
+ """
+ # x0, vx, y0, vy, pi are all shape (N_stars, N_times)
+ x_result = x0 + vx * dt + pi * self.pvec[:, 0, :] # Parallax contribution in x direction
+ y_result = y0 + vy * dt + pi * self.pvec[:, 1, :] # Parallax contribution in y direction
+ return x_result, y_result
+
+ def _model_fit(self, dt, x0, vx, y0, vy, pi):
+ """Wrapper for model_fit to return concatenated results for scipy fitting."""
+ x_result, y_result = self.model_fit(dt, x0, vx, y0, vy, pi)
+ # scipy.optimize.curve_fit expects a 1D output array with the same length
+ # as the input ydata. For single-star fits, intermediate broadcasting can
+ # yield arrays with shape (1, N_times); flatten to avoid M=1 interpretation.
+ return np.hstack([np.ravel(x_result), np.ravel(y_result)]) # Shape (2*N_times,)
+
+ def model(self, t, fit_params, fit_param_errs=None, fixed_params_dict=None):
+ """Model positions (and uncertainties, if fit_param_errs is provided) at time t of Parallax model.
+
+ Parameters
+ ----------
+ t : float or array-like
+ Times at which to evaluate the model
+ fit_params : array-like
+ x0, vx, y0, vy, pi in shape (N_fit_params,) or (N_stars, N_fit_params)
+ fit_param_errs : array-like, optional
+ Uncertainties in fit parameters, by default None
+ fixed_params : dict
+ - t0, shape (N_stars,) or (1,).
+ - ra, shape (N_stars,) or (1,).
+ - dec, shape (N_stars,) or (1,).
+ - pa, optional, shape (N_stars,) or (1,), by default 0.
+ - obsLocation, optional, string, by default 'earth'
+
+ Returns
+ -------
+ x, y (, xe, ye)
+ Predicted positions (and uncertainties, if fit_param_errs is provided) with shape (N_stars, N_times), or (N_times,) if N_stars=1, or (N_stars,) if N_times=1
+ """
+ if fixed_params_dict is None:
+ fixed_params_dict = self.fixed_params_dict
+ assert all([_ in fixed_params_dict for _ in ['t0', 'ra', 'dec']]), "Fixed parameters t0, ra, and dec are required for Parallax model."
+ self._check_param_dimensions(fit_params, fit_param_errs, fixed_params_dict)
+
+ t = np.atleast_1d(t)
+ fit_params = np.atleast_2d(fit_params) # (N_stars, N_fit_params)
+
+ N_stars = fit_params.shape[0]
+ N_times = len(t)
+
+ x0, vx, y0, vy, pi = fit_params.T # Each shape (N_stars,)
+ t0 = np.atleast_1d(fixed_params_dict['t0']) # Shape (N_stars,) or (1,)
+ ra = np.atleast_1d(fixed_params_dict['ra'])
+ dec = np.atleast_1d(fixed_params_dict['dec'])
+ pa = np.atleast_1d(fixed_params_dict.get('pa', 0.0))
+ obsLocation = fixed_params_dict.get('obsLocation', 'earth')
+
+ # TODO: vectorize parallax.parallax_in_direction to handle multiple obsLocation?
+ assert isinstance(obsLocation, str) or (np.unique(obsLocation).size == 1), "obsLocation must be a single string for all stars at this time."
+ if not isinstance(obsLocation, str):
+ obsLocation = np.unique(obsLocation)[0]
+
+
+ if N_times == N_stars:
+ # Assume each time corresponds to each star, so N_times = 1
+ dt = t - t0 # Shape (N_stars,)
+ dt = dt[:, np.newaxis] # Shape (N_stars, 1)
+ N_times = 1
+ else:
+ dt = t[np.newaxis, :] - t0[:, np.newaxis] # Shape (N_stars, N_times)
+
+ t_mjd = Time(t, format='decimalyear', scale='utc').mjd # Shape (N_times,)
+ self.pvec = self.calc_parallax_vector(t_mjd, ra, dec, pa=pa, obsLocation=obsLocation) # Shape (N_stars, 2, N_times)
+ x, y = self.model_fit(dt, x0[:, np.newaxis], vx[:, np.newaxis], y0[:, np.newaxis], vy[:, np.newaxis], pi[:, np.newaxis]) # Shape (N_stars, N_times)
+
+ if N_stars == 1 or N_times == 1:
+ # If only one star, return flattened arrays
+ x = x.flatten()
+ y = y.flatten()
+
+ if fit_param_errs is None:
+ return x, y
+
+ fit_param_errs = np.atleast_2d(fit_param_errs) # (N_stars, N_fit_params)
+ x0_err, vx_err, y0_err, vy_err, pi_err = fit_param_errs.T
+ x_err = np.sqrt(x0_err[:, np.newaxis]**2 + (vx_err[:, np.newaxis] * dt)**2 + (pi_err[:, np.newaxis] * self.pvec[:, 0, :])**2) # Shape (N_stars, N_times)
+ y_err = np.sqrt(y0_err[:, np.newaxis]**2 + (vy_err[:, np.newaxis] * dt)**2 + (pi_err[:, np.newaxis] * self.pvec[:, 1, :])**2) # Shape (N_stars, N_times)
+
+ if N_stars == 1 or N_times == 1:
+ # If only one star, return flattened arrays
+ x_err = x_err.flatten()
+ y_err = y_err.flatten()
+ return x, y, x_err, y_err
+
+
+ def run_fit(
+ self, t, x, y, xe, ye,
+ fixed_params_dict,
+ weighting='var',
+ use_scipy=True,
+ absolute_sigma=True,
+ params_guess=None,
+ fill_value=np.nan,
+ return_chi2=False,
+ method=None,
+ verbose=True
+ ):
+ if not use_scipy:
+ if verbose:
+ warnings.warn("Parallax model has no non-scipy fitter option. Running with scipy.", UserWarning)
+
+ assert all([k in fixed_params_dict for k in ['ra', 'dec']]), "Parallax model requires 'ra' and 'dec' in fixed_params."
+ t = np.atleast_1d(t)
+
+ if 't0' not in fixed_params_dict:
+ # Default t0 to weighted average time
+ fixed_params_dict['t0'] = np.average(t, weights=1./np.hypot(xe, ye))
+ if 'obsLocation' not in fixed_params_dict:
+ fixed_params_dict['obsLocation'] = 'earth'
+ self.fixed_params_dict = fixed_params_dict
+ t0 = np.atleast_1d(fixed_params_dict['t0'])
+ ra = np.atleast_1d(fixed_params_dict['ra'])
+ dec = np.atleast_1d(fixed_params_dict['dec'])
+ pa = np.atleast_1d(fixed_params_dict.get('pa', 0.0))
+ obsLocation = fixed_params_dict['obsLocation']
+
+ n_fit = len(t)
+ degree_of_freedom = n_fit - self.n_params
+ # Not enough data points to fit model
+ if degree_of_freedom < 0:
+ warnings.warn(
+ f'Not enough data points to fit model. Setting parameters to {fill_value} and uncertainties to np.inf.',
+ OptimizeWarning, stacklevel=2
+ )
+ params = np.full(self.n_fit_params, fill_value)
+ param_errors = np.full(self.n_fit_params, np.inf)
+ if return_chi2:
+ return params, param_errors, np.nan, np.nan
+ else:
+ return params, param_errors
+
+ # degree_of_freedom >= 0
+ t_mjd = Time(t, format='decimalyear', scale='utc').mjd
+ self.pvec = self.calc_parallax_vector(t_mjd, ra, dec, pa=pa, obsLocation=obsLocation) # Shape (2, N_times)
+
+ # Initial guesses, x0,y0 as x,y averages;
+ # vx,vy as average velocity if first and last points are perfectly measured;
+ # pi for 10 pc distance
+ if params_guess is None:
+ idx_first, idx_last = np.argmin(t), np.argmax(t)
+ t_span = t[idx_last] - t[idx_first]
+ params_guess = np.array([
+ x.mean(), (x[idx_last] - x[idx_first]) / t_span,
+ y.mean(), (y[idx_last] - y[idx_first]) / t_span,
+ 0.1
+ ])
+
+ sigma_x, sigma_y = self.calc_sigma(xe, ye, weighting=weighting)
+ popt, pcov, infodict, mesg, ier = curve_fit(
+ self._model_fit, t - t0, np.hstack([x, y]),
+ p0=params_guess, sigma=np.hstack([sigma_x, sigma_y]),
+ absolute_sigma=absolute_sigma, full_output=True, method=method
+ )
+ x0, vx, y0, vy, pi = popt
+ x0_err, vx_err, y0_err, vy_err, pi_err = np.sqrt(pcov.diagonal())
+
+ params = np.array([x0, vx, y0, vy, pi])
+ param_errors = np.array([x0_err, vx_err, y0_err, vy_err, pi_err])
+
+ if return_chi2:
+ # chi2_x, chi2_y = self.calc_chi2(t, x, y, xe, ye, params, fixed_params_dict)
+ chi2_x = np.sum(infodict['fvec'][:len(t)]**2)
+ chi2_y = np.sum(infodict['fvec'][len(t):]**2)
+ return params, param_errors, chi2_x, chi2_y
+ else:
+ return params, param_errors
+
+
+def motion_model_param_names(motion_models, with_errors=True, with_fixed=True):
+ """Get the motion model parameter names from a list of MotionModels.
+
+ Parameters
+ ----------
+ motion_models : MotionModel, str, or list of MotionModels/strings.
+ Motion model to query parameter names from. If str, should be the name of a MotionModel class.
+ with_errors : bool, optional
+ Add uncertainty names with '_err' suffix or not, by default True
+ with_fixed : bool, optional
+ Add fixed param names with '_fixed' suffix or not, by default True
+
+ Returns
+ -------
+ list
+ List of all unique parameter names across all motion models
+ """
+ list_of_parameters = []
+
+ def list_add(name):
+ if name not in list_of_parameters:
+ list_of_parameters.append(name)
+
+ motion_models = np.atleast_1d(motion_models)
+
+ # Callers (e.g. align.update_ref_table_aggregates) may pass one entry per
+ # star -- mostly repeats of the same handful of motion model names/classes.
+ # Re-expanding fit_param_names/fixed_param_names for every repeat is pure
+ # waste, since list_add() is a no-op for names already seen. Dedup up front
+ # (preserving first-occurrence order, which is what determines the order of
+ # list_of_parameters below) so each distinct motion model is expanded once.
+ seen = set()
+ unique_motion_models = []
+ for mm in motion_models:
+ key = mm if isinstance(mm, str) else id(mm)
+ if key not in seen:
+ seen.add(key)
+ unique_motion_models.append(mm)
+ motion_models = unique_motion_models
+
+ mm_map = motion_model_map()
+ for mm in motion_models:
+ if isinstance(mm, str):
+ mm = mm_map[mm]
+ for param in mm.fit_param_names:
+ # Fitter params
+ list_add(param)
+ # Error params
+ if with_errors:
+ list_add(param + '_err')
+ # Fixed params
+ if with_fixed:
+ for param in mm.fixed_param_names:
+ list_add(param)
+ return list_of_parameters
+
+
+def all_motion_model_param_names(with_errors=True, with_fixed=True):
+ """Get all motion model parameter names from all available MotionModels.
+
+ Parameters
+ ----------
+ with_errors : bool, optional
+ Add uncertainty names with '_err' suffix or not, by default True
+ with_fixed : bool, optional
+ Add fixed param names with '_fixed' suffix or not, by default True
+
+ Returns
+ -------
+ list
+ List of all unique parameter names across all motion models
+ """
+ return motion_model_param_names(MotionModel.__subclasses__(), with_errors=with_errors, with_fixed=with_fixed)
+
+def motion_model_map():
+ """Get a dictionary mapping motion model names to MotionModel classes.
+
+ Returns
+ -------
+ mm_map : dict
+ Dictionary mapping motion model names to MotionModel classes.
+ """
+ mm_map = dict(
+ [(mm.__name__, mm) for mm in MotionModel.__subclasses__()]
+ )
+ # Sort by required epochs
+ mm_map = dict(sorted(mm_map.items(), key=lambda item: item[1].n_params))
+ return mm_map
+
+def organize_motion_models(motion_models):
+ """
+ Organize a list of motion models of type str or MotionModel into a list of MotionModel classes,
+ sorted by increasing number of required parameters. Empty and Fixed are always added if not already present.
+ To be used in align and StarTable.fit_motion_models.
+
+ Parameters
+ ----------
+ motion_models : MotionModel, str, or list of MotionModels/strings.
+ Motion model(s) to organize.
+
+ Returns
+ -------
+ list
+ List of MotionModel classes sorted by increasing number of required parameters.
+ """
+
+ all_mm_map = motion_model_map()
+ # Change to list if not
+ motion_model_classes = []
+ if motion_models is None:
+ motion_models = [Empty, Fixed]
+ elif isinstance(motion_models, str):
+ assert motion_models in all_mm_map.keys(), f"motion_model must be in {list(all_mm_map.keys())}, but got '{motion_models}'"
+ motion_model_classes = [all_mm_map[motion_models]]
+ elif isinstance(motion_models, type) and issubclass(motion_models, MotionModel):
+ motion_model_classes = [motion_models]
+ elif isinstance(motion_models, (list, tuple, np.ndarray)):
+ for mm in motion_models:
+ if isinstance(mm, str):
+ assert mm in all_mm_map.keys(), f"motion_model must be in {list(all_mm_map.keys())}, but got '{mm}'"
+ motion_model_classes.append(all_mm_map[mm])
+ else:
+ assert issubclass(mm, MotionModel), f"motion_model must be a string or a MotionModel object, but got {type(mm)}"
+ motion_model_classes.append(mm)
+
+ mm_names = [mm.name for mm in motion_model_classes]
+ if 'Empty' not in mm_names:
+ motion_model_classes.append(all_mm_map['Empty'])
+ if 'Fixed' not in mm_names:
+ motion_model_classes.append(all_mm_map['Fixed'])
+
+ # Sort by increasing n_params
+ motion_model_classes = sorted(motion_model_classes, key=lambda mm: mm.n_params)
+ return motion_model_classes
diff --git a/flystar/parallax.py b/flystar/parallax.py
new file mode 100755
index 0000000..47da5aa
--- /dev/null
+++ b/flystar/parallax.py
@@ -0,0 +1,165 @@
+# Parallax calculation module for motion models involving parallax
+# Adapted from BAGLE's parallax.py
+
+import os
+import numpy as np
+from joblib import Memory
+from astropy.time import Time
+from astropy import units, units as u
+from astropy.coordinates import SkyCoord, get_body_barycentric, get_body_barycentric_posvel, solar_system_ephemeris, \
+ CartesianRepresentation
+
+# FIXME: Do we still need this?
+# Setup a parallax cache
+try:
+ cache_dir = os.environ['PARALLAX_CACHE_DIR']
+except:
+ cache_dir = os.path.dirname(__file__) + '/parallax_cache/'
+cache_memory = Memory(cache_dir, verbose=0)
+# Default cache size is 1 GB
+cache_memory.reduce_size()
+
+# @cache_memory.cache()
+def parallax_in_direction(ra, dec, mjd, obsLocation='earth', pa=0.):
+ """
+ Calculate the parallax vector in a given direction following MulensModel.
+
+ Parameters
+ ----------
+ RA : float or array-like
+ Right Ascension in degrees. (J2000)
+ Dec : float or array-like
+ Declination in degrees. (J2000)
+ mjd : float or array-like
+ Modified Julian Date.
+ obsLocation : str, optional
+ Observer location, by default 'earth'.
+ PA : float, optional
+ Position angle in degrees (counterclockwise offset of the image y-axis from North), by default 0.
+
+ Returns
+ -------
+ pvec : ndarray
+ Parallax vector components, shape of (N_stars, 2, N_times), where the second dimension corresponds to the x or y components.
+ """
+ # Munge inputs into astropy format.
+ # times = Time(mjd + 2400000.5, format='jd', scale='tdb')
+ ra = np.atleast_1d(ra)
+ dec = np.atleast_1d(dec)
+ mjd = np.atleast_1d(mjd)
+ pa = np.atleast_1d(pa)
+ times = Time(mjd, format='mjd', scale='tdb') # convert to TDB
+ coord = SkyCoord(ra, dec, unit=(units.deg, units.deg)) # Shape (N_stars,)
+
+ directions = coord.cartesian.xyz.value.T # Shape (N_stars, 3)
+ north = np.array([0., 0., 1.])
+ # Cross product of each star with north vector
+ _east_projected = np.cross(north, directions)
+ _east_projected /= np.linalg.norm(_east_projected, axis=1)[:, np.newaxis] # Shape (N_stars, 3)
+ _north_projected = np.cross(directions, _east_projected)
+ _north_projected /= np.linalg.norm(_north_projected, axis=1)[:, np.newaxis] # Shape (N_stars, 3)
+
+ obs_pos = get_observer_barycentric(obsLocation, times) # Shape (N_times,)
+ sun_pos = get_body_barycentric(body='sun', time=times) # Shape (N_times,)
+
+ sun_obs_pos = sun_pos - obs_pos
+
+ pos = sun_obs_pos.xyz.T.to(units.au).value # Shape (N_times, 3)
+ # Broadcast pos to (N_stars, 3, N_times) and take dot product with east and north unit vectors to get components in those directions.
+ pos = np.broadcast_to(pos.T, (directions.shape[0], 3, pos.shape[0])) # Shape (N_stars, 3, N_times)
+
+ e = np.einsum('sdt,sd->st', pos, _east_projected) # Shape (N_stars, N_times)
+ n = np.einsum('sdt,sd->st', pos, _north_projected) # Shape (N_stars, N_times)
+
+ # Rotate frame e,n->x,y accounting for PA
+ pa = np.deg2rad(pa) # shape (N_stars,)
+ x = -e * np.cos(pa[:, np.newaxis]) + n * np.sin(pa[:, np.newaxis]) # Shape (N_stars, N_times)
+ y = e * np.sin(pa[:, np.newaxis]) + n * np.cos(pa[:, np.newaxis]) # Shape (N_stars, N_times)
+ # pvec Shape (N_stars, 2, N_times)
+ pvec = np.stack((x, y), axis=1)
+ return pvec
+
+
+def get_observer_barycentric(body, times, min_ephem_step=1, velocity=False):
+ """
+ Get the barycentric position of a satellite or other Solar System body
+ using JPL emphemerides through the Horizon app.
+
+ The ephemeris is queried at a decimated time step set by min_ephem_step
+ (def=1 day) that must be 1 day or larger. The positions
+ (and optionally velocities) are then interpolated onto the desired
+ time array.
+
+ Inputs
+ ------
+ body : str
+ The name of the Solar System body. Must use the JPL Horizon
+ naming scheme.
+
+ times : astropy.time.Time array
+ Array of times (astropy.time.core.Time) objects at which to
+ fetch the position of the specified Solar System body.
+
+ Optional Inputs
+ ---------------
+ min_ephem_step : int
+ Minimum time step to query JPL in days. Must not be <1 and must
+ be in integer days.
+
+ velocity : bool
+ If true, return both position and velocity vectors over time.
+
+ Return
+ ------
+ coord : astropy.coordinates.CartesianRepresentation
+ The xyz coordinates in the plane of the Solar System at the
+ input times.
+ """
+ # Use the JPL ephemerides.
+ solar_system_ephemeris.set('jpl')
+
+ if body in solar_system_ephemeris.bodies:
+ if velocity:
+ obs_pos, obs_vel = get_body_barycentric_posvel(body=body, time=times)
+ else:
+ obs_pos = get_body_barycentric(body=body, time=times)
+ else:
+ # Figure out a cadence for the ephemerides, not smaller than 1 day.
+ dt = np.median(np.diff(times)).jd
+ if dt < min_ephem_step:
+ dt = min_ephem_step
+
+ # Get the date range, add some padding on each side.
+ t_min = times.min()
+ t_max = times.max()
+ t_min.format = 'iso'
+ t_max.format = 'iso'
+ t_min = str(t_min - dt*u.day).split()[0]
+ t_max = str(t_max + dt*u.day).split()[0]
+ step = f'{dt:.0f}d'
+
+ # Fetch the Horizons ephemeris.
+ from astroquery.jplhorizons import Horizons
+ obj = Horizons(id=body, epochs={'start':t_min, 'stop':t_max, 'step':step})
+ obj_data = obj.vectors()
+
+ ephem_jd = obj_data['datetime_jd']
+
+ # Interpolate to the actual time array.
+ obj_x_at_t = np.interp(times.jd, ephem_jd, obj_data['x'].to('km')) * u.km
+ obj_y_at_t = np.interp(times.jd, ephem_jd, obj_data['y'].to('km')) * u.km
+ obj_z_at_t = np.interp(times.jd, ephem_jd, obj_data['z'].to('km')) * u.km
+
+ if velocity:
+ obj_vx_at_t = np.interp(times.jd, ephem_jd, obj_data['vx'].to('km/s')) * u.km / u.s
+ obj_vy_at_t = np.interp(times.jd, ephem_jd, obj_data['vy'].to('km/s')) * u.km / u.s
+ obj_vz_at_t = np.interp(times.jd, ephem_jd, obj_data['vz'].to('km/s')) * u.km / u.s
+
+ obs_vel = CartesianRepresentation(obj_vx_at_t, obj_vy_at_t, obj_vz_at_t)
+
+ obs_pos = CartesianRepresentation(obj_x_at_t, obj_y_at_t, obj_z_at_t)
+
+ if velocity:
+ return (obs_pos, obs_vel)
+ else:
+ return obs_pos
\ No newline at end of file
diff --git a/flystar/plots.py b/flystar/plots.py
index c675170..7696b29 100755
--- a/flystar/plots.py
+++ b/flystar/plots.py
@@ -1,19 +1,100 @@
-from flystar import analysis
-import pylab as py
-import pylab as plt
-import numpy as np
-import matplotlib.mlab as mlab
-import matplotlib
-from matplotlib import colors
-import matplotlib.cm as cm
-from scipy.stats import chi2
-from scipy.optimize import curve_fit
-from scipy.stats import norm
-import pdb
+import os
import math
import astropy
+import matplotlib
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.colors as mcolors
+from matplotlib import cm
+from matplotlib.ticker import FormatStrFormatter
+from scipy.stats import chi2, norm
+from scipy.optimize import curve_fit
+from astropy import units as u
from astropy.table import Table
-from astropy.io import ascii
+from astropy.coordinates import SkyCoord
+
+
+# Moved from analysis old codes
+def calc_chi2(ref_mat, starlist_mat, transform, errs='both'):
+ """
+ calculate the chi2 and reduced chi2 of the position
+ between two matched starlists.
+ Input:
+ ref_mat: astropy table
+ Reference starlist only containing matched stars that were used in the
+ transformation. Standard column headers are assumed.
+
+ starlist_mat: astropy table
+ Transformed starlist only containing the matched stars used in
+ the transformation. Standard column headers are assumed.
+
+ transform: transformation object
+ Transformation object of final transform. Used in chi-square
+ determination
+
+ errs: string; 'both', 'reference', or 'starlist'
+ If both, add starlist errors in quadrature with reference errors.
+
+ If reference, only consider reference errors. This should be used if the starlist
+ does not have valid errors
+
+ If starlist, only consider starlist errors. This should be used if the reference
+ does not have valid errors
+
+ Output:
+ chi_sq: float
+ chi2 = sum (diff_x**2 / xerr**2 + diff_y**2 /yerr**2)
+ chi_sq_red: float
+ reduced chi2 = chi2/ degree of freedom
+ deg_freedom: int
+ degree of freedom
+
+ """
+ diff_x = ref_mat['x'] - starlist_mat['x']
+ diff_y = ref_mat['y'] - starlist_mat['y']
+
+ # Set errors as per user input
+ if errs == 'both':
+ xerr = np.hypot(ref_mat['xe'], starlist_mat['xe'])
+ yerr = np.hypot(ref_mat['ye'], starlist_mat['ye'])
+ elif errs == 'reference':
+ xerr = ref_mat['xe']
+ yerr = ref_mat['ye']
+ elif errs == 'starlist':
+ xerr = starlist_mat['xe']
+ yerr = starlist_mat['ye']
+
+
+ # For both X and Y, calculate chi-square. Combine arrays to get combined
+ # chi-square
+ chi_sq_x = diff_x**2. / xerr**2.
+ chi_sq_y = diff_y**2. / yerr**2.
+
+ chi_sq = np.append(chi_sq_x, chi_sq_y)
+
+ # Calculate degrees of freedom in transformation
+ num_mod_params = calc_nparam(transform)
+ deg_freedom = len(chi_sq) - num_mod_params
+
+ # Calculate reduced chi-square
+ chi_sq = np.sum(chi_sq)
+ chi_sq_red = chi_sq / deg_freedom
+
+ return chi_sq, chi_sq_red, deg_freedom
+
+
+def calc_nparam(transformation):
+ """
+ calculate the degree of freedom for a transformation
+ """
+ # Read transformation: Extract X, Y coefficients from transform
+ if transformation.__class__.__name__ == 'four_paramNW':
+ nparam = 4
+ elif transformation.__class__.__name__ == 'PolyTransform':
+ order = transformation.order
+ nparam = (order+1) * (order+2)
+ return nparam
+
####################################################
# Code for making diagnostic plots for astrometry
@@ -21,8 +102,8 @@
####################################################
-def trans_positions(ref, ref_mat, starlist, starlist_mat, xlim=None, ylim=None, fileName=None,
- equal_axis=True, root='./'):
+def trans_positions(ref, ref_mat, starlist, starlist_mat, xlim=None, ylim=None,
+ equal_axis=True, save_path=None, show_plot=True):
"""
Plot positions of stars in reference list and the transformed starlist,
in reference list coordinates. Stars used in the transformation are
@@ -38,7 +119,7 @@ def trans_positions(ref, ref_mat, starlist, starlist_mat, xlim=None, ylim=None,
transformation. Standard column headers are assumed.
starlist: astropy table
- Transformed starist with the reference starlist coordinates.
+ Transformed starlist with the reference starlist coordinates.
Standard column headers are assumed
starlist_mat: astropy table
@@ -49,35 +130,44 @@ def trans_positions(ref, ref_mat, starlist, starlist_mat, xlim=None, ylim=None,
If not None, sets the xmin and xmax limit of the plot
ylim: None or list/array [ymin, ymax]
- If not None, sets the ymin and ymax limit of the plot
+ If not None, sets the ymin and ymax limit of the plot
equal_axis: boolean
If true, make axes equal. True by default
-
+
+ save_path: string
+ Path to save the figure to. Default is None
+
+ show_plot: boolean
+ If true, show the plot. Default is True
+
"""
- py.figure(figsize=(10,10))
- py.clf()
- py.plot(ref['x'], ref['y'], 'g+', ms=5, label='Reference')
- py.plot(starlist['x'], starlist['y'], 'rx', ms=5, label='starlist')
- py.plot(ref_mat['x'], ref_mat['y'], color='skyblue', marker='s', ms=10, alpha=0.3,
+ plt.figure(figsize=(6, 6))
+ plt.clf()
+ plt.plot(ref['x'], ref['y'], 'g+', ms=5, label='Reference')
+ plt.plot(starlist['x'], starlist['y'], 'rx', ms=5, label='starlist')
+ plt.plot(ref_mat['x'], ref_mat['y'], color='skyblue', marker='s', ms=10, alpha=0.3,
linestyle='None', label='Matched Reference')
- py.plot(starlist_mat['x'], starlist_mat['y'], color='darkblue', marker='s', ms=5, alpha=0.3,
+ plt.plot(starlist_mat['x'], starlist_mat['y'], color='darkblue', marker='s', ms=5, alpha=0.3,
linestyle='None', label='Matched starlist')
- py.xlabel('X position (Reference Coords)')
- py.ylabel('Y position (Reference Coords)')
- py.legend(numpoints=1)
- py.title('Label.dat Positions After Transformation')
+ plt.xlabel('X position (Reference Coords)')
+ plt.ylabel('Y position (Reference Coords)')
+ plt.legend(numpoints=1, loc='lower right')
+ plt.title('Label.dat Positions After Transformation')
if xlim != None:
- py.axis([xlim[0], xlim[1], ylim[0], ylim[1]])
+ plt.axis([xlim[0], xlim[1], ylim[0], ylim[1]])
if equal_axis:
- py.axis('equal')
- if fileName!=None:
- #py.savefig(root + fileName[3:8] + 'Transformed_positions_' + '.png')
- py.savefig(root + 'Transformed_positions_{0}'.format(fileName) + '.png')
- else:
- py.savefig(root + 'Transformed_positions.png')
+ plt.axis('equal')
- py.close()
+ if save_path:
+ if not os.path.exists(os.path.dirname(save_path)):
+ os.makedirs(os.path.dirname(save_path))
+ plt.tight_layout()
+ plt.savefig(save_path, dpi=300)
+ if show_plot:
+ plt.show()
+ else:
+ plt.close()
return
@@ -91,10 +181,10 @@ def pos_diff_hist(ref_mat, starlist_mat, nbins=25, bin_width=None, xlim=None, fi
ref_mat: astropy table
Reference starlist only containing matched stars that were used in the
transformation. Standard column headers are assumed.
-
+
starlist_mat: astropy table
Transformed starlist only containing the matched stars used in
- the transformation. Standard column headers are assumed.
+ the transformation. Standard column headers are assumed.
nbins: int
Number of bins used in histogram, regardless of data range. This is
@@ -106,7 +196,7 @@ def pos_diff_hist(ref_mat, starlist_mat, nbins=25, bin_width=None, xlim=None, fi
xlim: None or [xmin, xmax]
If not none, set the X range of the plot
-
+
"""
diff_x = ref_mat['x'] - starlist_mat['x']
diff_y = ref_mat['y'] - starlist_mat['y']
@@ -118,23 +208,24 @@ def pos_diff_hist(ref_mat, starlist_mat, nbins=25, bin_width=None, xlim=None, fi
max_range = max([max(diff_x), max(diff_y)])
bins = np.arange(min_range, max_range+bin_width, bin_width)
-
- py.figure(figsize=(10,10))
- py.clf()
- py.hist(diff_x, histtype='step', bins=bins, color='blue', label='X')
- py.hist(diff_y, histtype='step', bins=bins, color='red', label='Y')
- py.xlabel('Reference Position - starlist Position')
- py.ylabel('N stars')
- py.title('Position Differences for matched stars')
+
+ plt.figure(figsize=(6, 6))
+ plt.clf()
+ plt.hist(diff_x, histtype='step', bins=bins, color='blue', label='X')
+ plt.hist(diff_y, histtype='step', bins=bins, color='red', label='Y')
+ plt.xlabel('Reference Position - starlist Position')
+ plt.ylabel('N stars')
+ plt.title('Position Differences for matched stars')
if xlim != None:
- py.xlim([xlim[0], xlim[1]])
- py.legend()
+ plt.xlim([xlim[0], xlim[1]])
+ plt.legend()
+ plt.tight_layout()
if fileName != None:
- py.savefig(root + fileName[3:8] + 'Positions_hist_' + '.png')
+ plt.savefig(root + fileName[3:8] + 'Positions_hist_' + '.png', dpi=300)
else:
- py.savefig(root + 'Positions_hist.png')
+ plt.savefig(root + 'Positions_hist.png', dpi=300)
- py.close()
+ plt.close()
return
def pos_diff_err_hist(ref_mat, starlist_mat, transform, nbins=25, bin_width=None, errs='both', xlim=None,
@@ -152,7 +243,7 @@ def pos_diff_err_hist(ref_mat, starlist_mat, transform, nbins=25, bin_width=None
ref_mat: astropy table
Reference starlist only containing matched stars that were used in the
transformation. Standard column headers are assumed.
-
+
starlist_mat: astropy table
Transformed starlist only containing the matched stars used in
the transformation. Standard column headers are assumed.
@@ -183,8 +274,8 @@ def pos_diff_err_hist(ref_mat, starlist_mat, transform, nbins=25, bin_width=None
outlier: float (default = 10)
Defines how many sigma away from 0 a star must be in order to be considered
- an outlier.
-
+ an outlier.
+
"""
diff_x = ref_mat['x'] - starlist_mat['x']
diff_y = ref_mat['y'] - starlist_mat['y']
@@ -199,7 +290,7 @@ def pos_diff_err_hist(ref_mat, starlist_mat, transform, nbins=25, bin_width=None
elif errs == 'starlist':
xerr = starlist_mat['xe']
yerr = starlist_mat['ye']
-
+
# Calculate ratio between differences and the combined error. This is
# what we will plot
ratio_x = diff_x / xerr
@@ -207,7 +298,7 @@ def pos_diff_err_hist(ref_mat, starlist_mat, transform, nbins=25, bin_width=None
# Identify non-outliers, within +/- sigma away from 0
good = np.where( (np.abs(ratio_x) < outlier) & (np.abs(ratio_y) < outlier) )
-
+
"""
# For both X and Y, calculate chi-square. Combine arrays to get combined
# chi-square
@@ -215,29 +306,29 @@ def pos_diff_err_hist(ref_mat, starlist_mat, transform, nbins=25, bin_width=None
chi_sq_y = diff_y**2. / yerr**2.
chi_sq = np.append(chi_sq_x, chi_sq_y)
-
+
# Calculate degrees of freedom in transformation
num_mod_params = calc_nparam(transform)
deg_freedom = len(chi_sq) - num_mod_params
-
+
# Calculate reduced chi-square
chi_sq_red = np.sum(chi_sq) / deg_freedom
"""
# Chi-square analysis for all stars, including outliers
- chi_sq, chi_sq_red, deg_freedom = analysis.calc_chi2(ref_mat, starlist_mat,
+ chi_sq, chi_sq_red, deg_freedom = calc_chi2(ref_mat, starlist_mat,
transform, errs=errs)
# Chi-square analysis for only non-outlier stars
- chi_sq_good, chi_sq_red_good, deg_freedom_good = analysis.calc_chi2(ref_mat[good],
+ chi_sq_good, chi_sq_red_good, deg_freedom_good = calc_chi2(ref_mat[good],
starlist_mat[good],
transform,
errs=errs)
-
- num_mod_params = analysis.calc_nparam(transform)
+
+ num_mod_params = calc_nparam(transform)
#-------------------------------------------#
# Plotting
#-------------------------------------------#
-
+
# Set the binning as per user input
bins = nbins
if bin_width != None:
@@ -245,52 +336,53 @@ def pos_diff_err_hist(ref_mat, starlist_mat, transform, nbins=25, bin_width=None
max_range = max([max(ratio_x), max(ratio_y)])
bins = np.arange(min_range, max_range+bin_width, bin_width)
-
- py.figure(figsize=(10,10))
- py.clf()
- n_x, bins_x, p = py.hist(ratio_x, histtype='step', bins=bins, color='blue',
+
+ plt.figure(figsize=(6, 6))
+ plt.clf()
+ n_x, bins_x, p = plt.hist(ratio_x, histtype='step', bins=bins, color='blue',
label='X', density=True, linewidth=2)
- n_y, bins_y, p = py.hist(ratio_y, histtype='step', bins=bins, color='red',
+ n_y, bins_y, p = plt.hist(ratio_y, histtype='step', bins=bins, color='red',
label='Y', density=True, linewidth=2)
# Overplot a Gaussian, as well
mean = 0
sigma = 1
x = np.arange(-6, 6, 0.1)
- py.plot(x, norm.pdf(x,mean,sigma), 'g-', linewidth=2)
-
+ plt.plot(x, norm.pdf(x,mean,sigma), 'g-', linewidth=2)
+
# Annotate reduced chi-sqared values in plot: with outliers
- xstr = '$\chi^2_r$ = {0}'.format(np.round(chi_sq_red, decimals=3))
- py.annotate(xstr, xy=(0.3, 0.77), xycoords='figure fraction', color='black')
+ xstr = r'$\chi^2_r$ = {0}'.format(np.round(chi_sq_red, decimals=3))
+ plt.annotate(xstr, xy=(0.3, 0.77), xycoords='figure fraction', color='black')
txt = r'$\nu$ = 2*{0} - {1} = {2}'.format(len(diff_x), num_mod_params,
deg_freedom)
- py.annotate(txt, xy=(0.25,0.74), xycoords='figure fraction', color='black')
+ plt.annotate(txt, xy=(0.25,0.74), xycoords='figure fraction', color='black')
xstr2 = 'With Outliers'
- xstr3 = '{0} with +/- {1}+ sigma'.format(len(ratio_x) - len(good[0]), outlier)
- py.annotate(xstr2, xy=(0.29, 0.83), xycoords='figure fraction', color='black')
- py.annotate(xstr3, xy=(0.25, 0.80), xycoords='figure fraction', color='black')
-
+ xstr3 = '{0} with ± {1}+ sigma'.format(len(ratio_x) - len(good[0]), outlier)
+ plt.annotate(xstr2, xy=(0.29, 0.83), xycoords='figure fraction', color='black')
+ plt.annotate(xstr3, xy=(0.25, 0.80), xycoords='figure fraction', color='black')
+
# Annotate reduced chi-sqared values in plot: without outliers
- xstr = '$\chi^2_r$ = {0}'.format(np.round(chi_sq_red_good, decimals=3))
- py.annotate(xstr, xy=(0.7, 0.8), xycoords='figure fraction', color='black')
+ xstr = r'$\chi^2_r$ = {0}'.format(np.round(chi_sq_red_good, decimals=3))
+ plt.annotate(xstr, xy=(0.7, 0.8), xycoords='figure fraction', color='black')
txt = r'$\nu$ = 2*{0} - {1} = {2}'.format(len(good[0]), num_mod_params,
deg_freedom_good)
- py.annotate(txt, xy=(0.65,0.77), xycoords='figure fraction', color='black')
+ plt.annotate(txt, xy=(0.65,0.77), xycoords='figure fraction', color='black')
xstr2 = 'Without Outliers'
- py.annotate(xstr2, xy=(0.67, 0.83), xycoords='figure fraction', color='black')
-
- py.xlabel('(Ref Pos - TransStarlist Pos) / Ast. Error')
- py.ylabel('N stars (normalized)')
- py.title('Position Residuals for Matched Stars')
+ plt.annotate(xstr2, xy=(0.67, 0.83), xycoords='figure fraction', color='black')
+
+ plt.xlabel('(Ref Pos - TransStarlist Pos) / Ast. Error')
+ plt.ylabel('N stars (normalized)')
+ plt.title('Position Residuals for Matched Stars')
if xlim != None:
- py.xlim([xlim[0], xlim[1]])
- py.legend()
+ plt.xlim([xlim[0], xlim[1]])
+ plt.legend()
+ plt.tight_layout()
if fileName != None:
- py.savefig(root + fileName[3:8] + 'Positions_err_ratio_hist_' + '.png')
+ plt.savefig(root + fileName[3:8] + 'Positions_err_ratio_hist_' + '.png', dpi=300)
else:
- py.savefig(root + 'Positions_err_ratio_hist.png')
+ plt.savefig(root + 'Positions_err_ratio_hist.png', dpi=300)
- py.close()
+ plt.close()
return
@@ -304,10 +396,10 @@ def mag_diff_hist(ref_mat, starlist_mat, bins=25, fileName=None, root='./'):
ref_mat: astropy table
Reference starlist only containing matched stars that were used in the
transformation. Standard column headers are assumed.
-
+
starlist_mat: astropy table
Transformed starlist only containing the matched stars used in
- the transformation. Standard column headers are assumed.
+ the transformation. Standard column headers are assumed.
"""
diff_m = ref_mat['m'] - starlist_mat['m']
@@ -316,19 +408,20 @@ def mag_diff_hist(ref_mat, starlist_mat, bins=25, fileName=None, root='./'):
bad = np.isnan(diff_m)
bad2 = np.where(bad == True)
diff_m = np.delete(diff_m, bad2)
-
- py.figure(figsize=(10,10))
- py.clf()
- py.hist(diff_m, bins=bins)
- py.xlabel('Reference Mag - TransStarlist Mag')
- py.ylabel('N stars')
- py.title('Magnitude Difference for matched stars')
+
+ plt.figure(figsize=(6, 6))
+ plt.clf()
+ plt.hist(diff_m, bins=bins)
+ plt.xlabel('Reference Mag - TransStarlist Mag')
+ plt.ylabel('N stars')
+ plt.title('Magnitude Difference for matched stars')
+ plt.tight_layout()
if fileName != None:
- py.savefig(root + fileName[3:8] + 'Magnitude_hist_' + '.png')
+ plt.savefig(root + fileName[3:8] + 'Magnitude_hist_' + '.png', dpi=300)
else:
- py.savefig(root + 'Magnitude_hist.png')
+ plt.savefig(root + 'Magnitude_hist.png', dpi=300)
- py.close()
+ plt.close()
return
def pos_diff_quiver(ref_mat, starlist_mat, qscale=10, keyLength=0.2, xlim=None, ylim=None,
@@ -342,7 +435,7 @@ def pos_diff_quiver(ref_mat, starlist_mat, qscale=10, keyLength=0.2, xlim=None,
ref_mat: astropy table
Reference starlist only containing matched stars that were used in the
transformation. Standard column headers are assumed.
-
+
starlist_mat: astropy table
Transformed starlist only containing the matched stars used in
the transformation. Standard column headers are assumed.
@@ -387,7 +480,7 @@ def pos_diff_quiver(ref_mat, starlist_mat, qscale=10, keyLength=0.2, xlim=None,
diff_y = diff_y[good]
xpos = xpos[good]
ypos = ypos[good]
-
+
# Divide differences by reference error, if desired
if sigma:
@@ -408,36 +501,39 @@ def pos_diff_quiver(ref_mat, starlist_mat, qscale=10, keyLength=0.2, xlim=None,
diff_y = np.append(diff_y, 0)
s = len(xpos)
-
- py.figure(figsize=(10,10))
- py.clf()
- q = py.quiver(xpos, ypos, diff_x, diff_y, scale=qscale)
+
+ plt.figure(figsize=(6, 6))
+ plt.clf()
+ q = plt.quiver(xpos, ypos, diff_x, diff_y, scale=qscale)
fmt = '{0} ref units'.format(keyLength)
- #py.quiverkey(q, 0.2, 0.92, keyLength, fmt, coordinates='figure', color='black')
+ #plt.quiverkey(q, 0.2, 0.92, keyLength, fmt, coordinates='figure', color='black')
# Make our reference arrow a different color
- q2 = py.quiver(xpos[s-2:s], ypos[s-2:s], diff_x[s-2:s], diff_y[s-2:s], scale=qscale, color='red')
+ q2 = plt.quiver(xpos[s-2:s], ypos[s-2:s], diff_x[s-2:s], diff_y[s-2:s], scale=qscale, color='red')
# Annotate our reference quiver arrow
- py.annotate(fmt, xy=(xpos[-1]-2, ypos[-1]+0.5), color='red')
- py.xlabel('X Position (Reference coords)')
- py.ylabel('Y Position (Reference coords)')
+ plt.annotate(fmt, xy=(xpos[-1]-2, ypos[-1]+0.5), color='red')
+ plt.xlabel('X Position (Reference coords)')
+ plt.ylabel('Y Position (Reference coords)')
if xlim != None:
- py.axis([xlim[0], ylim[1], ylim[0], ylim[1]])
+ plt.axis([xlim[0], ylim[1], ylim[0], ylim[1]])
if sigma:
if fileName != None:
- py.title('(Reference - Transformed Starlist positions) / sigma')
- py.savefig(root + fileName[3:8] + 'Positions_quiver_sigma_' + '.png')
+ title = '(Reference - Transformed Starlist positions) / sigma'
+ save_path = root + fileName[3:8] + 'Positions_quiver_sigma.png'
else:
- py.title('(Reference - Transformed Starlist positions) / sigma')
- py.savefig(root + 'Positions_quiver_sigma.png')
+ title = '(Reference - Transformed Starlist positions) / sigma'
+ save_path = root + 'Positions_quiver_sigma.png'
else:
if fileName != None:
- py.title('Reference - Transformed Starlist positions')
- py.savefig(root + fileName[3:8] + 'Positions_quiver_' + '.png')
+ title = 'Reference - Transformed Starlist positions'
+ save_path = root + fileName[3:8] + 'Positions_quiver.png'
else:
- py.title('Reference - Transformed Starlist positions')
- py.savefig(root + 'Positions_quiver.png')
+ title = 'Reference - Transformed Starlist positions'
+ save_path = root + 'Positions_quiver.png'
- py.close()
+ plt.title(title)
+ plt.tight_layout()
+ plt.savefig(save_path, dpi=300)
+ plt.close()
return
def vpd(ref, starlist_trans, vxlim, vylim):
@@ -462,7 +558,7 @@ def vpd(ref, starlist_trans, vxlim, vylim):
If not None, sets the vxmin and vxmax limit of the plot
vylim: None or list/array [vymin, vymax]
- If not None, sets the vymin and vymax limit of the plot
+ If not None, sets the vymin and vymax limit of the plot
"""
# Extract velocities
ref_vx = ref['vx']
@@ -470,17 +566,19 @@ def vpd(ref, starlist_trans, vxlim, vylim):
trans_vx = starlist_trans['vx']
trans_vy = starlist_trans['vy']
- py.figure(figsize=(10,10))
- py.clf()
- py.plot(trans_vx, trans_vy, 'k.', ms=8, label='Transformed', alpha=0.4)
- py.plot(ref_vx, ref_vy, 'r.', ms=8, label='Reference', alpha=0.4)
- py.xlabel('Vx (Reference units)')
- py.ylabel('Vy (Reference units)')
+ plt.figure(figsize=(6, 6))
+ plt.clf()
+ plt.plot(trans_vx, trans_vy, 'k.', ms=8, label='Transformed', alpha=0.4)
+ plt.plot(ref_vx, ref_vy, 'r.', ms=8, label='Reference', alpha=0.4)
+ plt.xlabel('Vx (Reference units)')
+ plt.ylabel('Vy (Reference units)')
if vxlim != None:
- py.axis([vxlim[0], vylim[1], vylim[0], vylim[1]])
- py.title('Reference and Transformed Proper Motions')
- py.legend()
- py.savefig('Transformed_velocities.png')
+ plt.axis([vxlim[0], vylim[1], vylim[0], vylim[1]])
+ plt.title('Reference and Transformed Proper Motions')
+ plt.legend()
+ plt.tight_layout()
+ plt.savefig('Transformed_velocities.png', dpi=300)
+ plt.close()
return
@@ -505,7 +603,7 @@ def vel_diff_err_hist(ref_mat, starlist_mat, nbins=25, bin_width=None, vxlim=Non
bin_width: None or float
If float, sets the width of the bins used in the histograms. Will override
nbins
-
+
vxlim: None or [vx_min, vx_max]
If not none, set the X axis of the Vx plot by defining the minimum
and maximum values
@@ -517,9 +615,9 @@ def vel_diff_err_hist(ref_mat, starlist_mat, nbins=25, bin_width=None, vxlim=Non
# Will produce 2-panel plot: Vx resid and Vy resid
diff_vx = ref_mat['vx'] - starlist_mat['vx']
diff_vy = ref_mat['vy'] - starlist_mat['vy']
-
- vx_err = np.hypot(ref_mat['vxe'], starlist_mat['vxe'])
- vy_err = np.hypot(ref_mat['vye'], starlist_mat['vye'])
+
+ vx_err = np.hypot(ref_mat['vx_err'], starlist_mat['vx_err'])
+ vy_err = np.hypot(ref_mat['vy_err'], starlist_mat['vy_err'])
ratio_vx = diff_vx / vx_err
ratio_vy = diff_vy / vy_err
@@ -535,28 +633,28 @@ def vel_diff_err_hist(ref_mat, starlist_mat, nbins=25, bin_width=None, vxlim=Non
mean = 0
sigma = 1
x = np.arange(-6, 6, 0.1)
-
- py.figure(figsize=(20,10))
- py.subplot(121)
- py.subplots_adjust(left=0.1)
- py.hist(ratio_vx, bins=xbins, histtype='step', color='black', density=True,
+
+ plt.figure(figsize=(12, 6))
+ plt.subplot(121)
+ plt.subplots_adjust(left=0.1)
+ plt.hist(ratio_vx, bins=xbins, histtype='step', color='black', density=True,
linewidth=2)
- py.plot(x, norm.pdf(x,mean,sigma), 'r-', linewidth=2)
- py.xlabel('(Ref Vx - Trans Vx) / Vxe')
- py.ylabel('N_stars')
- py.title('Vx Residuals, Matched')
+ plt.plot(x, norm.pdf(x,mean,sigma), 'r-', linewidth=2)
+ plt.xlabel('(Ref Vx - Trans Vx) / Vxe')
+ plt.ylabel('N_stars')
+ plt.title('Vx Residuals, Matched')
if vxlim != None:
- py.xlim([vxlim[0], vxlim[1]])
- py.subplot(122)
- py.hist(ratio_vy, bins=ybins, histtype='step', color='black', density=True,
+ plt.xlim([vxlim[0], vxlim[1]])
+ plt.subplot(122)
+ plt.hist(ratio_vy, bins=ybins, histtype='step', color='black', density=True,
linewidth=2)
- py.plot(x, norm.pdf(x,mean,sigma), 'r-', linewidth=2)
- py.xlabel('(Ref Vy - Trans Vy) / Vye')
- py.ylabel('N_stars')
- py.title('Vy Residuals, Matched')
+ plt.plot(x, norm.pdf(x,mean,sigma), 'r-', linewidth=2)
+ plt.xlabel('(Ref Vy - Trans Vy) / Vye')
+ plt.ylabel('N_stars')
+ plt.title('Vy Residuals, Matched')
if vylim != None:
- py.xlim([vylim[0], vylim[1]])
- py.savefig('Vel_err_ratio_dist.png')
+ plt.xlim([vylim[0], vylim[1]])
+ plt.savefig('Vel_err_ratio_dist.png', dpi=300)
return
@@ -589,10 +687,10 @@ def residual_vpd(ref_mat, starlist_trans_mat, pscale=None):
# Error calculation depends on if we are converting to mas/yr
if pscale != None:
- xerr_frac = np.hypot((ref_mat['vxe'] / ref_mat['vx']),
- (starlist_trans_mat['vxe'] / starlist_trans_mat['vx']))
- yerr_frac = np.hypot((ref_mat['vye'] / ref_mat['vy']),
- (starlist_trans_mat['vye'] / starlist_trans_mat['vy']))
+ xerr_frac = np.hypot((ref_mat['vx_err'] / ref_mat['vx']),
+ (starlist_trans_mat['vx_err'] / starlist_trans_mat['vx']))
+ yerr_frac = np.hypot((ref_mat['vy_err'] / ref_mat['vy']),
+ (starlist_trans_mat['vy_err'] / starlist_trans_mat['vy']))
# Now apply the plate scale to convert to mas/yr
diff_x *= pscale
@@ -600,31 +698,33 @@ def residual_vpd(ref_mat, starlist_trans_mat, pscale=None):
xerr = diff_x * xerr_frac
yerr = diff_y * yerr_frac
else:
- xerr = np.hypot(ref_mat['vxe'], starlist_trans_mat['vxe'])
- yerr = np.hypot(ref_mat['vye'], starlist_trans_mat['vye'])
+ xerr = np.hypot(ref_mat['vx_err'], starlist_trans_mat['vx_err'])
+ yerr = np.hypot(ref_mat['vy_err'], starlist_trans_mat['vy_err'])
# Plotting
- py.figure(figsize=(10,10))
- py.clf()
- py.errorbar(diff_x, diff_y, xerr=xerr, yerr=yerr, fmt='k.', ms=8, alpha=0.5)
+ plt.figure(figsize=(6, 6))
+ plt.clf()
+ plt.errorbar(diff_x, diff_y, xerr=xerr, yerr=yerr, fmt='k.', ms=8, alpha=0.5)
if pscale != None:
- py.xlabel('Reference_vx - Transformed_vx (mas/yr)')
- py.ylabel('Reference_vy - Transformed_vy (mas/yr)')
+ plt.xlabel('Reference_vx - Transformed_vx (mas/yr)')
+ plt.ylabel('Reference_vy - Transformed_vy (mas/yr)')
else:
- py.xlabel('Reference_vx - Transformed_vx (reference coords)')
- py.ylabel('Reference_vy - Transformed_vy (reference coords)')
- py.title('Proper Motion Residuals')
- py.savefig('resid_vpd.png')
+ plt.xlabel('Reference_vx - Transformed_vx (reference coords)')
+ plt.ylabel('Reference_vy - Transformed_vy (reference coords)')
+ plt.title('Proper Motion Residuals')
+ plt.tight_layout()
+ plt.savefig('resid_vpd.png', dpi=300)
+ plt.close()
return
def plotStar(starNames, rootDir='./', align='align/align_d_rms_1000_abs_t',
- poly='polyfit_d/fit', points='points_d/', radial=False, NcolMax=3, figsize=(15,15)):
+ poly='polyfit_d/fit', points='points_d/', radial=False, NcolMax=3, figsize=(6, 6)):
print( 'Creating residuals plots for star(s):' )
print( starNames )
-
+
s = starset.StarSet(rootDir + align)
s.loadPolyfit(rootDir + poly, accel=0, arcsec=0)
Nstars = len(starNames)
@@ -634,18 +734,18 @@ def plotStar(starNames, rootDir='./', align='align/align_d_rms_1000_abs_t',
else:
Nrows = math.ceil(Nstars / (Ncols / 2)) * 3
- py.close('all')
- py.figure(2, figsize=figsize)
+ plt.close('all')
+ plt.figure(2, figsize=figsize)
names = s.getArray('name')
mag = s.getArray('mag')
x = s.getArray('x')
y = s.getArray('y')
r = np.hypot(x,y)
-
+
for i in range(Nstars):
-
+
starName = starNames[i]
-
+
ii = names.index(starName)
star = s.stars[ii]
@@ -726,9 +826,9 @@ def plotStar(starNames, rootDir='./', align='align/align_d_rms_1000_abs_t',
idx = np.where(abs(sig) > 4)
print( 'Star: ', starName )
- print( '\tX Chi^2 = %5.2f (%6.2f for %2d dof)' %
+ print( '\tX Chi^2 = %5.2f (%6.2f for %2d dof)' %
(fitx.chi2red, fitx.chi2, fitx.dof))
- print( '\tY Chi^2 = %5.2f (%6.2f for %2d dof)' %
+ print( '\tY Chi^2 = %5.2f (%6.2f for %2d dof)' %
(fity.chi2red, fity.chi2, fity.dof))
# print( 'X Outliers: ', time[idxX] )
# print( 'Y Outliers: ', time[idxY] )
@@ -743,8 +843,8 @@ def plotStar(starNames, rootDir='./', align='align/align_d_rms_1000_abs_t',
t0 = int(np.floor(np.min(time)))
tO = int(np.ceil(np.max(time)))
-
- dateTicLoc = py.MultipleLocator(3)
+
+ dateTicLoc = plt.MultipleLocator(3)
dateTicRng = [t0-1, tO+1]
dateTics = np.arange(t0, tO+1)
DateTicsLabel = dateTics-2000
@@ -752,7 +852,7 @@ def plotStar(starNames, rootDir='./', align='align/align_d_rms_1000_abs_t',
# See if we are using MJD instead.
if time[0] > 50000:
print('MJD')
- dateTicLoc = py.MultipleLocator(1000)
+ dateTicLoc = plt.MultipleLocator(1000)
t0 = int(np.round(np.min(time), 50))
tO = int(np.round(np.max(time), 50))
dateTicRng = [t0-200, tO+200]
@@ -763,7 +863,6 @@ def plotStar(starNames, rootDir='./', align='align/align_d_rms_1000_abs_t',
maxErr = np.array([xerr, yerr]).max()
resTicRng = [-1.1*maxErr, 1.1*maxErr]
- from matplotlib.ticker import FormatStrFormatter
fmtX = FormatStrFormatter('%5i')
fmtY = FormatStrFormatter('%6.2f')
fontsize1 = 10
@@ -773,125 +872,125 @@ def plotStar(starNames, rootDir='./', align='align/align_d_rms_1000_abs_t',
row = 1
else:
col = 1 + 2*(i % (Ncols/2))
- row = 1 + 3*(i//(Ncols/2))
-
+ row = 1 + 3*(i//(Ncols/2))
+
ind = (row-1)*Ncols + col
- paxes = py.subplot(Nrows, Ncols, ind)
- py.plot(time, fitLineX, 'b-')
- py.plot(time, fitLineX + fitSigX, 'b--')
- py.plot(time, fitLineX - fitSigX, 'b--')
- py.errorbar(time, x, yerr=xerr, fmt='k.')
- rng = py.axis()
- py.ylim(np.min(x-xerr-0.1),np.max(x+xerr+0.1))
- py.xlabel('Date - 2000 (yrs)', fontsize=fontsize1)
+ paxes = plt.subplot(Nrows, Ncols, ind)
+ plt.plot(time, fitLineX, 'b-')
+ plt.plot(time, fitLineX + fitSigX, 'b--')
+ plt.plot(time, fitLineX - fitSigX, 'b--')
+ plt.errorbar(time, x, yerr=xerr, fmt='k.')
+ rng = plt.axis()
+ plt.ylim(np.min(x-xerr-0.1),np.max(x+xerr+0.1))
+ plt.xlabel('Date - 2000 (yrs)', fontsize=fontsize1)
if time[0] > 50000:
- py.xlabel('Date (MJD)', fontsize=fontsize1)
- py.ylabel('X (pix)', fontsize=fontsize1)
+ plt.xlabel('Date (MJD)', fontsize=fontsize1)
+ plt.ylabel('X (pix)', fontsize=fontsize1)
paxes.xaxis.set_major_formatter(fmtX)
paxes.get_xaxis().set_major_locator(dateTicLoc)
paxes.yaxis.set_major_formatter(fmtY)
paxes.tick_params(axis='both', which='major', labelsize=fontsize1)
- py.yticks(np.arange(np.min(x-xerr-0.1), np.max(x+xerr+0.1), 0.2))
- py.xticks(dateTics, DateTicsLabel)
- py.xlim(np.min(dateTics), np.max(dateTics))
- py.annotate(starName,xy=(1.0,1.1), xycoords='axes fraction', fontsize=12, color='red')
+ plt.yticks(np.arange(np.min(x-xerr-0.1), np.max(x+xerr+0.1), 0.2))
+ plt.xticks(dateTics, DateTicsLabel)
+ plt.xlim(np.min(dateTics), np.max(dateTics))
+ plt.annotate(starName,xy=(1.0,1.1), xycoords='axes fraction', fontsize=12, color='red')
col = col + 1
ind = (row-1)*Ncols + col
- paxes = py.subplot(Nrows, Ncols, ind)
- py.plot(time, fitLineY, 'b-')
- py.plot(time, fitLineY + fitSigY, 'b--')
- py.plot(time, fitLineY - fitSigY, 'b--')
- py.errorbar(time, y, yerr=yerr, fmt='k.')
- rng = py.axis()
- py.axis(dateTicRng + [rng[2], rng[3]], fontsize=fontsize1)
- py.xlabel('Date - 2000 (yrs)', fontsize=fontsize1)
+ paxes = plt.subplot(Nrows, Ncols, ind)
+ plt.plot(time, fitLineY, 'b-')
+ plt.plot(time, fitLineY + fitSigY, 'b--')
+ plt.plot(time, fitLineY - fitSigY, 'b--')
+ plt.errorbar(time, y, yerr=yerr, fmt='k.')
+ rng = plt.axis()
+ plt.axis(dateTicRng + [rng[2], rng[3]], fontsize=fontsize1)
+ plt.xlabel('Date - 2000 (yrs)', fontsize=fontsize1)
if time[0] > 50000:
- py.xlabel('Date (MJD)', fontsize=fontsize1)
- py.ylabel('Y (pix)', fontsize=fontsize1)
+ plt.xlabel('Date (MJD)', fontsize=fontsize1)
+ plt.ylabel('Y (pix)', fontsize=fontsize1)
#paxes.get_xaxis().set_major_locator(dateTicLoc)
paxes.xaxis.set_major_formatter(fmtX)
paxes.get_xaxis().set_major_locator(dateTicLoc)
paxes.yaxis.set_major_formatter(fmtY)
paxes.tick_params(axis='both', which='major', labelsize=12)
- py.ylim(np.min(y-yerr-0.1),np.max(y+yerr+0.1))
- py.yticks(np.arange(np.min(y-yerr-0.1), np.max(y+yerr+0.1), 0.2))
- py.xticks(dateTics, DateTicsLabel)
- py.xlim(np.min(dateTics), np.max(dateTics))
+ plt.ylim(np.min(y-yerr-0.1),np.max(y+yerr+0.1))
+ plt.yticks(np.arange(np.min(y-yerr-0.1), np.max(y+yerr+0.1), 0.2))
+ plt.xticks(dateTics, DateTicsLabel)
+ plt.xlim(np.min(dateTics), np.max(dateTics))
row = row + 1
col = col - 1
ind = (row-1)*Ncols + col
- paxes = py.subplot(Nrows, Ncols, ind)
- py.plot(time, np.zeros(len(time)), 'b-')
- py.plot(time, fitSigX, 'b--')
- py.plot(time, -fitSigX, 'b--')
- py.errorbar(time, x - fitLineX, yerr=xerr, fmt='k.')
- py.axis(dateTicRng + resTicRng, fontsize=fontsize1)
- py.xlabel('Date - 2000 (yrs)', fontsize=fontsize1)
+ paxes = plt.subplot(Nrows, Ncols, ind)
+ plt.plot(time, np.zeros(len(time)), 'b-')
+ plt.plot(time, fitSigX, 'b--')
+ plt.plot(time, -fitSigX, 'b--')
+ plt.errorbar(time, x - fitLineX, yerr=xerr, fmt='k.')
+ plt.axis(dateTicRng + resTicRng, fontsize=fontsize1)
+ plt.xlabel('Date - 2000 (yrs)', fontsize=fontsize1)
if time[0] > 50000:
- py.xlabel('Date (MJD)', fontsize=fontsize1)
- py.ylabel('X Residuals (pix)', fontsize=fontsize1)
+ plt.xlabel('Date (MJD)', fontsize=fontsize1)
+ plt.ylabel('X Residuals (pix)', fontsize=fontsize1)
paxes.get_xaxis().set_major_locator(dateTicLoc)
paxes.xaxis.set_major_formatter(fmtX)
paxes.tick_params(axis='both', which='major', labelsize=fontsize1)
- py.xticks(dateTics, DateTicsLabel)
- py.xlim(np.min(dateTics), np.max(dateTics))
+ plt.xticks(dateTics, DateTicsLabel)
+ plt.xlim(np.min(dateTics), np.max(dateTics))
col = col + 1
ind = (row-1)*Ncols + col
- paxes = py.subplot(Nrows, Ncols, ind)
- py.plot(time, np.zeros(len(time)), 'b-')
- py.plot(time, fitSigY, 'b--')
- py.plot(time, -fitSigY, 'b--')
- py.errorbar(time, y - fitLineY, yerr=yerr, fmt='k.')
- py.axis(dateTicRng + resTicRng, fontsize=fontsize1)
- py.xlabel('Date -2000 (yrs)', fontsize=fontsize1)
+ paxes = plt.subplot(Nrows, Ncols, ind)
+ plt.plot(time, np.zeros(len(time)), 'b-')
+ plt.plot(time, fitSigY, 'b--')
+ plt.plot(time, -fitSigY, 'b--')
+ plt.errorbar(time, y - fitLineY, yerr=yerr, fmt='k.')
+ plt.axis(dateTicRng + resTicRng, fontsize=fontsize1)
+ plt.xlabel('Date -2000 (yrs)', fontsize=fontsize1)
if time[0] > 50000:
- py.xlabel('Date (MJD)', fontsize=fontsize1)
- py.ylabel('Y Residuals (pix)', fontsize=fontsize1)
+ plt.xlabel('Date (MJD)', fontsize=fontsize1)
+ plt.ylabel('Y Residuals (pix)', fontsize=fontsize1)
paxes.get_xaxis().set_major_locator(dateTicLoc)
paxes.xaxis.set_major_formatter(fmtX)
paxes.tick_params(axis='both', which='major', labelsize=fontsize1)
- py.xticks(dateTics, DateTicsLabel)
- py.xlim(np.min(dateTics), np.max(dateTics))
+ plt.xticks(dateTics, DateTicsLabel)
+ plt.xlim(np.min(dateTics), np.max(dateTics))
row = row + 1
col = col - 1
ind = (row-1)*Ncols + col
- paxes = py.subplot(Nrows, Ncols, ind)
- py.errorbar(x,y, xerr=xerr, yerr=yerr, fmt='k.')
- py.yticks(np.arange(np.min(y-yerr-0.1), np.max(y+yerr+0.1), 0.2))
- py.xticks(np.arange(np.min(x-xerr-0.1), np.max(x+xerr+0.1), 0.2), rotation = 270)
- py.axis('equal')
+ paxes = plt.subplot(Nrows, Ncols, ind)
+ plt.errorbar(x,y, xerr=xerr, yerr=yerr, fmt='k.')
+ plt.yticks(np.arange(np.min(y-yerr-0.1), np.max(y+yerr+0.1), 0.2))
+ plt.xticks(np.arange(np.min(x-xerr-0.1), np.max(x+xerr+0.1), 0.2), rotation = 270)
+ plt.axis('equal')
paxes.tick_params(axis='both', which='major', labelsize=fontsize1)
paxes.yaxis.set_major_formatter(FormatStrFormatter('%.2f'))
paxes.xaxis.set_major_formatter(FormatStrFormatter('%.2f'))
- py.xlabel('X (pix)', fontsize=fontsize1)
- py.ylabel('Y (pix)', fontsize=fontsize1)
- py.plot(fitLineX, fitLineY, 'b-')
+ plt.xlabel('X (pix)', fontsize=fontsize1)
+ plt.ylabel('Y (pix)', fontsize=fontsize1)
+ plt.plot(fitLineX, fitLineY, 'b-')
col = col + 1
ind = (row-1)*Ncols + col
bins = np.arange(-7.5, 7.5, 1)
- paxes = py.subplot(Nrows, Ncols, ind)
+ paxes = plt.subplot(Nrows, Ncols, ind)
id = np.where(diffY < 0)[0]
- sig[id] = -1.*sig[id]
- (n, b, p) = py.hist(sigX, bins, histtype='stepfilled', color='b', label='X')
- py.setp(p, 'facecolor', 'b')
- (n, b, p) = py.hist(sigY, bins, histtype='step', color='r', label='Y')
- py.axis([-7, 7, 0, 8], fontsize=10)
- py.legend()
- py.xlabel('Residuals (sigma)', fontsize=fontsize1)
- py.ylabel('Number of Epochs', fontsize=fontsize1)
+ sig[id] = -1.*sig[id]
+ (n, b, p) = plt.hist(sigX, bins, histtype='stepfilled', color='b', label='X')
+ plt.setp(p, 'facecolor', 'b')
+ (n, b, p) = plt.hist(sigY, bins, histtype='step', color='r', label='Y')
+ plt.axis([-7, 7, 0, 8], fontsize=10)
+ plt.legend()
+ plt.xlabel('Residuals (sigma)', fontsize=fontsize1)
+ plt.ylabel('Number of Epochs', fontsize=fontsize1)
##########
#
@@ -899,111 +998,110 @@ def plotStar(starNames, rootDir='./', align='align/align_d_rms_1000_abs_t',
#
##########
if (radial == True):
- py.clf()
+ plt.clf()
- dateTicLoc = py.MultipleLocator(3)
+ dateTicLoc = plt.MultipleLocator(3)
maxErr = np.array([rerr, terr]).max()
resTicRng = [-3*maxErr, 3*maxErr]
- from matplotlib.ticker import FormatStrFormatter
fmtX = FormatStrFormatter('%5i')
fmtY = FormatStrFormatter('%6.2f')
- paxes = py.subplot(3,2,1)
- py.plot(time, fitLineR, 'b-')
- py.plot(time, fitLineR + fitSigR, 'b--')
- py.plot(time, fitLineR - fitSigR, 'b--')
- py.errorbar(time, r, yerr=rerr, fmt='k.')
- rng = py.axis()
- py.axis(dateTicRng + [rng[2], rng[3]])
- py.xlabel('Date (yrs)')
- py.ylabel('R (pix)')
+ paxes = plt.subplot(3,2,1)
+ plt.plot(time, fitLineR, 'b-')
+ plt.plot(time, fitLineR + fitSigR, 'b--')
+ plt.plot(time, fitLineR - fitSigR, 'b--')
+ plt.errorbar(time, r, yerr=rerr, fmt='k.')
+ rng = plt.axis()
+ plt.axis(dateTicRng + [rng[2], rng[3]])
+ plt.xlabel('Date (yrs)')
+ plt.ylabel('R (pix)')
paxes.xaxis.set_major_formatter(fmtX)
paxes.get_xaxis().set_major_locator(dateTicLoc)
paxes.yaxis.set_major_formatter(fmtY)
- paxes = py.subplot(3, 2, 2)
- py.plot(time, fitLineT, 'b-')
- py.plot(time, fitLineT + fitSigT, 'b--')
- py.plot(time, fitLineT - fitSigT, 'b--')
- py.errorbar(time, t, yerr=terr, fmt='k.')
- rng = py.axis()
- py.axis(dateTicRng + [rng[2], rng[3]])
- py.xlabel('Date (yrs)')
- py.ylabel('T (pix)')
+ paxes = plt.subplot(3, 2, 2)
+ plt.plot(time, fitLineT, 'b-')
+ plt.plot(time, fitLineT + fitSigT, 'b--')
+ plt.plot(time, fitLineT - fitSigT, 'b--')
+ plt.errorbar(time, t, yerr=terr, fmt='k.')
+ rng = plt.axis()
+ plt.axis(dateTicRng + [rng[2], rng[3]])
+ plt.xlabel('Date (yrs)')
+ plt.ylabel('T (pix)')
paxes.xaxis.set_major_formatter(fmtX)
paxes.get_xaxis().set_major_locator(dateTicLoc)
paxes.yaxis.set_major_formatter(fmtY)
- paxes = py.subplot(3, 2, 3)
- py.plot(time, np.zeros(len(time)), 'b-')
- py.plot(time, fitSigR, 'b--')
- py.plot(time, -fitSigR, 'b--')
- py.errorbar(time, r - fitLineR, yerr=rerr, fmt='k.')
- py.axis(dateTicRng + resTicRng)
- py.xlabel('Date (yrs)')
- py.ylabel('R Residuals (pix)')
+ paxes = plt.subplot(3, 2, 3)
+ plt.plot(time, np.zeros(len(time)), 'b-')
+ plt.plot(time, fitSigR, 'b--')
+ plt.plot(time, -fitSigR, 'b--')
+ plt.errorbar(time, r - fitLineR, yerr=rerr, fmt='k.')
+ plt.axis(dateTicRng + resTicRng)
+ plt.xlabel('Date (yrs)')
+ plt.ylabel('R Residuals (pix)')
paxes.get_xaxis().set_major_locator(dateTicLoc)
- paxes = py.subplot(3, 2, 4)
- py.plot(time, np.zeros(len(time)), 'b-')
- py.plot(time, fitSigT, 'b--')
- py.plot(time, -fitSigT, 'b--')
- py.errorbar(time, t - fitLineT, yerr=terr, fmt='k.')
- py.axis(dateTicRng + resTicRng)
- py.xlabel('Date (yrs)')
- py.ylabel('T Residuals (pix)')
+ paxes = plt.subplot(3, 2, 4)
+ plt.plot(time, np.zeros(len(time)), 'b-')
+ plt.plot(time, fitSigT, 'b--')
+ plt.plot(time, -fitSigT, 'b--')
+ plt.errorbar(time, t - fitLineT, yerr=terr, fmt='k.')
+ plt.axis(dateTicRng + resTicRng)
+ plt.xlabel('Date (yrs)')
+ plt.ylabel('T Residuals (pix)')
paxes.get_xaxis().set_major_locator(dateTicLoc)
bins = np.arange(-7, 7, 1)
- py.subplot(3, 2, 5)
- (n, b, p) = py.hist(sigR, bins)
- py.setp(p, 'facecolor', 'k')
- py.axis([-5, 5, 0, 20])
- py.xlabel('T Residuals (sigma)')
- py.ylabel('Number of Epochs')
-
- py.subplot(3, 2, 6)
- (n, b, p) = py.hist(sigT, bins)
- py.axis([-5, 5, 0, 20])
- py.setp(p, 'facecolor', 'k')
- py.xlabel('Y Residuals (sigma)')
- py.ylabel('Number of Epochs')
-
- py.subplots_adjust(wspace=0.4, hspace=0.4, right=0.95, top=0.95)
- py.savefig(rootDir+'plots/plotStarRadial_' + starName + '.png')
- py.show()
+ plt.subplot(3, 2, 5)
+ (n, b, p) = plt.hist(sigR, bins)
+ plt.setp(p, 'facecolor', 'k')
+ plt.axis([-5, 5, 0, 20])
+ plt.xlabel('T Residuals (sigma)')
+ plt.ylabel('Number of Epochs')
+
+ plt.subplot(3, 2, 6)
+ (n, b, p) = plt.hist(sigT, bins)
+ plt.axis([-5, 5, 0, 20])
+ plt.setp(p, 'facecolor', 'k')
+ plt.xlabel('Y Residuals (sigma)')
+ plt.ylabel('Number of Epochs')
+
+ plt.subplots_adjust(wspace=0.4, hspace=0.4, right=0.95, top=0.95)
+ plt.savefig(rootDir+'plots/plotStarRadial_' + starName + '.png', dpi=300)
+ plt.show()
title = rootDir.split('/')[-2]
- py.suptitle(title, x=0.5, y=0.97)
+ plt.suptitle(title, x=0.5, y=0.97)
if Nstars == 1:
- py.subplots_adjust(wspace=0.4, hspace=0.4, left = 0.15, bottom = 0.1, right=0.9, top=0.9)
- py.savefig(rootDir+'plots/plotStar_' + starName + '.png')
+ plt.subplots_adjust(wspace=0.4, hspace=0.4, left = 0.15, bottom = 0.1, right=0.9, top=0.9)
+ plt.savefig(rootDir+'plots/plotStar_' + starName + '.png', dpi=300)
else:
- py.subplots_adjust(wspace=0.6, hspace=0.6, left = 0.08, bottom = 0.05, right=0.95, top=0.90)
- py.savefig(rootDir+'plots/plotStar_all.png')
- py.show()
+ plt.subplots_adjust(wspace=0.6, hspace=0.6, left = 0.08, bottom = 0.05, right=0.95, top=0.90)
+ plt.savefig(rootDir+'plots/plotStar_all.png', dpi=300)
+ plt.show()
- py.show()
+ plt.show()
print('Fubar')
-
+
##################################################
# New codes for velocity support in FlyStar and using
-# the new StarTable and StarList format.
+# the new StarTable and StarList format.
##################################################
def plot_pm(tab):
- plt.figure(figsize=(6,6))
+ plt.figure(figsize=(6, 6))
plt.clf()
plt.subplots_adjust(top=0.85)
q = plt.quiver(tab['x0'].data, tab['y0'].data,
tab['vx'].data*1e3, tab['vy'].data*1e3,
scale=1e2, angles='xy')
- plt.quiverkey(q, 0.5, 0.8, 10, '10 mas/yr', color='red',
+ plt.quiverkey(q, 0.5, 0.8, 10, '10 mas/yr', color='red',
coordinates='figure', labelpos='E')
plt.xlabel(r'$\Delta \alpha$ (")')
plt.ylabel(r'$\Delta \delta$ (")')
@@ -1020,16 +1118,16 @@ def plot_gaia(gaia):
d_ra_tan = (ra_tan - ra_tan_mean) * cos_dec * 3600.0
d_de_tan = (de_tan - de_tan_mean) * 3600.0
-
+
pmra = gaia['pmra']
pmdec = gaia['pmdec']
- plt.figure(figsize=(6,6))
+ plt.figure(figsize=(6, 6))
plt.clf()
plt.subplots_adjust(top=0.85)
q = plt.quiver(d_ra_tan.data, d_de_tan.data,
pmra.data, pmdec.data,
scale=1e2, angles='xy')
- plt.quiverkey(q, 0.5, 0.8, 10, '10 mas/yr', color='red',
+ plt.quiverkey(q, 0.5, 0.8, 10, '10 mas/yr', color='red',
coordinates='figure', labelpos='E')
plt.xlabel(r'$\Delta \alpha \cos \delta$ ('')')
plt.ylabel(r'$\Delta \delta$ ('')')
@@ -1037,29 +1135,31 @@ def plot_gaia(gaia):
fmt = r'[$\alpha$, $\delta$] = [{0:8.3f}$^\circ$, {1:8.3f}$^\circ$]'
plt.title(fmt.format(ra_tan_mean, de_tan_mean))
plt.gca().invert_xaxis()
-
-
return
-def plot_pm_error(tab):
- plt.figure(figsize=(6,6))
- plt.clf()
- plt.semilogy(tab['m0'], tab['vxe']*1e3, 'r.', label=r'$\sigma_{\mu_{\alpha *}}$', alpha=0.4)
- plt.semilogy(tab['m0'], tab['vye']*1e3, 'b.', label=r'$\sigma_{\mu_{\delta}}$', alpha=0.4)
- plt.legend()
- plt.xlabel('Mag')
- plt.ylabel('PM Error (mas/yr)')
-
+def plot_pm_error(tab, save_path=None):
+ fig, ax = plt.subplots(1, 1, figsize=(6, 6))
+ ax.semilogy(tab['m0'], tab['vx_err']*1e3, color='C0', marker='.', ls='none', ms=3, label=r'$\sigma_{\mu_{\alpha *}}$', alpha=0.3)
+ ax.semilogy(tab['m0'], tab['vy_err']*1e3, color='C3', marker='.', ls='none', ms=3, label=r'$\sigma_{\mu_{\delta}}$', alpha=0.3)
+ ax.legend()
+ ax.set_xlabel('Mag')
+ ax.set_ylabel('PM Error (mas/yr)')
+ plt.tight_layout()
+ if save_path is not None:
+ plt.savefig(save_path, dpi=300)
+ plt.show()
return
-def plot_mag_error(tab):
- plt.figure(figsize=(6,6))
- plt.clf()
- plt.semilogy(tab['m0'], tab['m0e'], 'r.', alpha=0.4)
- plt.legend()
- plt.xlabel('Mag')
- plt.ylabel('Mag Error (mag)')
-
+def plot_mag_error(tab, save_path=None):
+ fig, ax = plt.subplots(1, 1, figsize=(6, 6))
+ ax.semilogy(tab['m0'], tab['m0_err'], color='C0', marker='.', ls='none', alpha=0.4)
+ ax.legend()
+ ax.set_xlabel('Mag')
+ ax.set_ylabel('Mag Error (mag)')
+ plt.tight_layout()
+ if save_path is not None:
+ plt.savefig(save_path, dpi=300)
+ plt.show()
return
def plot_mean_residuals_by_epoch(tab):
@@ -1069,9 +1169,8 @@ def plot_mean_residuals_by_epoch(tab):
the size of the mean residual.
"""
# Predicted model positions at each epoch
- dt = tab['t'] - tab['t0'][:, np.newaxis]
- xt_mod = tab['x0'][:, np.newaxis] + tab['vx'][:, np.newaxis] * dt
- yt_mod = tab['y0'][:, np.newaxis] + tab['vy'][:, np.newaxis] * dt
+ i_all_detected = np.where(~np.any(np.isnan(tab['t']),axis=1))[0][0]
+ xt_mod, yt_mod, xt_mod_err, yt_mod_err = tab.predict_positions(tab['t'][i_all_detected])
# Residuals
dx = tab['x'] - xt_mod
@@ -1117,10 +1216,10 @@ def plot_mean_residuals_by_epoch(tab):
plt.axhline(0, ls='--', color='black')
plt.xlabel('Time (yr)')
plt.ylabel('Mag Residuals')
-
+
return
-def plot_quiver_residuals_all_epochs(tab, unit='arcsec', scale=None, plotlim=None):
+def plot_quiver_residuals_all_epochs(tab, unit='arcsec', scale=None, plotlim=None, save_path=None, show_plot=True):
# Keep track of the residuals for averaging.
dr_good = np.zeros(len(tab), dtype=float)
@@ -1128,19 +1227,32 @@ def plot_quiver_residuals_all_epochs(tab, unit='arcsec', scale=None, plotlim=Non
dr_ref = np.zeros(len(tab), dtype=float)
n_ref = np.zeros(len(tab), dtype=int)
+ # motion_model_dict = motion_model.validate_motion_model_dict(motion_model_dict, tab, None)
+ complete_times = np.array([np.unique(col[~np.isnan(col)])[0] for col in tab['t'].T])
+ # xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.get_star_positions_at_time(complete_times, motion_model_dict, allow_alt_models=True)
+ xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.infer_positions(complete_times)
+
for ee in range(tab['x'].shape[1]):
- dt = tab['t'][:, ee] - tab['t0']
- xt_mod = tab['x0'] + tab['vx'] * dt
- yt_mod = tab['y0'] + tab['vy'] * dt
-
+ xt_mod = xt_mod_all[:,ee]
+ yt_mod = yt_mod_all[:,ee]
+
good_idx = np.where(np.isfinite(tab['x'][:, ee]) == True)[0]
ref_idx = np.where(tab[good_idx]['used_in_trans'][:, ee] == True)[0]
- dx, dy = plot_quiver_residuals(tab['x'][:, ee], tab['y'][:, ee],
- xt_mod, yt_mod,
- good_idx, ref_idx,
- 'Epoch {0:d}'.format(ee),
- unit=unit, scale=scale, plotlim=plotlim)
+ dx, dy = plot_quiver_residuals(
+ tab['x'][:, ee],
+ tab['y'][:, ee],
+ xt_mod,
+ yt_mod,
+ good_idx,
+ ref_idx,
+ 'Epoch {0:d}'.format(ee),
+ unit=unit,
+ scale=scale,
+ plotlim=plotlim,
+ show_plot=show_plot,
+ save_path=f'{save_path}/Quiver_Residual_{ee}.png' if save_path else None
+ )
# Building up average dr for a set of stars.
dr = np.hypot(dx, dy)
@@ -1154,13 +1266,13 @@ def plot_quiver_residuals_all_epochs(tab, unit='arcsec', scale=None, plotlim=Non
dr_good_avg = np.zeros(len(tab), dtype=float)
idx = np.where(n_good > 0)[0]
dr_good_avg[idx] = dr_good[idx] / n_good[idx]
-
+
dr_ref_avg = np.zeros(len(tab), dtype=float)
idx = np.where(n_ref > 0)[0]
dr_ref_avg[idx] = dr_ref[idx] / n_ref[idx]
- hdr = '{name:>16s} {mag:>5s} {dr:>6s} {x:>6s} {y:>6s} {r:>6s}'
- fmt = '{name:16s} {mag:5.2f} {dr:6.4f} {x:6.3f} {y:6.3f} {r:6.3f}'
+ # hdr = '{name:>16s} {mag:>5s} {dr:>6s} {x:>6s} {y:>6s} {r:>6s}'
+ # fmt = '{name:16s} {mag:5.2f} {dr:6.4f} {x:6.3f} {y:6.3f} {r:6.3f}'
# print()
# print('##########')
@@ -1180,11 +1292,11 @@ def plot_quiver_residuals_all_epochs(tab, unit='arcsec', scale=None, plotlim=Non
# if (dr_ref_avg[rr] > 0):
# print(fmt.format(name=tab['name'][rr], mag=tab['m0'][rr], dr=dr_ref_avg[rr],
# x=tab['x0'][rr], y=tab['y0'][rr], r=np.hypot(tab['x0'][rr], tab['y0'][rr])))
-
+
return
-def plot_quiver_residuals_with_orig_all_epochs(tab, trans_list, unit='arcsec', scale=None, plotlim=None, scale_orig=None, cte_fit=None, mlim=15):
+def plot_quiver_residuals_with_orig_all_epochs(tab, trans_list, unit='arcsec', scale=None, plotlim=None, scale_orig=None, cte_fit=None, mlim=15, show_plot=True, save_path=None):
# Keep track of the residuals for averaging.
dr_good = np.zeros(len(tab), dtype=float)
@@ -1192,59 +1304,64 @@ def plot_quiver_residuals_with_orig_all_epochs(tab, trans_list, unit='arcsec', s
dr_ref = np.zeros(len(tab), dtype=float)
n_ref = np.zeros(len(tab), dtype=int)
+ # motion_model_dict = motion_model.validate_motion_model_dict(motion_model_dict, tab, None)
+ i_all_detected = np.where(~np.any(np.isnan(tab['t']),axis=1))[0][0]
+ # xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.get_star_positions_at_time(tab['t'][i_all_detected], motion_model_dict, allow_alt_models=True)
+ xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.infer_positions(tab['t'][i_all_detected])
+
for ee in range(tab['x'].shape[1]):
dt = tab['t'][:, ee] - tab['t0']
- xt_mod = tab['x0'] + tab['vx'] * dt
- yt_mod = tab['y0'] + tab['vy'] * dt
-
+ xt_mod = xt_mod_all[ee]
+ yt_mod = yt_mod_all[ee]
+
good_idx = np.where(np.isfinite(tab['x'][:, ee]) == True)[0]
ref_idx = np.where(tab[good_idx]['used_in_trans'][:, ee] == True)[0]
da = calc_da(trans_list[ee])
- dx, dy = plot_quiver_residuals(tab['x'][:, ee], tab['y'][:, ee],
- xt_mod, yt_mod,
+ dx, dy = plot_quiver_residuals(tab['x'][:, ee], tab['y'][:, ee],
+ xt_mod, yt_mod,
good_idx, ref_idx,
- 'Epoch {0:d}'.format(ee),
- unit=unit, scale=scale, plotlim=plotlim)
+ 'Epoch {0:d}'.format(ee),
+ unit=unit, scale=scale, plotlim=plotlim, show_plot=show_plot, save_path=f'{save_path}/Quiver_Residual_{ee}.png' if save_path else None)
- plot_quiver_residuals_orig(tab['x'][:, ee], tab['y'][:, ee],
- xt_mod, yt_mod,
+ plot_quiver_residuals_orig(tab['x'][:, ee], tab['y'][:, ee],
+ xt_mod, yt_mod,
good_idx, ref_idx,
tab['x_orig'][:, ee], tab['y_orig'][:, ee], da,
- 'Epoch {0:d}'.format(ee),
- scale=scale_orig, plotlim=plotlim)
+ 'Epoch {0:d}'.format(ee),
+ scale=scale_orig, plotlim=plotlim, show_plot=show_plot, save_path=f'{save_path}/Quiver_Residual_Orig_{ee}.png' if save_path else None)
- plot_mag_scatter(tab['m'][:, ee],
- tab['m0'], tab['m0e'],
- tab['x'][:, ee], tab['y'][:, ee],
+ plot_mag_scatter(tab['m'][:, ee],
+ tab['m0'], tab['m0_err'],
+ tab['x'][:, ee], tab['y'][:, ee],
tab['xe'][:, ee], tab['ye'][:, ee],
- xt_mod, yt_mod,
+ xt_mod, yt_mod,
good_idx, ref_idx,
'Epoch {0:d}'.format(ee), da=da,
xorig=tab['x_orig'][:, ee], yorig=tab['y_orig'][:, ee],
- cte_fit=cte_fit, mlim=mlim)
+ cte_fit=cte_fit, mlim=mlim, show_plot=show_plot, save_path=f'{save_path}/Mag_Scatter_{ee}.png' if save_path else None)
- plot_y_scatter(tab['m'][:, ee],
- tab['m0'], tab['m0e'],
- tab['x'][:, ee], tab['y'][:, ee],
+ plot_y_scatter(tab['m'][:, ee],
+ tab['m0'], tab['m0_err'],
+ tab['x'][:, ee], tab['y'][:, ee],
tab['xe'][:, ee], tab['ye'][:, ee],
- xt_mod, yt_mod,
+ xt_mod, yt_mod,
good_idx, ref_idx,
'Epoch {0:d}'.format(ee), da=da,
xorig=tab['x_orig'][:, ee], yorig=tab['y_orig'][:, ee],
- cte_fit=cte_fit, mlim=mlim)
+ cte_fit=cte_fit, mlim=mlim, show_plot=show_plot, save_path=f'{save_path}/Y_Scatter_{ee}.png' if save_path else None)
# plot_quiver_residuals_orig_angle_xy(tab['x'][:, ee], tab['y'][:, ee],
-# xt_mod, yt_mod,
+# xt_mod, yt_mod,
# good_idx, ref_idx,
# tab['x_orig'][:, ee], tab['y_orig'][:, ee], da,
# 'Epoch {0:d}'.format(ee))
#
# plot_quiver_residuals_vs_pos_err(dx, dy, good_idx, ref_idx,
-# 1e3 * tab['xe'][:, ee], 1e3 * tab['ye'][:, ee],
+# 1e3 * tab['xe'][:, ee], 1e3 * tab['ye'][:, ee],
# 'positional err (mas)', 'Epoch {0:d}'.format(ee), da=da)
-
+
# Building up average dr for a set of stars.
dr = np.hypot(dx, dy)
@@ -1257,13 +1374,13 @@ def plot_quiver_residuals_with_orig_all_epochs(tab, trans_list, unit='arcsec', s
dr_good_avg = np.zeros(len(tab), dtype=float)
idx = np.where(n_good > 0)[0]
dr_good_avg[idx] = dr_good[idx] / n_good[idx]
-
+
dr_ref_avg = np.zeros(len(tab), dtype=float)
idx = np.where(n_ref > 0)[0]
dr_ref_avg[idx] = dr_ref[idx] / n_ref[idx]
- hdr = '{name:>16s} {mag:>5s} {dr:>6s} {x:>6s} {y:>6s} {r:>6s}'
- fmt = '{name:16s} {mag:5.2f} {dr:6.4f} {x:6.3f} {y:6.3f} {r:6.3f}'
+ # hdr = '{name:>16s} {mag:>5s} {dr:>6s} {x:>6s} {y:>6s} {r:>6s}'
+ # fmt = '{name:16s} {mag:5.2f} {dr:6.4f} {x:6.3f} {y:6.3f} {r:6.3f}'
# print()
# print('##########')
@@ -1283,7 +1400,7 @@ def plot_quiver_residuals_with_orig_all_epochs(tab, trans_list, unit='arcsec', s
# if (dr_ref_avg[rr] > 0):
# print(fmt.format(name=tab['name'][rr], mag=tab['m0'][rr], dr=dr_ref_avg[rr],
# x=tab['x0'][rr], y=tab['y0'][rr], r=np.hypot(tab['x0'][rr], tab['y0'][rr])))
-
+
return
@@ -1291,24 +1408,28 @@ def plot_mag_scatter_multi_trans_all_epochs(tab_list, trans_list_list, unit='arc
m_t_list = []
x_t_list = []
y_t_list = []
- xe_t_list = []
+ xe_t_list = []
ye_t_list = []
x_ref_list = []
- y_ref_list = []
- good_idx_list = []
- ref_idx_list =[]
+ y_ref_list = []
+ good_idx_list = []
+ ref_idx_list =[]
da_list = []
ntrans = len(tab_list)
+ # motion_model_dict = motion_model.validate_motion_model_dict(motion_model_dict, tab, None)
+ i_all_detected = np.where(~np.any(np.isnan(tab['t']),axis=1))[0][0]
+ # xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.get_star_positions_at_time(tab['t'][i_all_detected], motion_model_dict, allow_alt_models=True)
+ xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.infer_positions(tab['t'][i_all_detected])
for mm in range(ntrans):
tab = tab_list[mm]
trans_list = trans_list_list[mm]
for ee in range(tab['x'].shape[1]):
dt = tab['t'][:, ee] - tab['t0']
- xt_mod = tab['x0'] + tab['vx'] * dt
- yt_mod = tab['y0'] + tab['vy'] * dt
-
+ xt_mod = xt_mod_all[ee]
+ yt_mod = yt_mod_all[ee]
+
good_idx = np.where(np.isfinite(tab['x'][:, ee]) == True)[0]
ref_idx = np.where(tab[good_idx]['used_in_trans'][:, ee] == True)[0]
@@ -1317,19 +1438,19 @@ def plot_mag_scatter_multi_trans_all_epochs(tab_list, trans_list_list, unit='arc
m_t_list.append(tab['m'][:, ee])
x_t_list.append(tab['x'][:, ee])
y_t_list.append(tab['y'][:, ee])
- xe_t_list.append(tab['xe'][:, ee])
+ xe_t_list.append(tab['xe'][:, ee])
ye_t_list.append(tab['ye'][:, ee])
x_ref_list.append(xt_mod)
y_ref_list.append(yt_mod)
- good_idx_list.append(good_idx)
- ref_idx_list.append(ref_idx)
+ good_idx_list.append(good_idx)
+ ref_idx_list.append(ref_idx)
da_list.append(da)
for ee in range(tab_list[0]['x'].shape[1]):
- plot_mag_scatter_multi_trans(m_t_list[ee::ntrans], x_t_list[ee::ntrans], y_t_list[ee::ntrans],
- xe_t_list[ee::ntrans], ye_t_list[ee::ntrans], x_ref_list[ee::ntrans], y_ref_list[ee::ntrans],
+ plot_mag_scatter_multi_trans(m_t_list[ee::ntrans], x_t_list[ee::ntrans], y_t_list[ee::ntrans],
+ xe_t_list[ee::ntrans], ye_t_list[ee::ntrans], x_ref_list[ee::ntrans], y_ref_list[ee::ntrans],
good_idx_list[ee::ntrans], ref_idx_list[ee::ntrans], 'Epoch {0:d}'.format(ee), da_list[ee::ntrans])
-
+
return
@@ -1351,7 +1472,7 @@ def calc_da(trans_list):
c01 = trans_list.px.parameters[c01_idx]
c10 = trans_list.px.parameters[c10_idx]
da = np.degrees(np.arctan2(-c01, c10))
-
+
return da
@@ -1359,7 +1480,7 @@ def plot_mag_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx,
# Residual
dx = (x_t - x_ref)
dy = (y_t - y_ref)
-
+
# Magnitude
mgood = m_t[good_idx]
mref = m_t[good_idx][ref_idx]
@@ -1397,8 +1518,7 @@ def plot_mag_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx,
xgood = np.cos(np.radians(agood)) * rgood
xref = np.cos(np.radians(aref)) * rref
- fig, ax = plt.subplots(7, 1, figsize=(6,18), sharex=True, num=103)
-# plt.clf()
+ fig, ax = plt.subplots(7, 1, figsize=(6, 18), sharex=True, num=103)
plt.subplots_adjust(hspace=0.01)
ax[0].scatter(mgood, agood, color='black', alpha=0.3, s=2)
ax[0].scatter(mref, aref, color='red', alpha=0.3, s=2)
@@ -1448,15 +1568,17 @@ def plot_mag_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx,
ax[6].axhline(y=0)
ax[0].set_title(title)
+ plt.tight_layout()
plt.show()
plt.pause(1)
+ return
def plot_y_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx, ref_idx, title, da=0, xorig=None, yorig=None, cte_fit=None, mlim=15):
# Residual
dx = (x_t - x_ref)
dy = (y_t - y_ref)
-
+
# Magnitude
mgood = m_t[good_idx]
mref = m_t[good_idx][ref_idx]
@@ -1494,7 +1616,7 @@ def plot_y_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx, r
xgood = np.cos(np.radians(agood)) * rgood
xref = np.cos(np.radians(aref)) * rref
- fig, ax = plt.subplots(7, 1, figsize=(6,18), sharex=True, num=103)
+ fig, ax = plt.subplots(7, 1, figsize=(6, 18), sharex=True, num=103)
# plt.clf()
plt.subplots_adjust(hspace=0.01)
ax[0].scatter(yorig[good_idx], agood, color='black', alpha=0.3, s=2)
@@ -1547,6 +1669,7 @@ def plot_y_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx, r
ax[6].axhline(y=0)
ax[0].set_title(title)
+ plt.tight_layout()
plt.show()
plt.pause(1)
@@ -1567,24 +1690,24 @@ def plot_y_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx, r
if cte_fit=='power':
idx = np.where(mgood > mlim)[0]
gpopt, gpcov = curve_fit(T_cte_y, mgood[idx], ygood[idx], maxfev=100000)
-
+
marr = np.linspace(13, 24, 1000)
-
+
# Corrected values
ygood_new = ygood - T_cte_y(mgood, *gpopt)
yref_new = yref - T_cte_y(mref, *gpopt)
-
+
agood = angle_from_xy(xgood, ygood) % 360
rgood = np.hypot(xgood, ygood)
aref = angle_from_xy(xref, yref) % 360
rref = np.hypot(xref, yref)
-
+
agood_new = angle_from_xy(xgood, ygood_new) % 360
rgood_new = np.hypot(xgood, ygood_new)
aref_new = angle_from_xy(xref, yref_new) % 360
rref_new = np.hypot(xref, yref_new)
-
- fig, ax = plt.subplots(4, 2, figsize=(12,12), sharex=True, sharey='row', num=105)
+
+ fig, ax = plt.subplots(4, 2, figsize=(12, 12), sharex=True, sharey='row', num=105)
plt.subplots_adjust(hspace=0.01, wspace=0.01)
ax[0,0].scatter(mgood, ygood, color='black', alpha=0.3, s=2)
ax[0,0].scatter(mref, yref, color='red', alpha=0.3, s=2)
@@ -1593,24 +1716,24 @@ def plot_y_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx, r
ax[0,0].axhline(y=0)
ax[0,0].plot(marr, T_cte_y(marr, *gpopt), 'k-')
ax[0,0].set_title('No correction')
-
+
ax[0,1].scatter(mgood, ygood_new, color='black', alpha=0.3, s=2)
ax[0,1].scatter(mref, yref_new, color='red', alpha=0.3, s=2)
ax[0,1].set_ylim(-0.01, 0.01)
ax[0,1].axhline(y=0)
ax[0,1].set_title('Corrected')
-
+
ax[1,0].scatter(mgood, ygood/yegood, color='black', alpha=0.3, s=2)
ax[1,0].scatter(mref, yref/yeref, color='red', alpha=0.3, s=2)
ax[1,0].set_ylabel('Res/Pos Err, y')
ax[1,0].set_ylim(-10, 10)
ax[1,0].axhline(y=0)
-
+
ax[1,1].scatter(mgood, ygood_new/yegood, color='black', alpha=0.3, s=2)
ax[1,1].scatter(mref, yref_new/yeref, color='red', alpha=0.3, s=2)
ax[1,1].set_ylim(-10, 10)
ax[1,1].axhline(y=0)
-
+
ax[2,0].scatter(mgood, rgood, color='black', alpha=0.3, s=2)
ax[2,0].scatter(mref, rref, color='red', alpha=0.3, s=2)
ax[2,0].set_ylabel('Modulus (arcsec)')
@@ -1619,7 +1742,7 @@ def plot_y_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx, r
ax[2,0].set_ylim(1e-6, 1.1 * np.max(np.concatenate([rgood.data, rref.data])))
else:
ax[2,0].set_ylim(1e-6, 1.1 * np.max(np.concatenate([rgood, rref])))
-
+
ax[2,1].scatter(mgood, rgood_new, color='black', alpha=0.3, s=2)
ax[2,1].scatter(mref, rref_new, color='red', alpha=0.3, s=2)
ax[2,1].set_yscale('log')
@@ -1627,16 +1750,19 @@ def plot_y_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx, r
ax[2,1].set_ylim(1e-6, 1.1 * np.max(np.concatenate([rgood_new.data, rref_new.data])))
else:
ax[2,1].set_ylim(1e-6, 1.1 * np.max(np.concatenate([rgood_new, rref_new])))
-
+
ax[3,0].scatter(mgood, agood, color='black', alpha=0.3, s=2)
ax[3,0].scatter(mref, aref, color='red', alpha=0.3, s=2)
ax[3,0].set_ylabel('Angle (deg)')
ax[3,0].set_xlabel('mag')
-
+
ax[3,1].scatter(mgood, agood_new, color='black', alpha=0.3, s=2)
ax[3,1].scatter(mref, aref_new, color='red', alpha=0.3, s=2)
ax[3,1].set_xlabel('mag')
+ plt.tight_layout()
+ plt.show()
+
if cte_fit=='power_line':
idx1 = np.where((mgood > 15) & (mgood < 18.5))[0]
idx2 = np.where(mgood > 18.5)[0]
@@ -1646,7 +1772,7 @@ def plot_y_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx, r
gpopt1, gpcov1 = curve_fit(T_line, mgood[idx1], ygood[idx1], maxfev=100000)
gpopt2, gpcov2 = curve_fit(T_cte_y, mgood[idx2], ygood[idx2], maxfev=100000)
-
+
marr1 = np.linspace(13, 18.5, 1000)
marr2 = np.linspace(18.5, 24, 1000)
@@ -1674,7 +1800,7 @@ def plot_y_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx, r
xeref2 = xeref[idx2r]
yeref1 = yeref[idx1r]
yeref2 = yeref[idx2r]
-
+
# Corrected values
ygood_new1 = ygood1 - T_line(mgood1, *gpopt1)
yref_new1 = yref1 - T_line(mref1, *gpopt1)
@@ -1700,8 +1826,8 @@ def plot_y_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx, r
rgood_new2 = np.hypot(xgood2, ygood_new2)
aref_new2 = angle_from_xy(xref2, yref_new2) % 360
rref_new2 = np.hypot(xref2, yref_new2)
-
- fig, ax = plt.subplots(4, 2, figsize=(12,12), sharex=True, sharey='row', num=105)
+
+ fig, ax = plt.subplots(4, 2, figsize=(12, 12), sharex=True, sharey='row', num=105)
plt.subplots_adjust(hspace=0.01, wspace=0.01)
ax[0,0].scatter(mgood, ygood, color='black', alpha=0.3, s=2)
ax[0,0].scatter(mref, yref, color='red', alpha=0.3, s=2)
@@ -1711,7 +1837,7 @@ def plot_y_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx, r
ax[0,0].plot(marr1, T_line(marr1, *gpopt1), 'b-')
ax[0,0].plot(marr2, T_cte_y(marr2, *gpopt2), 'b-')
ax[0,0].set_title('No correction')
-
+
ax[0,1].scatter(mgood1, ygood_new1, color='black', alpha=0.3, s=2)
ax[0,1].scatter(mref1, yref_new1, color='red', alpha=0.3, s=2)
ax[0,1].scatter(mgood2, ygood_new2, color='black', alpha=0.3, s=2)
@@ -1719,20 +1845,20 @@ def plot_y_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx, r
ax[0,1].set_ylim(-0.01, 0.01)
ax[0,1].axhline(y=0)
ax[0,1].set_title('Corrected')
-
+
ax[1,0].scatter(mgood, ygood/yegood, color='black', alpha=0.3, s=2)
ax[1,0].scatter(mref, yref/yeref, color='red', alpha=0.3, s=2)
ax[1,0].set_ylabel('Res/Pos Err, y')
ax[1,0].set_ylim(-10, 10)
ax[1,0].axhline(y=0)
-
+
ax[1,1].scatter(mgood1, ygood_new1/yegood1, color='black', alpha=0.3, s=2)
ax[1,1].scatter(mref1, yref_new1/yeref1, color='red', alpha=0.3, s=2)
ax[1,1].scatter(mgood2, ygood_new2/yegood2, color='black', alpha=0.3, s=2)
ax[1,1].scatter(mref2, yref_new2/yeref2, color='red', alpha=0.3, s=2)
ax[1,1].set_ylim(-10, 10)
ax[1,1].axhline(y=0)
-
+
ax[2,0].scatter(mgood, rgood, color='black', alpha=0.3, s=2)
ax[2,0].scatter(mref, rref, color='red', alpha=0.3, s=2)
ax[2,0].set_ylabel('Modulus (arcsec)')
@@ -1741,7 +1867,7 @@ def plot_y_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx, r
ax[2,0].set_ylim(1e-6, 1.1 * np.max(np.concatenate([rgood.data, rref.data])))
else:
ax[2,0].set_ylim(1e-6, 1.1 * np.max(np.concatenate([rgood, rref])))
-
+
ax[2,1].scatter(mgood1, rgood_new1, color='black', alpha=0.3, s=2)
ax[2,1].scatter(mref1, rref_new1, color='red', alpha=0.3, s=2)
ax[2,1].scatter(mgood2, rgood_new2, color='black', alpha=0.3, s=2)
@@ -1751,18 +1877,18 @@ def plot_y_scatter(m_t, m0, m0e, x_t, y_t, xe_t, ye_t, x_ref, y_ref, good_idx, r
ax[2,1].set_ylim(1e-6, 1.1 * np.max(np.concatenate([rgood_new.data2, rref_new.data2])))
else:
ax[2,1].set_ylim(1e-6, 1.1 * np.max(np.concatenate([rgood_new2, rref_new2])))
-
+
ax[3,0].scatter(mgood, agood, color='black', alpha=0.3, s=2)
ax[3,0].scatter(mref, aref, color='red', alpha=0.3, s=2)
ax[3,0].set_ylabel('Angle (deg)')
ax[3,0].set_xlabel('mag')
-
+
ax[3,1].scatter(mgood1, agood_new1, color='black', alpha=0.3, s=2)
ax[3,1].scatter(mref1, aref_new1, color='red', alpha=0.3, s=2)
ax[3,1].scatter(mgood2, agood_new2, color='black', alpha=0.3, s=2)
ax[3,1].scatter(mref2, aref_new2, color='red', alpha=0.3, s=2)
ax[3,1].set_xlabel('mag')
-
+
def T_cte_y(m, A, m0, alpha, m1):
base = m/m0
@@ -1772,16 +1898,16 @@ def T_line(m, a, b):
return a + m*b
-def plot_quiver_residuals(x_t, y_t, x_ref, y_ref, good_idx, ref_idx, title,
- unit='pixel', scale=None, plotlim=None):
+def plot_quiver_residuals(x_t, y_t, x_ref, y_ref, good_idx, ref_idx, title,
+ unit='pixel', scale=None, plotlim=None, save_path=None, show_plot=True):
"""
unit : str
'pixel' or 'arcsec'
The pixel units of the input values. Note, if arcsec, then the values will be
- converted to milli-arcsec for plotting when appropriate.
+ converted to milli-arcsec for plotting when appropriate.
scale : float
- The quiver scale. If none, then default units will be used appropriate to the unit.
+ The quiver scale. If none, then default units will be used appropriate to the unit.
plotlim : float (positive)
Sets the size of the plotted figure. If None, then default is used.
@@ -1810,33 +1936,37 @@ def plot_quiver_residuals(x_t, y_t, x_ref, y_ref, good_idx, ref_idx, title,
unit2 = 'mas'
- plt.figure(101, figsize=(6,6))
- plt.clf()
- q = plt.quiver(x_ref[good_idx], y_ref[good_idx], dx[good_idx], dy[good_idx],
+ fig, ax = plt.subplots(1, 1, figsize=(6, 6))
+ q = ax.quiver(x_ref[good_idx], y_ref[good_idx], dx[good_idx], dy[good_idx],
color='black', scale=quiv_scale, angles='xy', alpha=0.5)
- plt.quiver(x_ref[good_idx][ref_idx], y_ref[good_idx][ref_idx], dx[good_idx][ref_idx], dy[good_idx][ref_idx],
+ ax.quiver(x_ref[good_idx][ref_idx], y_ref[good_idx][ref_idx], dx[good_idx][ref_idx], dy[good_idx][ref_idx],
color='red', scale=quiv_scale, angles='xy')
- plt.quiverkey(q, 0.5, 0.85, quiv_label_val, quiv_label,
+ ax.quiverkey(q, 0.5, 0.85, quiv_label_val, quiv_label,
coordinates='figure', labelpos='E', color='green')
- plt.xlabel('X (ref ' + unit + ')')
- plt.ylabel('Y (ref ' + unit + ')')
- plt.title(title)
- plt.axis('equal')
+ ax.set_xlabel('X (ref ' + unit + ')')
+ ax.set_ylabel('Y (ref ' + unit + ')')
+ ax.set_title(title)
+ ax.axis('equal')
if plotlim is not None:
- plt.xlim(-1 * plotlim, plotlim)
- plt.ylim(-1 * plotlim, plotlim)
- plt.show()
- plt.pause(1)
+ ax.set_xlim(-1 * plotlim, plotlim)
+ ax.set_ylim(-1 * plotlim, plotlim)
+ plt.tight_layout()
+ if save_path:
+ plt.savefig(save_path, dpi=300)
+ if show_plot:
+ plt.show()
+ else:
+ plt.close()
- str_fmt = 'Residuals (mean, std): dx = {0:7.3f} +/- {1:7.3f} {5:s} dy = {2:7.3f} +/- {3:7.3f} {5:s} for {4:s} stars'
+ str_fmt = '{0:s}: Residuals (mean, std): dx = {1:7.3f} ± {2:7.3f} {6:s} dy = {3:7.3f} ± {4:7.3f} {6:s} for {5:s} stars'
if len(ref_idx) > 1:
- print(str_fmt.format(dx[good_idx][ref_idx].mean(), dx[good_idx][ref_idx].std(),
+ print(str_fmt.format(title, dx[good_idx][ref_idx].mean(), dx[good_idx][ref_idx].std(),
dy[good_idx][ref_idx].mean(), dy[good_idx][ref_idx].std(), 'REF', unit2))
else:
- print(str_fmt.format(dx[good_idx][ref_idx].mean(), 0.0,
+ print(str_fmt.format(title, dx[good_idx][ref_idx].mean(), 0.0,
dy[good_idx][ref_idx].mean(), 0.0, 'REF', unit2))
-
- print(str_fmt.format(dx[good_idx].mean(), dx[good_idx].std(),
+
+ print(str_fmt.format(title, dx[good_idx].mean(), dx[good_idx].std(),
dy[good_idx].mean(), dy[good_idx].std(), 'GOOD', unit2))
@@ -1849,23 +1979,27 @@ def plot_quiver_residuals_magcolor_all_epochs(tab, unit='arcsec', scale=None, pl
dr_ref = np.zeros(len(tab), dtype=float)
n_ref = np.zeros(len(tab), dtype=int)
- idx = np.where((tab['m0'] < lower_mag) &
+ idx = np.where((tab['m0'] < lower_mag) &
(tab['m0'] > upper_mag))[0]
tab = tab[idx]
+ # motion_model_dict = motion_model.validate_motion_model_dict(motion_model_dict, tab, None)
+ i_all_detected = np.where(~np.any(np.isnan(tab['t']),axis=1))[0][0]
+ # xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.get_star_positions_at_time(tab['t'][i_all_detected], motion_model_dict, allow_alt_models=True)
+ xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.infer_positions(tab['t'][i_all_detected])
for ee in range(tab['x'].shape[1]):
dt = tab['t'][:, ee] - tab['t0']
- xt_mod = tab['x0'] + tab['vx'] * dt
- yt_mod = tab['y0'] + tab['vy'] * dt
+ xt_mod = xt_mod_all[ee]
+ yt_mod = yt_mod_all[ee]
mag = tab['m0']
good_idx = np.where(np.isfinite(tab['x'][:, ee]) == True)[0]
ref_idx = np.where(tab[good_idx]['used_in_trans'][:, ee] == True)[0]
- dx, dy = plot_quiver_residuals_magcolor(tab['x'][:, ee], tab['y'][:, ee],
+ dx, dy = plot_quiver_residuals_magcolor(tab['x'][:, ee], tab['y'][:, ee],
xt_mod, yt_mod, mag,
good_idx, ref_idx,
- 'Epoch {0:d}'.format(ee),
+ 'Epoch {0:d}'.format(ee),
unit=unit, scale=scale, plotlim=plotlim)
# Building up average dr for a set of stars.
@@ -1880,7 +2014,7 @@ def plot_quiver_residuals_magcolor_all_epochs(tab, unit='arcsec', scale=None, pl
dr_good_avg = np.zeros(len(tab), dtype=float)
idx = np.where(n_good > 0)[0]
dr_good_avg[idx] = dr_good[idx] / n_good[idx]
-
+
dr_ref_avg = np.zeros(len(tab), dtype=float)
idx = np.where(n_ref > 0)[0]
dr_ref_avg[idx] = dr_ref[idx] / n_ref[idx]
@@ -1890,16 +2024,16 @@ def plot_quiver_residuals_magcolor_all_epochs(tab, unit='arcsec', scale=None, pl
-def plot_quiver_residuals_magcolor(x_t, y_t, x_ref, y_ref, mag, good_idx, ref_idx, title,
+def plot_quiver_residuals_magcolor(x_t, y_t, x_ref, y_ref, mag, good_idx, ref_idx, title,
unit='pixel', scale=None, plotlim=None):
"""
unit : str
'pixel' or 'arcsec'
The pixel units of the input values. Note, if arcsec, then the values will be
- converted to milli-arcsec for plotting when appropriate.
+ converted to milli-arcsec for plotting when appropriate.
scale : float
- The quiver scale. If none, then default units will be used appropriate to the unit.
+ The quiver scale. If none, then default units will be used appropriate to the unit.
plotlim : float (positive)
Sets the size of the plotted figure. If None, then default is used.
@@ -1927,51 +2061,48 @@ def plot_quiver_residuals_magcolor(x_t, y_t, x_ref, y_ref, mag, good_idx, ref_id
quiv_label_val = 1.0
unit2 = 'mas'
- norm = matplotlib.colors.Normalize()
+ norm = mcolors.Normalize()
norm.autoscale(mag)
- cm = matplotlib.cm.viridis
- sm = matplotlib.cm.ScalarMappable(cmap=cm, norm=norm)
+ cmap = matplotlib.colormaps['viridis']
+ sm = matplotlib.cm.ScalarMappable(cmap=cmap, norm=norm)
# cmap = mpl.cm.cool
-# norm = mpl.colors.Normalize(vmin=np.min(mag), vmax=np.max(mag))
-#
+# norm = mpl.mcolors.Normalize(vmin=np.min(mag), vmax=np.max(mag))
+#
# cb1 = mpl.colorbar.ColorbarBase(ax, cmap=cmap,
# norm=norm,
# orientation='horizontal')
- plt.figure(101, figsize=(6,6))
- plt.clf()
- q = plt.quiver(x_ref[good_idx], y_ref[good_idx], dx[good_idx], dy[good_idx],
+ fig, ax=plt.subplots(1, 1, figsize=(6, 6))
+ q = ax.quiver(x_ref[good_idx], y_ref[good_idx], dx[good_idx], dy[good_idx],
color=cm(norm(mag[good_idx])), scale=quiv_scale, angles='xy', alpha=0.8)
- plt.quiverkey(q, 0.5, 0.85, quiv_label_val, quiv_label,
+ ax.quiverkey(q, 0.5, 0.85, quiv_label_val, quiv_label,
coordinates='figure', labelpos='E', color='green')
- plt.colorbar(sm)
- plt.xlabel('X (ref ' + unit + ')')
- plt.ylabel('Y (ref ' + unit + ')')
- plt.title(title + ', Good')
- plt.axis('equal')
+ fig.colorbar(sm, ax=ax)
+ ax.set_xlabel('X (ref ' + unit + ')')
+ ax.set_ylabel('Y (ref ' + unit + ')')
+ ax.set_title(title + ', Good')
+ ax.axis('equal')
if plotlim is not None:
- plt.xlim(-1 * plotlim, plotlim)
- plt.ylim(-1 * plotlim, plotlim)
+ ax.set_xlim(-1 * plotlim, plotlim)
+ ax.set_ylim(-1 * plotlim, plotlim)
+ plt.tight_layout()
plt.show()
- plt.pause(1)
- plt.figure(102, figsize=(6,6))
- plt.clf()
- q = plt.quiver(x_ref[good_idx][ref_idx], y_ref[good_idx][ref_idx], dx[good_idx][ref_idx], dy[good_idx][ref_idx],
+ fig, ax = plt.subplots(1, 1, figsize=(6, 6))
+ q = ax.quiver(x_ref[good_idx][ref_idx], y_ref[good_idx][ref_idx], dx[good_idx][ref_idx], dy[good_idx][ref_idx],
color=cm(norm(mag[good_idx][ref_idx])), scale=quiv_scale, angles='xy', alpha=0.8)
- plt.quiverkey(q, 0.5, 0.85, quiv_label_val, quiv_label,
+ ax.quiverkey(q, 0.5, 0.85, quiv_label_val, quiv_label,
coordinates='figure', labelpos='E', color='green')
- plt.colorbar(sm)
- plt.xlabel('X (ref ' + unit + ')')
- plt.ylabel('Y (ref ' + unit + ')')
- plt.title(title + ', Ref')
- plt.axis('equal')
+ fig.colorbar(sm, ax=ax)
+ ax.set_xlabel('X (ref ' + unit + ')')
+ ax.set_ylabel('Y (ref ' + unit + ')')
+ ax.set_title(title + ', Ref')
+ ax.axis('equal')
if plotlim is not None:
- plt.xlim(-1 * plotlim, plotlim)
- plt.ylim(-1 * plotlim, plotlim)
+ ax.set_xlim(-1 * plotlim, plotlim)
+ ax.set_ylim(-1 * plotlim, plotlim)
plt.show()
- plt.pause(1)
str_fmt = 'Residuals (mean, std): dx = {0:7.3f} +/- {1:7.3f} {5:s} dy = {2:7.3f} +/- {3:7.3f} {5:s} for {4:s} stars'
if len(ref_idx) > 1:
@@ -1980,7 +2111,7 @@ def plot_quiver_residuals_magcolor(x_t, y_t, x_ref, y_ref, mag, good_idx, ref_id
else:
print(str_fmt.format(dx[good_idx][ref_idx].mean(), 0.0,
dy[good_idx][ref_idx].mean(), 0.0, 'REF', unit2))
-
+
print(str_fmt.format(dx[good_idx].mean(), dx[good_idx].std(),
dy[good_idx].mean(), dy[good_idx].std(), 'GOOD', unit2))
@@ -1988,17 +2119,17 @@ def plot_quiver_residuals_magcolor(x_t, y_t, x_ref, y_ref, mag, good_idx, ref_id
return (dx, dy)
-def plot_quiver_residuals_orig(x_t, y_t, x_ref, y_ref, good_idx, ref_idx,
- x_orig, y_orig, da, title,
- scale=None, plotlim=None):
+def plot_quiver_residuals_orig(x_t, y_t, x_ref, y_ref, good_idx, ref_idx,
+ x_orig, y_orig, da, title,
+ scale=None, plotlim=None, save_path=None):
"""
unit : str
'pixel' or 'arcsec'
The pixel units of the input values. Note, if arcsec, then the values will be
- converted to milli-arcsec for plotting when appropriate.
+ converted to milli-arcsec for plotting when appropriate.
scale : float
- The quiver scale. If none, then default units will be used appropriate to the unit.
+ The quiver scale. If none, then default units will be used appropriate to the unit.
plotlim : float (positive)
Sets the size of the plotted figure. If None, then default is used.
@@ -2013,8 +2144,8 @@ def plot_quiver_residuals_orig(x_t, y_t, x_ref, y_ref, good_idx, ref_idx,
dy /= 0.04
# Residual modulus
- r_good = np.hypot(dx[good_idx], dy[good_idx])
- r_ref = np.hypot(dx[good_idx][ref_idx], dy[good_idx][ref_idx])
+ # r_good = np.hypot(dx[good_idx], dy[good_idx])
+ # r_ref = np.hypot(dx[good_idx][ref_idx], dy[good_idx][ref_idx])
# Residual angle
agood = angle_from_xy(dx[good_idx], dy[good_idx])
@@ -2030,21 +2161,23 @@ def plot_quiver_residuals_orig(x_t, y_t, x_ref, y_ref, good_idx, ref_idx,
dx_ref_new, dy_ref_new = rotate(dx[good_idx][ref_idx], dy[good_idx][ref_idx], -da)
print('Rotation angle between HST and Gaia (deg): ', da)
- plt.figure(102, figsize=(6,6))
- plt.clf()
- q = plt.quiver(x_orig[good_idx], y_orig[good_idx], dx_good_new, dy_good_new,
+ fig, ax = plt.subplots(1, 1, figsize=(6, 6))
+ q = ax.quiver(x_orig[good_idx], y_orig[good_idx], dx_good_new, dy_good_new,
color='black', scale=scale, angles='xy', alpha=0.5)
- plt.quiver(x_orig[good_idx][ref_idx], y_orig[good_idx][ref_idx], dx_ref_new, dy_ref_new,
+ ax.quiver(x_orig[good_idx][ref_idx], y_orig[good_idx][ref_idx], dx_ref_new, dy_ref_new,
color='red', scale=scale, angles='xy')
- plt.quiverkey(q, 0.5, 0.85, 0.3, '0.3 pix',
+ ax.quiverkey(q, 0.5, 0.85, 0.3, '0.3 pix',
coordinates='figure', labelpos='E', color='green')
- plt.xlabel('X (ref pix)')
- plt.ylabel('Y (ref pix)')
- plt.title(title)
- plt.axis('equal')
+ ax.set_xlabel('X (ref pix)')
+ ax.set_ylabel('Y (ref pix)')
+ ax.set_title(title)
+ ax.axis('equal')
if plotlim is not None:
- plt.xlim(-1 * plotlim, plotlim)
- plt.ylim(-1 * plotlim, plotlim)
+ ax.set_xlim(-1 * plotlim, plotlim)
+ ax.set_ylim(-1 * plotlim, plotlim)
+ plt.tight_layout()
+ if save_path:
+ plt.savefig(save_path, dpi=300)
plt.show()
plt.pause(1)
@@ -2058,11 +2191,11 @@ def plot_quiver_residuals_orig(x_t, y_t, x_ref, y_ref, good_idx, ref_idx,
# ax1.hist(aref ,color='red', histtype = 'step',
# alpha=0.8, bins = 36, density=True)
# ax1.set_xlabel('Quiver angle (degrees), HST camera')
-#
-# ax2.scatter(x_orig[good_idx], y_orig[good_idx],
+#
+# ax2.scatter(x_orig[good_idx], y_orig[good_idx],
# s=5e3 * r_good**2, alpha=0.3, color='black')
-# ax2.scatter(x_orig[good_idx][ref_idx], y_orig[good_idx][ref_idx],
-# s=5e3 * r_ref**2, alpha=0.5, color='red')
+# ax2.scatter(x_orig[good_idx][ref_idx], y_orig[good_idx][ref_idx],
+# s=5e3 * r_ref**2, alpha=0.5, color='red')
# ax2.set_xlabel('X (orig pix)')
# ax2.set_ylabel('Y (orig pix)')
# plt.title(title)
@@ -2088,16 +2221,16 @@ def rotate(x, y, theta):
return xnew, ynew
-def plot_quiver_residuals_orig_angle_xy(x_t, y_t, x_ref, y_ref, good_idx, ref_idx,
+def plot_quiver_residuals_orig_angle_xy(x_t, y_t, x_ref, y_ref, good_idx, ref_idx,
x_orig, y_orig, da, title, scale=None, plotlim=None):
"""
unit : str
'pixel' or 'arcsec'
The pixel units of the input values. Note, if arcsec, then the values will be
- converted to milli-arcsec for plotting when appropriate.
+ converted to milli-arcsec for plotting when appropriate.
scale : float
- The quiver scale. If none, then default units will be used appropriate to the unit.
+ The quiver scale. If none, then default units will be used appropriate to the unit.
plotlim : float (positive)
Sets the size of the plotted figure. If None, then default is used.
@@ -2105,7 +2238,7 @@ def plot_quiver_residuals_orig_angle_xy(x_t, y_t, x_ref, y_ref, good_idx, ref_id
"""
dx = (x_t - x_ref)
dy = (y_t - y_ref)
-
+
# Residual modulus
r_good = np.hypot(dx[good_idx], dy[good_idx])
r_ref = np.hypot(dx[good_idx][ref_idx], dy[good_idx][ref_idx])
@@ -2120,13 +2253,13 @@ def plot_quiver_residuals_orig_angle_xy(x_t, y_t, x_ref, y_ref, good_idx, ref_id
agood = agood % 360
aref = aref % 360
- plt.figure(figsize=(14,6))
- plt.clf()
- ax1 = plt.subplot(1, 2, 1)
- ax2 = plt.subplot(1, 2, 2)
- plt.subplots_adjust(wspace=0.3)
+ # plt.figure(figsize=(12,6))
+ # plt.clf()
+ # ax1 = plt.subplot(1, 2, 1)
+ # ax2 = plt.subplot(1, 2, 2)
+ # plt.subplots_adjust(wspace=0.3)
- plt.clf()
+ # plt.clf()
fig, ax = plt.subplots(1, 2, figsize=(12,6), sharey=True)
# plt.clf()
plt.subplots_adjust(wspace=0.01)
@@ -2143,13 +2276,14 @@ def plot_quiver_residuals_orig_angle_xy(x_t, y_t, x_ref, y_ref, good_idx, ref_id
if plotlim is not None:
plt.xlim(-1 * plotlim, plotlim)
plt.ylim(-1 * plotlim, plotlim)
+ plt.tight_layout()
plt.show()
plt.pause(1)
return
-def plot_chi2_dist(tab, Ndetect, xlim=40, n_bins=50):
+def plot_chi2_dist(tab, Ndetect, xlim=40, n_bins=50, boot_err=False):
"""
tab = flystar table
Ndetect = Number of epochs star detected in
@@ -2158,26 +2292,33 @@ def plot_chi2_dist(tab, Ndetect, xlim=40, n_bins=50):
chi2_y_list = []
fnd_list = [] # Number of non-NaN error measurements
+ # motion_model_dict = motion_model.validate_motion_model_dict(motion_model_dict, tab, None)
+ i_all_detected = np.where(~np.any(np.isnan(tab['t']),axis=1))[0][0]
+ # xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.get_star_positions_at_time(tab['t'][i_all_detected], motion_model_dict, allow_alt_models=True)
+ xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.infer_positions(tab['t'][i_all_detected])
+
for ii in range(len(tab)):
- # Ignore the NaNs
+ # Ignore the NaNs
fnd = np.argwhere(~np.isnan(tab['xe'][ii,:]))
-# fnd = np.where(tab['xe'][ii, :] > 0)[0]
fnd_list.append(len(fnd))
-
+
x = tab['x'][ii, fnd]
y = tab['y'][ii, fnd]
- xerr = tab['xe'][ii, fnd]
- yerr = tab['ye'][ii, fnd]
+ if boot_err:
+ xerr = np.hypot(tab['xe_boot'][ii, fnd], tab['xe'][ii, fnd])
+ yerr = np.hypot(tab['ye_boot'][ii, fnd], tab['ye'][ii, fnd])
+ else:
+ xerr = tab['xe'][ii, fnd]
+ yerr = tab['ye'][ii, fnd]
- dt = tab['t'][ii, fnd] - tab['t0'][ii]
- fitLineX = tab['x0'][ii] + (tab['vx'][ii] * dt)
- fitLineY = tab['y0'][ii] + (tab['vy'][ii] * dt)
+ fitLineX = xt_mod_all[ii, fnd]
+ fitLineY = yt_mod_all[ii,fnd]
diffX = x - fitLineX
diffY = y - fitLineY
sigX = diffX / xerr
sigY = diffY / yerr
-
+
chi2_x = np.sum(sigX**2)
chi2_y = np.sum(sigY**2)
chi2_x_list.append(chi2_x)
@@ -2186,27 +2327,36 @@ def plot_chi2_dist(tab, Ndetect, xlim=40, n_bins=50):
x = np.array(chi2_x_list)
y = np.array(chi2_y_list)
fnd = np.array(fnd_list)
-
+
idx = np.where(fnd == Ndetect)[0]
# Fitting position and velocity... so subtract 2 to get Ndof
- Ndof = Ndetect - 2
+ n_params = np.nanmean(tab['n_params'][idx])
+ Ndof = Ndetect - n_params
+ if len(np.unique(tab['n_params'][idx]))>1:
+ print("** Warning: using average Ndof for multiple motion models. **")
+ print("** Consider using plot_chi2_reduced_dist. **")
+ print(f"Ndof={Ndof:.2f}, Ndetect={Ndetect}, Nparams={n_params:.2f}")
+ else:
+ print(f"Ndof={Ndof}, Ndetect={Ndetect}, Nparams={n_params}")
chi2_xaxis = np.linspace(0, xlim, xlim*3)
chi2_bins = np.linspace(0, xlim, n_bins)
- plt.figure(figsize=(6,4))
+ plt.figure(figsize=(6, 4))
plt.clf()
plt.hist(x[idx], bins=chi2_bins, histtype='step', label='X', density=True)
plt.hist(y[idx], bins=chi2_bins, histtype='step', label='Y', density=True)
- plt.plot(chi2_xaxis, chi2.pdf(chi2_xaxis, Ndof), 'r-', alpha=0.6,
- label='$\chi^2$ ' + str(Ndof) + ' dof')
- plt.title('$N_{epoch} = $' + str(Ndetect) + ', $N_{dof} = $' + str(Ndof))
+ plt.plot(chi2_xaxis, chi2.pdf(chi2_xaxis, Ndof), 'r-', alpha=0.6,
+ label=r'$\chi^2$ ' + str(round(Ndof,2)) + ' dof')
+ plt.title('$N_{epoch} = $' + str(Ndetect) + ', $N_{dof} = $' + str(round(Ndof,2)))
plt.xlim(0, xlim)
plt.legend()
+ plt.tight_layout()
+ plt.show()
+
+ chi2red_x = x / Ndof
+ chi2red_y = y / Ndof
+ chi2red_t = (x + y) / (2.0 * Ndof)
- chi2red_x = x / (fnd - 2)
- chi2red_y = y / (fnd - 2)
- chi2red_t = (x + y) / (2.0 * (fnd - 2))
-
print('Mean reduced chi^2: (Ndetect = {0:d} of {1:d})'.format(len(idx), len(tab)))
fmt = ' {0:s} = {1:.1f} for N_detect and {2:.1f} for all'
med_chi2red_x_f = np.median(chi2red_x[idx])
@@ -2221,36 +2371,216 @@ def plot_chi2_dist(tab, Ndetect, xlim=40, n_bins=50):
return
+def plot_chi2_reduced_dist(tab, Ndetect, xlim=8, n_bins=50, boot_err=False):
+ """
+ tab = flystar table
+ Ndetect = Number of epochs star detected in
+ """
+ chi2_x_list = []
+ chi2_y_list = []
+ fnd_list = [] # Number of non-NaN error measurements
+
+ # motion_model_dict = motion_model.validate_motion_model_dict(motion_model_dict, tab, None)
+ i_all_detected = np.where(~np.any(np.isnan(tab['t']),axis=1))[0][0]
+ # xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.get_star_positions_at_time(tab['t'][i_all_detected], motion_model_dict, allow_alt_models=True)
+ xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.infer_positions(tab['t'][i_all_detected])
+
+ for ii in range(len(tab)):
+ # Ignore the NaNs
+ fnd = np.argwhere(~np.isnan(tab['xe'][ii,:]))
+ fnd_list.append(len(fnd))
+
+ x = tab['x'][ii, fnd]
+ y = tab['y'][ii, fnd]
+ if boot_err:
+ xerr = np.hypot(tab['xe_boot'][ii, fnd], tab['xe'][ii, fnd])
+ yerr = np.hypot(tab['ye_boot'][ii, fnd], tab['ye'][ii, fnd])
+ else:
+ xerr = tab['xe'][ii, fnd]
+ yerr = tab['ye'][ii, fnd]
+
+ fitLineX = xt_mod_all[ii, fnd]
+ fitLineY = yt_mod_all[ii,fnd]
-def plot_chi2_dist_per_epoch(tab, Ndetect, xlim, ylim = [-1, 1], target_idx = 0):
+ diffX = x - fitLineX
+ diffY = y - fitLineY
+ sigX = diffX / xerr
+ sigY = diffY / yerr
+
+ chi2_x = np.sum(sigX**2)
+ chi2_y = np.sum(sigY**2)
+ chi2_x_list.append(chi2_x)
+ chi2_y_list.append(chi2_y)
+
+ x = np.array(chi2_x_list)
+ y = np.array(chi2_y_list)
+ fnd = np.array(fnd_list)
+
+ idx = np.where(fnd == Ndetect)[0]
+ n_params = tab['n_params']
+ Ndof = Ndetect - n_params
+ print("Reduced chi2 for Ndetect="+str(Ndetect))
+ chi2_bins = np.linspace(0, xlim, n_bins)
+
+ plt.figure(figsize=(6, 4))
+ plt.clf()
+ plt.hist(x[idx]/Ndof[idx], bins=chi2_bins, histtype='step', label='X', density=True)
+ plt.hist(y[idx]/Ndof[idx], bins=chi2_bins, histtype='step', label='Y', density=True)
+ plt.axvline(np.median(x[idx]/Ndof[idx]), color='C0', linestyle='--', label='X median')
+ plt.axvline(np.median(y[idx]/Ndof[idx]), color='C1', linestyle='--', label='Y median')
+ plt.title('Reduced chi2, $N_{epoch} = $' + str(Ndetect))
+ plt.xlim(0, xlim)
+ plt.legend()
+ plt.tight_layout()
+ plt.show()
+
+ chi2red_x = x / Ndof
+ chi2red_y = y / Ndof
+ chi2red_t = (x + y) / (2.0 * Ndof + 1*(tab['motion_model_used']=='Parallax'))
+
+ print('Mean reduced chi^2: (Ndetect = {0:d} of {1:d})'.format(len(idx), len(tab)))
+ fmt = ' {0:s} = {1:.1f} for N_detect and {2:.1f} for all'
+ med_chi2red_x_f = np.median(chi2red_x[idx])
+ med_chi2red_x_a = np.median(chi2red_x)
+ med_chi2red_y_f = np.median(chi2red_y[idx])
+ med_chi2red_y_a = np.median(chi2red_y)
+ med_chi2red_t_f = np.median(chi2red_t[idx])
+ med_chi2red_t_a = np.median(chi2red_t)
+ print(fmt.format(' X', med_chi2red_x_f, med_chi2red_x_a))
+ print(fmt.format(' Y', med_chi2red_y_f, med_chi2red_y_a))
+ print(fmt.format('Tot', med_chi2red_t_f, med_chi2red_t_a))
+
+ return
+
+
+def plot_chi2_dist_per_filter(tab, Ndetect, xlim=40, n_bins=50, filter=None, boot_err=False):
"""
tab = flystar table
Ndetect = Number of epochs star detected in
"""
- diffX_arr = -99 * np.ones((len(tab['xe']), Ndetect))
- diffY_arr = -99 * np.ones((len(tab['xe']), Ndetect))
- errX_arr = -99 * np.ones((len(tab['xe']), Ndetect))
- errY_arr = -99 * np.ones((len(tab['xe']), Ndetect))
- sigX_arr = -99 * np.ones((len(tab['xe']), Ndetect))
- sigY_arr = -99 * np.ones((len(tab['xe']), Ndetect))
- m_arr = -99 * np.ones((len(tab['xe']), Ndetect))
+ chi2_x_list = []
+ chi2_y_list = []
+ fnd_list = [] # Number of non-NaN error measurements
+
+ # motion_model_dict = motion_model.validate_motion_model_dict(motion_model_dict, tab, None)
+ i_all_detected = np.where(~np.any(np.isnan(tab['t']),axis=1))[0][0]
+ # xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.get_star_positions_at_time(tab['t'][i_all_detected], motion_model_dict, allow_alt_models=True)
+ xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.infer_positions(tab['t'][i_all_detected])
+
+ for ii in range(len(tab)):
+ # Ignore the NaNs
+ fnd = np.argwhere(~np.isnan(tab['xe'][ii,:]))
+ fnd_list.append(len(fnd))
+
+ x = tab['x'][ii, fnd]
+ y = tab['y'][ii, fnd]
+ if boot_err:
+ xerr = np.hypot(tab['xe_boot'][ii, fnd], tab['xe'][ii, fnd])
+ yerr = np.hypot(tab['ye_boot'][ii, fnd], tab['ye'][ii, fnd])
+ else:
+ xerr = tab['xe'][ii, fnd]
+ yerr = tab['ye'][ii, fnd]
+
+ fitLineX = xt_mod_all[ii, fnd]
+ fitLineY = yt_mod_all[ii,fnd]
+
+ diffX = x - fitLineX
+ diffY = y - fitLineY
+ sigX = diffX / xerr
+ sigY = diffY / yerr
+
+ chi2_x = np.sum(sigX**2)
+ chi2_y = np.sum(sigY**2)
+ chi2_x_list.append(chi2_x)
+ chi2_y_list.append(chi2_y)
+ #print(fitLineX, x, xerr)
+
+ x = np.array(chi2_x_list)
+ y = np.array(chi2_y_list)
+ fnd = np.array(fnd_list)
+
+
+ idx = np.where(fnd == Ndetect)[0]
+ # Fitting position and velocity... so subtract n_params to get Ndof
+ n_params = np.nanmean(tab['n_params'][idx])
+ Ndof = Ndetect - n_params
+ print(f"Ndof={Ndof}, Ndetect={Ndetect}, Nparams={n_params}")
+ chi2_xaxis = np.linspace(0, xlim, xlim*3)
+ chi2_bins = np.linspace(0, xlim, n_bins)
+ print(x[idx])
+
+ plt.figure(figsize=(6, 4))
+ plt.clf()
+ plt.hist(x[idx], bins=chi2_bins, histtype='stepfilled', label='RA', density=True, color='skyblue', alpha=0.8, edgecolor='k')
+ plt.hist(y[idx], bins=chi2_bins, histtype='stepfilled', label='DEC', density=True, color='orange', alpha=0.8, edgecolor='k')
+ plt.plot(chi2_xaxis, chi2.pdf(chi2_xaxis, Ndof), 'r-', alpha=0.6,
+ label=r'$\chi^2$ ' + str(Ndof) + ' dof')
+ #plt.title('$N_{epoch} = $' + str(Ndetect) + ', $N_{dof} = $' + str(Ndof))
+ plt.title(str(filter)+' (N = '+str(len(chi2_x_list))+')', fontsize=22)
+ plt.xlim(0, xlim)
+ plt.ylabel(r'PDF', fontsize=28)
+ plt.legend(fontsize=20)
+ plt.tick_params(labelsize=20, direction='in', right=True, top=True)
+ plt.tight_layout()
+ plt.savefig(str(filter)+'_chi2_dist.png', dpi=300)
+ plt.close()
+
+ chi2red_x = x / Ndof
+ chi2red_y = y / Ndof
+ chi2red_t = (x + y) / (2.0 * Ndof)
+
+ print('Mean reduced chi^2: (Ndetect = {0:d} of {1:d})'.format(len(idx), len(tab)))
+ fmt = ' {0:s} = {1:.1f} for N_detect and {2:.1f} for all'
+ med_chi2red_x_f = np.median(chi2red_x[idx])
+ med_chi2red_x_a = np.median(chi2red_x)
+ med_chi2red_y_f = np.median(chi2red_y[idx])
+ med_chi2red_y_a = np.median(chi2red_y)
+ med_chi2red_t_f = np.median(chi2red_t[idx])
+ med_chi2red_t_a = np.median(chi2red_t)
+ print(fmt.format(' X', med_chi2red_x_f, med_chi2red_x_a))
+ print(fmt.format(' Y', med_chi2red_y_f, med_chi2red_y_a))
+ print(fmt.format('Tot', med_chi2red_t_f, med_chi2red_t_a))
+
+ return
+
+
+def plot_chi2_dist_per_epoch(tab, Ndetect, mlim=[14, 21], ylim=[-1, 1], target_idx=0, boot_err=False):
+ """
+ tab = flystar table
+ Ndetect = Number of epochs star detected in
+ """
+ diffX_arr = np.nan * np.ones((len(tab['xe']), Ndetect))
+ diffY_arr = np.nan * np.ones((len(tab['xe']), Ndetect))
+ errX_arr = np.nan * np.ones((len(tab['xe']), Ndetect))
+ errY_arr = np.nan * np.ones((len(tab['xe']), Ndetect))
+ sigX_arr = np.nan * np.ones((len(tab['xe']), Ndetect))
+ sigY_arr = np.nan * np.ones((len(tab['xe']), Ndetect))
+ m_arr = np.nan * np.ones((len(tab['xe']), Ndetect))
+
+ # motion_model_dict = motion_model.validate_motion_model_dict(motion_model_dict, tab, None)
+ i_all_detected = np.where(~np.any(np.isnan(tab['t']),axis=1))[0][0]
+ # xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.get_star_positions_at_time(tab['t'][i_all_detected], motion_model_dict, allow_alt_models=True)
+ xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.infer_positions(tab['t'][i_all_detected])
for ii in range(len(tab['xe'])):
- # Ignore the NaNs
+ # Ignore the NaNs
fnd = np.argwhere(~np.isnan(tab['xe'][ii,:]))
- if len(fnd) == Ndetect:
+ if len(fnd) == Ndetect and tab['use_in_trans'][ii]:
time = tab['t'][ii, fnd]
x = tab['x'][ii, fnd]
y = tab['y'][ii, fnd]
m = tab['m'][ii, fnd]
- xerr = tab['xe'][ii, fnd]
- yerr = tab['ye'][ii, fnd]
+ if boot_err:
+ xerr = np.hypot(tab['xe_boot'][ii, fnd], tab['xe'][ii, fnd])
+ yerr = np.hypot(tab['ye_boot'][ii, fnd], tab['ye'][ii, fnd])
+ else:
+ xerr = tab['xe'][ii, fnd]
+ yerr = tab['ye'][ii, fnd]
+
+ fitLineX = xt_mod_all[ii, fnd]
+ fitLineY = yt_mod_all[ii, fnd]
- dt = tab['t'][ii, fnd] - tab['t0'][ii]
- fitLineX = tab['x0'][ii] + (tab['vx'][ii] * dt)
- fitLineY = tab['y0'][ii] + (tab['vy'][ii] * dt)
-
diffX = x - fitLineX
diffY = y - fitLineY
sigX = diffX / xerr
@@ -2259,7 +2589,7 @@ def plot_chi2_dist_per_epoch(tab, Ndetect, xlim, ylim = [-1, 1], target_idx = 0)
diffX_arr[ii] = diffX.reshape(Ndetect,)
diffY_arr[ii] = diffY.reshape(Ndetect,)
errX_arr[ii] = xerr.reshape(Ndetect,)
- errY_arr[ii] = yerr.reshape(Ndetect,)
+ errY_arr[ii] = yerr.reshape(Ndetect,)
sigX_arr[ii] = sigX.reshape(Ndetect,)
sigY_arr[ii] = sigY.reshape(Ndetect,)
m_arr[ii] = m.reshape(Ndetect,)
@@ -2281,32 +2611,157 @@ def plot_chi2_dist_per_epoch(tab, Ndetect, xlim, ylim = [-1, 1], target_idx = 0)
if target_idx is not None:
ax2.plot(m_arr[target_idx, ii], sigX_arr[target_idx, ii], 's', color='black', ms=5)
ax2.plot(m_arr[target_idx, ii], sigY_arr[target_idx, ii], 'o', color='black', ms=5)
- ax2.set_xlim(xlim[0], xlim[1])
+ ax2.set_xlim(mlim[0], mlim[1])
ax2.set_ylim(-5, 5)
ax2.axhline(y=0, color='black', alpha=0.9, zorder=1000)
+ ax2.axhline(y=np.nanmean(sigX_arr[:, ii]), color='tab:blue', alpha=0.9,linestyle='dotted', zorder=1001)
+ ax2.axhline(y=np.nanmean(sigY_arr[:, ii]), color='tab:orange', alpha=0.9,linestyle='dotted', zorder=1002)
ax2.set_xlabel('mag')
ax2.set_ylabel('sigma')
ax2.set_title('Epoch {0}'.format(ii))
ax2.legend()
- ax3.errorbar(m_arr[:, ii], diffX_arr[:, ii]*1E3, yerr=errX_arr[:, ii]*1E3,
+ #print(errX_arr[:, ii])
+ ax3.errorbar(m_arr[:, ii], diffX_arr[:, ii]*1E3, yerr=errX_arr[:, ii]*1E3,
marker='s', label = 'X', ls='none', color='tab:blue', alpha=0.4, ms=5)
- ax3.errorbar(m_arr[:, ii], diffY_arr[:, ii]*1E3, yerr=errY_arr[:, ii]*1E3,
+ ax3.errorbar(m_arr[:, ii], diffY_arr[:, ii]*1E3, yerr=errY_arr[:, ii]*1E3,
marker='o', label = 'Y', ls='none', color='tab:orange', alpha=0.4, ms=5)
if target_idx is not None:
- ax3.errorbar(m_arr[target_idx, ii], diffX_arr[target_idx, ii]*1E3, yerr=errX_arr[target_idx, ii]*1E3,
+ ax3.errorbar(m_arr[target_idx, ii], diffX_arr[target_idx, ii]*1E3, yerr=errX_arr[target_idx, ii]*1E3,
marker='s', ls='none', color='black', ms=5)
- ax3.errorbar(m_arr[target_idx, ii], diffY_arr[target_idx, ii]*1E3, yerr=errY_arr[target_idx, ii]*1E3,
+ ax3.errorbar(m_arr[target_idx, ii], diffY_arr[target_idx, ii]*1E3, yerr=errY_arr[target_idx, ii]*1E3,
marker='o', ls='none', color='black', ms=5)
- ax3.set_xlim(xlim[0], xlim[1])
+ ax3.set_xlim(mlim[0], mlim[1])
ax3.set_ylim(ylim[0], ylim[1])
ax3.axhline(y=0, color='black', alpha=0.9, zorder=1000)
+ ax3.axhline(y=np.nanmean(diffX_arr[:, ii]*1E3), color='tab:blue', alpha=0.9,linestyle='dotted', zorder=1001)
+ ax3.axhline(y=np.nanmean(diffY_arr[:, ii]*1E3), color='tab:orange', alpha=0.9,linestyle='dotted', zorder=1002)
ax3.set_xlabel('mag')
ax3.set_ylabel('residual (mas)')
return
-def plot_chi2_dist_mag(tab, Ndetect, mlim=40, n_bins=30):
+# TODO: update for motion model
+def plot_chi2_ecliptic_per_epoch(tab, Ndetect,ra,dec, mlim=[14,21], ylim = [-1, 1], target_idx = 0):
+ """
+ tab = flystar table
+ Ndetect = Number of epochs star detected in
+ """
+ diffX_arr = -99 * np.ones((len(tab['xe']), Ndetect))
+ diffY_arr = -99 * np.ones((len(tab['xe']), Ndetect))
+ errX_arr = 99 * np.ones((len(tab['xe']), Ndetect))
+ errY_arr = 99 * np.ones((len(tab['xe']), Ndetect))
+ sigX_arr = -99 * np.ones((len(tab['xe']), Ndetect))
+ sigY_arr = -99 * np.ones((len(tab['xe']), Ndetect))
+ m_arr = -99 * np.ones((len(tab['xe']), Ndetect))
+
+ rad_to_as = 180/np.pi * 60 * 60
+ deg_to_as = 60 * 60
+ def eq_to_ec(ra,dec):
+ e = 23.446 * np.pi/180
+ sinb = np.sin(dec)*np.cos(e) - np.cos(dec)*np.sin(e)*np.sin(ra)
+ cosb = np.cos(np.arcsin(sinb))
+ cosg = np.cos(ra)*np.cos(dec)/cosb
+ sing = (np.sin(dec)*np.sin(e) + np.cos(dec)*np.cos(e)*np.sin(ra))/cosb
+ g,b = np.arctan2(sing,cosg)*180/np.pi,np.arcsin(sinb)*180/np.pi
+ g = 360+g
+ return g*deg_to_as,b*deg_to_as
+ coord0 = SkyCoord(ra=ra,dec=dec,unit=(u.hourangle, u.deg),frame='icrs')
+
+ for ii in range(len(tab['xe'])):
+ # Ignore the NaNs
+ fnd = np.argwhere(~np.isnan(tab['xe'][ii,:]))
+ if len(fnd) == Ndetect and tab['use_in_trans'][ii]:
+ time = tab['t'][ii, fnd]
+ x = tab['x'][ii, fnd]
+ y = tab['y'][ii, fnd]
+ m = tab['m'][ii, fnd]
+ vx = tab['vx'][ii]
+ vy = tab['vy'][ii]
+ lambda_0,beta_0 = eq_to_ec((coord0.ra - tab['x0'][ii]*u.arcsec).radian,
+ (coord0.dec + tab['y0'][ii]*u.arcsec).radian)
+ x1 = coord0.ra - u.arcsec*x
+ y1 = coord0.dec + u.arcsec*y
+ ra_rad,dec_rad = x1.radian, y1.radian
+ lambda_obs,beta_obs = eq_to_ec(ra_rad,dec_rad)
+ x2 = coord0.ra - tab['x0'][ii]*u.arcsec - (time-tab['t0'][ii])*vx*u.arcsec
+ y2 = coord0.dec + tab['y0'][ii]*u.arcsec + (time-tab['t0'][ii])*vy*u.arcsec
+ ra_rad,dec_rad = x2.radian, y2.radian
+ lambda_pm,beta_pm = eq_to_ec(ra_rad,dec_rad)
+
+ xerr = tab['xe'][ii, fnd]
+ yerr = tab['ye'][ii, fnd]
+
+ dt = tab['t'][ii, fnd] - tab['t0'][ii]
+ fitLineX = lambda_pm
+ fitLineY = beta_pm
+
+ diffX = lambda_obs - fitLineX
+ diffY = beta_obs - fitLineY
+ sigX = diffX / xerr
+ sigY = diffY / yerr
+
+ diffX_arr[ii] = diffX.reshape(Ndetect,)
+ diffY_arr[ii] = diffY.reshape(Ndetect,)
+ errX_arr[ii] = xerr.reshape(Ndetect,)
+ errY_arr[ii] = yerr.reshape(Ndetect,)
+ sigX_arr[ii] = sigX.reshape(Ndetect,)
+ sigY_arr[ii] = sigY.reshape(Ndetect,)
+ m_arr[ii] = m.reshape(Ndetect,)
+
+ ts_folded = tab['t'][0]%1
+ i_sort = np.argsort(ts_folded)
+ print(ts_folded,i_sort)
+ for ii in i_sort:
+# fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(15, 4),
+# gridspec_kw={'width_ratios': [1, 2, 2]})
+# plt.subplots_adjust(wspace=0.5)
+# ax1.hist(sigX_arr[:, ii], label = 'X', histtype='step', bins=np.linspace(-10, 10))
+# ax1.hist(sigY_arr[:, ii], label = 'Y', histtype='step', bins=np.linspace(-10, 10))
+# ax1.set_xlabel('sigma')
+# ax1.legend()
+
+ fig, (ax2, ax3) = plt.subplots(1, 2, figsize=(14, 4))
+ plt.subplots_adjust(wspace=0.25)
+
+ '''ax2.plot(m_arr[:, ii], sigX_arr[:, ii], 's', label = 'lambda', color='tab:blue', alpha=0.4, ms=5)
+ ax2.plot(m_arr[:, ii], sigY_arr[:, ii], 'o', label = 'beta', color='tab:orange', alpha=0.4, ms=5)
+ if target_idx is not None:
+ ax2.plot(m_arr[target_idx, ii], sigX_arr[target_idx, ii], 's', color='black', ms=5)
+ ax2.plot(m_arr[target_idx, ii], sigY_arr[target_idx, ii], 'o', color='black', ms=5)
+ ax2.set_xlim(mlim[0], mlim[1])
+ ax2.set_ylim(-5, 5)
+ ax2.axhline(y=0, color='black', alpha=0.9, zorder=1000)
+ ax2.set_xlabel('mag')
+ ax2.set_ylabel('sigma')'''
+ ax2.set_title('Epoch {0}'.format(ii)+', phase='+str(tab['t'][0][ii]%1)[:5])
+
+ #print(errX_arr[:, ii])
+ ax2.errorbar(m_arr[:, ii], diffX_arr[:, ii]*1E3, yerr=errX_arr[:, ii]*1E3,
+ marker='s', label = 'lambda', ls='none', color='tab:blue', alpha=0.4, ms=5)
+ ax3.errorbar(m_arr[:, ii], diffY_arr[:, ii]*1E3, yerr=errY_arr[:, ii]*1E3,
+ marker='o', label = 'beta', ls='none', color='tab:orange', alpha=0.4, ms=5)
+ if target_idx is not None:
+ #print('target',m_arr[target_idx, ii],diffX_arr[target_idx, ii]*1E3,diffY_arr[target_idx, ii]*1E3)
+ ax2.errorbar(m_arr[target_idx, ii], diffX_arr[target_idx, ii]*1E3, yerr=errX_arr[target_idx, ii]*1E3,
+ marker='s', ls='none', color='black', ms=5)
+ ax3.errorbar(m_arr[target_idx, ii], diffY_arr[target_idx, ii]*1E3, yerr=errY_arr[target_idx, ii]*1E3,
+ marker='o', ls='none', color='black', ms=5)
+ ax2.legend()
+ ax3.legend()
+ ax2.set_xlim(mlim[0], mlim[1])
+ ax3.set_xlim(mlim[0], mlim[1])
+ ax2.set_ylim(ylim[0], ylim[1])
+ ax3.set_ylim(ylim[0], ylim[1])
+ ax2.axhline(y=0, color='black', alpha=0.9, zorder=1000)
+ ax3.axhline(y=0, color='black', alpha=0.9, zorder=1000)
+ ax2.set_xlabel('mag')
+ ax2.set_ylabel('residual (mas)')
+ ax3.set_xlabel('mag')
+ ax3.set_ylabel('residual (mas)')
+ return
+
+def plot_chi2_dist_mag(tab, Ndetect, xlim=40, n_bins=30, boot_err=False):
"""
tab = flystar table
Ndetect = Number of epochs star detected in
@@ -2315,18 +2770,21 @@ def plot_chi2_dist_mag(tab, Ndetect, mlim=40, n_bins=30):
fnd_list = [] # Number of non-NaN error measurements
for ii in range(len(tab['me'])):
- # Ignore the NaNs
+ # Ignore the NaNs
fnd = np.argwhere(~np.isnan(tab['me'][ii,:]))
fnd_list.append(len(fnd))
-
+
m = tab['m'][ii, fnd]
- merr = tab['me'][ii, fnd]
+ if boot_err:
+ merr = np.hypot(tab['me_boot'][ii, fnd], tab['me'][ii, fnd])
+ else:
+ merr = tab['me'][ii, fnd]
m0 = tab['m0'][ii]
- m0err = tab['m0e'][ii]
+ m0err = tab['m0_err'][ii]
diff_m = m0 - m
sig_m = diff_m/merr
-
+
chi2_m = np.sum(sig_m**2)
chi2_m_list.append(chi2_m)
@@ -2337,34 +2795,95 @@ def plot_chi2_dist_mag(tab, Ndetect, mlim=40, n_bins=30):
# Fitting mean magnitude... so subtract 1 to get Ndof
Ndof = Ndetect - 1
- chi2_maxis = np.linspace(0, mlim, mlim*3)
- chi2_bins = np.linspace(0, mlim, n_bins)
+ chi2_maxis = np.linspace(0, xlim, xlim*3)
+ chi2_bins = np.linspace(0, xlim, n_bins)
- plt.figure(figsize=(6,4))
+ plt.figure(figsize=(6, 4))
plt.clf()
- plt.hist(chi2_m[idx], bins=np.arange(mlim*10), histtype='step', density=True)
- plt.plot(chi2_maxis, chi2.pdf(chi2_maxis, Ndof), 'r-', alpha=0.6,
- label='$\chi^2$ ' + str(Ndof) + ' dof')
+ plt.hist(chi2_m[idx], bins=np.arange(xlim*10), histtype='step', density=True)
+ plt.plot(chi2_maxis, chi2.pdf(chi2_maxis, Ndof), 'r-', alpha=0.6,
+ label=r'$\chi^2$ ' + str(Ndof) + ' dof')
plt.title('$N_{epoch} = $' + str(Ndetect) + ', $N_{dof} = $' + str(Ndof))
- plt.xlim(0, mlim)
+ plt.xlim(0, xlim)
plt.legend()
+ plt.tight_layout()
+ plt.show()
+
+ print('Mean reduced chi^2: (Ndetect = {0:d} of {1:d})'.format(len(idx), len(tab)))
+ fmt = ' {0:s} = {1:.1f} for N_detect and {2:.1f} for all'
+ print(fmt.format('M', np.median(chi2_m[idx] / (fnd[idx] - 2)), np.median(chi2_m / (fnd - 2))))
+
+ return
+
+def plot_chi2_dist_mag_per_filter(tab, Ndetect, mlim=40, n_bins=30, xlim=40, file_name=None, filter=None):
+ """
+ tab = flystar table
+ Ndetect = Number of epochs star detected in
+ """
+ chi2_m_list = []
+ fnd_list = [] # Number of non-NaN error measurements
+
+ for ii in range(len(tab['me'])):
+ # Ignore the NaNs
+ fnd = np.argwhere(~np.isnan(tab['me'][ii,:]))
+ fnd_list.append(len(fnd))
+
+ m = tab['m'][ii, fnd]
+ merr = tab['me'][ii, fnd]
+ m0 = tab['m0'][ii]
+ m0err = tab['m0_err'][ii]
+
+ diff_m = m0 - m
+ sig_m = diff_m/merr
+
+ chi2_m = np.sum(sig_m**2)
+ chi2_m_list.append(chi2_m)
+
+ chi2_m = np.array(chi2_m_list)
+ fnd = np.array(fnd_list)
+
+ idx = np.where(fnd == Ndetect)[0]
+
+ # Fitting mean magnitude... so subtract 1 to get Ndof
+ Ndof = Ndetect - 1
+ chi2_maxis = np.linspace(0, xlim, xlim*3)
+ chi2_bins = np.linspace(0, xlim, n_bins)
+
+ plt.figure(figsize=(6, 4))
+ plt.clf()
+ plt.hist(chi2_m[idx], bins=np.arange(xlim*10), label='mag', histtype='stepfilled', density=True, color='green', alpha=0.7, edgecolor='k')
+ plt.plot(chi2_maxis, chi2.pdf(chi2_maxis, Ndof), 'r-', alpha=0.6,
+ label=r'$\chi^2$ ' + str(Ndof) + ' dof')
+ #plt.title('$N_{epoch} = $' + str(Ndetect) + ', $N_{dof} = $' + str(Ndof))
+ plt.xlim(0, xlim)
+ plt.xlabel(r'$\chi^{2}$', fontsize=28)
+ plt.ylabel(r'PDF', fontsize=28)
+ plt.legend(fontsize=20)
+ plt.tick_params(labelsize=20, direction='in', right=True, top=True)
+ plt.tight_layout()
+ plt.savefig(str(filter)+'_chi2_dist_mag.png', dpi=300)
+ plt.close()
print('Mean reduced chi^2: (Ndetect = {0:d} of {1:d})'.format(len(idx), len(tab)))
fmt = ' {0:s} = {1:.1f} for N_detect and {2:.1f} for all'
print(fmt.format('M', np.median(chi2_m[idx] / (fnd[idx] - 2)), np.median(chi2_m / (fnd - 2))))
-
+
return
-def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25), color_time=False):
+def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25), color_time=False, boot_err=False):
"""
- Plot a set of stars positions, flux and residuals over time.
+ Plot a set of stars positions, flux and residuals over time.
epoch_array : None, array
Array of the epoch indicies to plot. If None, plots all epochs.
"""
+
+ def rs(x):
+ return x.reshape(len(x))
+
print( 'Creating residuals plots for star(s):' )
print( star_names )
-
+
Nstars = len(star_names)
Ncols = 3 * np.min([Nstars, NcolMax])
if Nstars <= Ncols/3:
@@ -2379,10 +2898,17 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
x = tab['x0']
y = tab['y0']
r = np.hypot(x, y)
-
+ # motion_model_dict = motion_model.validate_motion_model_dict(motion_model_dict, tab, None)
+ i_all_detected = np.where(~np.any(np.isnan(tab['t']),axis=1))[0][0]
+ cont_times = np.arange(np.min(tab['t'][i_all_detected]), np.max(tab['t'][i_all_detected]), 0.01)
+ # xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.get_star_positions_at_time(tab['t'][i_all_detected], motion_model_dict, allow_alt_models=True)
+ xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.infer_positions(tab['t'][i_all_detected])
+ # xt_cont_all, yt_cont_all, xt_cont_err, yt_cont_err = tab.get_star_positions_at_time(cont_times, motion_model_dict, allow_alt_models=True)
+ xt_cont_all, yt_cont_all, xt_cont_err, yt_cont_err = tab.infer_positions(cont_times)
+
for i in range(Nstars):
starName = star_names[i]
-
+
try:
ii = np.where(tab['name'] == starName)[0][0]
except IndexError:
@@ -2397,24 +2923,30 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
fnd = fnd.reshape(len(fnd),1)
time = tab['t'][ii, fnd]
- dtime = time.data % 1
+ dtime = time.data % 1
x = tab['x'][ii, fnd]
y = tab['y'][ii, fnd]
m = tab['m'][ii, fnd]
- xerr = tab['xe'][ii, fnd]
- yerr = tab['ye'][ii, fnd]
- merr = tab['me'][ii, fnd]
+ if boot_err:
+ xerr = np.hypot(tab['xe'][ii, fnd], tab['xe_boot'][ii, fnd])
+ yerr = np.hypot(tab['ye'][ii, fnd], tab['ye_boot'][ii, fnd])
+ merr = np.hypot(tab['me'][ii, fnd], tab['me_boot'][ii, fnd])
+ else:
+ xerr = tab['xe'][ii, fnd]
+ yerr = tab['ye'][ii, fnd]
+ merr = tab['me'][ii, fnd]
dt = tab['t'][ii, fnd] - tab['t0'][ii]
- fitLineX = tab['x0'][ii] + (tab['vx'][ii] * dt)
- fitLineY = tab['y0'][ii] + (tab['vy'][ii] * dt)
- fitSigX = np.hypot(tab['x0e'][ii], tab['vxe'][ii]*dt)
- fitSigY = np.hypot(tab['y0e'][ii], tab['vye'][ii]*dt)
+ fitLineX = xt_mod_all[ii, fnd]
+ fitLineY = yt_mod_all[ii, fnd]
+
+ fitSigX = xt_mod_err[ii, fnd]
+ fitSigY = yt_mod_err[ii, fnd]
fitLineM = np.repeat(tab['m0'][ii], len(dt)).reshape(len(dt),1)
- fitSigM = np.repeat(tab['m0e'][ii], len(dt)).reshape(len(dt),1)
+ fitSigM = np.repeat(tab['m0_err'][ii], len(dt)).reshape(len(dt),1)
diffX = x - fitLineX
diffY = y - fitLineY
@@ -2437,21 +2969,23 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
chi2_y = np.sum(sigY**2)
chi2_m = np.sum(sigM**2)
- dof = len(x) - 2
+ dof = (len(tab['x'][ii])-tab['n_params'][ii]).astype(int)
dofM = len(m) - 1
chi2_red_x = chi2_x / dof
chi2_red_y = chi2_y / dof
chi2_red_m = chi2_m / dofM
-
+
print( 'Star: ', starName )
- print( '\tX Chi^2 = %5.2f (%6.2f for %2d dof)' %
+ print( '\tX Chi^2 = %5.2f (%6.2f for %2d dof)' %
(chi2_red_x, chi2_x, dof))
- print( '\tY Chi^2 = %5.2f (%6.2f for %2d dof)' %
+ print( '\tY Chi^2 = %5.2f (%6.2f for %2d dof)' %
(chi2_red_y, chi2_y, dof))
- print( '\tM Chi^2 = %5.2f (%6.2f for %2d dof)' %
+ print( '\tM Chi^2 = %5.2f (%6.2f for %2d dof)' %
(chi2_red_m, chi2_m, dofM))
+ if 'motion_model_used' in tab.keys():
+ print('\tMotion model:', tab['motion_model_used'][ii])
tmin = time.min()
tmax = time.max()
@@ -2483,7 +3017,6 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
resTicRng = [-1.1*maxErr, 1.1*maxErr]
resTicRngM = [-1.1*maxErrM, 1.1*maxErrM]
- from matplotlib.ticker import FormatStrFormatter
fmtX = FormatStrFormatter('%5i')
fmtY = FormatStrFormatter('%6.3f')
fmtM = FormatStrFormatter('%5.2f')
@@ -2497,18 +3030,23 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
row = 1
else:
col = 1 + 3*(i % (Ncols/3))
- row = 1 + 3*(i//(Ncols/3))
+ row = 1 + 3*(i//(Ncols/3))
ind = int((row-1)*Ncols + col)
paxes = plt.subplot(Nrows, Ncols, ind)
- plt.plot(time, fitLineX, 'b-')
- plt.plot(time, fitLineX + fitSigX, 'b--')
- plt.plot(time, fitLineX - fitSigX, 'b--')
+ plt.plot(cont_times, xt_cont_all[ii], 'b-')
+ plt.plot(cont_times, xt_cont_all[ii] + xt_cont_err[ii], 'b--')
+ plt.plot(cont_times, xt_cont_all[ii] - xt_cont_err[ii], 'b--')
if not color_time:
- plt.errorbar(time, x, yerr=xerr.reshape(len(xerr),), fmt='k.')
+ #print('x:',x)
+ #print('xerr:',xerr)
+ #print('xerr_reshaped:', xerr.reshape(len(xerr),))
+ #plt.errorbar(time, x, yerr=xerr.reshape(len(xerr)), fmt='k.')
+ plt.errorbar(rs(time), rs(x), yerr=rs(xerr), fmt='k.')
+ #plt.errorbar(time, x, yerr=xerr, fmt='k.')
else:
- norm = colors.Normalize(vmin=0, vmax=1, clip=True)
+ norm = mcolors.Normalize(vmin=0, vmax=1, clip=True)
mapper = cm.ScalarMappable(norm=norm, cmap='hsv')
time_color = np.array([(mapper.to_rgba(v)) for v in dtime])
for xx, yy, ee, color in zip(time, x, xerr, time_color):
@@ -2534,13 +3072,13 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
ind = int((row-1)*Ncols + col)
paxes = plt.subplot(Nrows, Ncols, ind)
- plt.plot(time, fitLineY, 'b-')
- plt.plot(time, fitLineY + fitSigY, 'b--')
- plt.plot(time, fitLineY - fitSigY, 'b--')
+ plt.plot(cont_times, yt_cont_all[ii], 'b-')
+ plt.plot(cont_times, yt_cont_all[ii] + yt_cont_err[ii], 'b--')
+ plt.plot(cont_times, yt_cont_all[ii] - yt_cont_err[ii], 'b--')
if not color_time:
- plt.errorbar(time, y, yerr=yerr.reshape(len(yerr),), fmt='k.')
+ plt.errorbar(rs(time), rs(y), yerr=rs(yerr), fmt='k.')
else:
- norm = colors.Normalize(vmin=0, vmax=1, clip=True)
+ norm = mcolors.Normalize(vmin=0, vmax=1, clip=True)
mapper = cm.ScalarMappable(norm=norm, cmap='hsv')
time_color = np.array([(mapper.to_rgba(v)) for v in dtime])
for xx, yy, ee, color in zip(time, y, yerr, time_color):
@@ -2568,9 +3106,9 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
plt.plot(time, fitLineM + fitSigM, 'g--')
plt.plot(time, fitLineM - fitSigM, 'g--')
if not color_time:
- plt.errorbar(time, m, yerr=merr.reshape(len(merr),), fmt='k.')
+ plt.errorbar(rs(time), rs(m), yerr=rs(merr), fmt='k.')
else:
- norm = colors.Normalize(vmin=0, vmax=1, clip=True)
+ norm = mcolors.Normalize(vmin=0, vmax=1, clip=True)
mapper = cm.ScalarMappable(norm=norm, cmap='hsv')
time_color = np.array([(mapper.to_rgba(v)) for v in dtime])
for xx, yy, ee, color in zip(time, m, merr, time_color):
@@ -2586,7 +3124,7 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
paxes.xaxis.set_major_formatter(fmtX)
paxes.yaxis.set_major_formatter(fmtM)
paxes.tick_params(axis='both', which='major', labelsize=12)
-
+
##########
# X residuals vs time
@@ -2597,12 +3135,12 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
paxes = plt.subplot(Nrows, Ncols, ind)
plt.plot(time, np.zeros(len(time)), 'b-')
- plt.plot(time, fitSigX*1e3, 'b--')
- plt.plot(time, -fitSigX*1e3, 'b--')
+ plt.plot(cont_times, xt_cont_err[ii]*1e3, 'b--')
+ plt.plot(cont_times, -xt_cont_err[ii]*1e3, 'b--')
if not color_time:
- plt.errorbar(time, (x - fitLineX)*1e3, yerr=xerr.reshape(len(xerr),)*1e3, fmt='k.')
+ plt.errorbar(rs(time), rs(x - fitLineX)*1e3, yerr=rs(xerr)*1e3, fmt='k.')
else:
- norm = colors.Normalize(vmin=0, vmax=1, clip=True)
+ norm = mcolors.Normalize(vmin=0, vmax=1, clip=True)
mapper = cm.ScalarMappable(norm=norm, cmap='hsv')
time_color = np.array([(mapper.to_rgba(v)) for v in dtime])
for xx, yy, ee, color in zip(time, (x - fitLineX)*1e3, xerr*1e3, time_color):
@@ -2625,12 +3163,12 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
paxes = plt.subplot(Nrows, Ncols, ind)
plt.plot(time, np.zeros(len(time)), 'b-')
- plt.plot(time, fitSigY*1e3, 'b--')
- plt.plot(time, -fitSigY*1e3, 'b--')
+ plt.plot(cont_times, yt_cont_err[ii]*1e3, 'b--')
+ plt.plot(cont_times, -yt_cont_err[ii]*1e3, 'b--')
if not color_time:
- plt.errorbar(time, (y - fitLineY)*1e3, yerr=yerr.reshape(len(yerr),)*1e3, fmt='k.')
+ plt.errorbar(rs(time), rs(y - fitLineY)*1e3, yerr=rs(yerr)*1e3, fmt='k.')
else:
- norm = colors.Normalize(vmin=0, vmax=1, clip=True)
+ norm = mcolors.Normalize(vmin=0, vmax=1, clip=True)
mapper = cm.ScalarMappable(norm=norm, cmap='hsv')
time_color = np.array([(mapper.to_rgba(v)) for v in dtime])
for xx, yy, ee, color in zip(time, (y - fitLineY)*1e3, yerr*1e3, time_color):
@@ -2656,9 +3194,9 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
plt.plot(time, fitSigM*1e3, 'g--')
plt.plot(time, -fitSigM*1e3, 'g--')
if not color_time:
- plt.errorbar(time, (m - fitLineM), yerr=merr.reshape(len(merr),), fmt='k.')
+ plt.errorbar(rs(time), rs(m - fitLineM), yerr=rs(merr), fmt='k.')
else:
- norm = colors.Normalize(vmin=0, vmax=1, clip=True)
+ norm = mcolors.Normalize(vmin=0, vmax=1, clip=True)
mapper = cm.ScalarMappable(norm=norm, cmap='hsv')
time_color = np.array([(mapper.to_rgba(v)) for v in dtime])
for xx, yy, ee, color in zip(time, (m - fitLineM), merr, time_color):
@@ -2683,13 +3221,13 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
paxes = plt.subplot(Nrows, Ncols, ind)
if not color_time:
- plt.errorbar(x,y, xerr=xerr.reshape(len(xerr),),
- yerr=yerr.reshape(len(yerr),), fmt='k.')
+ plt.errorbar(rs(x),rs(y), xerr=rs(xerr),
+ yerr=rs(yerr), fmt='k.')
else:
sc = plt.scatter(x, y, s=0, c=dtime, vmin=0, vmax=1, cmap='hsv')
clb = plt.colorbar(sc)
clb.ax.tick_params(labelsize=fontsize1)
- norm = colors.Normalize(vmin=0, vmax=1, clip=True)
+ norm = mcolors.Normalize(vmin=0, vmax=1, clip=True)
mapper = cm.ScalarMappable(norm=norm, cmap='hsv')
time_color = np.array([(mapper.to_rgba(v)) for v in dtime])
for xx, yy, eexx, eeyy, color in zip(x, y, xerr, yerr, time_color):
@@ -2701,7 +3239,7 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
paxes.xaxis.set_major_formatter(FormatStrFormatter('%.3f'))
plt.xlabel('X (asec)', fontsize=fontsize1)
plt.ylabel('Y (asec)', fontsize=fontsize1)
- plt.plot(fitLineX, fitLineY, 'b-')
+ plt.plot(xt_cont_all[ii], yt_cont_all[ii], 'b-')
##########
# X, Y Histogram of Residuals
@@ -2712,7 +3250,7 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
bins = np.arange(-7.5, 7.5, 1)
paxes = plt.subplot(Nrows, Ncols, ind)
id = np.where(diffY < 0)[0]
- sig[id] = -1.*sig[id]
+ sig[id] = -1.*sig[id]
(n, b, p) = plt.hist(sigX, bins, histtype='stepfilled', color='b', label='X')
plt.setp(p, 'facecolor', 'b')
(n, b, p) = plt.hist(sigY, bins, histtype='step', color='r', label='Y')
@@ -2738,26 +3276,24 @@ def plot_stars(tab, star_names, NcolMax=2, epoch_array = None, figsize=(15,25),
plt.xlabel('Residuals (sigma)', fontsize=fontsize1)
plt.ylabel('Number of Epochs', fontsize=fontsize1)
paxes.tick_params(axis='both', which='major', labelsize=fontsize1)
-
+
if Nstars == 1:
- plt.subplots_adjust(wspace=0.4, hspace=0.4, left = 0.15, bottom = 0.1, right=0.9, top=0.9)
- # plt.savefig(rootDir+'plots/plotStar_' + starName + '.png')
+ plt.subplots_adjust(wspace=0.4, hspace=0.4, left = 0.15, bottom = 0.1, right=0.9, top=0.9)
+ # plt.savefig(rootDir+'plots/plotStar_' + starName + '.png', dpi=300)
else:
plt.subplots_adjust(wspace=0.6, hspace=0.6, left = 0.08, bottom = 0.05, right=0.95, top=0.90)
- # plt.savefig(rootDir+'plots/plotStar_all.png')
+ # plt.savefig(rootDir+'plots/plotStar_all.png', dpi=300)
plt.show()
plt.show()
return
-
-
def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_list = None,
- figsize=(15,25), color_time=False, resTicRng=None):
+ figsize=(15,25), color_time=False, resTicRng=None, save_name=None, boot_err=False):
"""
- Plot a set of stars positions, flux and residuals over time.
+ Plot a set of stars positions, flux and residuals over time.
epoch_array : None, array
Array of the epoch indicies to plot. If None, plots all epochs.
@@ -2767,7 +3303,14 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
"""
print( 'Creating residuals plots for star(s):' )
print( star_names )
-
+ def rs(x):
+ return x.reshape(len(x))
+
+ # motion_model_dict = motion_model.validate_motion_model_dict(motion_model_dict, tab, None)
+ i_all_detected = np.where(~np.any(np.isnan(tab['t']),axis=1))[0][0]
+ # xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.get_star_positions_at_time(tab['t'][i_all_detected], motion_model_dict, allow_alt_models=True)
+ xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.infer_positions(tab['t'][i_all_detected])
+
Nstars = len(star_names)
Ncols = 3 * np.min([Nstars, NcolMax])
if Nstars <= Ncols/3:
@@ -2782,45 +3325,56 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
x = tab['x0']
y = tab['y0']
r = np.hypot(x, y)
-
+ # motion_model_dict = motion_model.validate_motion_model_dict(motion_model_dict, tab, None)
+ i_all_detected = np.where(~np.any(np.isnan(tab['t']),axis=1))[0][0]
+ cont_times = np.arange(np.min(tab['t'][i_all_detected]), np.max(tab['t'][i_all_detected]), 0.01)
+ # xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.get_star_positions_at_time(tab['t'][i_all_detected], motion_model_dict, allow_alt_models=True)
+ xt_mod_all, yt_mod_all, xt_mod_err, yt_mod_err = tab.infer_positions(tab['t'][i_all_detected])
+ # xt_cont_all, yt_cont_all, xt_cont_err, yt_cont_err = tab.get_star_positions_at_time(cont_times, motion_model_dict, allow_alt_models=True)
+ xt_cont_all, yt_cont_all, xt_cont_err, yt_cont_err = tab.infer_positions(cont_times)
+
for i in range(Nstars):
for ea, epoch_array in enumerate(epoch_array_list):
color=color_list[ea]
starName = star_names[i]
-
+
try:
ii = np.where(tab['name'] == starName)[0][0]
except IndexError:
print("!! %s is not in this list"%starName)
continue
-
+
# Ignore the NaNs
fnd = np.argwhere(~np.isnan(tab['xe'][ii,:]))
-
+
if epoch_array is not None:
fnd = np.intersect1d(fnd, epoch_array)
fnd = fnd.reshape(len(fnd),1)
-
+
time = tab['t'][ii, fnd]
- dtime = time.data % 1
+ dtime = time.data % 1
x = tab['x'][ii, fnd]
y = tab['y'][ii, fnd]
m = tab['m'][ii, fnd]
-
- xerr = tab['xe'][ii, fnd]
- yerr = tab['ye'][ii, fnd]
- merr = tab['me'][ii, fnd]
-
- dt = tab['t'][ii, fnd] - tab['t0'][ii]
- fitLineX = tab['x0'][ii] + (tab['vx'][ii] * dt)
- fitLineY = tab['y0'][ii] + (tab['vy'][ii] * dt)
-
- fitSigX = np.hypot(tab['x0e'][ii], tab['vxe'][ii]*dt)
- fitSigY = np.hypot(tab['y0e'][ii], tab['vye'][ii]*dt)
-
- fitLineM = np.repeat(tab['m0'][ii], len(dt)).reshape(len(dt),1)
- fitSigM = np.repeat(tab['m0e'][ii], len(dt)).reshape(len(dt),1)
-
+
+ if boot_err:
+ xerr = np.hypot(tab['xe'][ii, fnd], tab['xe_boot'][ii, fnd])
+ yerr = np.hypot(tab['ye'][ii, fnd], tab['ye_boot'][ii, fnd])
+ merr = np.hypot(tab['me'][ii, fnd], tab['me_boot'][ii, fnd])
+ else:
+ xerr = tab['xe'][ii, fnd]
+ yerr = tab['ye'][ii, fnd]
+ merr = tab['me'][ii, fnd]
+
+ fitLineX = xt_mod_all[ii, fnd]
+ fitLineY = yt_mod_all[ii, fnd]
+
+ fitSigX = xt_mod_err[ii, fnd]
+ fitSigY = yt_mod_err[ii, fnd]
+
+ fitLineM = np.repeat(tab['m0'][ii], len(time)).reshape(len(time),1)
+ fitSigM = np.repeat(tab['m0_err'][ii], len(time)).reshape(len(time),1)
+
diffX = x - fitLineX
diffY = y - fitLineY
diffM = m - fitLineM
@@ -2830,42 +3384,42 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
sigY = diffY / yerr
sigM = diffM / merr
sig = diff / rerr
-
+
# Determine if there are points that are more than 4 sigma off
idxX = np.where(abs(sigX) > 4)
idxY = np.where(abs(sigY) > 4)
idxM = np.where(abs(sigM) > 4)
idx = np.where(abs(sig) > 4)
-
+
# Calculate chi^2 metrics
chi2_x = np.sum(sigX**2)
chi2_y = np.sum(sigY**2)
chi2_m = np.sum(sigM**2)
-
+
dof = len(x) - 2
dofM = len(m) - 1
-
+
chi2_red_x = chi2_x / dof
chi2_red_y = chi2_y / dof
chi2_red_m = chi2_m / dofM
-
-
+
+
print( 'Star: ', starName )
- print( '\tX Chi^2 = %5.2f (%6.2f for %2d dof)' %
+ print( '\tX Chi^2 = %5.2f (%6.2f for %2d dof)' %
(chi2_red_x, chi2_x, dof))
- print( '\tY Chi^2 = %5.2f (%6.2f for %2d dof)' %
+ print( '\tY Chi^2 = %5.2f (%6.2f for %2d dof)' %
(chi2_red_y, chi2_y, dof))
- print( '\tM Chi^2 = %5.2f (%6.2f for %2d dof)' %
+ print( '\tM Chi^2 = %5.2f (%6.2f for %2d dof)' %
(chi2_red_m, chi2_m, dofM))
-
+
tmin = time.min()
tmax = time.max()
-
+
dateTicLoc = plt.MultipleLocator(3)
dateTicRng = [np.floor(tmin), np.ceil(tmax)]
dateTics = np.arange(np.floor(tmin), np.ceil(tmax)+0.1)
DateTicsLabel = dateTics
-
+
# See if we are using MJD instead.
if time[0] > 50000:
print('MJD')
@@ -2875,12 +3429,12 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
dateTicRng = [tmin-200, tmax+200]
dateTics = np.arange(dateTicRng[0], dateTicRng[-1]+500, 1000)
DateTicsLabel = dateTics
-
-
+
+
maxErr = np.array([(diffX-xerr)*1e3, (diffX+xerr)*1e3,
(diffY-yerr)*1e3, (diffY+yerr)*1e3]).max()
maxErrM = np.array([(diffM - merr), (diffM + merr)]).max()
-
+
if maxErr > 2:
maxErr = 2.0
if maxErrM > 1.0:
@@ -2888,13 +3442,12 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
if resTicRng == None:
resTicRng = [-1.1*maxErr, 1.1*maxErr]
resTicRngM = [-1.1*maxErrM, 1.1*maxErrM]
-
- from matplotlib.ticker import FormatStrFormatter
+
fmtX = FormatStrFormatter('%5i')
fmtY = FormatStrFormatter('%6.3f')
fmtM = FormatStrFormatter('%5.2f')
fontsize1 = 10
-
+
##########
# X vs time
##########
@@ -2903,18 +3456,19 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
row = 1
else:
col = 1 + 3*(i % (Ncols/3))
- row = 1 + 3*(i//(Ncols/3))
-
+ row = 1 + 3*(i//(Ncols/3))
+
ind = int((row-1)*Ncols + col)
-
+
paxes = plt.subplot(Nrows, Ncols, ind)
- plt.plot(time, fitLineX, 'b-')
- plt.plot(time, fitLineX + fitSigX, 'b--')
- plt.plot(time, fitLineX - fitSigX, 'b--')
+ plt.plot(cont_times, xt_cont_all[ii], 'b-')
+ plt.plot(cont_times, xt_cont_all[ii] + xt_cont_err[ii], 'b--')
+ plt.plot(cont_times, xt_cont_all[ii] - xt_cont_err[ii], 'b--')
+ print(np.shape(xerr.reshape(len(xerr),)))
if not color_time:
- plt.errorbar(time, x, yerr=xerr.reshape(len(xerr),), marker='.', color=color, ls='none')
+ plt.errorbar(rs(time), rs(x), yerr=rs(xerr), marker='.', color=color, ls='none')
else:
- norm = colors.Normalize(vmin=0, vmax=1, clip=True)
+ norm = mcolors.Normalize(vmin=0, vmax=1, clip=True)
mapper = cm.ScalarMappable(norm=norm, cmap='hsv')
time_color = np.array([(mapper.to_rgba(v)) for v in dtime])
for xx, yy, ee, color in zip(time, x, xerr, time_color):
@@ -2931,22 +3485,22 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
paxes.yaxis.set_major_formatter(fmtY)
paxes.tick_params(axis='both', which='major', labelsize=fontsize1)
plt.annotate(starName, xy=(1.0,1.1), xycoords='axes fraction', fontsize=12, color='red')
-
-
+
+
##########
# Y vs time
##########
col = col + 1
ind = int((row-1)*Ncols + col)
-
+
paxes = plt.subplot(Nrows, Ncols, ind)
- plt.plot(time, fitLineY, 'b-')
- plt.plot(time, fitLineY + fitSigY, 'b--')
- plt.plot(time, fitLineY - fitSigY, 'b--')
+ plt.plot(cont_times, yt_cont_all[ii], 'b-')
+ plt.plot(cont_times, yt_cont_all[ii] + yt_cont_err[ii], 'b--')
+ plt.plot(cont_times, yt_cont_all[ii] - yt_cont_err[ii], 'b--')
if not color_time:
- plt.errorbar(time, y, yerr=yerr.reshape(len(yerr),), marker='.', color=color, ls='none')
+ plt.errorbar(rs(time), rs(y), yerr=rs(yerr), marker='.', color=color, ls='none')
else:
- norm = colors.Normalize(vmin=0, vmax=1, clip=True)
+ norm = mcolors.Normalize(vmin=0, vmax=1, clip=True)
mapper = cm.ScalarMappable(norm=norm, cmap='hsv')
time_color = np.array([(mapper.to_rgba(v)) for v in dtime])
for xx, yy, ee, color in zip(time, y, yerr, time_color):
@@ -2962,21 +3516,21 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
paxes.xaxis.set_major_formatter(fmtX)
paxes.yaxis.set_major_formatter(fmtY)
paxes.tick_params(axis='both', which='major', labelsize=fontsize1)
-
+
##########
# M vs time
##########
col = col + 1
ind = int((row - 1)*Ncols + col)
-
+
paxes = plt.subplot(Nrows, Ncols, ind)
plt.plot(time, fitLineM, 'g-')
plt.plot(time, fitLineM + fitSigM, 'g--')
plt.plot(time, fitLineM - fitSigM, 'g--')
if not color_time:
- plt.errorbar(time, m, yerr=merr.reshape(len(merr),), marker='.', color=color, ls='none')
+ plt.errorbar(rs(time), rs(m), yerr=rs(merr), marker='.', color=color, ls='none')
else:
- norm = colors.Normalize(vmin=0, vmax=1, clip=True)
+ norm = mcolors.Normalize(vmin=0, vmax=1, clip=True)
mapper = cm.ScalarMappable(norm=norm, cmap='hsv')
time_color = np.array([(mapper.to_rgba(v)) for v in dtime])
for xx, yy, ee, color in zip(time, m, merr, time_color):
@@ -2992,23 +3546,23 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
paxes.xaxis.set_major_formatter(fmtX)
paxes.yaxis.set_major_formatter(fmtM)
paxes.tick_params(axis='both', which='major', labelsize=12)
-
-
+
+
##########
# X residuals vs time
##########
row = row + 1
col = col - 2
ind = int((row-1)*Ncols + col)
-
+
paxes = plt.subplot(Nrows, Ncols, ind)
plt.plot(time, np.zeros(len(time)), 'b-')
- plt.plot(time, fitSigX*1e3, 'b--')
- plt.plot(time, -fitSigX*1e3, 'b--')
+ plt.plot(cont_times, xt_cont_err[ii]*1e3, 'b--')
+ plt.plot(cont_times, -xt_cont_err[ii]*1e3, 'b--')
if not color_time:
- plt.errorbar(time, (x - fitLineX)*1e3, yerr=xerr.reshape(len(xerr),)*1e3, marker='.', color=color, ls='none')
+ plt.errorbar(rs(time), rs(x - fitLineX)*1e3, yerr=rs(xerr)*1e3, marker='.', color=color, ls='none')
else:
- norm = colors.Normalize(vmin=0, vmax=1, clip=True)
+ norm = mcolors.Normalize(vmin=0, vmax=1, clip=True)
mapper = cm.ScalarMappable(norm=norm, cmap='hsv')
time_color = np.array([(mapper.to_rgba(v)) for v in dtime])
for xx, yy, ee, color in zip(time, (x - fitLineX)*1e3, xerr*1e3, time_color):
@@ -3022,21 +3576,21 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
plt.ylabel('X Residuals (mas)', fontsize=fontsize1)
paxes.xaxis.set_major_formatter(fmtX)
paxes.tick_params(axis='both', which='major', labelsize=fontsize1)
-
+
##########
# Y residuals vs time
##########
col = col + 1
ind = int((row-1)*Ncols + col)
-
+
paxes = plt.subplot(Nrows, Ncols, ind)
plt.plot(time, np.zeros(len(time)), 'b-')
- plt.plot(time, fitSigY*1e3, 'b--')
- plt.plot(time, -fitSigY*1e3, 'b--')
+ plt.plot(cont_times, yt_cont_err[ii]*1e3, 'b--')
+ plt.plot(cont_times, -yt_cont_err[ii]*1e3, 'b--')
if not color_time:
- plt.errorbar(time, (y - fitLineY)*1e3, yerr=yerr.reshape(len(yerr),)*1e3, marker='.', color=color, ls='none')
+ plt.errorbar(rs(time), rs(y - fitLineY)*1e3, yerr=rs(yerr)*1e3, marker='.', color=color, ls='none')
else:
- norm = colors.Normalize(vmin=0, vmax=1, clip=True)
+ norm = mcolors.Normalize(vmin=0, vmax=1, clip=True)
mapper = cm.ScalarMappable(norm=norm, cmap='hsv')
time_color = np.array([(mapper.to_rgba(v)) for v in dtime])
for xx, yy, ee, color in zip(time, (y - fitLineY)*1e3, yerr*1e3, time_color):
@@ -3050,21 +3604,21 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
plt.ylabel('Y Residuals (mas)', fontsize=fontsize1)
paxes.xaxis.set_major_formatter(fmtX)
paxes.tick_params(axis='both', which='major', labelsize=fontsize1)
-
+
##########
# M residuals vs time
##########
col = col + 1
ind = int((row-1)*Ncols + col)
-
+
paxes = plt.subplot(Nrows, Ncols, ind)
plt.plot(time, np.zeros(len(time)), 'g-')
plt.plot(time, fitSigM*1e3, 'g--')
plt.plot(time, -fitSigM*1e3, 'g--')
if not color_time:
- plt.errorbar(time, (m - fitLineM), yerr=merr.reshape(len(merr),), marker='.', color=color, ls='none')
+ plt.errorbar(rs(time), rs(m - fitLineM), yerr=rs(merr), marker='.', color=color, ls='none')
else:
- norm = colors.Normalize(vmin=0, vmax=1, clip=True)
+ norm = mcolors.Normalize(vmin=0, vmax=1, clip=True)
mapper = cm.ScalarMappable(norm=norm, cmap='hsv')
time_color = np.array([(mapper.to_rgba(v)) for v in dtime])
for xx, yy, ee, color in zip(time, (m - fitLineM), merr, time_color):
@@ -3078,24 +3632,24 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
plt.ylabel('m Residuals (mag)', fontsize=fontsize1)
paxes.xaxis.set_major_formatter(fmtX)
paxes.tick_params(axis='both', which='major', labelsize=fontsize1)
-
-
+
+
##########
# X vs. Y
##########
row = row + 1
col = col - 2
ind = int((row-1)*Ncols + col)
-
+
paxes = plt.subplot(Nrows, Ncols, ind)
if not color_time:
- plt.errorbar(x,y, xerr=xerr.reshape(len(xerr),),
- yerr=yerr.reshape(len(yerr),), marker='.', color=color, ls='none')
+ plt.errorbar(rs(x),rs(y), xerr=rs(xerr),
+ yerr=rs(yerr), marker='.', color=color, ls='none')
else:
sc = plt.scatter(x, y, s=0, c=dtime, vmin=0, vmax=1, cmap='hsv')
clb = plt.colorbar(sc)
clb.ax.tick_params(labelsize=fontsize1)
- norm = colors.Normalize(vmin=0, vmax=1, clip=True)
+ norm = mcolors.Normalize(vmin=0, vmax=1, clip=True)
mapper = cm.ScalarMappable(norm=norm, cmap='hsv')
time_color = np.array([(mapper.to_rgba(v)) for v in dtime])
for xx, yy, eexx, eeyy, color in zip(x, y, xerr, yerr, time_color):
@@ -3107,18 +3661,18 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
paxes.xaxis.set_major_formatter(FormatStrFormatter('%.3f'))
plt.xlabel('X (asec)', fontsize=fontsize1)
plt.ylabel('Y (asec)', fontsize=fontsize1)
- plt.plot(fitLineX, fitLineY, 'b-')
-
+ plt.plot(fitLineX, fitLineY, 'b-')
+
##########
# X, Y Histogram of Residuals
##########
col = col + 1
ind = int((row-1)*Ncols + col)
-
+
bins = np.arange(-7.5, 7.5, 1)
paxes = plt.subplot(Nrows, Ncols, ind)
id = np.where(diffY < 0)[0]
- sig[id] = -1.*sig[id]
+ sig[id] = -1.*sig[id]
(n, b, p) = plt.hist(sigX, bins, histtype='stepfilled', color='b', label='X')
plt.setp(p, 'facecolor', 'b')
(n, b, p) = plt.hist(sigY, bins, histtype='step', color='r', label='Y')
@@ -3128,13 +3682,13 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
plt.xlabel('Residuals (sigma)', fontsize=fontsize1)
plt.ylabel('Number of Epochs', fontsize=fontsize1)
paxes.tick_params(axis='both', which='major', labelsize=fontsize1)
-
+
##########
# M Histogram of Residuals
##########
col = col + 1
ind = int((row-1)*Ncols + col)
-
+
bins = np.arange(-7.5, 7.5, 1)
paxes = plt.subplot(Nrows, Ncols, ind)
(n, b, p) = plt.hist(sigM, bins, histtype='stepfilled', color='g', label='m')
@@ -3144,16 +3698,17 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
plt.xlabel('Residuals (sigma)', fontsize=fontsize1)
plt.ylabel('Number of Epochs', fontsize=fontsize1)
paxes.tick_params(axis='both', which='major', labelsize=fontsize1)
-
+
if Nstars == 1:
- plt.subplots_adjust(wspace=0.4, hspace=0.4, left = 0.15, bottom = 0.1, right=0.9, top=0.9)
- # plt.savefig(rootDir+'plots/plotStar_' + starName + '.png')
+ plt.subplots_adjust(wspace=0.4, hspace=0.4, left = 0.15, bottom = 0.1, right=0.9, top=0.9)
+ # plt.savefig(rootDir+'plots/plotStar_' + starName + '.png', dpi=300)
else:
plt.subplots_adjust(wspace=0.6, hspace=0.6, left = 0.08, bottom = 0.05, right=0.95, top=0.90)
- # plt.savefig(rootDir+'plots/plotStar_all.png')
+ # plt.savefig(rootDir+'plots/plotStar_all.png', dpi=300)
plt.show()
-
+ if save_name is not None:
+ plt.savefig(save_name + '.png', dpi=300)
plt.show()
return
@@ -3161,18 +3716,18 @@ def plot_stars_nfilt(tab, star_names, NcolMax=2, epoch_array_list = None, color_
def plot_errors_vs_r_m(star_tab, vmax_perr=0.75, vmax_pmerr=0.75):
"""
- Plot the positional errors and the proper motion errors as a function of radius
- and magnitude. The positional an proper motion errors will be the mean in the
- two axis (as is used in pick_good_ref_stars()).
+ Plot the positional errors and the proper motion errors as a function of radius
+ and magnitude. The positional an proper motion errors will be the mean in the
+ two axis (as is used in pick_good_ref_stars()).
"""
r = np.hypot(star_tab['x0'], star_tab['y0'])
- p_err = np.mean((star_tab['x0e'], star_tab['y0e']), axis=0) * 1e3
- pm_err = np.mean((star_tab['vxe'], star_tab['vye']), axis=0) * 1e3
+ p_err = np.mean((star_tab['x0_err'], star_tab['y0_err']), axis=0) * 1e3
+ pm_err = np.mean((star_tab['vx_err'], star_tab['vy_err']), axis=0) * 1e3
plt.figure(figsize=(12, 6))
plt.clf()
plt.subplots_adjust(wspace=0.4)
-
+
plt.subplot(1, 2, 1)
plt.scatter(star_tab['m0'], r, c=p_err, s=8, vmin=0, vmax=vmax_perr)
plt.colorbar(label='Pos Err (mas)')
@@ -3184,10 +3739,25 @@ def plot_errors_vs_r_m(star_tab, vmax_perr=0.75, vmax_pmerr=0.75):
plt.colorbar(label='PM Err (mas/yr)')
plt.xlabel('Mag')
plt.ylabel('Radius (")')
+ plt.tight_layout()
+ plt.show()
return
-
-
+
+def plot_plxs(star_tab, target_idx=0):
+ fig,ax = plt.subplots(nrows=1,ncols=2,figsize=(10,5))
+ ax[0].errorbar(star_tab['m0'],star_tab['pi']*1e3, yerr=star_tab['pi_err']*1e3,marker='.',linestyle='none')
+ if target_idx is not None:
+ ax[0].errorbar(star_tab['m0'][target_idx],star_tab['pi'][target_idx]*1e3, yerr=star_tab['pi_err'][target_idx]*1e3,marker='*',linestyle='none', color='orange', markersize=10)
+ ax[0].axhline(0, c='gray')
+ ax[0].set_ylabel('Plx (mas)')
+ ax[0].set_xlabel('Mag')
+ ax[1].hist(star_tab['pi']/star_tab['pi_err'], bins=range(-10,10))
+ ax[1].set_ylabel('N stars')
+ ax[1].set_xlabel('Plx/Plx_err')
+ plt.tight_layout()
+ ax[0].set_ylim(-5,5)
+
def plot_sky(stars_tab,
plot_errors=False, center_star=None, range=0.4,
xcenter=0, ycenter=0, show_names=False, saveplot=False,
@@ -3201,8 +3771,8 @@ def plot_sky(stars_tab,
Parameters
----------
stars_tab : flystar.startables.StarTable
- The StarTable containining 'x', 'y', 't', 'xe', 'ye', columns etc.
- for plotting, where each of these columns is a 2D array of
+ The StarTable containining 'x', 'y', 't', 'xe', 'ye', columns etc.
+ for plotting, where each of these columns is a 2D array of
[star_index, epoch_index].
@@ -3247,11 +3817,11 @@ def plot_sky(stars_tab,
good_t = np.isfinite(stars_tab['t'])
epochs = np.unique(stars_tab['t'][good_t])
assert len(epochs) == stars_tab['t'].shape[1]
-
+
yearsInt = np.floor(epochs).astype('int')
# Set up a color scheme
- cnorm = colors.Normalize(stars_tab['t'][0, :].min(), stars_tab['t'][0, :].max() + 1)
+ cnorm = mcolors.Normalize(stars_tab['t'][0, :].min(), stars_tab['t'][0, :].max() + 1)
cmap = plt.cm.gist_ncar
colorList = []
@@ -3259,8 +3829,8 @@ def plot_sky(stars_tab,
foo = cnorm(yearsInt[ee])
colorList.append( cmap(cnorm(yearsInt[ee])) )
- py.close(2)
- fig = py.figure(2, figsize=(13,10))
+ plt.close(2)
+ fig = plt.figure(2, figsize=(13,10))
previousYear = 0.0
@@ -3298,13 +3868,13 @@ def plot_sky(stars_tab,
label = '_nolegend_'
if plot_errors:
- (line, foo1, foo2) = py.errorbar(x, y, xerr=xe, yerr=ye,
+ (line, foo1, foo2) = plt.errorbar(x, y, xerr=xe, yerr=ye,
color=colorList[ee], fmt='^',
markeredgecolor=colorList[ee],
markerfacecolor=colorList[ee],
label=label, picker=4)
else:
- (line, foo1, foo2) = py.errorbar(x, y, xerr=None, yerr=None,
+ (line, foo1, foo2) = plt.errorbar(x, y, xerr=None, yerr=None,
color=colorList[ee], fmt='^',
markeredgecolor=colorList[ee],
markerfacecolor=colorList[ee],
@@ -3322,19 +3892,19 @@ def plot_sky(stars_tab,
point_labels[line] = points_info
foo = PrintSelected(point_labels, fig, stars_tab, mag_range, manual_print=manual_print)
- py.connect('pick_event', foo)
+ plt.connect('pick_event', foo)
xlo = xcenter + (range)
xhi = xcenter - (range)
ylo = ycenter - (range)
yhi = ycenter + (range)
- py.axis('equal')
- py.axis([xlo, xhi, ylo, yhi])
- py.xlabel('R.A. Offset from Sgr A* (arcsec)')
- py.ylabel('Dec. Offset from Sgr A* (arcsec)')
+ plt.axis('equal')
+ plt.axis([xlo, xhi, ylo, yhi])
+ plt.xlabel('R.A. Offset from Sgr A* (arcsec)')
+ plt.ylabel('Dec. Offset from Sgr A* (arcsec)')
- py.legend(handles=epochs_legend, numpoints=1, loc='lower left', fontsize=12)
+ plt.legend(handles=epochs_legend, numpoints=1, loc='lower left', fontsize=12)
if show_names:
xpos = stars_tab['x0']
@@ -3342,20 +3912,20 @@ def plot_sky(stars_tab,
goodind = np.where((xpos <= xlo) & (xpos >= xhi) &
(ypos >= ylo) & (ypos <= yhi))[0]
for ind in goodind:
- py.text(xpos[ind], ypos[ind], stars_tab['name'][ind], size=10)
+ plt.text(xpos[ind], ypos[ind], stars_tab['name'][ind], size=10)
if saveplot:
- py.show(block=0)
+ plt.show(block=0)
if (center_star != None):
- py.savefig('plot_sky_' + center_star + '.png')
+ plt.savefig('plot_sky_' + center_star + '.png', dpi=300)
else:
- py.savefig('plot_sky.png')
+ plt.savefig('plot_sky.png', dpi=300)
else:
- py.show()
+ plt.show()
return
-
-
+
+
class PrintSelected(object):
def __init__(self, points_info, fig, tab, mag_range, manual_print=False):
self.points_info = points_info
@@ -3423,3 +3993,127 @@ def __call__(self, event):
self.fig.canvas.draw()
return
+
+
+def plotly_stars(x, y, m=None, xe=None, ye=None, me=None, star_name=None, marker_size=3, color=None, alpha=0.7, symbol='circle', label=None, xlabel='x', ylabel='y', fig=None, figsize=(700, 700), show=None):
+ """Plot stars with plotly in interactive html format
+
+ Parameters
+ ----------
+ x : array-like
+ x positions
+ y : array-like
+ y positions
+ m : array-like, optional
+ magnitude to be added in hover label, by default None
+ xe : array-like, optional
+ x errors to be added in hover label, by default None
+ ye : array-like, optional
+ y errors to be added in hover label, by default None
+ me : array-like, optional
+ magnitude errors to be added in hover label, by default None
+ star_name : array-like, optional
+ Star names to be added in hover label, by default None
+ marker_size : int, optional
+ Size of marker, by default 10
+ color : array or str, optional
+ Color of marker, either a string (e.g., 'red') or rgba array, by default None
+ alpha : float, optional
+ Opacity of marker color, by default 0.7
+ symbol : str, optional
+ Marker symbol, by default 'circle'
+ label : str, optional
+ Label for the star list, by default None
+ xlabel : str, optional
+ Label for the x-axis, by default 'x'
+ ylabel : str, optional
+ Label for the y-axis, by default 'y'
+ fig : plotly.graph_objects.Figure object, optional
+ Figure if the stars are to be added to an exisiting plot, by default None
+ figsize : tuple, optional
+ Figure size, by default (700, 700)
+ show : bool, optional
+ Show figure or not. By default: True if fig is None, False if fig is not None, by default None
+
+ Returns
+ -------
+ fig : plotly.graph_objects.Figure
+ Figure object
+ """
+ import plotly.graph_objects as go
+ x = np.asarray(x)
+ y = np.asarray(y)
+ hover_template = 'x: %{x:.3f} y: %{y:.3f}'
+
+ if isinstance(color, str) and color.startswith('C') and color[1:].isdigit():
+ color = mcolors.to_rgba(color, alpha=alpha)
+ color = f'rgba({color[0]*255}, {color[1]*255}, {color[2]*255}, {color[3]:.2f})'
+
+ customdata = []
+
+ if star_name is not None:
+ hover_template = 'name: %{customdata[0]} ' + hover_template
+ customdata.append(star_name)
+
+ if label is not None:
+ hover_template = f'{label} ' + hover_template
+
+ if m is not None:
+ m = np.asarray(m)
+ m_idx = len(customdata)
+ hover_template += f' m: %{{customdata[{m_idx}]:.2f}}'
+ customdata.append(m)
+
+ if xe is not None:
+ xe = np.asarray(xe)
+ xe_idx = len(customdata)
+ hover_template += f' xe: %{{customdata[{xe_idx}]:.2e}}'
+ customdata.append(xe)
+
+ if ye is not None:
+ ye = np.asarray(ye)
+ ye_idx = len(customdata)
+ hover_template += f' ye: %{{customdata[{ye_idx}]:.2e}}'
+ customdata.append(ye)
+
+ if me is not None:
+ me = np.asarray(me)
+ me_idx = len(customdata)
+ hover_template += f' me: %{{customdata[{me_idx}]:.2e}}'
+ customdata.append(me)
+
+ if customdata:
+ customdata = np.column_stack(customdata)
+ hover_template += ''
+
+ fig_data = go.Scattergl(
+ x=x,
+ y=y,
+ mode='markers',
+ marker=dict(
+ size=marker_size,
+ color=color,
+ symbol=symbol
+ ),
+ customdata=customdata,
+ hovertemplate=hover_template,
+ name=label
+ )
+
+ if fig is None:
+ fig = go.Figure(data=[fig_data])
+ show = True if show is None else show
+ else:
+ fig.add_trace(fig_data)
+ show = False if show is None else show
+
+ fig.update_layout(
+ xaxis_title=xlabel,
+ yaxis_title=ylabel,
+ xaxis=dict(scaleanchor='y', scaleratio=1), # Ensure equal aspect ratio
+ width=figsize[0],
+ height=figsize[1]
+ )
+ if show:
+ fig.show()
+ return fig
\ No newline at end of file
diff --git a/flystar/starlists.py b/flystar/starlists.py
index be49458..1a0e462 100644
--- a/flystar/starlists.py
+++ b/flystar/starlists.py
@@ -1,8 +1,7 @@
+import warnings
import numpy as np
-from astropy.table import Table, Column, MaskedColumn
import astropy.table
-import warnings
-import pdb
+from astropy.table import Table, Column, MaskedColumn
try:
set
@@ -31,7 +30,7 @@ def restrict_by_name(table1, table2):
name1 = table1['name']
name2 = table2['name']
-
+
Name = np.intersect1d(name1, name2)
# trim out stars begin with 'star'
idx = []
@@ -67,7 +66,7 @@ def restrict_by_area(table1, area, exclude=False):
exclude: boolean (default=False)
If true, *exclude* the stars that fall within the given area. If false,
then only return stars that fall within the given area
-
+
Output:
------
array of indicies corresponding to stars which are within the designated
@@ -76,7 +75,7 @@ def restrict_by_area(table1, area, exclude=False):
# Extract star coordinates
xpos = table1['x']
ypos = table1['y']
-
+
# Extract desired coordinate ranges
x_range = area[0]
y_range = area[1]
@@ -89,7 +88,7 @@ def restrict_by_area(table1, area, exclude=False):
else:
good = np.where( ( (xpos < x_range[0]) | (xpos > x_range[1]) ) &
( (ypos < y_range[0]) | (ypos > y_range[1]) ) )
-
+
return good[0]
def restrict_by_use(label_mat, starlist_mat, idx_label, idx_starlist):
@@ -114,7 +113,7 @@ def restrict_by_use(label_mat, starlist_mat, idx_label, idx_starlist):
idx_starlist: array of indicies
Indicies of the matched stars in the starlist.
-
+
Output:
-------
idx_label_f: array of indicies in the label catalog that fulfill the restrict
@@ -122,15 +121,15 @@ def restrict_by_use(label_mat, starlist_mat, idx_label, idx_starlist):
idx_starlist_f: array of indicies in the starlist that fulfill the restrict
condition
-
-
+
+
label_trim: astropy table
label table with only use > 2 stars
starlist_trim: astropy table
reference table with only stars that correspond to use > 2 stars
in the label_mat table.
-
+
"""
print( 'Restrict option activated')
@@ -151,7 +150,7 @@ def restrict_by_use(label_mat, starlist_mat, idx_label, idx_starlist):
print( 'Restrict option activated')
print(( 'Keeping {0} of {1} stars'.format(len(idx_restrict),
len(label_mat))))
-
+
return idx_label_f, idx_starlist_f
@@ -188,7 +187,7 @@ def read_label(labelFile, prop_to_time=None, flipX=True):
If true, multiply the x positions and velocities by -1.0. This is
useful when label.dat has +x to the east, while reference starlist
has +x to the west.
-
+
#OLD# tref: reference epoch that label.dat is converted to.
Output:
@@ -196,11 +195,11 @@ def read_label(labelFile, prop_to_time=None, flipX=True):
labelFile: astropy.table.
containing name, m, x0, y0, x0e, y0e, vx, vy, vxe, vye, t0, use, r0,
(if prop_to_time: x, y, xe, ye, t)
-
+
x and y is in arcsec,
converted to tref epoch,
*(-1) so it increases to west
-
+
vx, vy, vxe, vye is converted to arcsec/yr
"""
@@ -209,12 +208,12 @@ def read_label(labelFile, prop_to_time=None, flipX=True):
t_label.rename_column('col2', 'm')
t_label.rename_column('col3', 'x0')
t_label.rename_column('col4', 'y0')
- t_label.rename_column('col5', 'x0e')
- t_label.rename_column('col6', 'y0e')
+ t_label.rename_column('col5', 'x0_err')
+ t_label.rename_column('col6', 'y0_err')
t_label.rename_column('col7', 'vx')
t_label.rename_column('col8', 'vy')
- t_label.rename_column('col9', 'vxe')
- t_label.rename_column('col10','vye')
+ t_label.rename_column('col9', 'vx_err')
+ t_label.rename_column('col10','vy_err')
t_label.rename_column('col11','t0')
t_label.rename_column('col12','use')
t_label.rename_column('col13','r0')
@@ -222,23 +221,23 @@ def read_label(labelFile, prop_to_time=None, flipX=True):
# Convert velocities from mas/yr to arcsec/year
# t_label['vx'] *= 0.001
# t_label['vy'] *= 0.001
-# t_label['vxe'] *= 0.001
-# t_label['vye'] *= 0.001
+# t_label['vx_err'] *= 0.001
+# t_label['vy_err'] *= 0.001
t_label['vx'] = t_label['vx'] * 0.001
t_label['vy'] = t_label['vy'] * 0.001
- t_label['vxe'] = t_label['vxe'] * 0.001
- t_label['vye'] = t_label['vye'] * 0.001
+ t_label['vx_err'] = t_label['vx_err'] * 0.001
+ t_label['vy_err'] = t_label['vy_err'] * 0.001
# propogate to prop_to_time if prop_to_time is given
if prop_to_time != None:
x0 = t_label['x0']
- x0e = t_label['x0e']
+ x0e = t_label['x0_err']
vx = t_label['vx']
- vxe = t_label['vxe']
+ vxe = t_label['vx_err']
y0 = t_label['y0']
- y0e = t_label['y0e']
+ y0e = t_label['y0_err']
vy = t_label['vy']
- vye = t_label['vye']
+ vye = t_label['vy_err']
t0 = t_label['t0']
t_label['x'] = x0 + vx*(prop_to_time - t0)
t_label['y'] = y0 + vy*(prop_to_time - t0)
@@ -248,7 +247,7 @@ def read_label(labelFile, prop_to_time=None, flipX=True):
t_label['y'].format = '.5f'
t_label['xe'].format = '.5f'
t_label['ye'].format = '.5f'
-
+
# flip the x axis if flipX is True
if flipX == True:
t_label['x0'] = t_label['x0'] * (-1.0)
@@ -295,7 +294,7 @@ def read_label_accel(labelFile, prop_to_time=None, flipX=True):
If true, multiply the x positions and velocities by -1.0. This is
useful when label.dat has +x to the east, while reference starlist
has +x to the west.
-
+
#OLD# tref: reference epoch that label.dat is converted to.
Output:
@@ -303,11 +302,11 @@ def read_label_accel(labelFile, prop_to_time=None, flipX=True):
labelFile: astropy.table.
containing name, m, x0, y0, x0e, y0e, vx, vy, vxe, vye, t0, use, r0,
(if prop_to_time: x, y, xe, ye, t)
-
+
x and y is in arcsec,
converted to tref epoch,
*(-1) so it increases to west
-
+
vx, vy, vxe, vye is converted to arcsec/yr
"""
@@ -316,12 +315,12 @@ def read_label_accel(labelFile, prop_to_time=None, flipX=True):
t_label.rename_column('col2', 'm')
t_label.rename_column('col3', 'x0')
t_label.rename_column('col4', 'y0')
- t_label.rename_column('col5', 'x0e')
- t_label.rename_column('col6', 'y0e')
+ t_label.rename_column('col5', 'x0_err')
+ t_label.rename_column('col6', 'y0_err')
t_label.rename_column('col7', 'vx')
t_label.rename_column('col8', 'vy')
- t_label.rename_column('col9', 'vxe')
- t_label.rename_column('col10','vye')
+ t_label.rename_column('col9', 'vx_err')
+ t_label.rename_column('col10','vy_err')
t_label.rename_column('col11', 'ax')
t_label.rename_column('col12', 'ay')
t_label.rename_column('col13', 'axe')
@@ -333,12 +332,12 @@ def read_label_accel(labelFile, prop_to_time=None, flipX=True):
# Convert velocities from mas/yr to arcsec/year
# t_label['vx'] *= 0.001
# t_label['vy'] *= 0.001
-# t_label['vxe'] *= 0.001
-# t_label['vye'] *= 0.001
+# t_label['vx_err'] *= 0.001
+# t_label['vy_err'] *= 0.001
t_label['vx'] = t_label['vx'] * 0.001
t_label['vy'] = t_label['vy'] * 0.001
- t_label['vxe'] = t_label['vxe'] * 0.001
- t_label['vye'] = t_label['vye'] * 0.001
+ t_label['vx_err'] = t_label['vx_err'] * 0.001
+ t_label['vy_err'] = t_label['vy_err'] * 0.001
t_label['ax'] = t_label['ax'] * 0.001
t_label['ay'] = t_label['ay'] * 0.001
@@ -348,15 +347,15 @@ def read_label_accel(labelFile, prop_to_time=None, flipX=True):
# propogate to prop_to_time if prop_to_time is given
if prop_to_time != None:
x0 = t_label['x0']
- x0e = t_label['x0e']
+ x0e = t_label['x0_err']
vx = t_label['vx']
- vxe = t_label['vxe']
+ vxe = t_label['vx_err']
ax = t_label['ax']
axe = t_label['axe']
y0 = t_label['y0']
- y0e = t_label['y0e']
+ y0e = t_label['y0_err']
vy = t_label['vy']
- vye = t_label['vye']
+ vye = t_label['vy_err']
ay = t_label['ay']
aye = t_label['aye']
t0 = t_label['t0']
@@ -411,21 +410,21 @@ def read_starlist(starlistFile, error=True):
col7: corr
col8: N_frames
col9: ? (left as default)
-
+
error: boolean (default=True)
If true, assumes starlist has error columns. This significantly
changes the order of the columns.
-
+
Output:
------
starlist astropy table.
containing: name, m, x, y, xe, ye, t
"""
- t_ref = Table.read(starlistFile, format='ascii', delimiter='\s')
+ t_ref = Table.read(starlistFile, format='ascii', delimiter=r'\s')
# Check if this already has column names:
cols = t_ref.colnames
-
+
if cols[0] != 'col1':
t_ref['name'] = t_ref['name'].astype(str)
return t_ref
@@ -436,7 +435,7 @@ def read_starlist(starlistFile, error=True):
t_ref.rename_column(cols[2], 't')
t_ref.rename_column(cols[3], 'x')
t_ref.rename_column(cols[4], 'y')
-
+
if error==True:
t_ref.rename_column(cols[5], 'xe')
t_ref.rename_column(cols[6], 'ye')
@@ -449,120 +448,123 @@ def read_starlist(starlistFile, error=True):
t_ref.rename_column(cols[6], 'corr')
t_ref.rename_column(cols[7], 'N_frames')
t_ref.rename_column(cols[8], 'flux')
-
+
return t_ref
class StarList(Table):
- """
- A StarList is an astropy.Table with star catalog from a single image.
-
- Required table columns (input as keywords):
- -------------------------
- name : 1D numpy.array with shape = N_stars
- List of names of the stars in the table.
+ def __init__(self, *args, **kwargs):
+ """
+ A StarList is an astropy.Table with star catalog from a single image.
- x : 1D numpy.array with shape = N_stars
- Positions of N_stars in the x dimension.
+ Required table columns (input as keywords):
+ -------------------------
+ name : 1D numpy.array with shape = N_stars
+ List of names of the stars in the table.
- y : 1D numpy.array with shape = N_stars
- Positions of N_stars in the y dimension.
+ x : 1D numpy.array with shape = N_stars
+ Positions of N_stars in the x dimension.
- m : 1D numpy.array with shape = N_stars
- Magnitudes of N_stars.
+ y : 1D numpy.array with shape = N_stars
+ Positions of N_stars in the y dimension.
- Optional table columns (input as keywords):
- -------------------------
- xe : 1D numpy.array with shape = N_stars
- Position uncertainties of N_stars in the x dimension.
+ m : 1D numpy.array with shape = N_stars
+ Magnitudes of N_stars.
- ye : 1D numpy.array with shape = N_stars
- Position uncertainties of N_stars in the y dimension.
+ Optional table columns (input as keywords):
+ -------------------------
+ xe : 1D numpy.array with shape = N_stars
+ Position uncertainties of N_stars in the x dimension.
- me : 1D numpy.array with shape = N_stars
- Magnitude uncertainties of N_stars.
-
- corr : 1D numpy.array with shape = N_stars
- Fitting correlation of N_stars.
+ ye : 1D numpy.array with shape = N_stars
+ Position uncertainties of N_stars in the y dimension.
- Optional table meta data
- -------------------------
- list_name : str
- Name of the starlist.
+ me : 1D numpy.array with shape = N_stars
+ Magnitude uncertainties of N_stars.
- list_time : int or float
- Time/date of the starlist.
+ corr : 1D numpy.array with shape = N_stars
+ Fitting correlation of N_stars.
+ Optional table meta data
+ -------------------------
+ list_name : str
+ Name of the starlist.
- """
-
- def __init__(self, *args, **kwargs):
- """
+ list_time : int or float
+ Time/date of the starlist.
"""
# Check if the required arguments are present
arg_req = ('name', 'x', 'y', 'm')
found_all_required = True
-
+
for arg_test in arg_req:
if arg_test not in kwargs:
found_all_required = False
if not found_all_required:
- if not ('copy' in kwargs) | ('names' in kwargs.keys()) | \
- ('masked' in kwargs.keys()): # If it's not making a copy of the
- # StarList or replacing columns or selecting from slices
+ # A single positional Table-like argument (another Table/StarList,
+ # a dict/OrderedDict of Columns, a list of Columns, etc.) can
+ # already carry name/x/y/m even though they're not in kwargs --
+ # e.g. astropy's Table.__setstate__ reconstructs a pickled
+ # StarList as self.__init__(columns_dict, meta=meta), which is
+ # exactly this case. Don't warn then.
+ has_required_positionally = False
+ if len(args) == 1:
+ candidate = args[0]
+ if hasattr(candidate, 'colnames'):
+ candidate_names = candidate.colnames
+ elif hasattr(candidate, 'keys'):
+ candidate_names = list(candidate.keys())
+ elif isinstance(candidate, (list, tuple)) and all(hasattr(c, 'name') for c in candidate):
+ candidate_names = [c.name for c in candidate]
+ else:
+ candidate_names = []
+ has_required_positionally = all(a in candidate_names for a in arg_req)
+
+ if not has_required_positionally and not any(key in kwargs for key in ['copy', 'names', 'masked']):
+ # If it's not making a copy of the StarList or replacing columns or selecting from slices
err_msg = "The StarList class requires a arguments" + str(arg_req)
warnings.warn(err_msg, UserWarning)
- Table.__init__(self, *args, **kwargs)
+ super().__init__(*args, **kwargs)
else:
# If we have errors, we need them in both dimensions.
if ('xe' in kwargs) ^ ('ye' in kwargs):
- raise TypeError("The StarList class requires both 'xe' and" +
- " 'ye' arguments")
+ raise TypeError("The StarList class requires both 'xe' and 'ye' arguments")
# Figure out the shape
+ kwargs['x'] = np.array(kwargs['x'])
n_stars = kwargs['x'].shape[0]
# Check if the type and size of the arguments are correct.
# Name checking: type and shape
+ kwargs['name'] = np.array(kwargs['name'])
if (not isinstance(kwargs['name'], np.ndarray)) or (
len(kwargs['name']) != n_stars):
- err_msg = "The '{0:s}' argument has to be a numpy array "
- err_msg += "with length = {1:d}"
- raise TypeError(err_msg.format('name', n_stars))
+ raise TypeError(f"The 'name' argument has to be a numpy array with length {n_stars}, but has type {type(kwargs['name'])} and length {len(kwargs['name'])}")
# Check all the arrays.
arg_tab = ('x', 'y', 'm', 'xe', 'ye', 'me', 'corr')
+ #print(kwargs)
+
for arg_test in arg_tab:
if arg_test in kwargs:
- if not isinstance(kwargs[arg_test], np.ndarray):
- err_msg = "The '{0:s}' argument has to be a numpy array"
- raise TypeError(err_msg.format(arg_test))
-
+ kwargs[arg_test] = np.array(kwargs[arg_test])
if kwargs[arg_test].shape != (n_stars,):
- err_msg = "The '{0:s}' argument has to have shape = ({1:d},)"
- raise TypeError(err_msg.format(arg_test, n_stars))
+ raise ValueError(f"The '{arg_test:s}' argument has to match the shape of x ({n_stars:d},), but has shape {kwargs[arg_test].shape}")
# We have to have special handling of meta-data
meta_tab = ('list_time', 'list_name')
meta_type = ((float, int), str)
- for mm in range(len(meta_tab)):
- meta_test = meta_tab[mm]
- meta_type_test = meta_type[mm]
-
- if meta_test in kwargs:
-
- if not isinstance(kwargs[meta_test], meta_type_test):
- err_msg = "The '{0:s}' argument has to be a {1:s}."
- raise TypeError(
- err_msg.format(meta_test, str(meta_type_test)))
+ for mtab, mtype in zip(meta_tab, meta_type):
+ if (mtab in kwargs) and (not isinstance(kwargs[mtab], mtype)):
+ raise TypeError(f"The '{mtab:s}' argument has to be a {mtype:s}, but has type {type(kwargs[mtab])}")
#####
# Create the starlist
#####
- Table.__init__(self,
+ super().__init__(
(kwargs['name'], kwargs['x'], kwargs['y'], kwargs['m']),
names=('name', 'x', 'y', 'm'))
self.meta = {'n_stars': n_stars}
@@ -575,13 +577,12 @@ def __init__(self, *args, **kwargs):
if arg in ['name', 'x', 'y', 'm']:
continue
if arg in kwargs:
- # 2022-08-25: Need to explicitly add MaskedColumn if
- # data is masked
+ # 2022-08-25: Need to explicitly add MaskedColumn if data is masked
if isinstance(kwargs[arg], MaskedColumn):
self.add_column(MaskedColumn(data=kwargs[arg], name=arg))
else:
self.add_column(Column(data=kwargs[arg], name=arg))
-
+
return
@classmethod
@@ -622,7 +623,7 @@ def from_lis_file(cls, filename, error=True, fvu_file=None):
------
starlists.StarList() object (subclass of Astropy Table).
"""
- t_ref = Table.read(filename, format='ascii', delimiter='\s')
+ t_ref = Table.read(filename, format='ascii', delimiter=r'\s')
# Check if this already has column names:
cols = t_ref.colnames
@@ -639,7 +640,7 @@ def from_lis_file(cls, filename, error=True, fvu_file=None):
t_ref.rename_column(cols[2], 't')
t_ref.rename_column(cols[3], 'x')
t_ref.rename_column(cols[4], 'y')
-
+
if error==True:
t_ref.rename_column(cols[5], 'xe')
t_ref.rename_column(cols[6], 'ye')
@@ -652,7 +653,7 @@ def from_lis_file(cls, filename, error=True, fvu_file=None):
t_ref.rename_column(cols[6], 'corr')
t_ref.rename_column(cols[7], 'N_frames')
t_ref.rename_column(cols[8], 'flux')
-
+
if ('me' not in cols) and ('snr' in cols) and (error == True):
t_ref['me'] = 1.0 / t_ref['snr']
@@ -665,16 +666,16 @@ def from_lis_file(cls, filename, error=True, fvu_file=None):
msg = 'Star list and metric list have different lengths.\n'
msg += '\t len(stars) = {0:d}\n'
msg += '\t len(fvu) = {1:d}\n'
-
+
raise RuntimeError(msg.format(len(t_ref), len(t_fvu)))
-
- t_ref = astropy.table.hstack([t_ref, t_fvu])
+
+ t_ref = astropy.table.hstack([t_ref, t_fvu])
return cls.from_table(t_ref)
def to_lis_file(self, filename):
_out = open(filename, 'w')
-
+
hdr = '{name:13s} {mag:>6s} {year:>8s} '
hdr += '{x:>9s} {y:>9s} {xe:>9s} {ye:>9s} '
hdr += '{snr:>20s} {corr:>6s} {nimg:>8s} {flux:>20s}\n'
@@ -682,7 +683,7 @@ def to_lis_file(self, filename):
_out.write(hdr.format(name='# name', mag='m', year='t',
x='x', y='y', xe='xe', ye='ye',
snr='snr', corr='corr', nimg='N_frames', flux='flux'))
-
+
fmt = '{name:13s} {mag:6.3f} {year:8.3f} '
fmt += '{x:9.3f} {y:9.3f} {xe:9.3f} {ye:9.3f} '
@@ -695,10 +696,10 @@ def to_lis_file(self, filename):
flux=self['flux'][ss]))
_out.close()
-
+
return
-
-
+
+
@classmethod
def from_table(cls, table):
"""
@@ -707,7 +708,7 @@ def from_table(cls, table):
will be added to the new StarList object that is returned.
"""
starlist = cls(name=table['name'], x=table['x'], y=table['y'], m=table['m'], meta=table.meta)
-
+
for col in table.colnames:
if col in ['name', 'x', 'y', 'm']:
continue
@@ -719,10 +720,10 @@ def from_table(cls, table):
def fubar(self):
print('This is in StarList')
return
-
+
def restrict_by_value(self, **kwargs):
"""
- Restrict a table to any min/max range of column values. For instance,
+ Restrict a table to any min/max range of column values. For instance,
to restrict to only stars between 10 <= m <= 15, use:
starlist.restrict_by_value(m_min=10, m_max=15)
@@ -730,31 +731,31 @@ def restrict_by_value(self, **kwargs):
where 'm' was the column name.
This function acts on self, so the rows are removed
- forever.
+ forever.
"""
# Loop through all conditions and build up
- # an array of indicies of rows to remove.
+ # an array of indicies of rows to remove.
remove_flag = np.zeros(len(self), dtype=bool)
-
- for kwarg in kwargs:
- if kwargs[kwarg] is not None:
+
+ for key, value in kwargs.items():
+ if value is not None:
# Get the name of the column to act on and
# whether the condition is min or max.
- kwarg_split = kwarg.split('_')
+ key_split = key.split('_')
- # Support column names such as x_0.
- col = '_'.join(kwarg_split[:-1])
+ # Support column names such as x_0.
+ col = '_'.join(key_split[:-1])
- if kwarg_split[-1] == 'min':
- remove_flag = np.logical_or(remove_flag, self[col] <= kwargs[kwarg])
-
- if kwarg_split[-1] == 'max':
- remove_flag = np.logical_or(remove_flag, self[col] >= kwargs[kwarg])
+ if key_split[-1] == 'min':
+ remove_flag = np.logical_or(remove_flag, self[col] <= value)
+
+ if key_split[-1] == 'max':
+ remove_flag = np.logical_or(remove_flag, self[col] >= value)
rem_idx = np.where(remove_flag == True)[0]
-
+
self.remove_rows(rem_idx)
-
+
return
def transform_xym(self, trans):
@@ -767,7 +768,7 @@ def transform_xym(self, trans):
self.transform_xy(trans)
self.transform_m(trans)
-
+
return
def transform_xy(self, trans):
@@ -779,7 +780,7 @@ def transform_xy(self, trans):
"""
if trans == None:
return
-
+
x_T, y_T = trans.evaluate(self['x'], self['y'])
self['x'] = x_T
self['y'] = y_T
@@ -790,7 +791,7 @@ def transform_xy(self, trans):
self['ye'] = ye_T
return
-
+
def transform_m(self, trans):
"""
Apply a transformation (instance of flystar.transforms.Transform2D)
@@ -800,17 +801,78 @@ def transform_m(self, trans):
"""
if trans == None:
return
-
+
m_T = trans.evaluate_mag(self['m'])
self['m'] = m_T
if 'me' in self.colnames:
me_T = trans.evaluate_magerror(self['m'], self['me'])
self['me'] = me_T
-
+
return
+
+def write_region(x, y, save_path, frame='image', colors='magenta', shape='circle', shape_properties={'radius': 10}):
+ """
+ Write a DS9 region file with the given x, y coordinates.
+
+ Parameters:
+ ----------
+ x: 1D numpy.array
+ X coordinates of the stars to write to the region file.
+ y: 1D numpy.array
+ Y coordinates of the stars to write to the region file.
+ frame: str
+ Frame of reference for the coordinates. Default is 'image'. Other options include 'fk5', 'icrs', 'galactic', 'wcs', etc.
+ See https://ds9.si.edu/doc/ref/region.html for more details.
+ save_path: str
+ Path to the file where the region file will be saved.
+ colors: str or list of str
+ Color(s) of the regions. If a single string is given, all regions will be that color.
+ If a list of strings is given, it must have the same length as x and y.
+ shape: str
+ Shape of the regions. Default is 'circle'. Other options include 'box', 'ellipse', etc.
+ shape_properties: dict
+ Dictionary of properties for the shape. For example, for circles, you can specify {'radius': 10}.
+ For boxes, you can specify {'width': 20, 'height': 10}.
+
+ Output:
+ ------
+ A DS9 region file will be created at the specified save_path.
+ """
+ if isinstance(colors, str):
+ colors = [colors] * len(x)
+
+ if shape == 'circle':
+ radius = shape_properties.get('radius', 1)
+ write_format = f'circle {{x}} {{y}} {radius} # color={{color}}\n'
+ elif shape == 'box':
+ width = shape_properties.get('width', 3)
+ height = shape_properties.get('height', 3)
+ angle = shape_properties.get('angle', 0)
+ write_format = f'box {{x}} {{y}} {width} {height} {angle} # color={{color}}\n'
+ elif shape == 'ellipse':
+ semimajor = shape_properties.get('semi-major', 6)
+ semiminor = shape_properties.get('semi-minor', 3)
+ angle = shape_properties.get('angle', 0)
+ write_format = f'ellipse {{x}} {{y}} {semimajor} {semiminor} {angle} # color={{color}}\n'
+ elif shape == 'point':
+ point = shape_properties.get('point', 'circle')
+ size = shape_properties.get('size', 3)
+ write_format = f'point {{x}} {{y}} # point={point} {size} color={{color}}\n'
+ else:
+ raise ValueError(f"Unsupported shape: {shape}")
+
+ with open(save_path, 'w') as f:
+ f.write('# Region file format: DS9 version 4.1\n')
+ f.write('global color=green dashlist=8 3 width=1 font="helvetica 10 normal" select=1 highlite=1 dash=0 fixed=0 edit=1 move=1 delete=1 include=1 source=1\n')
+ f.write(f'{frame}\n')
+ for i in range(len(x)):
+ f.write(write_format.format(x=x[i], y=y[i], color=colors[i]))
+
+ return
+
def write_starlist(list, outfile):
formats = {'name': '%-13s',
@@ -834,4 +896,3 @@ def write_starlist(list, outfile):
return outfile
-
diff --git a/flystar/startables.py b/flystar/startables.py
index 84953a9..79074f3 100644
--- a/flystar/startables.py
+++ b/flystar/startables.py
@@ -1,85 +1,93 @@
-from astropy.table import Table, Column, hstack
-from astropy.stats import sigma_clipping
-from scipy.optimize import curve_fit
-from flystar.fit_velocity import linear_fit, calc_chi2, linear, fit_velocity
-from tqdm import tqdm
-import numpy as np
-import warnings
-import collections
import pdb
-import time
import copy
-
+import warnings
+import numpy as np
+from tqdm import tqdm
+from multiprocessing import Pool
+from astropy.time import Time
+from astropy.stats import sigma_clip
+from astropy.table import Table, Column
+from pandas.api.types import is_string_dtype
+from collections.abc import Iterable
+from flystar import motion_model
class StarTable(Table):
- """
- A StarTable is an astropy.Table with stars matched from multiple starlists.
+ def __init__(self, *args, ref_list=0, copy=True, **kwargs):
+ """
+ A StarTable is an astropy.Table with stars matched from multiple starlists.
- Required table columns (input as keywords):
- -------------------------
- name : 1D numpy.array with shape = N_stars
- List of unique names for each of the stars in the table.
+ Required table columns (input as keywords):
+ -------------------------
+ name : 1D numpy.array with shape = N_stars
+ List of unique names for each of the stars in the table.
- x : 2D numpy.array with shape = (N_stars, N_lists)
- Positions of N_stars in each of N_lists in the x dimension.
+ x : 2D numpy.array with shape = (N_stars, N_lists)
+ Positions of N_stars in each of N_lists in the x dimension.
- y : 2D numpy.array with shape = (N_stars, N_lists)
- Positions of N_stars in each of N_lists in the y dimension.
+ y : 2D numpy.array with shape = (N_stars, N_lists)
+ Positions of N_stars in each of N_lists in the y dimension.
- m : 2D numpy.array with shape = (N_stars, N_lists)
- Magnitudes of N_stars in each of N_lists.
+ m : 2D numpy.array with shape = (N_stars, N_lists)
+ Magnitudes of N_stars in each of N_lists.
- Optional table columns (input as keywords):
- -------------------------
- xe : 2D numpy.array with shape = (N_stars, N_lists)
- Position uncertainties of N_stars in each of N_lists in the x dimension.
+ Optional table columns (input as keywords):
+ -------------------------
+ motion_model : 1D numpy.array with shape = N_stars
+ string indicating motion model type for each star
- ye : 2D numpy.array with shape = (N_stars, N_lists)
- Position uncertainties of N_stars in each of N_lists in the y dimension.
+ xe : 2D numpy.array with shape = (N_stars, N_lists)
+ Position uncertainties of N_stars in each of N_lists in the x dimension.
- me : 2D numpy.array with shape = (N_stars, N_lists)
- Magnitude uncertainties of N_stars in each of N_lists.
+ ye : 2D numpy.array with shape = (N_stars, N_lists)
+ Position uncertainties of N_stars in each of N_lists in the y dimension.
- ep_name : 2D numpy.array with shape = (N_stars, N_lists)
- Names in each epoch for each of N_stars in each of N_lists. This is
- useful for tracking purposes.
-
- corr : 2D numpy.array with shape = (N_stars, N_lists)
- Fitting correlation for each of N_stars in each of N_lists.
+ me : 2D numpy.array with shape = (N_stars, N_lists)
+ Magnitude uncertainties of N_stars in each of N_lists.
- Optional table meta data
- -------------------------
- list_names : list of strings
- List of names, one for each of the starlists.
+ ep_name : 2D numpy.array with shape = (N_stars, N_lists)
+ Names in each epoch for each of N_stars in each of N_lists. This is
+ useful for tracking purposes.
- list_times : list of integers or floats
- List of times/dates for each starlist.
+ corr : 2D numpy.array with shape = (N_stars, N_lists)
+ Fitting correlation for each of N_stars in each of N_lists.
- ref_list : int
- Specify which list is the reference list (if any).
+ Optional table meta data
+ -------------------------
+ list_names : list of strings
+ List of names, one for each of the starlists.
+ list_times : list of integers or floats
+ List of times/dates for each starlist.
- Examples
- --------------------------
+ ref_list : int
+ Specify which list is the reference list (if any).
- t = startables.StarTable(name=name, x=x, y=y, m=m)
+ copy : bool, optional
+ If True (default), the table makes its own independent copy of
+ every input array -- safe if the caller might mutate their
+ arrays afterward. If False, arrays that are already a
+ compatible ndarray are used directly without copying (they're
+ still converted/copied if genuinely necessary, e.g. from a
+ list or an incompatible dtype) -- only pass False when you
+ know the caller won't touch these arrays again (e.g. they were
+ just freshly built and not stored anywhere else), since the
+ table's data would otherwise alias and mutating one would
+ silently mutate the other.
- # Access the data:
- print(t)
- print(t['name'][0:10]) # print the first 10 star names
- print(t['x'][0:10, 0]) # print x from the first epoch/list/column for the first 10 stars
- """
- def __init__(self, *args, ref_list=0, **kwargs):
- """
+ Examples
+ --------------------------
+
+ t = startables.StarTable(name=name, x=x, y=y, m=m)
+
+ # Access the data:
+ print(t)
+ print(t['name'][0:10]) # print the first 10 star names
+ print(t['x'][0:10, 0]) # print x from the first epoch/list/column for the first 10 stars
"""
-
+
# Check if the required arguments are present
arg_req = ('name', 'x', 'y', 'm')
-
- found_all_required = True
- for arg_test in arg_req:
- if arg_test not in kwargs:
- found_all_required = False
+ found_all_required = all(arg in kwargs for arg in arg_req)
if not found_all_required:
if len(args) > 1: # If there are no arguments, it's because the
@@ -88,12 +96,26 @@ def __init__(self, *args, ref_list=0, **kwargs):
# columns selected
err_msg = "The StarTable class requires arguments: " + str(arg_req)
warnings.warn(err_msg, UserWarning)
- Table.__init__(self, *args, **kwargs)
+ Table.__init__(self, *args, copy=copy, **kwargs)
else:
# If we have errors, we need them in both dimensions.
if ('xe' in kwargs) ^ ('ye' in kwargs):
raise TypeError("The StarTable class requires both 'xe' and" +
" 'ye' arguments")
+ # np.array(..., copy=True) (the default) always copies; np.asarray
+ # only converts/copies when actually necessary (e.g. a list, or an
+ # incompatible dtype) -- pass a caller-owned, already-correct
+ # ndarray straight through with copy=False.
+ array_convert = np.array if copy else np.asarray
+ kwargs['name'] = array_convert(kwargs['name'])
+ kwargs['x'] = array_convert(kwargs['x'])
+ kwargs['y'] = array_convert(kwargs['y'])
+ kwargs['m'] = array_convert(kwargs['m'])
+ if ('xe' in kwargs) and ('ye' in kwargs):
+ kwargs['xe'] = array_convert(kwargs['xe'])
+ kwargs['ye'] = array_convert(kwargs['ye'])
+ if 'me' in kwargs:
+ kwargs['me'] = array_convert(kwargs['me'])
# Figure out the shape
n_stars = kwargs['x'].shape[0]
@@ -101,10 +123,9 @@ def __init__(self, *args, ref_list=0, **kwargs):
# Check if the type and size of the arguments are correct.
# Name checking: type and shape
- if (not isinstance(kwargs['name'], np.ndarray)) or (len(kwargs['name']) != n_stars):
- err_msg = "The '{0:s}' argument has to be a numpy array "
- err_msg += "with length = {1:d}"
- raise TypeError(err_msg.format('name', n_stars))
+ if len(kwargs['name']) != n_stars:
+ err_msg += f"The 'name' argument length should be {n_stars}, but got {len(kwargs['name'])}."
+ raise TypeError(err_msg)
# Check all the 2D arrays.
arg_tab = ('x', 'y', 'm', 'xe', 'ye', 'me', 'name_in_list')
@@ -112,63 +133,78 @@ def __init__(self, *args, ref_list=0, **kwargs):
for arg_test in arg_tab:
if arg_test in kwargs:
if not isinstance(kwargs[arg_test], np.ndarray):
- err_msg = "The '{0:s}' argument has to be a numpy array"
- raise TypeError(err_msg.format(arg_test))
+ err_msg = f"The '{arg_test}' argument has to be a numpy array, not {type(kwargs[arg_test])}"
+ raise TypeError(err_msg)
if kwargs[arg_test].shape != (n_stars, n_lists):
- err_msg = "The '{0:s}' argument has to have shape = ({1:d}, {2:d})"
- raise TypeError(err_msg.format(arg_test, n_stars, n_lists))
+ err_msg = f"The '{arg_test}' argument has to have shape = ({n_stars}, {n_lists}), but got {kwargs[arg_test].shape}"
+ raise TypeError(err_msg)
# Check that the reference list is specified.
if ref_list not in range(n_lists):
- err_msg = "The 'ref_list' argument has to be an integer between 0 and {0:d}"
- raise IndexError(err_msg.format(n_lists-1))
+ err_msg = f"The 'ref_list' argument has to be an integer between 0 and {n_lists-1}"
+ raise IndexError(err_msg)
# We have to have special handling of meta-data (i.e. info that has
# dimensions of n_lists).
- meta_tab = ('LIST_TIMES', 'LIST_NAMES')
+ meta_tab = ('list_times', 'list_names')
meta_type = ((float, int), str)
- for mm in range(len(meta_tab)):
- meta_test = meta_tab[mm]
- meta_type_test = meta_type[mm]
-
- if meta_test in kwargs:
- if len(kwargs[meta_test]) != n_lists:
- err_msg = "The '{0:s}' argument has to have length = {1:d}"
- raise ValueError(err_msg.format(meta_test, n_lists))
-
- if not all(isinstance(tt, meta_type_test) for tt in kwargs[meta_test]):
- err_msg = "The '{0:s}' argument has to be a list of {1:s}."
- raise TypeError(err_msg.format(meta_test, str(meta_type_test)))
+ for mtab, mtype in zip(meta_tab, meta_type):
+ if mtab in kwargs:
+ kwargs[mtab] = list(kwargs[mtab]) # Convert to list, as astropy.Table doesn't like numpy arrays in meta-data.
+ if len(kwargs[mtab]) != n_lists:
+ raise ValueError(f"The '{mtab}' argument has to have length = {n_lists}")
+ if not all(isinstance(tt, mtype) for tt in kwargs[mtab]):
+ raise TypeError(f"The '{mtab}' argument has to be a list of {str(mtype)}.")
#####
# Create the startable
#####
- Table.__init__(self, (kwargs['name'], kwargs['x'], kwargs['y'], kwargs['m']),
- names=('name', 'x', 'y', 'm'))
- self['name'] = self['name'].astype('U20')
- self.meta = {'n_stars': n_stars, 'n_lists': n_lists, 'ref_list': ref_list}
-
+ # Pull the special meta-data args out of kwargs first, so the
+ # column-building loop below doesn't see them.
+ meta_updates = {}
for meta_arg in meta_tab:
if meta_arg in kwargs:
- self.meta[meta_arg] = kwargs[meta_arg]
- del kwargs[meta_arg]
-
+ meta_updates[meta_arg] = kwargs.pop(meta_arg)
+ elif meta_arg.upper() in kwargs:
+ meta_updates[meta_arg] = kwargs.pop(meta_arg.upper())
+
+ # Build every column's (name, data) pair upfront and construct
+ # the whole table in a single call, instead of constructing the
+ # 4 required columns and then add_column()-ing the rest one at
+ # a time. add_column() is dramatically more expensive per call
+ # than passing every column to the constructor together
+ # (confirmed empirically: ~1.2s and +4.6GB for ~29 columns
+ # built via a loop of add_column() calls at ~1.4M rows, vs
+ # ~0.001s and ~0GB for the exact same columns passed to the
+ # constructor at once) -- almost certainly because add_column()
+ # re-validates/re-indexes the whole table on every single call.
+ all_col_names = ['name', 'x', 'y', 'm']
+ all_col_data = [kwargs['name'], kwargs['x'], kwargs['y'], kwargs['m']]
for arg in kwargs:
- if arg in ['name', 'x', 'y', 'm']:
+ if arg in ('name', 'x', 'y', 'm'):
continue
- else:
- self.add_column(Column(data=kwargs[arg], name=arg))
- if arg == 'name_in_list':
- self['name_in_list'] = self['name_in_list'].astype('U20')
+ data = kwargs[arg]
+ if arg in ('name_in_list', 'motion_model_input', 'motion_model_used'):
+ width = 'U30' if arg == 'name_in_list' else 'U20'
+ data = np.asarray(data).astype(width, copy=copy)
+ all_col_names.append(arg)
+ all_col_data.append(data)
+
+ super().__init__(tuple(all_col_data), names=tuple(all_col_names), copy=copy)
+ self['name'] = self['name'].astype('U30')
+ self.meta = {'n_stars': n_stars, 'n_lists': n_lists, 'ref_list': ref_list}
+ self.meta.update(meta_updates)
+ #if 'motion_model_input' not in kwargs:
+ # self['motion_model_input'] = np.repeat(self.default_motion_model, len(self['name']))
return
-
- def add_starlist(self, **kwargs):
+
+ def add_starlist(self, warn_missing_meta=True, **kwargs):
"""
- Add data from a new list to an existing StarTable.
+ Add data from a new list to an existing StarTable.
Note, you can pass in the data via a StarList object or
- via a series of keywords with a 1D array on each.
+ via a series of keywords with a 1D array on each.
In either case, the number of stars must already match
the existing number of stars in the StarTable.
@@ -181,13 +217,22 @@ def add_starlist(self, **kwargs):
Example 2: Pass in data via keywords and 1D arrays.
t.add_starlist(x=x_new, y=y_new, m=m_new)
+ Parameters
+ ----------
+ warn_missing_meta : bool, optional
+ Whether to warn when a per-list meta value (e.g. list_times)
+ already tracked by this table isn't supplied by this call. Set
+ to False when the caller knows that value will be set some other
+ way (e.g. rebuilt in full immediately afterward), so the warning
+ would just be noise about a value that was never meant to be
+ given here. By default True.
"""
# Check if we are dealing with a StarList object or a
# set of arguments with individual arrays.
if 'starlist' in kwargs:
self._add_list_data_from_starlist(kwargs['starlist'])
else:
- self._add_list_data_from_keywords(**kwargs)
+ self._add_list_data_from_keywords(warn_missing_meta=warn_missing_meta, **kwargs)
return
@@ -204,16 +249,27 @@ def _add_list_data_from_starlist(self, starlist):
old_type = self[col_name].info.dtype
new_data = np.empty((old_data.shape[0], old_data.shape[1] + 1), dtype=old_type)
new_data[:, :-1] = old_data
-
+
# Save the new data array (with both old and new data in it) to the table.
- self[col_name] = new_data
-
+ self[col_name] = new_data
+
if (col_name in starlist.colnames): # Add data if it was input
self[col_name][:, -1] = starlist[col_name]
else: # Add junk data it if wasn't input
self._set_invalid_list_values(col_name, -1)
-
-
+
+ # Special case for list_times: Update 't' column in startable
+ if ('list_time' in starlist.meta):
+ if 't' not in self.colnames:
+ self.add_column(Column(data=np.full((len(self), 1), starlist.meta['list_time']), name='t'))
+ else:
+ old_data = self['t'].data
+ old_type = self['t'].info.dtype
+ new_data = np.empty((old_data.shape[0], old_data.shape[1] + 1), dtype=old_type)
+ new_data[:, :-1] = old_data
+ self['t'] = new_data
+ self['t'][:, -1] = starlist.meta['list_time']
+
##########
# Update the table meta-data. Remember that entries are lists not numpy arrays.
##########
@@ -222,38 +278,38 @@ def _add_list_data_from_starlist(self, starlist):
lis_meta_keys = list(starlist.meta.keys())
# append 's' to the end to pluralize the input starlist.
lis_meta_keys_plural = [lis_meta_key + 's' for lis_meta_key in lis_meta_keys]
-
+
for kk in range(len(tab_meta_keys)):
tab_key = tab_meta_keys[kk]
# Meta table entries with a size that matches the n_lists size are the ones
# that need a new value. We have to add something... whatever was passed in or None
- if isinstance(self.meta[tab_key], collections.abc.Iterable) and (len(self.meta[tab_key]) == self.meta['n_lists']):
-
+ if isinstance(self.meta[tab_key], Iterable) and (len(self.meta[tab_key]) == self.meta['n_lists']) and (not isinstance(self.meta[tab_key], str)):
# If we find the key in the starlists' meta argument, then add the new values.
# Otherwise, add "None".
- idx = np.where(lis_meta_keys_plural == tab_key)[0]
- if len(idx) > 0:
- lis_key = lis_meta_keys[idx[0]]
- self.meta[tab_key] = np.append(self.meta[tab_key], [starlist.meta[lis_key]])
+ self.meta[tab_key] = list(self.meta[tab_key]) # Convert to list, as astropy.Table doesn't like numpy arrays in meta-data.
+ idx = lis_meta_keys_plural.index(tab_key) if tab_key in lis_meta_keys_plural else None
+ if idx is not None:
+ lis_key = lis_meta_keys[idx]
+ self.meta[tab_key].append(starlist.meta[lis_key])
else:
self._append_invalid_meta_values(tab_key)
# Update the n_lists meta keyword.
self.meta['n_lists'] += 1
-
+
return
-
-
- def _add_list_data_from_keywords(self, **kwargs):
+
+
+ def _add_list_data_from_keywords(self, warn_missing_meta=True, **kwargs):
# # Check if the required arguments are present
# arg_req = ('x', 'y', 'm')
-
+
# for arg_test in arg_req:
# if arg_test not in kwargs:
# err_msg = "Added lists require a '{0:s}' argument"
# raise TypeError(err_msg.format(arg_test))
-
+
# # If we have errors, we need them in both dimensions.
# if ('xe' in kwargs) ^ ('ye' in kwargs):
# raise TypeError("Added lists with errors require both 'xe' and" +
@@ -263,7 +319,7 @@ def _add_list_data_from_keywords(self, **kwargs):
# If there is no input data for a particular column, then fill it with
# zeros and mask it.
for col_name in self.colnames:
- if (len(self[col_name].data.shape) == 2) and (col_name not in ['detect', 'n_detect']): # Find the 2D columns
+ if (np.ndim(self[col_name].data) == 2) and (col_name not in ['detect', 'n_detect']): # Find the 2D columns
# Make a new 2D array with +1 extra column. Copy over the old data.
# This is much faster than hstack or concatenate according to:
# https://stackoverflow.com/questions/8486294/how-to-add-an-extra-column-to-an-numpy-array
@@ -271,37 +327,53 @@ def _add_list_data_from_keywords(self, **kwargs):
old_type = self[col_name].info.dtype
new_data = np.empty((old_data.shape[0], old_data.shape[1] + 1), dtype=old_type)
new_data[:, :-1] = old_data
-
+
# Save the new data array (with both old and new data in it) to the table.
self[col_name] = new_data
-
+
if (col_name in kwargs): # Add data if it was input
self[col_name][:, -1] = kwargs[col_name]
else: # Add junk data it if wasn't input
self._set_invalid_list_values(col_name, -1)
-
+
# Update the table meta-data. Remember that entries are lists not numpy arrays.
for key in self.meta.keys():
# Meta table entries with a size that matches the n_lists size are the ones
# that need a new value. We have to add something... whatever was passed in or None
- if isinstance(self.meta[key], collections.abc.Iterable) and (len(self.meta[key]) == self.meta['n_lists']):
+ if isinstance(self.meta[key], Iterable) and (len(self.meta[key]) == self.meta['n_lists']) and (not isinstance(self.meta[key], str)):
# If we find the key is the passed in meta argument, then add the new values.
# Otherwise, add "None".
+ self.meta[key] = list(self.meta[key]) # Convert to list, as astropy.Table doesn't like numpy arrays in meta-data.
if 'meta' in kwargs:
new_meta_keys = kwargs['meta'].keys()
if key in new_meta_keys:
- self.meta[key] = np.append(self.meta[key], [kwargs['meta'][key]])
+ self.meta[key].append(kwargs['meta'][key])
else:
- self._append_invalid_meta_values(key)
+ self._append_invalid_meta_values(key, warn=warn_missing_meta)
else:
- self._append_invalid_meta_values(key)
+ self._append_invalid_meta_values(key, warn=warn_missing_meta)
# Update the n_lists meta keyword.
self.meta['n_lists'] += 1
-
+
return
+ @staticmethod
+ def _invalid_float_value(col_name):
+ """
+ The "no data" placeholder for a float column: np.inf for uncertainty
+ columns (xe, ye, me, or anything ending in '_err'), np.nan for
+ everything else (x, y, m, t, ...). Matches the convention already
+ used by add_rows_for_new_stars() for brand-new rows -- without this,
+ the exact same "never detected in this list" situation ends up as
+ NaN or inf depending only on whether the row or the column existed
+ first, not on what the data actually means.
+ """
+ if col_name in ('xe', 'ye', 'me') or col_name.endswith('_err'):
+ return np.inf
+ return np.nan
+
def _set_invalid_list_values(self, col_name, col_idx):
"""
Set the contents of the specified column (in the 2D column objects)
@@ -310,10 +382,10 @@ def _set_invalid_list_values(self, col_name, col_idx):
if np.issubdtype(self[col_name].info.dtype, np.integer):
self[col_name][:, col_idx] = -1
elif np.issubdtype(self[col_name].info.dtype, np.floating):
- self[col_name][:, col_idx] = np.nan
+ self[col_name][:, col_idx] = self._invalid_float_value(col_name)
else:
self[col_name][:, col_idx] = None
-
+
return
def _set_invalid_star_values(self, col_name, row_idx):
@@ -324,36 +396,36 @@ def _set_invalid_star_values(self, col_name, row_idx):
if np.issubdtype(self[col_name].info.dtype, np.integer):
self[col_name][row_idx] = -1
elif np.issubdtype(self[col_name].info.dtype, np.floating):
- self[col_name][row_idx] = np.nan
+ self[col_name][row_idx] = self._invalid_float_value(col_name)
else:
self[col_name][row_idx] = None
-
+
return
-
- def _append_invalid_meta_values(self, key):
+
+ def _append_invalid_meta_values(self, key, warn=True):
"""
- For an existing meta keyword that is a list (already known),
- add an invalid value depending on the type.
+ For an existing meta keyword that is a list (already known),
+ add an invalid value depending on the type.
"""
if issubclass(type(self.meta[key][0]), np.integer):
- self.meta[key] = np.append(self.meta[key], [-1])
+ self.meta[key].append(-1)
elif issubclass(type(self.meta[key][0]), np.floating):
- self.meta[key] = np.append(self.meta[key], [np.nan])
+ self.meta[key].append(np.nan)
elif issubclass(type(self.meta[key][0]), str):
- self.meta[key] = np.append(self.meta[key], [''])
+ self.meta[key].append('')
else:
- self.meta[key] = np.append(self.meta[key], [None])
+ self.meta[key].append(None)
- # Print a warning message:
- err_msg = "StarTable.add_starlist(): Missing meta keyword: {0:s}".format(key)
- warnings.warn(err_msg, UserWarning)
+ if warn:
+ err_msg = "StarTable.add_starlist(): Missing meta keyword: {0:s}".format(key)
+ warnings.warn(err_msg, UserWarning)
return
-
-
+
+
def get_starlist(self, list_index):
"""
- Return a StarList object for the specified list_index or epoch.
+ Return a StarList object for the specified list_index or epoch.
Parameters
----------
@@ -373,28 +445,33 @@ def get_starlist(self, list_index):
col_req_dict[col_name] = self[col_name]
starlist = StarList(**col_req_dict)
-
+
for col_name in self.colnames:
if col_name in col_req_names:
pass
-
+
if len(self[col_name].data.shape) == 2: # Find the 2D columns
starlist[col_name] = self[col_name][:, list_index]
else:
starlist[col_name] = self[col_name]
-
+
return starlist
- def combine_lists_xym(self, weighted_xy=True, weighted_m=True, mask_lists=False, sigma=3):
+ def combine_lists_xym(self, weighted_xy=True, weighted_m=True, mask_lists=None, sigma=3, select_stars=None):
"""
For x, y and m columns in the table, collapse along the lists
direction. For 'x', 'y' this means calculating the average position with
outlier rejection. Optionally, weight by the 'xe' and 'ye' individual
uncertainties. Optionally, use sigma clipping.
- "mask_lists" is a list with the indices of starlists that are
+ "mask_lists" is a list with the indices of starlists that are
excluded from the combination.
Also, count the number of times a star is found in starlists.
+
+ select_stars : array-like of bool or int, optional
+ If given, only (re)compute x0/y0/m0 (and errors) for these star
+ rows; see combine_lists() for details. By default None (compute
+ for all rows, same as before).
"""
# Combine by position
@@ -409,15 +486,16 @@ def combine_lists_xym(self, weighted_xy=True, weighted_m=True, mask_lists=False,
weights_colm = 'me'
else:
weights_colm = None
-
- self.combine_lists('x', weights_col=weights_colx, mask_lists=mask_lists, sigma=sigma)
- self.combine_lists('y', weights_col=weights_coly, mask_lists=mask_lists, sigma=sigma)
- self.combine_lists('m', weights_col=weights_colm, mask_lists=mask_lists, sigma=sigma, ismag=True)
-
+
+ self.combine_lists('x', weights_col=weights_colx, mask_lists=mask_lists, sigma=sigma, select_stars=select_stars)
+ self.combine_lists('y', weights_col=weights_coly, mask_lists=mask_lists, sigma=sigma, select_stars=select_stars)
+ self.combine_lists('m', weights_col=weights_colm, mask_lists=mask_lists, sigma=sigma, ismag=True, select_stars=select_stars)
+
return
def combine_lists(self, col_name_in, weights_col=None, mask_val=None,
- mask_lists=False, meta_add=True, ismag=False, sigma=3):
+ mask_lists=None, meta_add=True, ismag=False, sigma=3,
+ select_stars=None):
"""
For the specified column (col_name_in), collapse along the starlists
direction and calculated the average value, with outlier rejection.
@@ -427,604 +505,1271 @@ def combine_lists(self, col_name_in, weights_col=None, mask_val=None,
0e -- the std (with outlier rejection)
Masking of NaN values is also performed.
-
- "mask_lists" is a list with the indices of starlists that are
+
+ "mask_lists" is a list with the indices of starlists that are
excluded from the combination.
-
+
A flag can be stored in the metadata to record if the average was
weighted or not.
+
+ select_stars : array-like of bool or int, optional
+ If given, only (re)compute the averaged columns for these star
+ rows; every other row is left untouched. Useful when most rows
+ already hold a valid average from a previous call and only a
+ subset of rows (e.g. newly matched/added stars) actually need
+ recomputing -- avoids redoing work for the whole (potentially
+ very large) table every time. Ignored (falls back to computing
+ for all rows) if the 0/0_err columns
+ don't exist yet, since there's nothing to selectively update on
+ a first pass. By default None (compute for all rows).
"""
- # Get the array we are going to combine. Make a copy so we don't mod it.
- val_2d = copy.deepcopy( self[col_name_in].data )
+ col_name_avg = col_name_in + '0'
+ col_name_std = col_name_in + '0_err'
+ if (select_stars is not None) and (col_name_avg not in self.colnames):
+ select_stars = None
+
+ if mask_lists is not None:
+ # Extract list of indices that we want to keep (i.e. not mask)
+ mask_lists = np.atleast_1d(mask_lists)
+ assert mask_lists.dtype == int, "mask_lists needs to be a list of integers."
+ list_indices = np.array([i for i in np.arange(self[col_name_in].data.shape[1]) if i not in mask_lists])
+ else:
+ # Use all indices. A plain slice (rather than an arange array) keeps
+ # the col_data[:, list_indices] indexing below a view instead of a
+ # forced fancy-index copy -- np.array()/masked_invalid() further down
+ # already makes the one copy that's actually needed.
+ list_indices = slice(None)
+
+ if select_stars is not None:
+ col_data = self[col_name_in].data[select_stars]
+ else:
+ col_data = self[col_name_in].data
+ val_2d = np.array(col_data[:, list_indices], dtype=float)
if ismag:
# Convert to flux.
- val_2d = 10**(-val_2d / 2.5)
- # Make a mask of invalid (NaN) values and a user-specified invalid value.
- val_2d = np.ma.masked_invalid(val_2d)
+ val_2d = 10**(-0.4 * val_2d)
+
+ # `valid` tracks, elementwise, whether a value is usable at all --
+ # this replaces numpy.ma's masking, but as a plain boolean array so
+ # the arithmetic below can use ordinary (fast) numpy ops instead of
+ # numpy.ma's much slower generic dispatch for every operator.
+ valid = np.isfinite(val_2d)
+
+ # Mask a user-specified invalid value too.
if mask_val:
- val_2d = np.ma.masked_values(val_2d, mask_val)
-
- if mask_lists is not False:
- # Remove a list
- if isinstance(mask_lists, list):
- if all(isinstance(item, int) for item in mask_lists):
- val_2d.mask[:, mask_lists] = True
-
- # Throw a warning if mask_lists is not a list
- if not isinstance(mask_lists, list):
- raise RuntimeError('mask_lists needs to be a list.')
-
- # Decide if we are going to have weights (before we
- # do the expensive sigma clipping routine). Note that
- # if we have only 1 column to average, then we can't do weighting.
- if (weights_col and weights_col in self.colnames) and (val_2d.shape[1] > 1):
- err_2d = self[weights_col].data
-
+ valid &= ~np.isclose(val_2d, mask_val, rtol=1e-05, atol=1e-08)
+
+ # Figure out which ones are outliers. sigma_clip already treats NaN
+ # (and, via the mask below, our own invalid entries) as excluded, and
+ # returns a masked array -- pull its mask into `valid` and its data
+ # into a plain array immediately, rather than keep operating on the
+ # masked array itself for every subsequent step.
+ if sigma:
+ # Pass a masked (not NaN-filled) array in: sigma_clip treats an
+ # explicit mask as "already known invalid" silently, whereas raw
+ # NaNs trigger an "invalid values...automatically clipped"
+ # warning that the original implementation never produced.
+ val_2d_for_clip = np.ma.masked_array(val_2d, mask=~valid, copy=False)
+ clipped = sigma_clip(val_2d_for_clip, sigma=sigma, maxiters=5, axis=1)
+ valid &= ~np.ma.getmaskarray(clipped)
+ val_2d_clip = np.where(valid, clipped.data, 0.0)
+ else:
+ val_2d_clip = np.where(valid, val_2d, 0.0)
+
+ # Decide if we are going to have weights (before we do the expensive sigma clipping routine).
+ if weights_col in self.colnames:
+ if select_stars is not None:
+ weights_data = self[weights_col].data[select_stars]
+ else:
+ weights_data = self[weights_col].data
+ err_2d = np.array(weights_data[:, list_indices], dtype=float)
+
if ismag:
# Convert to flux error
- err_2d = err_2d * val_2d * np.log(10) / 2.5
-
- np.seterr(divide='ignore')
- wgt_2d = np.ma.masked_invalid(1.0 / err_2d**2)
- np.seterr(divide='warn')
-
+ err_2d = 0.4 * np.log(10) * val_2d * err_2d
+
+ # Inverse variance weights minimize the propagated uncertainty.
+ # `err_2d` here is never faked/patched -- it's exactly what was
+ # measured, so the `wgt_2d`/`wgt_sum` derived from it below are
+ # an honest record of how much real uncertainty information we
+ # actually have for each star. weight_from_sigma safely zeroes
+ # out any epoch where the value isn't valid (post-clipping) or
+ # the error itself is invalid/zero/overflow-inducing, rather
+ # than letting a bad error corrupt the weighted sum.
+ wgt_2d = motion_model.weight_from_sigma(err_2d, valid)
+
+ # Honest weight sum, built only from real, known uncertainties.
+ # The reported std below is derived directly from this, so a
+ # star whose every epoch lacks a usable error naturally ends up
+ # with wgt_sum == 0 -> std = sqrt(1/0) == inf via ordinary
+ # division -- there's no separate flag to remember to apply
+ # afterward, and no way for a fabricated finite error to reach std.
+ wgt_sum = wgt_2d.sum(axis=1)
+ n_valid = valid.sum(axis=1)
+ has_data = n_valid > 0
+
+ with np.errstate(divide='ignore', invalid='ignore'):
+ avg = (val_2d_clip * wgt_2d).sum(axis=1) / wgt_sum
+ # Equivalent of avg = np.average(val_2d_clip, weights=wgt_2d, axis=1)
+ std = np.sqrt(1. / wgt_sum) # Error propagation for weighted mean
+
+ # A star whose every epoch has an invalid raw uncertainty (e.g.
+ # missing/invalid me/xe/ye everywhere) but at least one valid
+ # value still gets an average -- a plain mean of its valid
+ # epoch(s), same as the unweighted branch below would give --
+ # instead of discarding a real measurement as nan just because
+ # we don't know how to weight it. std is untouched here (still
+ # the honest sqrt(1/wgt_sum) computed above, i.e. inf), so this
+ # can't accidentally fabricate a finite reported error.
+ no_usable_err = (wgt_sum == 0) & has_data
+ if no_usable_err.any():
+ avg[no_usable_err] = val_2d_clip[no_usable_err].sum(axis=1) / n_valid[no_usable_err]
+
+ avg[~has_data] = np.nan
+
+ # Use standard deviation of the weighted residuals as the uncertainty
+ # std = np.ma.sqrt(np.ma.average((val_2d_clip.T - avg).T**2, weights=wgt_2d, axis=1))
+
if meta_add:
self.meta[col_name_in + '0'] = 'weighted'
else:
- wgt_2d = None
+ # Calculate the (unweighted) mean and uncertainty
+ n_valid = valid.sum(axis=1)
+ has_data = n_valid > 0
+ with np.errstate(divide='ignore', invalid='ignore'):
+ avg = val_2d_clip.sum(axis=1) / n_valid
+ avg[~has_data] = np.nan
+ # Use standard deviation of the residuals as the uncertainty
+ deviations = np.where(valid, val_2d_clip - avg[:, np.newaxis], 0.0)
+ with np.errstate(divide='ignore', invalid='ignore'):
+ std = np.sqrt((deviations**2).sum(axis=1) / n_valid)
+
if meta_add:
self.meta[col_name_in + '0'] = 'not_weighted'
- # Figure out which ones are outliers. Returns a masked array.
- if sigma:
- warnings.filterwarnings('ignore', category=RuntimeWarning)
- val_2d_clip = sigma_clipping.sigma_clip(val_2d, sigma=sigma, maxiters=5, axis=1)
- warnings.filterwarnings('default', category=RuntimeWarning)
- else:
- val_2d_clip = val_2d
-
- # Calculate the (weighted) mean and standard deviation along
- # the N_lists direction (axis=1).
- if wgt_2d is not None:
- avg = np.ma.average(val_2d_clip, weights=wgt_2d, axis=1)
- std = np.sqrt(np.ma.average((val_2d_clip.T - avg).T**2, weights=wgt_2d, axis=1))
- else:
- avg = np.ma.mean(val_2d_clip, axis=1)
- std = np.ma.std(val_2d_clip, axis=1)
- # To Do: bring the previous uncertainties of stars that are detected
- # in only one input frame.
- if (weights_col and weights_col in self.colnames) and (val_2d.shape[1] > 1):
- mask_for_singles = ((~np.isnan(val_2d_clip)).sum(axis=1)==1)
- std[mask_for_singles]=np.nanmean(err_2d[mask_for_singles], axis=1)
-
- # Save off our new AVG and STD into new columns with shape (N_stars).
- col_name_avg = col_name_in + '0'
- col_name_std = col_name_in + '0e'
+ std_invalid = (~has_data) | (std == 0.) # Mask out zero uncertainties
+ # Save off our new AVG and STD into columns with shape (N_stars)
+ # (col_name_avg/col_name_std were resolved at the top of this function).
if ismag:
- std = (2.5 / np.log(10)) * std / avg
- avg = -2.5 * np.ma.log10(avg)
- if col_name_avg in self.colnames:
- self[col_name_avg] = avg.data
- self[col_name_std] = std.data
+ with np.errstate(divide='ignore', invalid='ignore'):
+ std = 2.5 / np.log(10) * std / avg # Error propagation
+ avg = -2.5 * np.log10(avg)
+
+ # Fill invalid entries with nan (avg) or inf (std)
+ std[std_invalid] = np.inf
+
+ if select_stars is not None:
+ # Columns must already exist -- only the selected rows are updated,
+ # everything else is left exactly as it was.
+ self[col_name_avg][select_stars] = avg
+ self[col_name_std][select_stars] = std
+ elif col_name_avg in self.colnames:
+ self[col_name_avg] = avg
+ self[col_name_std] = std
else:
- self.add_column(Column(data=avg.data, name=col_name_avg))
- self.add_column(Column(data=std.data, name=col_name_std))
-
+ self.add_column(Column(data=avg, name=col_name_avg))
+ self.add_column(Column(data=std, name=col_name_std))
+
return
- def detections(self):
+ def detections(self, weight_col=None):
"""
Find where stars are detected.
+
+ weight_col : str, optional
+ If given and present in this table's columns, sum this per-list
+ column (wherever x, y are valid) instead of counting each valid
+ (x, y) as 1. Used to inherit a per-list 'n_detect_list' column
+ from starlists that are themselves the output of a previous,
+ lower-level align pass, so n_detect reflects the total number
+ of raw detections a star represents. By default None (plain
+ count).
# """
- n_detect = np.sum(~np.isnan(self['x']), axis=1)
-
+ valid = np.isfinite(self['x']) & np.isfinite(self['y'])
+ if (weight_col is not None) and (weight_col in self.colnames):
+ n_detect = np.sum(np.where(valid, self[weight_col], 0), axis=1)
+ else:
+ n_detect = np.sum(valid, axis=1)
+
if 'n_detect' in self.colnames:
self['n_detect'] = n_detect
else:
- self.add_column(Column(n_detect), name='n_detect')
-
+ self.add_column(Column(data=n_detect, name='n_detect'))
+
return
-
- def fit_velocities(self, weighting='var', use_scipy=True, absolute_sigma=True, bootstrap=0, fixed_t0=False, verbose=False,
- mask_val=None, mask_lists=False, show_progress=True):
- """Fit velocities for all stars in the table and add to the columns 'vx', 'vxe', 'vy', 'vye', 'x0', 'x0e', 'y0', 'y0e'.
+ def fit_motion_models(
+ self,
+ motion_models=None,
+ fixed_params_dict=None,
+ weighting='var',
+ use_scipy=True,
+ absolute_sigma=True,
+ method=None,
+ select_stars=None,
+ keep_existing=True,
+ bootstrap=0,
+ seed=None,
+ mask_value=None,
+ mask_lists=None,
+ fill_value=np.nan,
+ art_star=False,
+ processes=1,
+ chunksize=None,
+ mp_star_threshold=100_000,
+ verbose=True
+ ):
+ """Fit velocity for star table
Parameters
----------
+ motion_models : list of MotionModel or str, optional
+ Motion models to use, by default Empty, Fixed and Linear.
+ Empty and Fixed models are always added automatically for stars with n_fit = 0 or 1.
+ The behavior is as follows:
+ 1. If 'motion_model_input' column is NOT in table:
+ - Use the most complex model that has enough parameters to fit the data (n_fit >= n_params).
+ - If multiple models are supplied, prioritize the model with the most parameters to fit.
+ - If multiple models have the same number of parameters, raise AssertionError: not sure which to use.
+ 2. If 'motion_model_input' column IS in table:
+ - Use the model specified in the 'motion_model_input' column.
+ - If not enough data points to fit the specified model, use the most complex model in any 'motion_model_input' column that has enough parameters to fit the data (n_fit >= n_params) among the provided motion_models and 'motion_model_input'.
+ The actual used motion model is stored in the 'motion_model_used' column. The default motion_models are [Empty, Fixed, Linear].
+ fixed_params_dict : dict, optional
+ Dictionary of fixed parameters for motion models, e.g., {'t0': 0., 'ra': np.array([...]), 'dec': np.array([...])}.
+ - Scalar values are used for all stars, array values should have length = N_stars.
+ - t0 is automatically calculated as np.average(t, weights=1/np.hypot(xe, ye)) if not provided.
+ - The keys should match the fixed parameter names in the motion models. See MotionModel class for details, by default None
weighting : str, optional
- Weight by variance 'var' or standard deviation 'std', by default 'var'
+ Uncertainty weighting, 'std' for weight=1/xe(ye) or 'var' for weight=1/xe(ye)**2, by default 'var'
use_scipy : bool, optional
- Use scipy.curve_fit (recommended for large number of epochs, but may return inf or nan) or analytic fitting from flystar.fit_velocity.linear_fit (recommended for a few epochs), by default True
+ Use scipy.optimize.curve_fit or algebraic solution (for Linear model only), by default False
absolute_sigma : bool, optional
- Absolute sigma or not. See https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html for details, by default True
+ Use absolute sigma or not, see scipy curve_fit for details, by default True
+ method : str, optional
+ Method of scipy.curve_fit, {'lm', 'trf', 'dogbox'}, by default None
+ select_stars : list of int, optional
+ Indices of stars to fit, by default None (fit all stars)
+ keep_existing : bool, optional
+ Keep existing motion model results in the table, or set them to fill_value and Inf for stars not in select_stars, by default True
bootstrap : int, optional
- Calculate uncertain using bootstraping or not, by default 0
- fixed_t0 : bool or array-like, optional
- Fix the t0 in dt = time - t0 if user provides an array with the same length of the table, or automatically calculate t0 = np.average(time, weights=1/np.hypot(xe, ye)) if False, by default False
+ Number of bootstrap samples for uncertainty resampling, by default 0
+ seed : int, optional
+ Random seed for bootstrap resampling, by default None
+ mask_value : float, optional
+ Values to mask in data, by default None
+ mask_lists : list of int, optional
+ Indices of lists to mask/exclude from fitting, by default None
+ fill_value : float, optional
+ Fill value when there is not enough data points to fit, by default np.nan
+ art_star : bool, optional
+ Artifical star table or observed star table. If artificial stars, Use the output coordinates for fitting motion models (x[..., 1], y[..., 1])
+ processes : int, optional
+ Number of processes to use for parallel processing, maximum os.cpu_count(), by default 1 (no multiprocessing)
+ chunksize : int, optional
+ Chunk size for multiprocessing, by default None (auto)
+ mp_star_threshold : int, optional
+ Minimum number of stars needing the per-star fitting path before a
+ multiprocessing Pool is spun up, even if processes > 1 was
+ requested. A star needs that path when its motion model has no
+ vectorized run_fit_batch, or when bootstrap > 0. Below this
+ threshold, fitting runs serially in the calling process instead --
+ spinning up a Pool has real fixed overhead (worker startup,
+ pickling the shared data arrays to each worker) that a small
+ per-star workload doesn't recoup. Measured break-even was between
+ 20,000 and 100,000 stars on a 10-core machine, so 100,000
+ (default) is a conservative choice. By default 100_000.
verbose : bool, optional
- Output verbose information or not, by default False
- mask_val : float, optional
- Value that needs to be masked in the data, e.g. -100000, by default None
- mask_lists : list, optional
- Columns that needs to be masked, by default False
- show_progress : bool, optional
- Show progress bar or not, by default True
+ Print verbose messages or not, by default True
+
Raises
------
ValueError
- If weighting is neither 'var' or 'std'
+ If weighting is not 'var' or 'std'.
+ KeyError
+ If time values are not found in the table or meta.
KeyError
- If there's not time information in the table
+ If required columns 'x' and 'y' are missing in the table.
"""
+ ###########################
+ ####### Check Params ######
+ ###########################
if weighting not in ['var', 'std']:
- raise ValueError(f"fit_velocities: Weighting must either be 'var' or 'std', not {weighting}!")
-
- if ('t' not in self.colnames) and ('LIST_TIMES' not in self.meta):
- raise KeyError("fit_velocities: Failed to access time values. No 't' column in table, no 'LIST_TIMES' in meta.")
-
+ raise ValueError(f"fit_motion_models: Weighting must either be 'var' or 'std', not {weighting}!")
+
+ if ('t' not in self.colnames) and ('list_times' not in self.meta):
+ raise KeyError("fit_motion_models: Failed to access time values. No 't' column in table, no 'list_times' in meta.")
+
# Check if we have the required columns
if not all([_ in self.colnames for _ in ['x', 'y']]):
- raise KeyError(f"fit_velocities: Missing required columns in the table: {', '.join(['x', 'y'])}!")
-
- N_stars = len(self)
+ raise KeyError(f"fit_motion_models: Missing required columns in the table: {', '.join(['x', 'y'])}!")
- if verbose:
- start_time = time.time()
- msg = 'Starting startable.fit_velocities for {0:d} stars with n={1:d} bootstrap'
- print(msg.format(N_stars, bootstrap))
-
- # Clean/remove up old arrays.
- if 'x0' in self.colnames: self.remove_column('x0')
- if 'vx' in self.colnames: self.remove_column('vx')
- if 'y0' in self.colnames: self.remove_column('y0')
- if 'vy' in self.colnames: self.remove_column('vy')
- if 'x0e' in self.colnames: self.remove_column('x0e')
- if 'vxe' in self.colnames: self.remove_column('vxe')
- if 'y0e' in self.colnames: self.remove_column('y0e')
- if 'vye' in self.colnames: self.remove_column('vye')
- if 'chi2_vx' in self.colnames: self.remove_column('chi2_vx')
- if 'chi2_vy' in self.colnames: self.remove_column('chi2_vy')
- if 't0' in self.colnames: self.remove_column('t0')
- if 'n_vfit' in self.colnames: self.remove_column('n_vfit')
-
- # Define output arrays for the best-fit parameters.
- self.add_column(Column(data = np.zeros(N_stars, dtype=float), name = 'x0'))
- self.add_column(Column(data = np.zeros(N_stars, dtype=float), name = 'vx'))
- self.add_column(Column(data = np.zeros(N_stars, dtype=float), name = 'y0'))
- self.add_column(Column(data = np.zeros(N_stars, dtype=float), name = 'vy'))
-
- self.add_column(Column(data = np.zeros(N_stars, dtype=float), name = 'x0e'))
- self.add_column(Column(data = np.zeros(N_stars, dtype=float), name = 'vxe'))
- self.add_column(Column(data = np.zeros(N_stars, dtype=float), name = 'y0e'))
- self.add_column(Column(data = np.zeros(N_stars, dtype=float), name = 'vye'))
-
- self.add_column(Column(data = np.zeros(N_stars, dtype=float), name = 'chi2_vx'))
- self.add_column(Column(data = np.zeros(N_stars, dtype=float), name = 'chi2_vy'))
-
- self.add_column(Column(data = np.zeros(N_stars, dtype=float), name = 't0'))
- self.add_column(Column(data = np.zeros(N_stars, dtype=int), name = 'n_vfit'))
-
- self.meta['N_VFIT_BOOTSTRAP'] = bootstrap
-
- # (FIXME: Do we need to catch the case where there's a single *unmasked* epoch?)
- # Catch the case when there is only a single epoch. Just return 0 velocity
- # and the same input position for the x0/y0.
- if len(self['x'].shape) == 1:
- self['x0'] = self['x']
- self['y0'] = self['y']
- if 't' in self.colnames:
- self['t0'] = self['t']
- else:
- self['t0'] = self.meta['LIST_TIMES'][0]
- if 'xe' in self.colnames:
- self['x0e'] = self['xe']
- self['y0e'] = self['ye']
- self['n_vfit'] = 1
+ # Make a copy of fixed_params_dict to avoid modifying the original one outside the function
+ fixed_params_dict = copy.deepcopy(fixed_params_dict)
- return
-
- if self['x'].shape[1] == 1:
- self['x0'] = self['x'][:,0]
- self['y0'] = self['y'][:,0]
+ # Check fixed_params_dict is a dict
+ if fixed_params_dict is not None:
+ if not isinstance(fixed_params_dict, dict):
+ raise ValueError("fit_motion_models: fixed_params_dict must be a dictionary!")
- if 't' in self.colnames:
- self['t0'] = self['t'][:, 0]
+ if select_stars is not None:
+ select_idx = np.asarray(select_stars)
+ if select_idx.dtype == bool:
+ select_idx = np.flatnonzero(select_idx)
else:
- self['t0'] = self.meta['LIST_TIMES'][0]
-
- if 'xe' in self.colnames:
- self['x0e'] = self['xe'][:,0]
- self['y0e'] = self['ye'][:,0]
+ select_idx = np.asarray(select_idx, dtype=int)
+ if len(select_idx) == 0:
+ return
+ else:
+ select_idx = None
- self['n_vfit'] = 1
+ N_stars = len(self)
+ if (select_idx is not None) and (len(select_idx) < N_stars):
+ # Everything below this point -- the masked-array data prep,
+ # n_fit/motion-model classification, and per-star fixed-params
+ # dict construction -- costs O(N_stars) every single call,
+ # regardless of how few stars select_stars actually asks to
+ # fit. For a mosaic that's re-fit once per starlist (this
+ # function called repeatedly as the table keeps growing), that
+ # made the redundant, unselected majority of the table get
+ # copied and reprocessed on every single call -- for many
+ # starlists and a large final table, this dwarfs the actual
+ # fitting cost. Slice down to just the selected rows (fancy/
+ # boolean indexing always copies in numpy, so this bounds cost
+ # to len(select_stars), not N_stars), run this same function
+ # unmodified on that much smaller table, then scatter its
+ # results back into self at the selected positions. (If
+ # select_stars covers the whole table there's nothing to save
+ # by slicing -- that would just pay a full-table copy for no
+ # benefit -- so fall through to the normal path below instead.)
+ sub_fixed_params_dict = {
+ k: (v[select_idx] if (np.ndim(v) > 0 and len(v) == N_stars) else v)
+ for k, v in (fixed_params_dict or {}).items()
+ }
+
+ sub_table = self[select_idx]
+ orig_meta_keys = set(self.meta.keys())
+ sub_table.fit_motion_models(
+ motion_models=motion_models, fixed_params_dict=sub_fixed_params_dict,
+ weighting=weighting, use_scipy=use_scipy, absolute_sigma=absolute_sigma,
+ method=method, select_stars=None, keep_existing=keep_existing,
+ bootstrap=bootstrap, seed=seed, mask_value=mask_value, mask_lists=mask_lists,
+ fill_value=fill_value, art_star=art_star, processes=processes,
+ chunksize=chunksize, mp_star_threshold=mp_star_threshold, verbose=verbose
+ )
+
+ for col_name in sub_table.colnames:
+ if col_name not in self.colnames:
+ default = np.inf if (col_name.endswith('_err')) else fill_value
+ dtype = sub_table[col_name].dtype
+ if dtype.kind in 'US':
+ default = ''
+ elif dtype.kind == 'i':
+ default = -1
+ elif dtype.kind == 'b':
+ default = False
+ self.add_column(Column(data=np.full(N_stars, default, dtype=dtype), name=col_name))
+ self[col_name][select_idx] = sub_table[col_name]
+
+ # Only propagate meta keys fit_motion_models itself newly added
+ # (e.g. n_bootstrap, or a scalar-valued fixed param) -- not
+ # table-size-specific ones the smaller sub_table happens to
+ # carry (n_stars, ref_list, list_times, ...).
+ for key, value in sub_table.meta.items():
+ if key not in orig_meta_keys:
+ self.meta[key] = value
return
- # STARS LOOP through the stars and work on them 1 at a time.
- # This is slow; but robust.
- if show_progress:
- for ss in tqdm(range(N_stars)):
- self.fit_velocity_for_star(ss, weighting=weighting, use_scipy=use_scipy, absolute_sigma=absolute_sigma, bootstrap=bootstrap, fixed_t0=fixed_t0,
- mask_val=mask_val, mask_lists=mask_lists)
+ all_mm_map = motion_model.motion_model_map()
+ # Setting the default to None to avoid mutable default argument issue
+ # See https://stackoverflow.com/questions/15189245/assigning-class-variable-as-default-value-to-class-method-argument
+ if motion_models is None:
+ # Linear by default
+ motion_models = [motion_model.Linear]
+ motion_models = motion_model.organize_motion_models(motion_models)
+ mm_names = [mm.name for mm in motion_models]
+
+ # Construct motion models if motion_model_input column exists
+ if 'motion_model_input' in self.colnames:
+ input_mm_names = np.unique(self['motion_model_input'])
+ assert all([name in all_mm_map.keys() for name in input_mm_names]), \
+ f"fit_motion_models: Unknown motion model name(s) in 'motion_model_input' column. Available motion models are: {', '.join(all_mm_map.keys())}."
+ for mm_name in input_mm_names:
+ if mm_name not in mm_names:
+ motion_models.append(all_mm_map[mm_name])
+
+ # Sort motion models by required epochs
+ motion_models = sorted(motion_models, key=lambda mm: mm.n_params)
+
+ input_mm_map = {mm.name: mm for mm in motion_models}
+
+ mm_n_params = np.sort([mm.n_params for mm in motion_models])
+ if 'motion_model_input' not in self.colnames:
+ # If motion_model_input column is not provided, assert that motion model n_params are unique and sorted
+ # Otherwise the fitter does not know which motion model to use based on n_obs
+ assert len(mm_n_params) == len(set(mm_n_params)), \
+ f"fit_motion_models: Provided motion model n_params are not unique! Motion Models are: {[_.name for _ in motion_models]}" + '\n' + "Cannot decide which motion model to use based on n_obs. Please provide unique motion_models or a 'motion_model_input' column."
+
+
+ ###########################
+ ####### Prepare Data ######
+ ###########################
+ # Prepare data for fitting
+ N_stars = len(self)
+ if art_star:
+ x = self['x'].data[..., 1]
+ y = self['y'].data[..., 1]
else:
- for ss in range(N_stars):
- self.fit_velocity_for_star(ss, weighting=weighting, use_scipy=use_scipy, absolute_sigma=absolute_sigma, bootstrap=bootstrap, fixed_t0=fixed_t0,
- mask_val=mask_val, mask_lists=mask_lists, )
- if verbose:
- stop_time = time.time()
- print('startable.fit_velocities runtime = {0:.0f} s for {1:d} stars'.format(stop_time - start_time, N_stars))
-
- return
+ x = self['x'].data
+ y = self['y'].data
- def fit_velocity_for_star(self, ss, weighting='var', use_scipy=True, absolute_sigma=True, bootstrap=False, fixed_t0=False,
- mask_val=None, mask_lists=False):
+ xe = self['xe'].data if 'xe' in self.colnames else None
+ ye = self['ye'].data if 'ye' in self.colnames else None
+ with_xe_ye = (xe is not None) and (ye is not None)
- # Make a mask of invalid (NaN) values and a user-specified invalid value.
- x = np.ma.masked_invalid(self['x'][ss, :].data)
- y = np.ma.masked_invalid(self['y'][ss, :].data)
- if mask_val:
- x = np.ma.masked_values(x, mask_val)
- y = np.ma.masked_values(y, mask_val)
- # If no mask, convert x.mask to list
- if not np.ma.is_masked(x):
- x.mask = np.zeros_like(x.data, dtype=bool)
- if not np.ma.is_masked(y):
- y.mask = np.zeros_like(y.data, dtype=bool)
-
-
- if mask_lists is not False:
- # Remove a list
- if isinstance(mask_lists, list):
- if all(isinstance(item, int) for item in mask_lists):
- x.mask[mask_lists] = True
- y.mask[mask_lists] = True
-
- # Throw a warning if mask_lists is not a list
- if not isinstance(mask_lists, list):
- raise RuntimeError('mask_lists needs to be a list.')
-
- if 'xe' in self.colnames:
- # Make a mask of invalid (NaN) values and a user-specified invalid value.
- xe = np.ma.masked_invalid(self['xe'][ss, :].data)
- ye = np.ma.masked_invalid(self['ye'][ss, :].data)
-
- # Catch the case where we have positions but no errors for
- # some of the entries... we need to "fill in" reasonable
- # weights for these... just use the average weights over
- # all the other epochs.
- pos_no_err = np.where((np.isfinite(x) & np.isfinite(y)) &
- (np.isfinite(xe) == False) & (np.isfinite(ye) == False))[0]
- pos_with_err = np.where((np.isfinite(x) & np.isfinite(y)) &
- (np.isfinite(xe) & np.isfinite(ye)))[0]
-
- if len(pos_with_err) > 0:
- xe[pos_no_err] = xe[pos_with_err].mean()
- ye[pos_no_err] = ye[pos_with_err].mean()
- else:
- xe[pos_no_err] = 1.0
- ye[pos_no_err] = 1.0
+ N_times = x.shape[1]
+ if mask_lists is not None:
+ list_indices = np.array([i for i in range(N_times) if i not in mask_lists])
else:
- N_epochs = len(x)
- xe = np.ones(N_epochs, dtype=float)
- ye = np.ones(N_epochs, dtype=float)
- xe = np.ma.masked_invalid(xe)
- ye = np.ma.masked_invalid(xe)
-
- if mask_val:
- xe = np.ma.masked_values(xe, mask_val)
- ye = np.ma.masked_values(ye, mask_val)
- # If no mask, convert xe.mask to list
- if not np.ma.is_masked(xe):
- xe.mask = np.zeros_like(xe.data, dtype=bool)
- if not np.ma.is_masked(ye):
- ye.mask = np.zeros_like(ye.data, dtype=bool)
-
- if mask_lists is not False:
- # Remove a list
- if isinstance(mask_lists, list):
- if all(isinstance(item, int) for item in mask_lists):
- xe.mask[mask_lists] = True
- ye.mask[mask_lists] = True
-
- # Throw a warning if mask_lists is not a list
- if not isinstance(mask_lists, list):
- raise RuntimeError('mask_lists needs to be a list.')
-
- # Make a mask of invalid (NaN) values and a user-specified invalid value.
+ # A plain slice (rather than an arange array) keeps x[:, list_indices]
+ # etc. below a view instead of a forced fancy-index copy -- the
+ # explicit copy=True/deepcopy calls further down already make the one
+ # copy that's actually needed. At full-table scale this was making two
+ # full (N_stars, N_times) copies of x, y, xe, ye, and t where one would do.
+ list_indices = slice(None)
+
+ x_data = np.ma.masked_invalid(x[:, list_indices], copy=True)
+ y_data = np.ma.masked_invalid(y[:, list_indices], copy=True)
+ xe_data = np.ma.masked_invalid(xe[:, list_indices], copy=True) if with_xe_ye else None
+ ye_data = np.ma.masked_invalid(ye[:, list_indices], copy=True) if with_xe_ye else None
+
+ # Mask out close to 0 values to avoid infinite weights
+ if with_xe_ye:
+ xe_data.mask[np.isclose(xe_data, 0)] = True
+ ye_data.mask[np.isclose(ye_data, 0)] = True
+
+ # If all of xe and ye is masked for a star, effectively no uncertainties provided, fill with 1.
+ # Note that this automatically turn the mask to False for these stars
+ if with_xe_ye:
+ fill_with_one = np.all(xe_data.mask, axis=1) & np.all(ye_data.mask, axis=1)
+ xe_data[fill_with_one] = 1.
+ ye_data[fill_with_one] = 1.
+
+ # Ensure data is 2D for consistent indexing, even if we have only one list/epoch (shape (N_stars, 1) instead of (N_stars,))
+ if np.ndim(x_data) == 1:
+ x_data = x_data[:, np.newaxis]
+ if np.ndim(y_data) == 1:
+ y_data = y_data[:, np.newaxis]
+ if with_xe_ye:
+ if np.ndim(xe_data) == 1:
+ xe_data = xe_data[:, np.newaxis]
+ if np.ndim(ye_data) == 1:
+ ye_data = ye_data[:, np.newaxis]
+
+ # t_data: 2d array with shape (N_stars, N_epochs)
+ # t0: 1d array with shape (N_stars,)
if 't' in self.colnames:
- t = np.ma.masked_invalid(self['t'][ss, :].data)
+ t_data = copy.deepcopy(self['t'].data[:, list_indices])
+ else:
+ t_data = copy.deepcopy(np.array(self.meta['list_times']))[list_indices]
+ t_data = np.broadcast_to(t_data, x_data.shape)
+
+ fixed_params_dict = {} if fixed_params_dict is None else fixed_params_dict
+ # Add default t0 if not provided in fixed_params_dict
+ if 't0' not in fixed_params_dict:
+ weights = 1. / np.hypot(xe_data, ye_data) if with_xe_ye else None
+ # t_data must be masked (not just weights) and np.ma.average (not
+ # plain np.average) must be used here: for the fill_with_one
+ # stars above (no usable xe/ye anywhere at all), the substitute
+ # weight is uniform/unmasked, but t can still be genuinely
+ # invalid in undetected epochs, or weights can be masked (e.g.
+ # only some epochs have usable xe/ye) while t_data itself is
+ # plain. Plain np.average's weight-sum denominator doesn't
+ # respect either mask in that case, silently producing NaN.
+ fixed_params_dict['t0'] = np.ma.average(np.ma.masked_invalid(t_data), axis=1, weights=weights).filled(np.nan)
else:
- t = np.ma.masked_invalid(self.meta['LIST_TIMES'])
+ if np.ndim(fixed_params_dict['t0']) == 0:
+ fixed_params_dict['t0'] = np.full(N_stars, fixed_params_dict['t0'])
+
+ t0 = fixed_params_dict['t0']
+
+ # Apply mask_value if provided
+ if mask_value:
+ x_data = np.ma.masked_values(x_data, mask_value)
+ y_data = np.ma.masked_values(y_data, mask_value)
+ if with_xe_ye:
+ xe_data = np.ma.masked_values(xe_data, mask_value)
+ ye_data = np.ma.masked_values(ye_data, mask_value)
+
+
+ # Calculate mask array
+ valid_xy = ~ (x_data.mask | y_data.mask)
+ if with_xe_ye:
+ valid_xy &= ~ (xe_data.mask | ye_data.mask)
+
+ # Calculate n_fit: unmasked x y values
+ # This will be used to determine which motion model to use for each star.
+ # Note that we don't require unique times here
+ # as scipy.curve_fit and Linear algebra can fit non-unique times.
+ # self['n_fit'] = np.sum(valid_xy, axis=1)
+
+ # Calculate n_fit: unique times & unmasked x y values.
+ # Vectorized equivalent of len(set(t_data[i][valid_xy[i]])) per star:
+ # push each star's invalid entries to +inf (so they sort last and
+ # never affect the count), sort, then count 1 (for the first valid
+ # entry, if any) plus the number of adjacent sorted valid entries
+ # that differ -- mathematically identical to counting unique values,
+ # but as whole-array numpy ops instead of a per-star Python loop
+ # building a set() object for each of potentially millions of stars.
+ N_epochs = t_data.shape[1]
+ t_for_sort = np.where(valid_xy, t_data, np.inf)
+ t_sorted = np.sort(t_for_sort, axis=1)
+ n_valid_per_star = valid_xy.sum(axis=1)
+ if N_epochs > 1:
+ with np.errstate(invalid='ignore'):
+ diffs_differ = np.diff(t_sorted, axis=1) != 0
+ col_idx = np.arange(N_epochs - 1)
+ diff_counts_valid = col_idx[np.newaxis, :] < (n_valid_per_star[:, np.newaxis] - 1)
+ n_unique_extra = (diffs_differ & diff_counts_valid).sum(axis=1)
+ else:
+ n_unique_extra = np.zeros(N_stars, dtype=int)
+ n_fit = np.where(n_valid_per_star > 0, 1 + n_unique_extra, 0)
+ self['n_fit'] = n_fit
- if mask_val:
- t = np.ma.masked_values(t, mask_val)
- if not np.ma.is_masked(t):
- t.mask = np.zeros_like(t.data, dtype=bool)
-
- if mask_lists is not False:
- # Remove a list
- if isinstance(mask_lists, list):
- if all(isinstance(item, int) for item in mask_lists):
- t.mask[mask_lists] = True
-
- # Throw a warning if mask_lists is not a list
- if not isinstance(mask_lists, list):
- raise RuntimeError('mask_lists needs to be a list.')
-
- # For inconsistent masks, mask the star if any of the values are masked.
- new_mask = np.logical_or.reduce((t.mask, x.mask, y.mask, xe.mask, ye.mask))
- # Figure out where we have detections (as indicated by error columns)
- good = np.where((xe != 0) & (ye != 0) &
- np.isfinite(xe) & np.isfinite(ye) &
- np.isfinite(x) & np.isfinite(y) & ~new_mask)[0]
-
- N_good = len(good)
-
- # Catch the case where there is NO good data.
- if N_good == 0:
- return
- # Everything below has N_good >= 1
- x = x[good]
- y = y[good]
- t = t[good]
- xe = xe[good]
- ye = ye[good]
-
- # slope, intercept
- p0x = np.array([0., x.mean()])
- p0y = np.array([0., y.mean()])
-
- # Unless t0 is fixed, calculate the t0 for the stars.
- if fixed_t0 is False:
- t_weight = 1.0 / np.hypot(xe, ye)
- t0 = np.average(t, weights=t_weight)
+ ###########################
+ ####### Determine MM ######
+ ###########################
+ if 'motion_model_input' in self.colnames:
+ # Determine which motion model to use based on motion_model_input column
+ # If n_fit < n_params for the input motion model, use the most complicated motion model with n_fit >= n_params
+ required_params = np.array([all_mm_map[mm_name].n_params for mm_name in self['motion_model_input']])
+ reassign_mm = n_fit < required_params
+
+ mm_digitized = np.digitize(
+ x=n_fit[reassign_mm],
+ bins=mm_n_params
+ ) - 1 # Convert to 0-based index
+
+ # Assign motion models to stars
+ self['motion_model_used'] = self['motion_model_input']
+ self['motion_model_used'][reassign_mm] = np.array([motion_models[d].name for d in mm_digitized], dtype='U20')
+
else:
- t0 = fixed_t0[ss]
- dt = t - t0
-
- self['t0'][ss] = t0
- self['n_vfit'][ss] = N_good
-
- # Catch the case where all the times are identical
- if (dt == dt[0]).all():
- if weighting == 'var':
- wgt_x = (1.0/xe)**2
- wgt_y = (1.0/ye)**2
- elif weighting == 'std':
- wgt_x = 1./np.abs(xe)
- wgt_y = 1./np.abs(ye)
-
- self['x0'][ss] = np.average(x, weights=wgt_x)
- self['y0'][ss] = np.average(y, weights=wgt_y)
- self['x0e'][ss] = np.sqrt(np.average((x - self['x0'][ss])**2, weights=wgt_x))
- self['y0e'][ss] = np.sqrt(np.average((y - self['y0'][ss])**2, weights=wgt_x))
-
- self['vx'][ss] = 0.0
- self['vy'][ss] = 0.0
- self['vxe'][ss] = 0.0
- self['vye'][ss] = 0.0
+ # If motion_model_input column is not provided, use the most complicated model in motion_models with n_fit >= n_params.
+ mm_digitized = np.digitize(
+ x=n_fit,
+ bins=mm_n_params
+ ) - 1 # Convert to 0-based index
+
+ # Assign motion models to stars
+ self['motion_model_used'] = np.array([motion_models[d].name for d in mm_digitized], dtype='U20')
+
+ ############################
+ # Prepare Fixed Parameters #
+ ############################
+ # If required fixed params in self.meta or columns, but not provided in fixed_params_dict, add them to fixed_params_dict
+ motion_model_used = [all_mm_map[name] for name in np.unique(self['motion_model_used'])]
+ raise_key_error = False
+ missing_params = []
+ for mm in motion_model_used:
+ # Check required fixed parameters
+ for param in mm.required_fixed_param_names:
+ # Check in the order of fixed_params_dict -> self.meta -> self columns
+ if param not in fixed_params_dict:
+ # If not provided in fixed_params_dict, it must be in table columns
+ if param in self.colnames:
+ fixed_params_dict[param] = self[param].data
+ elif param in self.meta:
+ # Check if the parameter is in self.meta
+ fixed_params_dict[param] = self.meta[param]
+ else:
+ raise_key_error = True
+ missing_params.append(f"'{param}'")
+
+ # Check optional fixed parameters
+ # Set to default value if not provided in fixed_params_dict or in self
+ for param, value in mm.optional_fixed_params.items():
+ if param not in fixed_params_dict:
+ # If param is not provided in fixed_params_dict
+ if param in self.colnames:
+ # Set to column value if column exists
+ fixed_params_dict[param] = self[param].data
+ elif param in self.meta:
+ # Check if the parameter is in self.meta
+ fixed_params_dict[param] = self.meta[param]
+ else:
+ # Set to default value if neither in columns nor provided in fixed_params_dict
+ fixed_params_dict[param] = value
+ self.meta[param] = value
+
+ if raise_key_error:
+ raise KeyError(f"fit_motion_models: Missing required fixed parameter(s) for the motion models used: {', '.join(missing_params)}! Please provide them in fixed_params_dict, or as columns in the table, or as table metadata.")
+
+
+ # Prepare fixed_params_dict for each star
+ # This avoids checking types and slicing inside the fitting loop
+ # Identify array parameters (length N_stars) and scalar parameters
+ array_params = {k: v for k, v in fixed_params_dict.items() if np.ndim(v) > 0 and len(v) == N_stars}
+ scalar_params = {k: v for k, v in fixed_params_dict.items() if k not in array_params}
+
+ # Convert any masked-array fixed params (e.g. the default t0, which
+ # comes out of np.average() as a masked array whenever xe/ye are
+ # masked) to plain arrays before the per-star dict construction
+ # below -- indexing a MaskedArray once per star goes through numpy.ma's
+ # much slower generic machinery vs. plain ndarray indexing.
+ array_params = {k: (np.ma.filled(v, np.nan) if np.ma.isMaskedArray(v) else v) for k, v in array_params.items()}
+
+ # fixed_params_stars (one dict per star) is only actually needed by
+ # the per-star/multiprocessing fitting path below, for stars whose
+ # motion model has no vectorized run_fit_batch -- building it here
+ # for all N_stars unconditionally meant allocating a Python dict (plus
+ # boxed scalar values) per star even for the (often large) fraction
+ # handled entirely by the batched Fixed-model path, which never even
+ # looks at it. It's built lazily further down, once we know which
+ # stars actually need it (same idea as unmasked_idx below).
+
+
+ ############################
+ ####### Prepare Table ######
+ ############################
+ # Fill table with all possible motion model parameter names as new columns.
+ new_col_list = motion_model.motion_model_param_names(motion_model_used, with_errors=True, with_fixed=False)
+ new_col_list += ['chi2_x', 'chi2_y', 'n_params']
+
+ if 't0' not in new_col_list:
+ new_col_list.append('t0')
+
+ # Add new columns if they do not exist
+ for col in new_col_list:
+ if col in self.colnames:
+ # Keep old data if the column already exists
+ if keep_existing:
+ continue
+ else:
+ self.remove_column(col)
- return
+ if col.endswith('_err'):
+ self.add_column(
+ Column(data=np.full(N_stars, np.inf, dtype=float), name=col),
+ rename_duplicate=True
+ )
+ else:
+ self.add_column(
+ Column(data=np.full(N_stars, fill_value, dtype=float), name=col),
+ rename_duplicate=True
+ )
+
+ # Add fixed parameter meta if scalar, column if array.
+ fixed_param_names = []
+ for mm in motion_model_used:
+ for param in mm.fixed_param_names:
+ if param not in fixed_param_names:
+ fixed_param_names.append(param)
+ # Remove t0 from fixed_param_names as it will be saved during fitting
+ if 't0' in fixed_param_names:
+ fixed_param_names.remove('t0')
+
+
+ for param in fixed_param_names:
+ # Equivalent to np.array([fps[param] for fps in fixed_params_stars])
+ # from the (no-longer-built-eagerly) per-star dicts, without ever
+ # materializing them: every param here came from array_params or
+ # scalar_params above, so it's already exactly this column, or a
+ # single value to be broadcast to one.
+ if param in array_params:
+ coldata = np.asarray(array_params[param])
+ else:
+ coldata = np.full(N_stars, scalar_params[param])
+
+ if param in self.colnames:
+ existing = self[param]
+
+ # Skip if identical
+ same = (
+ np.array_equal(existing, coldata)
+ if is_string_dtype(existing)
+ else np.allclose(existing, coldata, equal_nan=True)
+ )
+
+ if same:
+ continue
- # Catch the case where we have enough measurements to actually
- # fit a velocity!
- if N_good > 2:
- if weighting == 'var':
- sigma_x = xe
- sigma_y = ye
- elif weighting == 'std':
- sigma_x = np.abs(xe)**0.5
- sigma_y = np.abs(ye)**0.5
-
- if use_scipy:
- vx_opt, vx_cov = curve_fit(linear, dt, x, p0=p0x, sigma=sigma_x, absolute_sigma=absolute_sigma)
- vy_opt, vy_cov = curve_fit(linear, dt, y, p0=p0y, sigma=sigma_y, absolute_sigma=absolute_sigma)
- vx = vx_opt[0]
- x0 = vx_opt[1]
- vy = vy_opt[0]
- y0 = vy_opt[1]
- chi2_vx = calc_chi2(dt, x, sigma_x, *vx_opt)
- chi2_vy = calc_chi2(dt, y, sigma_y, *vy_opt)
-
+ # Different (or column does not yet exist)
+ if len(np.unique(coldata)) == 1:
+ # If param is the same for all stars, save it as meta
+ self.meta[param] = coldata[0]
else:
- result_vx = linear_fit(dt, x, sigma_x, absolute_sigma=absolute_sigma)
- result_vy = linear_fit(dt, y, sigma_y, absolute_sigma=absolute_sigma)
- vx = result_vx['slope']
- x0 = result_vx['intercept']
- vy = result_vy['slope']
- y0 = result_vy['intercept']
- chi2_vx = result_vx['chi2']
- chi2_vy = result_vy['chi2']
-
- self['vx'][ss] = vx
- self['x0'][ss] = x0
- self['vy'][ss] = vy
- self['y0'][ss] = y0
- self['chi2_vx'][ss] = chi2_vx
- self['chi2_vy'][ss] = chi2_vy
-
- # Run the bootstrap
- if bootstrap > 0:
- edx = np.arange(N_good, dtype=int)
-
- vx_b = np.zeros(bootstrap, dtype=float)
- x0_b = np.zeros(bootstrap, dtype=float)
- vy_b = np.zeros(bootstrap, dtype=float)
- y0_b = np.zeros(bootstrap, dtype=float)
-
- for bb in range(bootstrap):
- bdx = np.random.choice(edx, N_good)
- if weighting == 'var':
- sigma_x_b = xe[bdx]
- sigma_y_b = ye[bdx]
- elif weighting == 'std':
- sigma_x_b = xe[bdx]**0.5
- sigma_y_b = ye[bdx]**0.5
-
- if use_scipy:
- vx_opt_b, vx_cov_b = curve_fit(linear, dt[bdx], x[bdx], p0=vx_opt, sigma=sigma_x_b,
- absolute_sigma=absolute_sigma)
- vy_opt_b, vy_cov_b = curve_fit(linear, dt[bdx], y[bdx], p0=vy_opt, sigma=sigma_y_b,
- absolute_sigma=absolute_sigma)
- vx_b[bb] = vx_opt_b[0]
- x0_b[bb] = vx_opt_b[1]
- vy_b[bb] = vy_opt_b[0]
- y0_b[bb] = vy_opt_b[1]
-
- else:
- result_vx_b = linear_fit(dt[bdx], x[bdx], sigma=sigma_x_b, absolute_sigma=absolute_sigma)
- result_vy_b = linear_fit(dt[bdx], y[bdx], sigma=sigma_y_b, absolute_sigma=absolute_sigma)
- vx_b[bb] = result_vx_b['slope']
- x0_b[bb] = result_vx_b['intercept']
- vy_b[bb] = result_vy_b['slope']
- y0_b[bb] = result_vy_b['intercept']
-
- # Save the errors from the bootstrap
- self['vxe'][ss] = vx_b.std()
- self['x0e'][ss] = x0_b.std()
- self['vye'][ss] = vy_b.std()
- self['y0e'][ss] = y0_b.std()
-
+ self.add_column(
+ Column(data=coldata, name=f"{param}_mm"),
+ rename_duplicate=True,
+ )
+
+ # Add a column to keep track of the number of points used in a fit and number of bootstrap used.
+ self.meta['n_bootstrap'] = bootstrap
+
+ # A star whose motion_model_used just changed to a simpler model
+ # (e.g. Linear -> Fixed, because it now matches fewer epochs than
+ # it used to) would otherwise keep whatever vx/vy (or other params
+ # its old, more complex model had) its previous fit wrote --
+ # nothing rewrites those columns for this star since they aren't
+ # in its new model's fit_param_names. Reset any such leftover
+ # param to fill_value/inf for every star, based on its current
+ # motion_model_used, before the fitting loop below fills in the
+ # correct values for the params that DO belong to its model.
+ # Check against every motion model that could ever exist, not just
+ # ones assigned to a star this round -- a param column can still
+ # exist from an earlier call (e.g. 'vx' from a prior Linear fit)
+ # even if no star is currently classified as that model.
+ all_possible_params = set()
+ for mm in all_mm_map.values():
+ all_possible_params.update(mm.fit_param_names)
+ for param_name in all_possible_params:
+ if param_name not in self.colnames:
+ continue
+ models_with_this_param = [mm.name for mm in all_mm_map.values() if param_name in mm.fit_param_names]
+ belongs = np.isin(self['motion_model_used'], models_with_this_param)
+ self[param_name][~belongs] = fill_value
+ err_name = param_name + '_err'
+ if err_name in self.colnames:
+ self[err_name][~belongs] = np.inf
+
+
+ ###########################
+ ######### FITTING #########
+ ###########################
+ unique_motion_models, unique_inv_indices = np.unique(self['motion_model_used'], return_inverse=True)
+ if select_stars is not None:
+ select_stars = np.asarray(select_stars)
+ if select_stars.dtype == bool:
+ select_stars = np.flatnonzero(select_stars)
else:
- if use_scipy:
- vxe, x0e = np.sqrt(vx_cov.diagonal())
- vye, y0e = np.sqrt(vy_cov.diagonal())
- else:
- vxe = result_vx['e_slope']
- x0e = result_vx['e_intercept']
- vye = result_vy['e_slope']
- y0e = result_vy['e_intercept']
-
- self['vxe'][ss] = vxe
- self['x0e'][ss] = x0e
- self['vye'][ss] = vye
- self['y0e'][ss] = y0e
-
- elif N_good == 2:
- # Not enough epochs to fit a velocity.
- dx = np.diff(x)[0]
- dy = np.diff(y)[0]
- dt_diff = np.diff(dt)[0]
-
- if weighting == 'var':
- sigma_x = 1./xe**2
- sigma_y = 1./ye**2
- elif weighting == 'std':
- sigma_x = 1./np.abs(xe)
- sigma_y = 1./np.abs(ye)
-
- self['x0'][ss] = np.average(x, weights=sigma_x)
- self['y0'][ss] = np.average(y, weights=sigma_y)
- self['x0e'][ss] = np.abs(dx) / 2**0.5
- self['y0e'][ss] = np.abs(dy) / 2**0.5
- self['vx'][ss] = dx / dt_diff
- self['vy'][ss] = dy / dt_diff
- self['vxe'][ss] = 0.0
- self['vye'][ss] = 0.0
- self['chi2_vx'][ss] = calc_chi2(dt, x, sigma_x, self['vx'][ss], self['x0'][ss])
- self['chi2_vy'][ss] = calc_chi2(dt, y, sigma_y, self['vy'][ss], self['y0'][ss])
-
+ select_stars = np.asarray(select_stars, dtype=int)
+ indices_by_motion_model = {key: np.intersect1d(select_stars, np.flatnonzero(unique_inv_indices == k)) for k, key in enumerate(unique_motion_models)}
else:
- # N_good == 1 case
- self['n_vfit'][ss] = 1
- self['x0'][ss] = x
- self['y0'][ss] = y
-
- if 'xe' in self.colnames:
- self['x0e'] = xe
- self['y0e'] = ye
+ indices_by_motion_model = {key: np.flatnonzero(unique_inv_indices == k) for k, key in enumerate(unique_motion_models)}
+
+ # Unmasked indices for each star -- but only for stars in groups that
+ # actually need the generic per-star path below. Groups handled by
+ # run_fit_batch (currently just Fixed) use valid_xy directly and
+ # never touch unmasked_idx at all, and Fixed is often the majority
+ # of stars in a growing mosaic -- computing this (an inherently
+ # per-star Python loop) for all N_stars regardless was previously
+ # pure waste for that (often large) fraction. Left as None for stars
+ # that don't need it; those entries are never looked up.
+ non_batch_star_idxs = [
+ idx for key, idx in indices_by_motion_model.items()
+ if not (hasattr(input_mm_map[key](), 'run_fit_batch') and bootstrap == 0)
+ ]
+ if non_batch_star_idxs:
+ non_batch_star_idxs = np.concatenate(non_batch_star_idxs)
+ unmasked_idx = [None] * N_stars
+ fixed_params_stars = [None] * N_stars
+ for i in non_batch_star_idxs:
+ unmasked_idx[i] = np.flatnonzero(valid_xy[i])
+ fixed_params_stars[i] = {**scalar_params, **{k: v[i] for k, v in array_params.items()}}
+ else:
+ unmasked_idx = None
+ fixed_params_stars = None
+
+ # Plain (non-masked) views of the per-star arrays for the per-star
+ # extraction below. x_data/y_data/xe_data/ye_data need to stay
+ # numpy.ma arrays up to this point because valid_xy (and thus
+ # unmasked_idx) is derived from their masks -- but once we have
+ # unmasked_idx, indexing with it only ever touches already-known-
+ # valid entries, so the mask itself is no longer needed and plain
+ # ndarray indexing (via .data, a zero-copy view) is far cheaper than
+ # numpy.ma's per-element indexing machinery. Doing this extraction
+ # with the masked arrays directly was previously the single largest
+ # cost in this function for large tables (confirmed by profiling:
+ # tens of millions of numpy.ma.core.__getitem__ calls).
+ t_data_arr = np.asarray(t_data)
+ x_data_arr = x_data.data if np.ma.isMaskedArray(x_data) else np.asarray(x_data)
+ y_data_arr = y_data.data if np.ma.isMaskedArray(y_data) else np.asarray(y_data)
+ xe_data_arr = (xe_data.data if np.ma.isMaskedArray(xe_data) else np.asarray(xe_data)) if with_xe_ye else None
+ ye_data_arr = (ye_data.data if np.ma.isMaskedArray(ye_data) else np.asarray(ye_data)) if with_xe_ye else None
+
+ # If multiprocessing, spawn ONE pool for the whole function (not one
+ # per motion-model group below), and hand each worker the shared
+ # per-star data arrays exactly once via the initializer. Each task
+ # then only needs to cross the process boundary with a star index +
+ # its small fixed_params_dict, and does its own (ragged -- stars
+ # have different numbers of valid epochs) data extraction locally,
+ # instead of the parent process pre-extracting a t_stars/x_stars/...
+ # slice for every single star up front and pickling all of it per task.
+ # Only actually pay for a multiprocessing Pool when there's enough
+ # per-star work to recoup its fixed cost (worker startup, pickling
+ # the shared data arrays to each worker) -- below mp_star_threshold,
+ # run serially in this process even if processes > 1 was requested.
+ pool = None
+ if processes > 1 and unmasked_idx is not None and len(non_batch_star_idxs) >= mp_star_threshold:
+ pool = Pool(
+ processes,
+ initializer=_fit_motion_models_init,
+ initargs=(t_data_arr, x_data_arr, y_data_arr, xe_data_arr, ye_data_arr,
+ unmasked_idx, input_mm_map, weighting, use_scipy, absolute_sigma,
+ method, fill_value, bootstrap, seed, verbose)
+ )
+
+ try:
+ # For each motion model
+ for unique_motion_model, unique_index in indices_by_motion_model.items():
+ # Create motion model instance
+ motion_model_instance = input_mm_map[unique_motion_model]()
+ param_names = motion_model_instance.fit_param_names
+ # Initialize arrays to store results
+ n_stars_this_model = len(unique_index)
+ n_params = len(param_names)
+
+ params_array = np.full((n_stars_this_model, n_params), fill_value, dtype=float)
+ param_errs_array = np.full((n_stars_this_model, n_params), np.inf, dtype=float)
+ chi2_x_array = np.full(n_stars_this_model, np.nan, dtype=float)
+ chi2_y_array = np.full(n_stars_this_model, np.nan, dtype=float)
+
+ # For each star
+ if len(unique_index) > 0:
+ if hasattr(motion_model_instance, 'run_fit_batch') and bootstrap == 0:
+ # Closed-form models (currently just Fixed) can be fit
+ # for the whole subgroup in one vectorized pass instead
+ # of star-by-star. This matters even when the table
+ # isn't ALL Fixed (the align.py-level shortcut to
+ # combine_lists_xym only fires then): a large fraction
+ # of stars in a growing mosaic are often still Fixed
+ # regardless of what other stars need, and that
+ # fraction only shrinks as more epochs get added -- so
+ # without this, the (often huge) Fixed subset would
+ # keep paying the per-star loop/multiprocessing cost.
+ # Bootstrap resampling isn't vectorized here, so that
+ # case still falls through to the per-star path below.
+ if verbose:
+ print(f"Fitting {unique_motion_model} motion model: vectorized batch fit for {n_stars_this_model} star(s)")
+ n_epochs = t_data_arr.shape[1]
+ xe_batch = xe_data_arr[unique_index] if with_xe_ye else np.ones((n_stars_this_model, n_epochs))
+ ye_batch = ye_data_arr[unique_index] if with_xe_ye else np.ones((n_stars_this_model, n_epochs))
+ # Same {scalar params} + {array params sliced to this
+ # group} construction as fixed_params_stars above, but
+ # kept batched (not exploded into one dict per star)
+ # since run_fit_batch takes it once for the whole group.
+ fixed_params_batch = {
+ **scalar_params,
+ **{k: v[unique_index] for k, v in array_params.items()}
+ }
+ params_array, param_errs_array, chi2_x_array, chi2_y_array = motion_model_instance.run_fit_batch(
+ t_data_arr[unique_index], x_data_arr[unique_index], y_data_arr[unique_index],
+ xe_batch, ye_batch, valid_xy[unique_index],
+ fixed_params_dict=fixed_params_batch,
+ weighting=weighting, absolute_sigma=absolute_sigma, fill_value=fill_value, verbose=verbose
+ )
+
+ elif pool is not None:
+ # Use multiprocessing to fit stars in parallel
+ arguments = [(i_star, unique_motion_model, fixed_params_stars[i_star]) for i_star in unique_index]
+
+ results = pool.starmap(
+ _fit_motion_models_worker,
+ tqdm(
+ arguments,
+ desc=f"Fitting {unique_motion_model} motion model with {processes} processes",
+ disable=not verbose
+ ),
+ chunksize=chunksize
+ )
+
+ for idx, (params, param_errs, chi2_x, chi2_y) in enumerate(results):
+ params_array[idx] = params
+ param_errs_array[idx] = param_errs
+ chi2_x_array[idx] = chi2_x
+ chi2_y_array[idx] = chi2_y
+ else:
+ # Prepare data as lists of arrays for faster access during fitting
+ t_stars = [t_data_arr[i][unmasked_idx[i]] for i in unique_index]
+ x_stars = [x_data_arr[i][unmasked_idx[i]] for i in unique_index]
+ y_stars = [y_data_arr[i][unmasked_idx[i]] for i in unique_index]
+ xe_stars = [xe_data_arr[i][unmasked_idx[i]] for i in unique_index] if with_xe_ye else [np.ones_like(x_star) for x_star in x_stars]
+ ye_stars = [ye_data_arr[i][unmasked_idx[i]] for i in unique_index] if with_xe_ye else [np.ones_like(y_star) for y_star in y_stars]
+
+ # Expensive for loop! Prepare everything beforehand to speed up.
+ for idx, i_star in enumerate(tqdm(unique_index, disable=not verbose, desc=f"Fitting {unique_motion_model} motion model")):
+ # Fit the star
+ params, param_errs, chi2_x, chi2_y = motion_model_instance.fit(
+ t=t_stars[idx],
+ x=x_stars[idx],
+ y=y_stars[idx],
+ xe=xe_stars[idx],
+ ye=ye_stars[idx],
+ fixed_params_dict=fixed_params_stars[i_star],
+ weighting=weighting,
+ use_scipy=use_scipy,
+ absolute_sigma=absolute_sigma,
+ method=method,
+ fill_value=fill_value,
+ return_chi2=True,
+ bootstrap=bootstrap,
+ seed=seed,
+ verbose=verbose
+ )
+ params_array[idx] = params
+ param_errs_array[idx] = param_errs
+ chi2_x_array[idx] = chi2_x
+ chi2_y_array[idx] = chi2_y
+
+ # fill_with_one substitutes a unit weight so the fit can
+ # still run, but that's not a real measurement uncertainty
+ # -- we still don't know the true error for these stars, so
+ # report it as such rather than the fabricated finite value
+ # the unit weight would otherwise propagate to.
+ if with_xe_ye and fill_with_one.any():
+ param_errs_array[fill_with_one[unique_index]] = np.inf
+
+ # Store results back to the table
+ for j, param_name in enumerate(param_names):
+ self[param_name][unique_index] = params_array[:, j]
+ self[param_name + '_err'][unique_index] = param_errs_array[:, j]
+ self['chi2_x'][unique_index] = chi2_x_array
+ self['chi2_y'][unique_index] = chi2_y_array
+ self['t0'][unique_index] = t0[unique_index]
+ finally:
+ if pool is not None:
+ pool.close()
+ pool.join()
+
+ # Update n_params regardless of selections
+ for mm in motion_model_used:
+ self['n_params'][self['motion_model_used'] == mm.name] = mm.n_params
return
-
-
- def fit_velocities_all_detected(self, weighting='var', use_scipy=False, absolute_sigma=False, epoch_cols='all', mask_val=None, art_star=False, return_result=False):
- """Fit velocities for stars detected in all epochs specified by epoch_cols.
- Criterion: xe/ye error > 0 and finite, x/y not masked.
+
+ def infer_positions(self, times, fixed_params_dict=None, fill_value=np.nan):
+ """Infer star positions at given times using fitted motion models.
Parameters
----------
- weighting : str, optional
- Variance weighting('var') or standard deviation weighting ('std'), by default 'var'
- use_scipy : bool, optional
- Use scipy.curve_fit or flystar.fit_velocity.fit_velocity, by default False
- absolute_sigma : bool, optional
- Absolute sigma or rescaled sigma, by default False
- epoch_cols : str or list of intergers, optional
- List of epoch column indices used for fitting velocity, by default 'all'
- mask_val : float, optional
- Values in x, y to be masked
- art_star : bool, optional
- Artificial star or observation star catalog. If artificial star, use 'det' column to select stars detected in all epochs, by default False
- return_result : bool, optional
- Return the velocity results or not, by default False
-
+ times : array_like
+ Times at which to predict positions. Scalar, or (N_times,) array, or (N_stars, N_times) array.
+ fixed_params_dict : None or dict, optional
+ Dictionary of fixed parameters to use for prediction.
+ If not provided, will try to look for fixed parameters in the meta data then in table columns.
+ If fixed params are found in both the table and the fixed_params_dict, the values in the table will be used and the fixed_params_dict values will be ignored,
+ by default None
+ fill_value : float, optional
+ Value to use for missing data, by default np.nan
+
Returns
-------
- vel_result : astropy Table
- Astropy Table with velocity results
+ x, y, xe, ye : ndarray
+ Arrays of predicted x, y positions and their uncertainties xe, ye, with shape (N_stars, N_times) or (N_stars,) if N_times=1, or (N_times,) if N_stars=1, or scalar.
"""
-
+ assert 'motion_model_used' in self.colnames, \
+ "infer_positions: 'motion_model_used' column not found in the table. Please run fit_motion_models first."
+
N_stars = len(self)
-
- if epoch_cols == 'all':
- epoch_cols = np.arange(np.shape(self['x'])[1])
-
- # Artificial Star
- if art_star:
- detected_in_all_epochs = np.all(self['det'][:, epoch_cols], axis=1)
-
- # Observation Star
+ times = np.atleast_1d(times)
+ N_times = len(times)
+
+ x_pred = np.full((N_stars, N_times), fill_value, dtype=float)
+ y_pred = np.full((N_stars, N_times), fill_value, dtype=float)
+
+ # Only calculate xe ye if columns exist in table, otherwise fill with np.inf
+ if 'x0_err' in self.colnames and 'y0_err' in self.colnames:
+ # 'x0_err' and 'y0_err' are the common uncertainty params for all motion models
+ with_xe_ye = True
+ xe_pred = np.full((N_stars, N_times), np.inf, dtype=float)
+ ye_pred = np.full((N_stars, N_times), np.inf, dtype=float)
else:
- valid_xe = np.all(self['xe'][:, epoch_cols]!=0, axis=1) & np.all(np.isfinite(self['xe'][:, epoch_cols]), axis=1)
- valid_ye = np.all(self['ye'][:, epoch_cols]!=0, axis=1) & np.all(np.isfinite(self['ye'][:, epoch_cols]), axis=1)
-
- if mask_val:
- x = np.ma.masked_values(self['x'][:, epoch_cols], mask_val)
- y = np.ma.masked_values(self['y'][:, epoch_cols], mask_val)
-
- # If no mask, convert x.mask to list
- if not np.ma.is_masked(x):
- x.mask = np.zeros_like(self['x'][:, epoch_cols].data, dtype=bool)
- if not np.ma.is_masked(y):
- y.mask = np.zeros_like(self['y'][:, epoch_cols].data, dtype=bool)
-
- valid_x = ~np.any(x.mask, axis=1)
- valid_y = ~np.any(y.mask, axis=1)
- detected_in_all_epochs = np.logical_and.reduce((
- valid_x, valid_y, valid_xe, valid_ye
- ))
+ with_xe_ye = False
+ xe_pred = np.full((N_stars, N_times), np.inf, dtype=float)
+ ye_pred = np.full((N_stars, N_times), np.inf, dtype=float)
+
+ # Calculate the dictionary of {motion_model: indices of stars with this motion model} for faster access during prediction
+ unique_motion_models, unique_inv_indices = np.unique(self['motion_model_used'], return_inverse=True)
+ indices_by_motion_model = {key: np.flatnonzero(unique_inv_indices == k) for k, key in enumerate(unique_motion_models)}
+
+ mm_map = motion_model.motion_model_map()
+ # Prepare fit_params, fixed_params, fit_param_errs for each star
+ for unique_motion_model, unique_index in indices_by_motion_model.items():
+ # Create motion model instance
+ motion_model_instance = mm_map[unique_motion_model]()
+ # Prepare parameters for prediction
+ fit_params = np.array([
+ self[param_name][unique_index] for param_name in motion_model_instance.fit_param_names
+ ]).T # shape (N_stars_this_model, N_params)
+
+ fit_param_errs = np.array([
+ self[param_name + '_err'][unique_index] for param_name in motion_model_instance.fit_param_names
+ ]).T if with_xe_ye else None # shape (N_stars_this_model, N_params)
+
+ # Construct fixed_params: Look for fixed_params_dict -> table columns -> meta data -> default value
+ fixed_params = fixed_params_dict.copy() if fixed_params_dict is not None else {}
+ for param in motion_model_instance.required_fixed_param_names:
+ if param not in fixed_params:
+ # If required fixed param not provided, find it in the table columns or meta data
+ if param in self.colnames:
+ fixed_params[param] = self[param][unique_index]
+ elif param in self.meta:
+ fixed_params[param] = self.meta[param]
+ else:
+ raise KeyError(f"infer_positions: Required fixed parameter '{param}' not found for motion model '{unique_motion_model}'. Please provide it in fixed_params_dict, or add it as a column in the table, or add it to the meta data.")
+ else:
+ fixed_params[param] = fixed_params_dict[param]
+
+ for param, default_value in motion_model_instance.optional_fixed_params.items():
+ if param not in fixed_params:
+ # If optional fixed param not provided, find it in the table columns or meta data, otherwise use default value
+ if param in self.colnames:
+ if param == 'obsLocation':
+ # Special case for obsLocation: no vectorization implemented yet, use the value from the first star
+ assert np.unique(self[param][unique_index]).size == 1, \
+ f"infer_positions: obsLocation fixed parameter has different values ({np.unique(self[param][unique_index])}) for different stars. Vectorized handling not implemented yet."
+ fixed_params[param] = self[param][unique_index]
+ elif param in self.meta:
+ fixed_params[param] = self.meta[param]
+ else:
+ fixed_params[param] = default_value
+ else:
+ fixed_params[param] = fixed_params_dict[param]
+
+
+ # Predict positions
+ # shape = (N_stars_this_model, N_times) or (N_stars_this_model,) if N_times=1 or (N_times,) if N_stars_this_model=1 or scalar
+ if with_xe_ye:
+ x, y, xe, ye = motion_model_instance.model(
+ times, fit_params, fit_param_errs, fixed_params
+ )
else:
- detected_in_all_epochs = np.logical_and(valid_xe, valid_ye)
-
-
- # Fit velocities
- vel_result = fit_velocity(self[detected_in_all_epochs], weighting=weighting, use_scipy=use_scipy, absolute_sigma=absolute_sigma, epoch_cols=epoch_cols, art_star=art_star)
- vel_result = Table.from_pandas(vel_result)
-
-
- # Add n_vfit
- n_vfit = len(epoch_cols)
- vel_result['n_vfit'] = n_vfit
-
- # Clean/remove up old arrays.
- columns = [*vel_result.keys(), 'n_vfit']
- for column in columns:
- if column in self.colnames: self.remove_column(column)
-
- # Update self
- for column in columns:
- column_array = np.ma.zeros(N_stars)
- column_array[detected_in_all_epochs] = vel_result[column]
- column_array[~detected_in_all_epochs] = np.nan
- column_array.mask = ~detected_in_all_epochs
- self[column] = column_array
-
- if return_result:
- return vel_result
+ x, y = motion_model_instance.model(
+ times, fit_params, fixed_params=fixed_params
+ )
+
+ if N_stars==1 and N_times > 1:
+ # Reshape (N_times,) to (1, N_times)
+ x = x[np.newaxis, :]
+ y = y[np.newaxis, :]
+ if with_xe_ye:
+ xe = xe[np.newaxis, :]
+ ye = ye[np.newaxis, :]
+ elif N_times==1 and N_stars > 1:
+ # Reshape (N_stars,) to (N_stars, 1)
+ x = x[:, np.newaxis]
+ y = y[:, np.newaxis]
+ if with_xe_ye:
+ xe = xe[:, np.newaxis]
+ ye = ye[:, np.newaxis]
+
+ x_pred[unique_index] = x
+ y_pred[unique_index] = y
+ if with_xe_ye:
+ xe_pred[unique_index] = xe
+ ye_pred[unique_index] = ye
+
+ if N_stars==1 or N_times==1:
+ # Reshape back to 1D array or scalar
+ x_pred = x_pred.flatten()
+ y_pred = y_pred.flatten()
+ if with_xe_ye:
+ xe_pred = xe_pred.flatten()
+ ye_pred = ye_pred.flatten()
+
+ xe_pred = xe_pred if with_xe_ye else np.full_like(x_pred, np.inf)
+ ye_pred = ye_pred if with_xe_ye else np.full_like(y_pred, np.inf)
+ return x_pred, y_pred, xe_pred, ye_pred
+
+
+ # New function, to use in align
+ def get_star_positions_at_time(self, t, motion_model_dict, allow_alt_models=True):
+ """ Get current x,y positions of each star according to its motion_model
+ """
+ # Start with empty arrays so we can fill them in batches
+ N_stars = len(self)
+ if hasattr(t, "__len__"):
+ x = np.full((N_stars,len(t)), np.nan, dtype=float)
+ y = np.full((N_stars,len(t)), np.nan, dtype=float)
+ xe = np.full((N_stars,len(t)), np.nan, dtype=float)
+ ye = np.full((N_stars,len(t)), np.nan, dtype=float)
else:
- return
\ No newline at end of file
+ x = np.full(N_stars, np.nan, dtype=float)
+ y = np.full(N_stars, np.nan, dtype=float)
+ xe = np.full(N_stars, np.nan, dtype=float)
+ ye = np.full(N_stars, np.nan, dtype=float)
+
+ # TODO: probably worth some additional testing here
+ # Check which motion models we need
+ # use complex_mms to collect models besides Fixed and Linear
+ unique_mms = np.unique(self['motion_model_input']).tolist()
+ # Calculate current position in batches by motion model
+ for mm in unique_mms:
+ try:
+ # Identify stars with this model & get class
+ idx = np.where(self['motion_model_input']==mm)[0]
+ mod = motion_model_dict[mm]
+ # Set up parameters
+ param_dict = {}
+ for par in mod.fit_param_names + mod.fixed_param_names + [pm+'_err' for pm in mod.fit_param_names]:
+ param_dict[par] = self[par][idx]
+ x[idx],y[idx],xe[idx],ye[idx] = mod.get_batch_pos_at_time(t,**param_dict)
+ except:
+ pass
+ if np.isnan(x).any() and allow_alt_models:
+ re_calc = np.where(np.isnan(x))[0]
+ unique_mms = np.unique(self['motion_model_used'][re_calc]).tolist()
+ # Calculate current position in batches by motion model
+ for mm in unique_mms:
+ # Identify stars with this model & get class
+ idx_0 = np.where(self['motion_model_used']==mm)[0]
+ idx = np.intersect1d(re_calc, idx_0)
+ mod = motion_model_dict[mm]
+ # Set up parameters
+ param_dict = {}
+ for par in motion_model.get_one_motion_model_param_names(mm,with_errors=True,with_fixed=True):
+ param_dict[par] = self[par][idx]
+ x[idx],y[idx],xe[idx],ye[idx] = mod.get_batch_pos_at_time(t,**param_dict)
+
+ return x, y, xe, ye
+
+
+
+ def shift_reference_frame(self, delta_vx=0.0, delta_vy=0.0, delta_pi=0.0, fixed_params_dict=None):
+ """
+ After completing an alignment, shift from your relative reference frame to
+ the absolute frame using either Gaia or a Galactic model. This modified the
+ motion model fit parameters as well as the time series astrometry, assuming
+ zero error on the shift values.
+
+ Parameters
+ ----------
+ delta_vx : float, optional
+ velocity shift in x-direction (as/yr)
+ delta_vy : float, optional
+ velocity shift in y-direction (as/yr)
+ delta_pi : float, optional
+ parallax shift (as)
+ fixed_params_dict : None or dict, optional
+ Dictionary of fixed parameters to use for prediction: ra, dec, obsLocation, specifically in this case
+ """
+ if delta_vx==0.0 and delta_vy==0.0 and delta_pi==0.0:
+ print("No shifts input, reference frame unchanged.")
+ print("Specify delta_vx, delta_vy, and/or delta_pi to perform a reference frame shift.")
+ return
+ self['vx'] += delta_vx
+ self['x'] += delta_vx*(self['t']-self['t0'][:, np.newaxis])
+ self['vy'] += delta_vy
+ self['y'] += delta_vy*(self['t']-self['t0'][:, np.newaxis])
+ if delta_pi!=0.0:
+ fixed_params_dict = {} if fixed_params_dict is None else fixed_params_dict
+ if 'ra' not in fixed_params_dict or 'dec' not in fixed_params_dict:
+ raise KeyError("shift_reference_frame: 'ra' and 'dec' must be provided in fixed_params_dict for parallax shift.")
+ from .motion_model import Parallax
+ ra = fixed_params_dict['ra']
+ dec = fixed_params_dict['dec']
+ pa = fixed_params_dict.get('pa', 0.0)
+ obsLocation = fixed_params_dict.get('obsLocation', 'earth')
+ t_all = self['t'][np.where(~np.any(np.isnan(self['t']), axis=1))[0][0]]
+ t_mjd = Time(t_all, format='decimalyear', scale='utc').mjd
+ pvec = Parallax().calc_parallax_vector(t_mjd, ra=ra, dec=dec, pa=pa, obsLocation=obsLocation)
+ self['pi'] += delta_pi
+ self['x'] += delta_pi*pvec[:, 0, :] # Shape (N_stars, N_times)
+ self['y'] += delta_pi*pvec[:, 1, :] # Shape (N_stars, N_times)
+ return
+
+def shift_reference_frame(table, delta_vx=0.0, delta_vy=0.0, delta_pi=0.0, fixed_params_dict=None):
+ """
+ After completing an alignment, shift from your relative reference frame to
+ the absolute frame using either Gaia or a Galactic model. This modified the
+ motion model fit parameters as well as the time series astrometry, assuming
+ zero error on the shift values.
+
+ Parameters
+ ----------
+ delta_vx : float, optional
+ velocity shift in x-direction (as/yr)
+ delta_vy : float, optional
+ velocity shift in y-direction (as/yr)
+ delta_pi : float, optional
+ parallax shift (as)
+ """
+ if delta_vx==0.0 and delta_vy==0.0 and delta_pi==0.0:
+ print("No shifts input, reference frame unchanged.")
+ print("Specify delta_vx, delta_vy, and/or delta_pi to perform a reference frame shift.")
+ return
+ table['vx'] += delta_vx
+ table['x'] += delta_vx*(table['t']-table['t0'][:, np.newaxis])
+ table['vy'] += delta_vy
+ table['y'] += delta_vy*(table['t']-table['t0'][:, np.newaxis])
+ if delta_pi!=0.0:
+ from .motion_model import Parallax
+ fixed_params_dict = {} if fixed_params_dict is None else fixed_params_dict
+ if 'ra' not in fixed_params_dict or 'dec' not in fixed_params_dict:
+ raise KeyError("shift_reference_frame: 'ra' and 'dec' must be provided in fixed_params_dict for parallax shift.")
+ ra = fixed_params_dict['ra']
+ dec = fixed_params_dict['dec']
+ pa = fixed_params_dict.get('pa', 0.0)
+ obsLocation = fixed_params_dict.get('obsLocation', 'earth')
+ t_all = table['t'][np.where(~np.any(np.isnan(table['t']), axis=1))[0][0]]
+ t_mjd = Time(t_all, format='decimalyear', scale='utc').mjd
+ pvec = Parallax().calc_parallax_vector(t_mjd, ra=ra, dec=dec, pa=pa, obsLocation=obsLocation)
+ table['pi'] += delta_pi
+ table['x'] += delta_pi*pvec[:, 0, :] # Shape (N_stars, N_times)
+ table['y'] += delta_pi*pvec[:, 1, :] # Shape (N_stars, N_times)
+ return table
+
+
+# Per-worker state for the fit_motion_models() process pool, set once by
+# _fit_motion_models_init() when each worker starts. Using a Pool initializer
+# instead of passing this data with every task means the (potentially large)
+# shared arrays cross the process boundary once per worker, not once per star.
+_fmm_worker_state = {}
+
+
+def _fit_motion_models_init(t_data, x_data, y_data, xe_data, ye_data, unmasked_idx,
+ input_mm_map, weighting, use_scipy, absolute_sigma,
+ method, fill_value, bootstrap, seed, verbose):
+ """
+ Pool initializer for fit_motion_models(). Stashes the per-star data
+ arrays (shared, read-only across all stars/tasks) as module-level state
+ in each worker process, so individual tasks only need to send a star
+ index and its small fixed_params_dict -- not a freshly-extracted slice
+ of every array -- to get fit.
+ """
+ _fmm_worker_state.update(
+ t_data=t_data, x_data=x_data, y_data=y_data, xe_data=xe_data, ye_data=ye_data,
+ unmasked_idx=unmasked_idx, input_mm_map=input_mm_map, weighting=weighting,
+ use_scipy=use_scipy, absolute_sigma=absolute_sigma, method=method,
+ fill_value=fill_value, bootstrap=bootstrap, seed=seed, verbose=verbose,
+ )
+
+
+def _fit_motion_models_worker(i_star, motion_model_name, fixed_params_dict):
+ """
+ Pool worker for fit_motion_models(). Slices out this one star's own
+ (ragged -- stars have different numbers of valid epochs) data from the
+ shared arrays stashed by _fit_motion_models_init(), then fits it.
+ """
+ s = _fmm_worker_state
+ idx = s['unmasked_idx'][i_star]
+ t = np.array(s['t_data'][i_star][idx])
+ x = np.array(s['x_data'][i_star][idx])
+ y = np.array(s['y_data'][i_star][idx])
+ if s['xe_data'] is not None:
+ xe = np.array(s['xe_data'][i_star][idx])
+ ye = np.array(s['ye_data'][i_star][idx])
+ else:
+ xe = np.ones_like(x)
+ ye = np.ones_like(y)
+
+ motion_model_instance = s['input_mm_map'][motion_model_name]()
+ return motion_model_instance.fit(
+ t=t, x=x, y=y, xe=xe, ye=ye,
+ fixed_params_dict=fixed_params_dict,
+ weighting=s['weighting'],
+ use_scipy=s['use_scipy'],
+ absolute_sigma=s['absolute_sigma'],
+ method=s['method'],
+ fill_value=s['fill_value'],
+ return_chi2=True,
+ bootstrap=s['bootstrap'],
+ seed=s['seed'],
+ verbose=s['verbose'],
+ )
\ No newline at end of file
diff --git a/flystar/stitch_method2.py b/flystar/stitch_method2.py
index 8cab361..100fcc3 100644
--- a/flystar/stitch_method2.py
+++ b/flystar/stitch_method2.py
@@ -1,7 +1,7 @@
-from flystar import starlists,plots,match,align,analysis, transforms
import numpy as np
-from astropy.table import vstack, Table
import pandas as pd
+from astropy.table import Table
+from flystar import starlists, match, align, transforms
def align_starlists(starlist, ref, transModel=transforms.PolyTransform, order=2, N_loop=2,
dr_tol=1.0, briteN=None, weights='both'):
@@ -42,7 +42,7 @@ def align_starlists(starlist, ref, transModel=transforms.PolyTransform, order=2,
if weights==None, we don't use weights.
"""
-
+
#--------------------------------------------------
# Initial transformation with brightest briteN stars
#--------------------------------------------------
@@ -98,7 +98,7 @@ def weighted_mean(df,x,xe,frames_in_use):
# error = xe or ye
# all_frames = e.g. ['A', 'B', 'C', ...]
-
+
cols_x=["{0}_{1}".format(x,f) for f in frames_in_use] # columns for x_* e.g. ['x_A', 'x_B', 'x_C', ....]
cols_xe=["{0}_{1}".format(xe,f) for f in frames_in_use] # columns for xe_* e.g. ['xe_A', 'xe_B', 'xe_C', ....]
@@ -120,11 +120,11 @@ def weighted_mean(df,x,xe,frames_in_use):
xe_master.append(array_xe[i][mask][0])
else:
rows_to_drop.append(i)
-
+
df=df.drop(rows_to_drop)
df[x]=np.array(x_master)
df[xe]=np.array(xe_master)
-
+
return df
@@ -132,12 +132,12 @@ def normal_mean(df,x,frames_in_use):
cols_x=["{0}_{1}".format(x,f) for f in frames_in_use]
df[x]=df[cols_x].mean(axis=1)
-
+
return df
def stitch(all_starlists, name_initial_ref, N_iter=5, corr_thresh=0.8, outMaster='./master.lis'):
-
+
# all_starslist: the list of the names of all starlists e.g. ['A', 'B', 'C', ... ]
# name_initial_ref: the name of the reference that you use in the very first match.
# corr_thresh : threshold for correlation values.
@@ -149,11 +149,11 @@ def stitch(all_starlists, name_initial_ref, N_iter=5, corr_thresh=0.8, outMaste
input_starslists.remove(name_initial_ref)
for name_starlist in input_starslists:
-
+
starlist=starlists.read_starlist('{0}.lis'.format(name_starlist))
if 'ref' not in locals():
ref=starlists.read_starlist('{0}.lis'.format(name_initial_ref))
-
+
#------------ Choose good stars to use for a trans object --------------------
@@ -162,14 +162,14 @@ def stitch(all_starlists, name_initial_ref, N_iter=5, corr_thresh=0.8, outMaste
# Select the very first 11 columns (i.e. the master reference) consistent with those of the starlist.
# Table -> dataframe -> Table, which lets us avoid the following error: 'MaskedColumn' object has no attribute '_mask'
-
+
ref_for_align=ref_for_align.to_pandas()
-
+
ref_for_align=Table.from_pandas(ref_for_align[starlist_for_align.colnames])
_,_,_,trans=align_starlists(starlist_for_align,ref_for_align,order=2,dr_tol=1,N_loop=15)
-
+
#------------ Transform the whole starlist using the trans object and match with the reference -------------
starlist_transformed=align.transform_from_object(starlist,trans)
@@ -183,7 +183,7 @@ def stitch(all_starlists, name_initial_ref, N_iter=5, corr_thresh=0.8, outMaste
#-------------Convert the astropy talbes into dataframes ---------------------
df_ref=ref.to_pandas()
df_starlist_transformed=starlist_transformed.to_pandas()
-
+
#-------------Columns 11-21 contain the measurments for the initial reference--------------
colnames=starlist.colnames
@@ -199,11 +199,11 @@ def stitch(all_starlists, name_initial_ref, N_iter=5, corr_thresh=0.8, outMaste
for col in colnames:
df_ref['{0}_{1}'.format(col,name_starlist)]=np.nan
df_ref.loc[idx_ref_matched,'{0}_{1}'.format(col,name_starlist)]= np.array(df_starlist_transformed.loc[idx_starlist_transformed_matched,col])
-
+
else:
for col in colnames:
-
+
df_ref.insert(len(df_ref.columns),'{0}_{1}'.format(col,name_starlist),np.nan)
df_ref.loc[idx_ref_matched,'{0}_{1}'.format(col,name_starlist)]= np.array(df_starlist_transformed.loc[idx_starlist_transformed_matched,col])
@@ -218,7 +218,7 @@ def stitch(all_starlists, name_initial_ref, N_iter=5, corr_thresh=0.8, outMaste
#-------------- Figure out which frames are currently included in the master frame -----------
frames_in_use=sorted(set([column[-1] for column in columns if (column[-1] in all_starlists)]))
-
+
#-------------- Average the measurements -------------
for col in colnames:
if (col!='name') and (col!='x') and (col!='y') and (col!='xe') and (col!='ye') and (col!='N_frames'):
@@ -226,7 +226,7 @@ def stitch(all_starlists, name_initial_ref, N_iter=5, corr_thresh=0.8, outMaste
df_comb=weighted_mean(df_comb,'x','xe',frames_in_use)
df_comb=weighted_mean(df_comb,'y','ye',frames_in_use)
-
+
#-------------Recalculate 'N_frames' for the master frame -> N_frames = the number of input starlists containing the star-----------
# N_frames = the number of notnull columns at each row in the master frame divided by the number of columns in an input starlist, then minus one.
# The "minus one" at the end accounts for the very first columns, i.e. master columns, that contain the averaged values of all the input starlists.
@@ -244,7 +244,7 @@ def stitch(all_starlists, name_initial_ref, N_iter=5, corr_thresh=0.8, outMaste
#-------------- Convert the final dataframe back into an astropy table ------
ref=Table.from_pandas(df_comb)
-
+
ref.write(outMaster,format='ascii.commented_header', header_start=-1, overwrite=True)
return
diff --git a/flystar/template.py b/flystar/template.py
index c714f9d..333b411 100644
--- a/flystar/template.py
+++ b/flystar/template.py
@@ -1,35 +1,30 @@
-from flystar import match
-from flystar import align
-from flystar import starlists
-from flystar import plots
-from flystar import transforms
-from astropy.table import Table
-import numpy as np
import pdb
+import numpy as np
+from flystar import align, starlists, plots, transforms
-def align_template(labelFile, reference, transModel=transforms.PolyTransform, order=1, N_loop=2,
+def align_template(labelFile, reference, transModel=transforms.PolyTransform, order=1, N_loop=2,
dr_tol=1.0, dm_tol=None, briteN=100, weights='both', restrict=False, outFile='outTrans.txt'):
"""
Base example of how to use the flystar code. Assumes we are transforming a label.dat into
a reference starlist.
-
+
Parameters:
-----------
labelFile: ascii file
Starlist we would like to transform into the reference frame. For this
code, we expect a label.dat file
-
+
reference: ascii file
Starlist that defines the reference frame
-
+
transModel: transformation class (default: transforms.polyTransform)
Defines which transformation model to use. Both the four-parameter and
polynomial transformations are supported
-
+
order: int (default=1)
Order of the polynomial transformation. Only used for polynomial transform
-
+
N_loop: int (default=2)
How many times to iterate on the transformation calculation. Ideally,
each iteration adds more stars and thus a better transform, to some
@@ -39,11 +34,11 @@ def align_template(labelFile, reference, transModel=transforms.PolyTransform, or
the distance tolerance for matching two stars in align.transform_and_match
dm_tol: float (defalut=None)
- the magnitude tolerance for matching two stars in align.trnasform_and_match
+ the magnitude tolerance for matching two stars in align.trnasform_and_match
briteN: int (default=100)
the number of stars used in blind matching
-
+
weights: string (default='both')
if weights=='both', we use both position error in transformed starlist and
reference starlist as uncertanty. And weights is the reciprocal of this uncertanty.
@@ -66,7 +61,7 @@ def align_template(labelFile, reference, transModel=transforms.PolyTransform, or
tref = starlist['t'][0]
# label.dat has position & position err and velocity & velocity error
label = starlists.read_label(labelFile, prop_to_time=tref, flipX=True)
-
+
#--------------------------------------------------
# Initial transformation with brightest briteN stars
@@ -79,21 +74,21 @@ def align_template(labelFile, reference, transModel=transforms.PolyTransform, or
# and calculate initial transform
label_ini = label[idx_ini_label]
starlist_ini = starlist[idx_ini_starlist]
-
+
trans = align.initial_align(label_ini, starlist_ini, briteN=briteN,
transformModel=transModel, order=order)
-
+
# apply the initial transform to label.dat
# this is used for future weights calculation
label_trans_ini = align.transform_from_object(label, trans)
-
+
#------------------------------------------------------------------------
# Use transformation to match starlists, then recalculate transformation.
#------------------------------------------------------------------------
# Iterate on this as many times as desired
for i in range(N_loop):
- # apply the transformation to label.dat and
+ # apply the transformation to label.dat and
# matched the transformed label with starlist.
idx_label, idx_starlist = align.transform_and_match(label, starlist, trans,
dr_tol=dr_tol, dm_tol=dm_tol)
@@ -101,17 +96,17 @@ def align_template(labelFile, reference, transModel=transforms.PolyTransform, or
if restrict:
label_match = label[idx_label]
starlist_match = starlist[idx_starlist]
- idx_label, idx_starlist = stalists.restrict_by_use(label_match, starlist_match,
+ idx_label, idx_starlist = starlists.restrict_by_use(label_match, starlist_match,
idx_label, idx_starlist)
-
+
# use the matched stars to calculate new transformation
label_match = label[idx_label]
starlist_match = starlist[idx_starlist]
label_ini_match = label_trans_ini[idx_label]
- trans, N_trans = align.find_transform(label_match, label_ini_match, starlist_match,
+ trans, N_trans = align.find_transform(label_match, label_ini_match, starlist_match,
transModel=transModel, order=order, weights = weights)
-
+
#---------------------------------------------
# Write final transform in java align format
@@ -121,7 +116,7 @@ def align_template(labelFile, reference, transModel=transforms.PolyTransform, or
# write the transformation coefficients to 'outTrans.txt'
align.write_transform(trans, labelFile, reference, N_trans, deltaMag=delta_m,
restrict=restrict, weights=weights, outFile=outFile)
-
+
#-----------------------------------------------------------
# Test transform: apply to label.dat, make diagnostic plots
@@ -129,11 +124,11 @@ def align_template(labelFile, reference, transModel=transforms.PolyTransform, or
# apply the final transformation to label.dat
label_trans = align.transform_from_object(label, trans)
label_trans_match = label_trans[idx_label]
-
+
# postion map with every star in starlist and transformed label.
# both matched and unmatched stars.
plots.trans_positions( starlist, starlist_match, label_trans, label_trans_match)
-
+
# position difference histogram for matched stars.
plots.pos_diff_hist( starlist_match, label_trans_match)
@@ -146,6 +141,6 @@ def align_template(labelFile, reference, transModel=transforms.PolyTransform, or
# quiver plot of postion residules
plots.pos_diff_quiver( starlist_match, label_trans_match)
-
+
return
-
+
diff --git a/flystar/tests/compare_branches.py b/flystar/tests/compare_branches.py
new file mode 100644
index 0000000..6dd71b8
--- /dev/null
+++ b/flystar/tests/compare_branches.py
@@ -0,0 +1,45 @@
+import pickle
+import flystar
+import matplotlib.pyplot as plt
+from flystar import align, transforms, motion_model
+from flystar.plots import plot_stars
+
+branch = 'mm_rework_lingfeng' # 'mm_rework_lingfeng' or 'mm_rework'
+
+test_data_path = f'{flystar.__path__[0]}/tests/test_data'
+
+with open(f'{test_data_path}/my_gaia.pkl', 'rb') as f:
+ my_gaia = pickle.load(f)
+with open(f'{test_data_path}/list_of_starlists.pkl', 'rb') as f:
+ list_of_starlists = pickle.load(f)
+ra_deg, dec_deg = 18.0, -30.0
+my_gaia.remove_column('motion_model_used')
+# my_gaia['motion_model_input'] = 'Fixed'
+if branch == 'mm_rework_lingfeng':
+ msc = align.MosaicToRef(my_gaia, list_of_starlists, iters=1,
+ dr_tol=[0.2], dm_tol=[5],
+ outlier_tol=[None], mag_lim=[6, 20],
+ trans_class=transforms.PolyTransform,
+ trans_args=[{'order': 1}],
+ motion_models=['Fixed', 'Parallax'],
+ fixed_params_dict = {'ra':ra_deg, 'dec':dec_deg, 'pa':0.0, 'obsLocation':'earth'},
+ use_ref_new=True,
+ update_ref_orig=False,
+ mag_trans=True,
+ trans_weights='both,std',
+ init_guess_mode='name', verbose=3)
+elif branch == 'mm_rework':
+ msc = align.MosaicToRef(my_gaia, list_of_starlists, iters=1,
+ dr_tol=[0.2], dm_tol=[5],
+ outlier_tol=[None], mag_lim=[6, 20],
+ trans_class=transforms.PolyTransform,
+ trans_args=[{'order': 1}],
+ default_motion_model='Parallax',
+ motion_model_dict = {'Parallax': motion_model.Parallax(RA=ra_deg, Dec=dec_deg, PA=0.0, obsLocation='earth')},
+ use_ref_new=True,
+ update_ref_orig=False,
+ mag_trans=True,
+ trans_weights='both,std',
+ init_guess_mode='name', verbose=3)
+
+msc.fit()
\ No newline at end of file
diff --git a/flystar/tests/test_align.ipynb b/flystar/tests/test_align.ipynb
deleted file mode 100644
index 02442b9..0000000
--- a/flystar/tests/test_align.ipynb
+++ /dev/null
@@ -1,366 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Notebook for Running Align Tests"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {},
- "outputs": [],
- "source": [
- "from flystar.tests import test_align\n",
- "from flystar import starlists\n",
- "from astropy.table import Table"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Test: make_fake_starlists_poly1_vel\n",
- "\n",
- "Just make sure the tables look sensible and are in the right units."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- " name m0 m0e ... vye t0 \n",
- "-------- ----------------- -------------------- ... ------------------- ------\n",
- "star_155 9.106905292995506 0.054167528156861204 ... 0.1564397531527286 2019.5\n",
- "star_113 9.153031462110043 0.0421090989942197 ... 0.08128628950126615 2019.5\n",
- "star_077 9.16547870263162 0.02021147759307802 ... 0.05907352582911862 2019.5\n",
- "star_069 9.169817788300977 0.027788213230369625 ... 0.04965351499764548 2019.5\n",
- "star_037 9.173200786855755 0.007665400875860144 ... 0.22723357600795704 2019.5\n",
- " name m me ... ye t \n",
- "-------- ----------------- -------------------- ... -------------------- ------\n",
- "star_155 9.198437965086988 0.054167528156861204 ... 0.02649499466969545 2018.5\n",
- "star_113 9.257333243243941 0.0421090989942197 ... 0.02606700846524875 2018.5\n",
- "star_077 9.252158908537464 0.02021147759307802 ... 0.04250920654497108 2018.5\n",
- "star_069 9.267901667333167 0.027788213230369625 ... 0.042689240225924296 2018.5\n",
- "star_037 9.276780126418494 0.007665400875860144 ... 0.03592203011554212 2018.5\n",
- " name m me ... ye t \n",
- "-------- ----------------- -------------------- ... -------------------- ------\n",
- "star_155 9.478887659623185 0.054167528156861204 ... 0.02649499466969545 2019.5\n",
- "star_113 9.569878576042546 0.0421090989942197 ... 0.02606700846524875 2019.5\n",
- "star_077 9.575998150724095 0.02021147759307802 ... 0.04250920654497108 2019.5\n",
- "star_069 9.593581807234129 0.027788213230369625 ... 0.042689240225924296 2019.5\n",
- "star_037 9.553127108740597 0.007665400875860144 ... 0.03592203011554212 2019.5\n",
- "['name', 'm0', 'm0e', 'x0', 'x0e', 'y0', 'y0e', 'vx', 'vxe', 'vy', 'vye', 't0']\n",
- "['name', 'm', 'me', 'x', 'xe', 'y', 'ye', 't']\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "/Users/jlu/code/python/flystar/flystar/starlists.py:386: UserWarning: The StarList class requires a arguments('name', 'x', 'y', 'm')\n",
- " warnings.warn(err_msg, UserWarning)\n"
- ]
- }
- ],
- "source": [
- "test_align.make_fake_starlists_poly1_vel()\n",
- "\n",
- "ref = Table.read('random_vel_ref.fits')\n",
- "lis0 = Table.read('random_vel_0.fits')\n",
- "lis1 = Table.read('random_vel_1.fits')\n",
- "\n",
- "print(ref[0:5])\n",
- "print(lis0[0:5])\n",
- "print(lis1[0:5])\n",
- "\n",
- "print(ref.colnames)\n",
- "print(lis0.colnames)\n"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## test_align_vel\n",
- "\n",
- "Make sure it runs, make some plots along the way, etc."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 12,
- "metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "/Users/jlu/code/python/flystar/flystar/starlists.py:386: UserWarning: The StarList class requires a arguments('name', 'x', 'y', 'm')\n",
- " warnings.warn(err_msg, UserWarning)\n",
- "/Users/jlu/code/python/flystar/flystar/starlists.py:386: UserWarning: The StarList class requires a arguments('name', 'x', 'y', 'm')\n",
- " warnings.warn(err_msg, UserWarning)\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- " \n",
- "**********\n",
- "**********\n",
- "Starting iter 0 with ref_table shape: (200, 1)\n",
- "**********\n",
- "**********\n",
- " \n",
- " **********\n",
- " Matching catalog 1 / 4 in iteration 0 with 200 stars\n",
- " **********\n",
- "initial_guess: 50 stars matched between starlist and reference list\n",
- "initial_guess: [-6.05144456e+00 1.01098279e+00 -2.50608887e-04] [-1.07161761e+01 4.89226304e-05 1.01096529e+00]\n",
- " Found 0 duplicates out of 196 matches\n",
- "In Loop 0 found 196 matches\n",
- " Found 0 duplicates out of 196 matches\n",
- " \n",
- " **********\n",
- " Matching catalog 2 / 4 in iteration 0 with 200 stars\n",
- " **********\n",
- "initial_guess: 49 stars matched between starlist and reference list\n",
- "initial_guess: [-1.02158015e+02 1.02080743e+00 -1.45081519e-04] [-5.07779471e+01 -2.60729494e-05 9.99423500e-01]\n",
- " Found 0 duplicates out of 200 matches\n",
- "In Loop 0 found 200 matches\n",
- " Found 0 duplicates out of 200 matches\n",
- " \n",
- " **********\n",
- " Matching catalog 3 / 4 in iteration 0 with 200 stars\n",
- " **********\n",
- "initial_guess: 50 stars matched between starlist and reference list\n",
- "initial_guess: [-2.14220566e-10 1.00000000e+00 -2.24089697e-16] [2.50622339e-10 0.00000000e+00 1.00000000e+00]\n",
- " Found 0 duplicates out of 200 matches\n",
- "In Loop 0 found 200 matches\n",
- " Found 0 duplicates out of 200 matches\n",
- " \n",
- " **********\n",
- " Matching catalog 4 / 4 in iteration 0 with 200 stars\n",
- " **********\n",
- "initial_guess: 50 stars matched between starlist and reference list\n",
- "initial_guess: [-2.57803428e+02 1.03052409e+00 -5.28390832e-05] [ 2.49886631e+02 -6.00884405e-05 9.98642952e-01]\n",
- " Found 0 duplicates out of 200 matches\n",
- "In Loop 0 found 200 matches\n",
- " Found 0 duplicates out of 200 matches\n",
- " \n",
- "**********\n",
- "**********\n",
- "Starting iter 1 with ref_table shape: (204, 4)\n",
- "**********\n",
- "**********\n",
- " \n",
- " **********\n",
- " Matching catalog 1 / 4 in iteration 1 with 200 stars\n",
- " **********\n",
- " Found 0 duplicates out of 199 matches\n",
- "In Loop 1 found 199 matches\n",
- " Found 0 duplicates out of 199 matches\n",
- " \n",
- " **********\n",
- " Matching catalog 2 / 4 in iteration 1 with 200 stars\n",
- " **********\n",
- " Found 0 duplicates out of 198 matches\n",
- "In Loop 1 found 198 matches\n",
- " Found 0 duplicates out of 199 matches\n",
- " \n",
- " **********\n",
- " Matching catalog 3 / 4 in iteration 1 with 200 stars\n",
- " **********\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "/Users/jlu/code/python/flystar/flystar/starlists.py:386: UserWarning: The StarList class requires a arguments('name', 'x', 'y', 'm')\n",
- " warnings.warn(err_msg, UserWarning)\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- " Found 0 duplicates out of 200 matches\n",
- "In Loop 1 found 200 matches\n",
- " Found 0 duplicates out of 200 matches\n",
- " \n",
- " **********\n",
- " Matching catalog 4 / 4 in iteration 1 with 200 stars\n",
- " **********\n",
- " Found 0 duplicates out of 200 matches\n",
- "In Loop 1 found 200 matches\n",
- " Found 0 duplicates out of 200 matches\n",
- "**********\n",
- "Final Matching\n",
- "**********\n",
- " Found 0 duplicates out of 199 matches\n",
- "Matched 199 out of 200 stars in list 0\n",
- " Found 0 duplicates out of 199 matches\n",
- "Matched 199 out of 200 stars in list 1\n",
- " Found 0 duplicates out of 200 matches\n",
- "Matched 200 out of 200 stars in list 2\n",
- " Found 0 duplicates out of 199 matches\n",
- "Matched 199 out of 200 stars in list 3\n",
- "\n",
- " Preparing the reference table...\n"
- ]
- }
- ],
- "source": [
- "test_align.test_mosaic_lists_vel()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "> /Users/jlu/code/python/flystar/flystar/align.py(3244)apply_mag_lim()\n",
- "-> star_list_T.restrict_by_value(**conditions)\n"
- ]
- },
- {
- "name": "stdin",
- "output_type": "stream",
- "text": [
- "(Pdb) conditions\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "{'m0_min': None, 'm0_max': None}\n"
- ]
- },
- {
- "name": "stdin",
- "output_type": "stream",
- "text": [
- "(Pdb) type(star_list_T)\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "\n"
- ]
- },
- {
- "name": "stdin",
- "output_type": "stream",
- "text": [
- "(Pdb) type(ref_list)\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "*** NameError: name 'ref_list' is not defined\n"
- ]
- },
- {
- "name": "stdin",
- "output_type": "stream",
- "text": [
- "(Pdb) ref_list\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "*** NameError: name 'ref_list' is not defined\n"
- ]
- },
- {
- "name": "stdin",
- "output_type": "stream",
- "text": [
- "(Pdb) u\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "> /Users/jlu/code/python/flystar/flystar/align.py(991)mosaic_lists()\n",
- "-> ref_list_T = apply_mag_lim(ref_list, mag_lim[ref_index])\n"
- ]
- },
- {
- "name": "stdin",
- "output_type": "stream",
- "text": [
- "(Pdb) type(ref_list)\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "\n"
- ]
- },
- {
- "name": "stdin",
- "output_type": "stream",
- "text": [
- "(Pdb) q\n"
- ]
- }
- ],
- "source": [
- "import pdb\n",
- "pdb.pm()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.6.7"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
-}
diff --git a/flystar/tests/test_align.py b/flystar/tests/test_align.py
index 026a8b1..429ff9a 100644
--- a/flystar/tests/test_align.py
+++ b/flystar/tests/test_align.py
@@ -1,20 +1,18 @@
-from flystar import align
-from flystar import starlists
-from flystar import startables
-from flystar import transforms
-from flystar import analysis
-from astropy.table import Table
-import numpy as np
-import pylab as plt
import pdb
-import datetime
+import flystar
+import numpy as np
+import matplotlib.pyplot as plt
+from astropy.table import Table
+from flystar.plots import plot_stars
+from flystar import align, starlists, transforms, analysis, motion_model
+test_data_path = f'{flystar.__path__[0]}/tests/test_data'
def test_MosaicSelfRef():
"""
Cross-match and align 4 starlists using the OO version of mosaic lists.
"""
- list_files = ['A.lis', 'B.lis', 'C.lis', 'D.lis']
+ list_files = [f'{test_data_path}/{f}' for f in ['A.lis', 'B.lis', 'C.lis', 'D.lis']]
lists = [starlists.StarList.from_lis_file(lf) for lf in list_files]
##########
@@ -27,70 +25,67 @@ def test_MosaicSelfRef():
trans_args={'order': 2})
msc.fit()
-
+
# Check some of the output quantities on the final table.
assert 'x0' in msc.ref_table.colnames
- assert 'x0e' in msc.ref_table.colnames
+ assert 'x0_err' in msc.ref_table.colnames
assert 'y0' in msc.ref_table.colnames
- assert 'y0e' in msc.ref_table.colnames
+ assert 'y0_err' in msc.ref_table.colnames
assert 'm0' in msc.ref_table.colnames
- assert 'm0e' in msc.ref_table.colnames
+ assert 'm0_err' in msc.ref_table.colnames
assert 'use_in_trans' in msc.ref_table.colnames
assert 'used_in_trans' in msc.ref_table.colnames
assert 'ref_orig' in msc.ref_table.colnames
assert msc.ref_table['use_in_trans'].shape == msc.ref_table['x0'].shape
assert msc.ref_table['used_in_trans'].shape == msc.ref_table['x'].shape
-
# Check that we have some matched stars... should be at least 35 stars
# that are detected in all 4 starlists.
idx = np.where(msc.ref_table['n_detect'] == 4)[0]
- assert len(idx) > 35
+ assert len(idx) > 35
# Check that the transformation error isn't too big
- assert (msc.ref_table['x0e'] < 3.0).all() # less than 1 pix
- assert (msc.ref_table['y0e'] < 3.0).all()
- #assert (msc.ref_table['m0e'] < 1.0).all() # less than 0.5 mag
- assert (msc.ref_table['m0e'] < 1.5).all() # less than 0.5 mag
-
+ valid_err = np.isfinite(msc.ref_table['x0_err']) & np.isfinite(msc.ref_table['y0_err']) & np.isfinite(msc.ref_table['m0_err'])
+ assert (msc.ref_table['x0_err'][valid_err] < 3.0).all() # less than 1 pix
+ assert (msc.ref_table['y0_err'][valid_err] < 3.0).all()
+ #assert (msc.ref_table['m0_err'][valid_err] < 1.0).all() # less than 0.5 mag
+ assert (msc.ref_table['m0_err'][valid_err] < 1.5).all() # less than 0.5 mag
# Check that the transformation lists aren't too wacky
for ii in range(4):
- np.testing.assert_almost_equal(msc.trans_list[ii].px.c1_0, 1.0, 2)
- np.testing.assert_almost_equal(msc.trans_list[ii].py.c0_1, 1.0, 2)
-
+ np.testing.assert_allclose(msc.trans_list[ii].px.c1_0, 1.0, rtol=1e-2)
+ np.testing.assert_allclose(msc.trans_list[ii].py.c0_1, 1.0, rtol=1e-2)
# We didn't do any velocity fitting, so make sure nothing got created.
assert 'vx' not in msc.ref_table.colnames
assert 'vy' not in msc.ref_table.colnames
- assert 'vxe' not in msc.ref_table.colnames
- assert 'vye' not in msc.ref_table.colnames
+ assert 'vx_err' not in msc.ref_table.colnames
+ assert 'vy_err' not in msc.ref_table.colnames
plt.clf()
plt.plot(msc.ref_table['x'][:, 0],
msc.ref_table['y'][:, 0],
- 'k+', color='red', mec='red', mfc='none')
+ '+', color='red', mec='red', mfc='none')
plt.plot(msc.ref_table['x'][:, 1],
msc.ref_table['y'][:, 1],
- 'kx', color='blue', mec='blue', mfc='none')
+ 'x', color='blue', mec='blue', mfc='none')
plt.plot(msc.ref_table['x'][:, 2],
msc.ref_table['y'][:, 2],
- 'ko', color='cyan', mec='cyan', mfc='none')
+ 'o', color='cyan', mec='cyan', mfc='none')
plt.plot(msc.ref_table['x'][:, 3],
msc.ref_table['y'][:, 3],
- 'k^', color='green', mec='green', mfc='none')
+ '^', color='green', mec='green', mfc='none')
plt.plot(msc.ref_table['x0'],
msc.ref_table['y0'],
- 'k.', color='black', alpha=0.2)
-
+ '.', color='black', alpha=0.2)
return
def test_MosaicSelfRef_vel_tconst():
"""
Cross-match and align 4 starlists using the OO version of mosaic lists.
The 4 lists are all taken at the same time (so 0 velocities should result).
-
+
"""
- list_files = ['A.lis', 'B.lis', 'C.lis', 'D.lis']
+ list_files = [f'{test_data_path}/{f}' for f in ['A.lis', 'B.lis', 'C.lis', 'D.lis']]
lists = [starlists.StarList.from_lis_file(lf) for lf in list_files]
##########
@@ -100,70 +95,66 @@ def test_MosaicSelfRef_vel_tconst():
msc = align.MosaicSelfRef(lists, ref_index=0, iters=2,
dr_tol=[3, 3], dm_tol=[1, 1],
trans_class=transforms.PolyTransform,
- trans_args={'order': 2}, use_vel=True,
+ trans_args={'order': 2},
+ motion_models=['Empty', 'Fixed', 'Linear'],
verbose=False)
msc.fit()
-
+
# Check some of the output quantities on the final table.
assert 'x0' in msc.ref_table.colnames
- assert 'x0e' in msc.ref_table.colnames
+ assert 'x0_err' in msc.ref_table.colnames
assert 'y0' in msc.ref_table.colnames
- assert 'y0e' in msc.ref_table.colnames
+ assert 'y0_err' in msc.ref_table.colnames
assert 'm0' in msc.ref_table.colnames
- assert 'm0e' in msc.ref_table.colnames
- assert 'vx' in msc.ref_table.colnames
- assert 'vxe' in msc.ref_table.colnames
- assert 'vy' in msc.ref_table.colnames
- assert 'vye' in msc.ref_table.colnames
+ assert 'm0_err' in msc.ref_table.colnames
+ # Since they are in the same epoch, no velocity information can be inferred
+ # assert 'vx' in msc.ref_table.colnames
+ # assert 'vx_err' in msc.ref_table.colnames
+ # assert 'vy' in msc.ref_table.colnames
+ # assert 'vy_err' in msc.ref_table.colnames
assert 't0' in msc.ref_table.colnames
# Check that we have some matched stars... should be at least 35 stars
# that are detected in all 4 starlists.
idx = np.where(msc.ref_table['n_detect'] == 4)[0]
- assert len(idx) > 35
+ assert len(idx) > 35
# Check that the transformation error isn't too big
- assert (msc.ref_table['x0e'] < 3.0).all() # less than 1 pix
- assert (msc.ref_table['y0e'] < 3.0).all()
- assert (msc.ref_table['m0e'] < 1.0).all() # less than 0.5 mag
-
+ valid_err = np.isfinite(msc.ref_table['x0_err']) & np.isfinite(msc.ref_table['y0_err']) & np.isfinite(msc.ref_table['m0_err'])
+ assert (msc.ref_table['x0_err'][valid_err] < 3.0).all() # less than 1 pix
+ assert (msc.ref_table['y0_err'][valid_err] < 3.0).all()
+ # A star detected in only 1 epoch now correctly gets a finite m0_err
+ # from that single epoch's own 'me' (weighted average of 1 point)
+ # instead of being silently excluded via an inf from the unweighted
+ # fallback -- so its (legitimately large, single-detection) uncertainty
+ # is included here rather than skipped by the isfinite() filter above.
+ assert (msc.ref_table['m0_err'][valid_err] < 1.5).all()
+
# Check that the transformation lists aren't too wacky
for ii in range(4):
- np.testing.assert_almost_equal(msc.trans_list[ii].px.c1_0, 1.0, 2)
- np.testing.assert_almost_equal(msc.trans_list[ii].py.c0_1, 1.0, 2)
-
- # Check that the velocities aren't crazy...
- # they should be zero (since there is no time difference)
- np.testing.assert_almost_equal(msc.ref_table['vx'], 0, 1)
- np.testing.assert_almost_equal(msc.ref_table['vy'], 0, 1)
-
- assert (msc.ref_table['vx'] == 0).all()
- assert (msc.ref_table['vy'] == 0).all()
- assert (msc.ref_table['vxe'] == 0).all()
- assert (msc.ref_table['vye'] == 0).all()
-
+ np.testing.assert_allclose(msc.trans_list[ii].px.c1_0, 1.0, rtol=1e-2)
+ np.testing.assert_allclose(msc.trans_list[ii].py.c0_1, 1.0, rtol=1e-2)
return
def test_MosaicSelfRef_vel():
"""
Cross-match and align 4 starlists using the OO version of mosaic lists.
-
"""
- list_files = ['A.lis', 'B.lis', 'C.lis', 'D.lis']
+ list_files = [f'{test_data_path}/{f}' for f in ['A.lis', 'B.lis', 'C.lis', 'D.lis']]
lists = [starlists.StarList.from_lis_file(lf) for lf in list_files]
# Modify the times so that we get velocities out.
- lists[0].meta['list_time'] = 2001.4
+ lists[0].meta['list_times'] = 2001.4
lists[0]['t'] = 2001.4
-
- lists[1].meta['list_time'] = 2002.4
+
+ lists[1].meta['list_times'] = 2002.4
lists[1]['t'] = 2002.4
-
- lists[2].meta['list_time'] = 2003.4
+
+ lists[2].meta['list_times'] = 2003.4
lists[2]['t'] = 2003.4
-
- lists[3].meta['list_time'] = 2004.4
+
+ lists[3].meta['list_times'] = 2004.4
lists[3]['t'] = 2004.4
@@ -171,76 +162,72 @@ def test_MosaicSelfRef_vel():
# Test instantiation and basic fitting.
##########
msc = align.MosaicSelfRef(lists, ref_index=0, iters=3,
- dr_tol=[5, 3, 3], dm_tol=[1, 1, 0.5], outlier_tol=None,
+ dr_tol=[5, 3, 3], dm_tol=[1, 1, 0.5], outlier_tol=None, briteN=30,
trans_class=transforms.PolyTransform,
- trans_args={'order': 2}, use_vel=True,
+ trans_args={'order': 2}, motion_models=['Empty', 'Fixed', 'Linear'],
verbose=False)
msc.fit()
-
+
# Check some of the output quantities on the final table.
assert 'x0' in msc.ref_table.colnames
- assert 'x0e' in msc.ref_table.colnames
+ assert 'x0_err' in msc.ref_table.colnames
assert 'y0' in msc.ref_table.colnames
- assert 'y0e' in msc.ref_table.colnames
+ assert 'y0_err' in msc.ref_table.colnames
assert 'm0' in msc.ref_table.colnames
- assert 'm0e' in msc.ref_table.colnames
+ assert 'm0_err' in msc.ref_table.colnames
assert 'vx' in msc.ref_table.colnames
- assert 'vxe' in msc.ref_table.colnames
+ assert 'vx_err' in msc.ref_table.colnames
assert 'vy' in msc.ref_table.colnames
- assert 'vye' in msc.ref_table.colnames
+ assert 'vy_err' in msc.ref_table.colnames
assert 't0' in msc.ref_table.colnames
# Check that we have some matched stars... should be at least 35 stars
# that are detected in all 4 starlists.
idx = np.where(msc.ref_table['n_detect'] == 4)[0]
- assert len(idx) > 35
+ assert len(idx) >= 35, f"Expected at least 35 stars detected in all 4 starlists, but only found {len(idx)}"
# Check that the transformation error isn't too big
- assert (msc.ref_table['x0e'] < 3.0).all() # less than 1 pix
- assert (msc.ref_table['y0e'] < 3.0).all()
- assert (msc.ref_table['m0e'] < 1.0).all() # less than 0.5 mag
-
+ valid_err = np.isfinite(msc.ref_table['x0_err']) & np.isfinite(msc.ref_table['y0_err']) & np.isfinite(msc.ref_table['m0_err'])
+ assert (msc.ref_table['x0_err'][valid_err] < 3.0).all() # less than 1 pix
+ assert (msc.ref_table['y0_err'][valid_err] < 3.0).all()
+ # A star detected in only 1 epoch now correctly gets a finite m0_err
+ # from that single epoch's own 'me' (weighted average of 1 point)
+ # instead of being silently excluded via an inf from the unweighted
+ # fallback -- so its (legitimately large, single-detection) uncertainty
+ # is included here rather than skipped by the isfinite() filter above.
+ assert (msc.ref_table['m0_err'][valid_err] < 1.5).all()
+
# Check that the transformation lists aren't too wacky
for ii in range(4):
- np.testing.assert_almost_equal(msc.trans_list[ii].px.c1_0, 1.0, 2)
- np.testing.assert_almost_equal(msc.trans_list[ii].py.c0_1, 1.0, 2)
+ np.testing.assert_allclose(msc.trans_list[ii].px.c1_0, 1.0, rtol=2e-2)
+ np.testing.assert_allclose(msc.trans_list[ii].py.c0_1, 1.0, rtol=2e-2)
-
plt.clf()
plt.plot(msc.ref_table['vx'],
msc.ref_table['vy'],
'k.', color='black', alpha=0.2)
+
return
def test_MosaicToRef():
- make_fake_starlists_poly1_vel(seed=42)
-
- ref_file = 'random_vel_ref.fits'
- list_files = ['random_vel_0.fits',
- 'random_vel_1.fits',
- 'random_vel_2.fits',
- 'random_vel_3.fits']
+ make_fake_starlists_poly1(seed=42)
- ref_list = Table.read(ref_file)
+ ref_file = f'{test_data_path}/random_ref.fits'
+ list_files = [f'{test_data_path}/random_{i}.fits' for i in range(8)]
- # Convert velocities to arcsec/yr
- ref_list['vx'] *= 1e-3
- ref_list['vy'] *= 1e-3
- ref_list['vxe'] *= 1e-3
- ref_list['vye'] *= 1e-3
+ ref_list = Table.read(ref_file)
# Switch our list to a "increasing to the West" list.
ref_list['x0'] *= -1.0
- ref_list['vx'] *= -1.0
-
+
lists = [starlists.StarList.read(lf) for lf in list_files]
msc = align.MosaicToRef(ref_list, lists, iters=2,
dr_tol=[0.2, 0.1], dm_tol=[1, 0.5],
trans_class=transforms.PolyTransform,
- trans_args={'order': 2}, use_vel=True,
+ trans_args={'order': 2}, motion_models=['Empty', 'Fixed'],
update_ref_orig=False, verbose=False)
msc.fit()
@@ -252,250 +239,288 @@ def test_MosaicToRef():
assert msc.ref_table['use_in_trans'].shape == msc.ref_table['x0'].shape
assert msc.ref_table['used_in_trans'].shape == msc.ref_table['x'].shape
- # The velocities should be almost the same as the input
+ # The velocities should be almost the same as the input
# velocities since update_ref_orig == False.
- np.testing.assert_almost_equal(msc.ref_table['vx'], ref_list['vx'], 5)
- np.testing.assert_almost_equal(msc.ref_table['vy'], ref_list['vy'], 5)
-
+ np.testing.assert_allclose(msc.ref_table['x0'], ref_list['x0'], rtol=1e-5)
+ np.testing.assert_allclose(msc.ref_table['y0'], ref_list['y0'], rtol=1e-5)
##########
- # Align and let velocities be free.
+ # Align and let velocities be free.
##########
- msc.update_ref_orig = True
+ msc.update_ref_orig = 'periter'
msc.fit()
# The velocities should be almost the same (but not as close as before)
# as the input velocities since update_ref == False.
- np.testing.assert_almost_equal(msc.ref_table['vx'], ref_list['vx'], 1)
- np.testing.assert_almost_equal(msc.ref_table['vy'], ref_list['vy'], 1)
+ np.testing.assert_allclose(msc.ref_table['x0'], ref_list['x0'], rtol=1e-1)
+ np.testing.assert_allclose(msc.ref_table['y0'], ref_list['y0'], rtol=1e-1)
# Also double check that they aren't exactly the same for the reference stars.
- assert np.any(np.not_equal(msc.ref_table['vx'], ref_list['vx']))
-
- return msc
-
+ assert np.not_equal(msc.ref_table['x0'], ref_list['x0']).all()
+ assert np.not_equal(msc.ref_table['y0'], ref_list['y0']).all()
-def make_fake_starlists_shifts():
- N_stars = 200
- x = np.random.rand(N_stars) * 1000
- y = np.random.rand(N_stars) * 1000
- m = (np.random.rand(N_stars) * 8) + 9
-
- sdx = np.argsort(m)
- x = x[sdx]
- y = y[sdx]
- m = m[sdx]
-
- name = ['star_{0:03d}'.format(ii) for ii in range(N_stars)]
+ return
- # Save original positions as reference (1st) list.
- fmt = '{0:10s} {1:5.2f} 2015.0 {2:9.4f} {3:9.4f} 0 0 0 0\n'
- _out = open('random_0.lis', 'w')
- for ii in range(N_stars):
- _out.write(fmt.format(name[ii], m[ii], x[ii], y[ii]))
- _out.close()
+def test_MosaicToRef_p0_vel():
+ make_fake_starlists_poly0_vel(seed=42)
+
+ ref_file = f'{test_data_path}/random_vel_ref.fits'
+ list_files = [f'{test_data_path}/random_vel_p0_{i}.fits' for i in range(4)]
+
+ ref_list = Table.read(ref_file)
+
+ # Convert velocities to arcsec/yr
+ ref_list['vx'] *= 1e-3
+ ref_list['vy'] *= 1e-3
+ ref_list['vx_err'] *= 1e-3
+ ref_list['vy_err'] *= 1e-3
+
+ # Switch our list to a "increasing to the West" list.
+ ref_list['x0'] *= -1.0
+ ref_list['vx'] *= -1.0
+
+ lists = [starlists.StarList.read(lf) for lf in list_files]
+
+ msc = align.MosaicToRef(ref_list, lists, iters=2,
+ dr_tol=[0.2, 0.1], dm_tol=[1, 0.5],
+ outlier_tol=[None, None],
+ trans_class=transforms.PolyTransform,
+ trans_args={'order': 1}, motion_models=['Empty', 'Fixed', 'Linear'],
+ update_ref_orig=False, verbose=False)
+ msc.fit()
+
+ # Check our status columns
+ assert 'use_in_trans' in msc.ref_table.colnames
+ assert 'used_in_trans' in msc.ref_table.colnames
+ assert 'ref_orig' in msc.ref_table.colnames
+ assert msc.ref_table['use_in_trans'].shape == msc.ref_table['x0'].shape
+ assert msc.ref_table['used_in_trans'].shape == msc.ref_table['x'].shape
+ # The velocities should be almost the same as the input
+ # velocities since update_ref_orig == False.
+ assert (msc.ref_table['name']==ref_list['name']).all()
+ np.testing.assert_allclose(msc.ref_table['vx'], ref_list['vx'], rtol=1e-5)
+ np.testing.assert_allclose(msc.ref_table['vy'], ref_list['vy'], rtol=1e-5)
##########
- # Shifts
+ # Align and let velocities be free.
##########
- # Make 4 new starlists with different shifts.
- shifts = [[ 6.5, 10.1],
- [100.3, 50.5],
- [-30.0,-100.7],
- [250.0,-250.0]]
+ msc.update_ref_orig = 'periter'
+ msc.fit()
- for ss in range(len(shifts)):
- xnew = x - shifts[ss][0]
- ynew = y - shifts[ss][1]
+ # The velocities should be almost the same (but not as close as before)
+ # as the input velocities since update_ref == True.
+ assert (msc.ref_table['name']==ref_list['name']).all()
+ np.testing.assert_allclose(msc.ref_table['vx'], ref_list['vx'], rtol=1e-1, atol=3e-4)
+ np.testing.assert_allclose(msc.ref_table['vy'], ref_list['vy'], rtol=1e-1, atol=3e-4)
- # Perturb with small errors (0.1 pix)
- xnew += np.random.randn(N_stars) * 0.1
- ynew += np.random.randn(N_stars) * 0.1
+ # Also double check that they aren't exactly the same for the reference stars.
+ #assert np.any(np.not_equal(msc.ref_table['vx'], ref_list['vx']))
+ assert np.not_equal(msc.ref_table['vx'], ref_list['vx']).any()
- mnew = m + np.random.randn(N_stars) * 0.05
+ return
- _out = open('random_shift_{0:d}.lis'.format(ss+1), 'w')
- for ii in range(N_stars):
- _out.write(fmt.format(name[ii], mnew[ii], xnew[ii], ynew[ii]))
- _out.close()
+def test_MosaicToRef_vel():
+ make_fake_starlists_poly1_vel(seed=42)
- return shifts
+ ref_file = f'{test_data_path}/random_vel_ref.fits'
+ list_files = [f'{test_data_path}/random_vel_{i}.fits' for i in range(4)]
-def make_fake_starlists_poly1(seed=-1):
- # If seed >=0, then set random seed to that value
- if seed >= 0:
- np.random.seed(seed=seed)
-
- N_stars = 200
- x = np.random.rand(N_stars) * 1000
- y = np.random.rand(N_stars) * 1000
- m = (np.random.rand(N_stars) * 8) + 9
-
- sdx = np.argsort(m)
- x = x[sdx]
- y = y[sdx]
- m = m[sdx]
-
- name = ['star_{0:03d}'.format(ii) for ii in range(N_stars)]
+ ref_list = Table.read(ref_file)
- # Save original positions as reference (1st) list.
- fmt = '{0:10s} {1:5.2f} 2015.0 {2:9.4f} {3:9.4f} 0 0 0 0\n'
- _out = open('random_0.lis', 'w')
- for ii in range(N_stars):
- _out.write(fmt.format(name[ii], m[ii], x[ii], y[ii]))
- _out.close()
+ # Convert velocities to arcsec/yr
+ ref_list['vx'] *= 1e-3
+ ref_list['vy'] *= 1e-3
+ ref_list['vx_err'] *= 1e-3
+ ref_list['vy_err'] *= 1e-3
+
+ # Switch our list to a "increasing to the West" list.
+ ref_list['x0'] *= -1.0
+ ref_list['vx'] *= -1.0
+
+ lists = [starlists.StarList.read(lf) for lf in list_files]
+
+ msc = align.MosaicToRef(ref_list, lists, iters=2,
+ dr_tol=[0.2, 0.1], dm_tol=[1, 0.5],
+ outlier_tol=[None, None],
+ trans_class=transforms.PolyTransform,
+ trans_args={'order': 1}, motion_models=['Empty', 'Fixed', 'Linear'],
+ update_ref_orig=False, verbose=False)
+ msc.fit()
+
+ # Check our status columns
+ assert 'use_in_trans' in msc.ref_table.colnames
+ assert 'used_in_trans' in msc.ref_table.colnames
+ assert 'ref_orig' in msc.ref_table.colnames
+ assert msc.ref_table['use_in_trans'].shape == msc.ref_table['x0'].shape
+ assert msc.ref_table['used_in_trans'].shape == msc.ref_table['x'].shape
+ # The velocities should be almost the same as the input
+ # velocities since update_ref_orig == False.
+ assert (msc.ref_table['name']==ref_list['name']).all()
+ np.testing.assert_allclose(msc.ref_table['vx'], ref_list['vx'], rtol=1e-5)
+ np.testing.assert_allclose(msc.ref_table['vy'], ref_list['vy'], rtol=1e-5)
##########
- # Shifts
+ # Align and let velocities be free.
##########
- # Make 4 new starlists with different shifts.
- transforms = [[[ 6.5, 0.99, 1e-5], [ 10.1, 1e-5, 0.99]],
- [[100.3, 0.98, 1e-5], [ 50.5, 9e-6, 1.001]],
- [[-30.0, 1.00, 1e-5], [-100.7, 2e-5, 0.999]],
- [[250.0, 0.97, 2e-5], [-250.0, 1e-5, 1.001]]]
+ msc.update_ref_orig = 'periter'
+ msc.fit()
- for ss in range(len(shifts)):
- #transforms.PolyTransform2D(1, transforms[ss])
- xnew = x - shifts[ss][0]
- ynew = y - shifts[ss][1]
+ # The velocities should be almost the same (but not as close as before)
+ # as the input velocities since update_ref == True.
+ assert (msc.ref_table['name']==ref_list['name']).all()
+ np.testing.assert_allclose(msc.ref_table['vx'], ref_list['vx'], rtol=1e-1, atol=3e-4)
+ np.testing.assert_allclose(msc.ref_table['vy'], ref_list['vy'], rtol=1e-1, atol=3e-4)
- # Perturb with small errors (0.1 pix)
- xnew += np.random.randn(N_stars) * 0.1
- ynew += np.random.randn(N_stars) * 0.1
+ # Also double check that they aren't exactly the same for the reference stars.
+ #assert np.any(np.not_equal(msc.ref_table['vx'], ref_list['vx']))
+ assert np.not_equal(msc.ref_table['vx'], ref_list['vx']).any()
- mnew = m + np.random.randn(N_stars) * 0.05
+ return
- _out = open('random_shift_{0:d}.lis'.format(ss+1), 'w')
- for ii in range(N_stars):
- _out.write(fmt.format(name[ii], mnew[ii], xnew[ii], ynew[ii]))
- _out.close()
+def test_MosaicToRef_acc():
+ make_fake_starlists_poly1_acc(seed=42)
- return shifts
+ ref_file = f'{test_data_path}/random_acc_ref.fits'
+ list_files = [f'{test_data_path}/random_acc_{i}.fits' for i in range(8)]
+ ref_list = Table.read(ref_file)
-def make_fake_starlists_poly1_vel(seed=-1):
- # If seed >=0, then set random seed to that value
- if seed >= 0:
- np.random.seed(seed=seed)
-
- N_stars = 200
+ # Convert velocities to arcsec/yr
+ ref_list['vx0'] *= 1e-3
+ ref_list['vy0'] *= 1e-3
+ ref_list['vx0_err'] *= 1e-3
+ ref_list['vy0_err'] *= 1e-3
- x0 = np.random.rand(N_stars) * 10.0 # arcsec (increasing to East)
- y0 = np.random.rand(N_stars) * 10.0 # arcsec
- x0e = np.random.randn(N_stars) * 5.0e-4 # arcsec
- y0e = np.random.randn(N_stars) * 5.0e-4 # arcsec
- vx = np.random.randn(N_stars) * 5.0 # mas / yr
- vy = np.random.randn(N_stars) * 5.0 # mas / yr
- vxe = np.random.randn(N_stars) * 0.1 # mas / yr
- vye = np.random.randn(N_stars) * 0.1 # mas / yr
- m0 = (np.random.rand(N_stars) * 8) + 9 # mag
- m0e = np.random.randn(N_stars) * 0.05 # mag
- t0 = np.ones(N_stars) * 2019.5
+ # Convert accelerations to arcsec/yr**2
+ ref_list['ax'] *= 1e-3
+ ref_list['ay'] *= 1e-3
+ ref_list['ax_err'] *= 1e-3
+ ref_list['ay_err'] *= 1e-3
- # Make all the errors positive
- x0e = np.abs(x0e)
- y0e = np.abs(y0e)
- m0e = np.abs(m0e)
- vxe = np.abs(vxe)
- vye = np.abs(vye)
-
- name = ['star_{0:03d}'.format(ii) for ii in range(N_stars)]
+ # Switch our list to a "increasing to the West" list.
+ ref_list['x0'] *= -1.0
+ ref_list['vx0'] *= -1.0
+ ref_list['ax'] *= -1.0
- # Make an StarList
- lis = starlists.StarList([name, m0, m0e, x0, x0e, y0, y0e, vx, vxe, vy, vye, t0],
- names = ('name', 'm0', 'm0e', 'x0', 'x0e', 'y0', 'y0e',
- 'vx', 'vxe', 'vy', 'vye', 't0'))
-
- sdx = np.argsort(m0)
- lis = lis[sdx]
+ lists = [starlists.StarList.read(lf) for lf in list_files]
- # Save original positions as reference (1st) list
- # in a StarList format (with velocities).
- lis.write('random_vel_ref.fits', overwrite=True)
-
- ##########
- # Propogate to new times and distort.
- ##########
- # Make 4 new starlists with different epochs and transformations.
- times = [2018.5, 2019.5, 2020.5, 2021.5]
- xy_trans = [[[ 6.5, 0.99, 1e-5], [ 10.1, 1e-5, 0.99]],
- [[100.3, 0.98, 1e-5], [ 50.5, 9e-6, 1.001]],
- [[ 0.0, 1.00, 0.0], [ 0.0, 0.0, 1.0]],
- [[250.0, 0.97, 2e-5], [-250.0, 1e-5, 1.001]]]
- mag_trans = [0.1, 0.4, 0.0, -0.3]
+ msc = align.MosaicToRef(ref_list, lists, iters=2,
+ dr_tol=[0.4, 0.2], dm_tol=[1, 0.5],
+ trans_class=transforms.PolyTransform,
+ trans_args={'order': 2},
+ motion_models=['Acceleration'],
+ update_ref_orig=False, verbose=False)
- # Convert into pixels (undistorted) with the following info.
- scale = 0.01 # arcsec / pix
- shift = [1.0, 1.0] # pix
-
- for ss in range(len(times)):
- dt = times[ss] - lis['t0']
-
- x = lis['x0'] + (lis['vx']/1e3) * dt
- y = lis['y0'] + (lis['vy']/1e3) * dt
- t = np.ones(N_stars) * times[ss]
+ msc.fit()
- # Convert into pixels
- xp = (x / -scale) + shift[0] # -1 from switching to increasing to West (right)
- yp = (y / scale) + shift[1]
- xpe = lis['x0e'] / scale
- ype = lis['y0e'] / scale
+ # Check our status columns
+ assert 'use_in_trans' in msc.ref_table.colnames
+ assert 'used_in_trans' in msc.ref_table.colnames
+ assert 'ref_orig' in msc.ref_table.colnames
+ assert msc.ref_table['use_in_trans'].shape == msc.ref_table['x0'].shape
+ assert msc.ref_table['used_in_trans'].shape == msc.ref_table['x'].shape
- # Distort the positions
- trans = transforms.PolyTransform(1, xy_trans[ss][0], xy_trans[ss][1], mag_offset=mag_trans[ss])
- xd, yd = trans.evaluate(xp, yp)
- md = trans.evaluate_mag(lis['m0'])
+ # The velocities should be almost the same as the input
+ # velocities since update_ref_orig == False.
+ i_orig, i_fit = [],[]
+ for i,star in enumerate(ref_list["name"]):
+ if star in msc.ref_table["name"]:
+ i_fit.append(np.where(msc.ref_table["name"]==star)[0][0])
+ i_orig.append(i)
+ np.testing.assert_allclose(msc.ref_table['ax'][i_fit], ref_list['ax'][i_orig], rtol=1e-5)
+ np.testing.assert_allclose(msc.ref_table['ay'][i_fit], ref_list['ay'][i_orig], rtol=1e-5)
- # Perturb with small errors (0.1 pix)
- xd += np.random.randn(N_stars) * 0.1
- yd += np.random.randn(N_stars) * 0.1
- md += np.random.randn(N_stars) * 0.02
- xde = xpe
- yde = ype
- mde = lis['m0e']
+ ##########
+ # Align and let velocities be free.
+ ##########
+ msc.update_ref_orig = 'periter'
+ msc.fit()
- # Save the new list as a starlist.
- new_lis = starlists.StarList([lis['name'], md, mde, xd, xde, yd, yde, t],
- names=('name', 'm', 'me', 'x', 'xe', 'y', 'ye', 't'))
+ # The velocities should be almost the same (but not as close as before)
+ # as the input velocities since update_ref == False.
+ i_orig, i_fit = [],[]
+ for i,star in enumerate(ref_list["name"]):
+ if star in msc.ref_table["name"]:
+ ix_fit = np.where(msc.ref_table["name"]==star)[0][0]
+ if ~np.isnan(msc.ref_table['ax'][ix_fit]):
+ i_orig.append(i)
+ i_fit.append(ix_fit)
+ # Accelerations all too small, rtol doesn't work well here. atol is
+ # loosened slightly beyond the fit noise floor (individual ax_err/ay_err
+ # are themselves ~2-3e-4 for the most weakly-constrained stars) since
+ # correctly weighting the magnitude combination by 'me' (rather than the
+ # previous unweighted average) nudges the mag-based transform fit enough
+ # to shift the most marginal star's acceleration by a comparable amount.
+ atol = 6e-4
+ np.testing.assert_allclose(msc.ref_table['ax'][i_fit], ref_list['ax'][i_orig], atol=atol)
+ np.testing.assert_allclose(msc.ref_table['ay'][i_fit], ref_list['ay'][i_orig], atol=atol)
+
+ ax_min = np.min(ref_list['ax'][i_orig])
+ ax_max = np.max(ref_list['ax'][i_orig])
+ ay_min = np.min(ref_list['ay'][i_orig])
+ ay_max = np.max(ref_list['ay'][i_orig])
- new_lis.write('random_vel_{0:d}.fits'.format(ss), overwrite=True)
+ plt.clf()
+ fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 5))
+ ax1.plot(ref_list['ax'][i_orig], msc.ref_table['ax'][i_fit], '.')
+ ax1.plot([ax_min, ax_max], [ax_min, ax_max], color='C3')
+ ax1.plot([ax_min, ax_max], [ax_min - atol, ax_max - atol], ls='--', color='C3')
+ ax1.plot([ax_min, ax_max], [ax_min + atol, ax_max + atol], ls='--', color='C3')
+ ax1.set_xlabel('Input ax')
+ ax1.set_ylabel('Ref Table ax')
+ ax1.set_title('Acceleration in X')
+
+ ax2.plot(ref_list['ay'][i_orig], msc.ref_table['ay'][i_fit], '.')
+ ax2.plot([ay_min, ay_max], [ay_min, ay_max], color='C3')
+ ax2.plot([ay_min, ay_max], [ay_min - atol, ay_max - atol], ls='--', color='C3')
+ ax2.plot([ay_min, ay_max], [ay_min + atol, ay_max + atol], ls='--', color='C3')
+ ax2.set_xlabel('Input ay')
+ ax2.set_ylabel('Ref Table ay')
+ ax2.set_title('Acceleration in Y')
+ plt.tight_layout()
+
+ # Also double check that they aren't exactly the same for the reference stars.
+ assert np.any(np.not_equal(msc.ref_table['ax'][i_fit], ref_list['ax'][i_orig]))
+ return
- return (xy_trans, mag_trans)
-
def test_MosaicToRef_hst_me():
"""
- Test Casey's issue with 'me' not getting propogated
+ Test Casey's issue with 'me' not getting propogated
from the input starlists to the output table.
- Use data from MB10-364 microlensing target for the test.
+ Use data from MB10-364 microlensing target for the test.
"""
# Target RA and Dec (MOA data download)
- ra = '17:57:05.401'
- dec = '-34:27:05.01'
-
+ # ra = '17:57:05.401'
+ # dec = '-34:27:05.01'
+
# Load up a Gaia catalog (queried around the RA/Dec above)
- my_gaia = Table.read('mb10364_data/my_gaia.fits')
+ my_gaia = Table.read(f'{test_data_path}/mb10364_data/my_gaia.fits')
my_gaia['me'] = 0.01
-
+
+ my_gaia.rename_columns(
+ ['x0e', 'y0e', 'vxe', 'vye'],
+ ['x0_err', 'y0_err', 'vx_err', 'vy_err']
+ )
# Gather the list of starlists. For first pass, don't modify the starlists.
# Loop through the observations and read them in, in prep for alignment with Gaia
epochs = [2011.83, 2012.73, 2013.81]
- starlist_names = ['mb10364_data/2011_10_31_F606W_MATCHUP_XYMEEE_final.calib',
- 'mb10364_data/2012_09_25_F606W_MATCHUP_XYMEEE_final.calib',
- 'mb10364_data/2013_10_24_F606W_MATCHUP_XYMEEE_final.calib']
-
+ starlist_names = [f'{test_data_path}/mb10364_data/2011_10_31_F606W_MATCHUP_XYMEEE_final.calib',
+ f'{test_data_path}/mb10364_data/2012_09_25_F606W_MATCHUP_XYMEEE_final.calib',
+ f'{test_data_path}/mb10364_data/2013_10_24_F606W_MATCHUP_XYMEEE_final.calib']
+
list_of_starlists = []
-
+
# Just using the F606W filters first.
for ee in range(len(starlist_names)):
lis = starlists.StarList.from_lis_file(starlist_names[ee])
-
+
# # Add additive error term. MAYBE YOU DON'T NEED THIS
# lis['xe'] = np.hypot(lis['xe'], 0.01) # Adding 0.01 pix (0.1 mas) in quadrature.
# lis['ye'] = np.hypot(lis['ye'], 0.01)
-
+
lis['t'] = epochs[ee]
# Lets dump the faint stars.
@@ -503,40 +528,42 @@ def test_MosaicToRef_hst_me():
lis = lis[idx]
list_of_starlists.append(lis)
-
- msc = align.MosaicToRef(my_gaia, list_of_starlists, iters=1,
- dr_tol=[0.1], dm_tol=[5],
- outlier_tol=[None], mag_lim=[13, 21],
- trans_class=transforms.PolyTransform,
- trans_args=[{'order': 1}],
- use_vel=False,
- use_ref_new=False,
- update_ref_orig=False,
- mag_trans=False,
- weights='both,std',
- init_guess_mode='miracle', verbose=False)
- msc.fit()
- tab = msc.ref_table
- assert 'me' in tab.colnames
+ msc = align.MosaicToRef(
+ my_gaia, list_of_starlists, iters=1,
+ dr_tol=[0.1], dm_tol=[5],
+ outlier_tol=[None], mag_lim=[13, 21],
+ trans_class=transforms.PolyTransform,
+ trans_args=[{'order': 1}],
+ motion_models=['Empty', 'Fixed'],
+ use_ref_new=False,
+ update_ref_orig=False,
+ mag_trans=False,
+ trans_weights='both,std',
+ init_guess_mode='miracle',
+ # save_path=f'{test_data_path}/mb10364_data/test_MosaicToRef_hst_me.pkl',
+ verbose=False
+ )
+ msc.fit()
+ assert 'me' in msc.ref_table.colnames
return
def test_bootstrap():
"""
- Test to make sure calc_bootstrap_error() call is working
+ Test to make sure calc_bootstrap_error() call is working
properly (e.g., only called when user calls calc_bootstrap_error,
n_boot param for calc_bootstrap_error only, boot_epochs_min working,
etc.)
"""
# Read in starlists for MosaicToRef
- ref = Table.read('ref_vel.lis', format='ascii')
- list1 = Table.read('E.lis', format='ascii')
- list2 = Table.read('F.lis', format='ascii')
+ ref = Table.read(f'{test_data_path}/ref_vel.lis', format='ascii')
+ list1 = Table.read(f'{test_data_path}/E.lis', format='ascii')
+ list2 = Table.read(f'{test_data_path}/F.lis', format='ascii')
list1 = starlists.StarList.from_table(list1)
list2 = starlists.StarList.from_table(list2)
-
+
# Set parameters for alignment
transModel = transforms.PolyTransform
trans_args = {'order':2}
@@ -546,7 +573,7 @@ def test_bootstrap():
outlier_tol = None
mag_lim = None
ref_mag_lim = None
- weights = 'both,var'
+ trans_weights = 'both,var'
mag_trans = False
n_boot = 15
@@ -560,8 +587,8 @@ def test_bootstrap():
mag_trans=mag_trans,
mag_lim=mag_lim,
ref_mag_lim=ref_mag_lim,
- weights=weights,
- use_vel=True,
+ trans_weights=trans_weights,
+ motion_models=['Linear'],
use_ref_new=False,
update_ref_orig=False,
init_guess_mode='name',
@@ -575,13 +602,12 @@ def test_bootstrap():
assert 'vye_boot' not in match1.ref_table.keys()
# Run bootstrap: no boot_epochs_min
- match1.calc_bootstrap_errors(n_boot=n_boot, boot_epochs_min=boot_epochs_min)
-
+ match1.calc_bootstrap_errors(n_boot=n_boot, boot_epochs_min=boot_epochs_min, seed=42)
# Make sure columns exist, and none of them are nan values
assert np.sum(np.isnan(match1.ref_table['xe_boot'])) == 0
assert np.sum(np.isnan(match1.ref_table['ye_boot'])) == 0
- assert np.sum(np.isnan(match1.ref_table['vxe_boot'])) == 0
- assert np.sum(np.isnan(match1.ref_table['vye_boot'])) == 0
+ assert np.sum(np.isnan(match1.ref_table['vx_err_boot'])) == 0
+ assert np.sum(np.isnan(match1.ref_table['vy_err_boot'])) == 0
# Test 2: make sure boot_epochs_min is working
# Eliminate some rows to list2, so some stars are only in 1 epoch.
@@ -595,8 +621,8 @@ def test_bootstrap():
mag_trans=mag_trans,
mag_lim=mag_lim,
ref_mag_lim=ref_mag_lim,
- weights=weights,
- use_vel=True,
+ trans_weights=trans_weights,
+ motion_models=['Linear'],
use_ref_new=False,
update_ref_orig=False,
init_guess_mode='name',
@@ -605,7 +631,7 @@ def test_bootstrap():
# Now run_calc_bootstrap_error, with boot_epochs_min engaged
boot_epochs_min2 = 2
- match2.calc_bootstrap_errors(n_boot=n_boot, boot_epochs_min=boot_epochs_min2)
+ match2.calc_bootstrap_errors(n_boot=n_boot, boot_epochs_min=boot_epochs_min2, seed=42)
# Make sure boot_epochs_min cut worked as intended
out = match2.ref_table
@@ -618,38 +644,37 @@ def test_bootstrap():
assert len(good[0]) > 0
# For "good" stars: all bootstrap vals should be present
- assert np.sum(np.isnan(out['xe_boot'][good])) == 0
- assert np.sum(np.isnan(out['ye_boot'][good])) == 0
- assert np.sum(np.isnan(out['vxe_boot'][good])) == 0
- assert np.sum(np.isnan(out['vye_boot'][good])) == 0
+ assert np.sum(~np.isfinite(out['xe_boot'][good])) == 0
+ assert np.sum(~np.isfinite(out['ye_boot'][good])) == 0
+ assert np.sum(~np.isfinite(out['vx_err_boot'][good])) == 0
+ assert np.sum(~np.isfinite(out['vy_err_boot'][good])) == 0
# For "bad" stars, all bootstrap vals should be nans
assert np.sum(np.isfinite(out['xe_boot'][bad])) == 0
assert np.sum(np.isfinite(out['ye_boot'][bad])) == 0
- assert np.sum(np.isfinite(out['vxe_boot'][bad])) == 0
- assert np.sum(np.isfinite(out['vye_boot'][bad])) == 0
+ assert np.sum(np.isfinite(out['vx_err_boot'][bad])) == 0
+ assert np.sum(np.isfinite(out['vy_err_boot'][bad])) == 0
return
def test_calc_vel_in_bootstrap():
"""
Check calc_vel_in_bootstrap performance in calc_bootstrap_errors()
-
- Only calculate velocity bootstrap (e.g., bootstrap over epochs and
+
+ Only calculate velocity bootstrap (e.g., bootstrap over epochs and
calculating proper motions) if calc_vel_in_bootstrap=True.
"""
import copy
-
- # Define match parameters
- ref = Table.read('ref_vel.lis', format='ascii')
- list1 = Table.read('E.lis', format='ascii')
- list2 = Table.read('F.lis', format='ascii')
+ # Define match parameters
+ ref = Table.read(f'{test_data_path}/ref_vel.lis', format='ascii')
+ list1 = Table.read(f'{test_data_path}/E.lis', format='ascii')
+ list2 = Table.read(f'{test_data_path}/F.lis', format='ascii')
list1 = starlists.StarList.from_table(list1)
list2 = starlists.StarList.from_table(list2)
-
+
# Set parameters for alignment
transModel = transforms.PolyTransform
trans_args = {'order':2}
@@ -659,7 +684,7 @@ def test_calc_vel_in_bootstrap():
outlier_tol = None
mag_lim = None
ref_mag_lim = None
- weights = 'both,var'
+ trans_weights = 'both,var'
mag_trans = False
n_boot = 15
@@ -673,8 +698,8 @@ def test_calc_vel_in_bootstrap():
mag_trans=mag_trans,
mag_lim=mag_lim,
ref_mag_lim=ref_mag_lim,
- weights=weights,
- use_vel=True,
+ trans_weights=trans_weights,
+ motion_models=['Linear'],
use_ref_new=False,
update_ref_orig=False,
init_guess_mode='name',
@@ -688,36 +713,36 @@ def test_calc_vel_in_bootstrap():
# Run calc_bootstrap_error function with calc_vel_in_bootstrap=True.
# Make sure bootstrap velocity errors are calculated and valid
n_boot = 50
- match_vel.calc_bootstrap_errors(n_boot=n_boot, calc_vel_in_bootstrap=True)
+ match_vel.calc_bootstrap_errors(n_boot=n_boot, calc_vel_in_bootstrap=True, seed=42)
assert 'xe_boot' in match_vel.ref_table.keys()
assert np.sum(np.isnan(match_vel.ref_table['xe_boot'])) == 0
- assert 'vxe_boot' in match_vel.ref_table.keys()
- assert np.sum(np.isnan(match_vel.ref_table['vxe_boot'])) == 0
+ assert 'vx_err_boot' in match_vel.ref_table.keys()
+ assert np.sum(np.isnan(match_vel.ref_table['vx_err_boot'])) == 0
# Run without calc_vel_in_bootstrap, make sure velocities are NOT calculated
- match.calc_bootstrap_errors(n_boot=n_boot, calc_vel_in_bootstrap=False)
+ match.calc_bootstrap_errors(n_boot=n_boot, calc_vel_in_bootstrap=False, seed=42)
assert 'xe_boot' in match.ref_table.keys()
assert np.sum(np.isnan(match.ref_table['xe_boot'])) == 0
- assert 'vxe_boot' not in match.ref_table.keys()
-
+ assert 'vx_err_boot' not in match.ref_table.keys()
+
return
def test_transform_xym():
"""
Test to make sure transforms are being done to mags only
- if mag_trans = True. This can cause subtle bugs
+ if mag_trans = True. This can cause subtle bugs
otherwise
"""
#---Align 1: self.mag_Trans = False---#
- ref = Table.read('ref_vel.lis', format='ascii')
- list1 = Table.read('E.lis', format='ascii')
- list2 = Table.read('F.lis', format='ascii')
+ ref = Table.read(f'{test_data_path}/ref_vel.lis', format='ascii')
+ list1 = Table.read(f'{test_data_path}/E.lis', format='ascii')
+ list2 = Table.read(f'{test_data_path}/F.lis', format='ascii')
list1 = starlists.StarList.from_table(list1)
list2 = starlists.StarList.from_table(list2)
-
+
# Set parameters for alignment
transModel = transforms.PolyTransform
trans_args = {'order':2}
@@ -727,7 +752,7 @@ def test_transform_xym():
outlier_tol = None
mag_lim = None
ref_mag_lim = None
- weights = 'both,var'
+ trans_weights = 'both,var'
n_boot = 15
mag_trans = False
@@ -740,17 +765,17 @@ def test_transform_xym():
mag_trans=mag_trans,
mag_lim=mag_lim,
ref_mag_lim=ref_mag_lim,
- weights=weights,
- use_vel=False,
+ trans_weights=trans_weights,
+ motion_models=['Fixed'],
use_ref_new=False,
update_ref_orig=False,
init_guess_mode='name',
verbose=False)
match1.fit()
- match1.calc_bootstrap_errors(n_boot=n_boot)
+ match1.calc_bootstrap_errors(n_boot=n_boot, seed=42)
- # Make sure all transformations have mag_offset = 0
+ # Make sure all transformations have mag_offset = 0
trans_list = match1.trans_list
for ii in trans_list:
@@ -759,7 +784,7 @@ def test_transform_xym():
# Check that no mag transformation has been applied to m col in ref_table
tab1 = match1.ref_table
assert np.all(tab1['m'] == tab1['m_orig'])
-
+
# Check me_boost == 0 or really small (should be the case
# since we don't transform mags)
assert np.isclose(np.max(tab1['me_boot']), 0, rtol=10**-5)
@@ -775,15 +800,15 @@ def test_transform_xym():
mag_trans=mag_trans,
mag_lim=mag_lim,
ref_mag_lim=ref_mag_lim,
- weights=weights,
- use_vel=False,
+ trans_weights=trans_weights,
+ motion_models=['Fixed'],
use_ref_new=False,
update_ref_orig=False,
init_guess_mode='name',
verbose=False)
match2.fit()
- match2.calc_bootstrap_errors(n_boot=n_boot)
+ match2.calc_bootstrap_errors(n_boot=n_boot, seed=42)
# Make sure all transformations have correct mag offset
@@ -792,34 +817,34 @@ def test_transform_xym():
for ii in trans_list2:
assert ii.mag_offset > 20
- # Make sure final table mags have transform applied (i.e,
+ # Make sure final table mags have transform applied (i.e,
tab2 = match2.ref_table
assert np.all(tab2['m'] != tab2['m_orig'])
-
+
# Check me_boost > 0
assert np.min(tab2['me_boot']) > 10**-3
print('Done mag_trans = True case')
-
+
return
def test_MosaicToRef_mag_bug():
"""
Bug found by Tuan Do on 2020-04-12.
"""
- make_fake_starlists_poly1_vel()
+ make_fake_starlists_poly1_vel(seed=42)
- ref_list = starlists.StarList.from_lis_file('random_0.lis', error=False)
+ ref_list = starlists.StarList.read(f'{test_data_path}/random_vel_0.fits')
lists = [ref_list]
- msc = align.MosaicToRef(ref_list, lists,
+ msc = align.MosaicToRef(ref_list, lists,
mag_trans=True,
- iters=1,
+ iters=1,
dr_tol=[0.2], dm_tol=[1],
outlier_tol=None,
trans_class=transforms.PolyTransform,
trans_args=[{'order': 1}],
- use_vel=False,
+ motion_models=['Fixed'],
use_ref_new=False,
update_ref_orig=False,
verbose=True)
@@ -839,7 +864,7 @@ def test_MosaicToRef_mag_bug():
def test_masked_cols():
"""
Test to make sure analysis.prepare_gaia_for_flystar
- produces an astropy.table.Table, NOT a masked column
+ produces an astropy.table.Table, NOT a masked column
table. MosaicToRef cannot handle masked column tables.
Also make sure this example works, since we use it for the examples
@@ -847,25 +872,26 @@ def test_masked_cols():
"""
# Get gaia reference stars using analysis.py
# around a test location.
- target = 'ob150029'
+ # target = 'ob150029'
ra = '17:59:46.60'
dec = '-28:38:41.8'
# Coordinates are arcsecs offset +x to the East.
- targets_dict = {'ob150029': [0.0, 0.0],
- 'S11_15_3.9': [ 1.13982, 3.73524],
- 'S13_13_4.5': [-4.42878, 0.03100]
- }
+ targets_dict = {
+ 'ob150029': [0.0, 0.0],
+ 'S005': [1.1416, 3.7405],
+ 'S002': [-4.421, 0.027]
+ }
# Get gaia catalog stars. Note that this produces a masked column table
- search_rad = 10.0 # arcsec
- gaia = analysis.query_gaia(ra, dec, search_radius=search_rad)
+ search_radius = 10.0 # arcsec
+ gaia = analysis.query_gaia(ra, dec, search_radius=search_radius)
my_gaia = analysis.prepare_gaia_for_flystar(gaia, ra, dec, targets_dict=targets_dict)
assert isinstance(my_gaia, Table)
# Let's make sure the entire align runs, just to be safe
-
+
# Get starlists to align to gaia
epochs = ['15jun07','16jul14', '17may21']
@@ -873,21 +899,713 @@ def test_masked_cols():
for ee in range(len(epochs)):
lis_file = 'mag' + epochs[ee] + '_ob150029_kp_rms_named.lis'
- lis = starlists.StarList.from_lis_file(lis_file)
-
+ lis = starlists.StarList.from_lis_file(f'{test_data_path}/{lis_file}')
list_of_starlists.append(lis)
# Run the align
msc = align.MosaicToRef(my_gaia, list_of_starlists, iters=2,
dr_tol=[0.2, 0.1], dm_tol=[1, 1],
trans_class=transforms.PolyTransform,
- trans_args=[{'order': 1}, {'order': 1}],
- use_vel=True,
+ trans_args=[{'order': 1}, {'order': 1}],
+ motion_models=['Linear'],
use_ref_new=False,
- update_ref_orig=False,
+ update_ref_orig=False,
mag_trans=True,
init_guess_mode='name', verbose=True)
msc.fit()
-
return
+
+def make_fake_starlists_shifts():
+ N_stars = 200
+ x = np.random.rand(N_stars) * 1000
+ y = np.random.rand(N_stars) * 1000
+ m = (np.random.rand(N_stars) * 8) + 9
+
+ sdx = np.argsort(m)
+ x = x[sdx]
+ y = y[sdx]
+ m = m[sdx]
+
+ name = ['star_{0:03d}'.format(ii) for ii in range(N_stars)]
+
+ # Save original positions as reference (1st) list.
+ fmt = '{0:10s} {1:5.2f} 2015.0 {2:9.4f} {3:9.4f} 0 0 0 0\n'
+ _out = open(f'{test_data_path}/random_0.lis', 'w')
+ for ii in range(N_stars):
+ _out.write(fmt.format(name[ii], m[ii], x[ii], y[ii]))
+ _out.close()
+
+
+ ##########
+ # Shifts
+ ##########
+ # Make 4 new starlists with different shifts.
+ shifts = [[ 6.5, 10.1],
+ [100.3, 50.5],
+ [-30.0,-100.7],
+ [250.0,-250.0]]
+
+ for ss in range(len(shifts)):
+ xnew = x - shifts[ss][0]
+ ynew = y - shifts[ss][1]
+
+ # Perturb with small errors (0.1 pix)
+ xnew += np.random.randn(N_stars) * 0.1
+ ynew += np.random.randn(N_stars) * 0.1
+
+ mnew = m + np.random.randn(N_stars) * 0.05
+
+ _out = open(f'{test_data_path}/random_shift_{ss+1}.lis', 'w')
+ for ii in range(N_stars):
+ _out.write(fmt.format(name[ii], mnew[ii], xnew[ii], ynew[ii]))
+ _out.close()
+
+ return shifts
+
+def make_fake_starlists_poly1(seed=-1):
+ # If seed >=0, then set random seed to that value
+ if seed >= 0:
+ np.random.seed(seed=seed)
+
+ N_stars = 200
+
+ x0 = np.random.rand(N_stars) * 10.0 # arcsec (increasing to East)
+ y0 = np.random.rand(N_stars) * 10.0 # arcsec
+ x0e = np.random.randn(N_stars) * 5.0e-4 # arcsec
+ y0e = np.random.randn(N_stars) * 5.0e-4 # arcsec
+ m0 = (np.random.rand(N_stars) * 8) + 9 # mag
+ m0e = np.random.randn(N_stars) * 0.05 # mag
+ t0 = np.ones(N_stars) * 2019.5
+
+ # Make all the errors positive
+ x0e = np.abs(x0e)
+ y0e = np.abs(y0e)
+ m0e = np.abs(m0e)
+
+ name = ['star_{0:03d}'.format(ii) for ii in range(N_stars)]
+
+ # Make an StarList
+ lis = starlists.StarList([name, m0, m0e, x0, x0e, y0, y0e, t0],
+ names = ('name', 'm0', 'm0_err', 'x0', 'x0_err', 'y0', 'y0_err', 't0'))
+
+ sdx = np.argsort(m0)
+ lis = lis[sdx]
+
+ # Save original positions as reference (1st) list
+ # in a StarList format (with velocities).
+ lis.write(f'{test_data_path}/random_ref.fits', overwrite=True)
+
+ ##########
+ # Shifts
+ ##########
+ # Make 4 new starlists with different shifts.
+ times = [2018.5, 2019.0, 2019.5, 2020.0, 2020.5, 2021.0, 2021.5, 2022.0]
+ xy_trans = [[[ 6.5, 0.99, 1e-5], [ 10.1, 1e-5, 0.99]],
+ [[100.3, 0.98, 1e-5], [ 50.5, 9e-6, 1.001]],
+ [[ 0.0, 1.00, 0.0], [ 0.0, 0.0, 1.0]],
+ [[250.0, 0.97, 2e-5], [-250.0, 1e-5, 1.001]],
+ [[ 50.0, 1.01, 1e-5], [ -31.0, 1e-5, 1.000]],
+ [[ 78.0, 0.98, 0.0 ], [ 45.0, 9e-6, 1.001]],
+ [[-13.0, 0.99, 1e-5], [ 150, 2e-5, 1.002]],
+ [[ 94.0, 1.00, 9e-6], [-182.0, 0.0, 0.99]]]
+ mag_trans = [0.1, 0.4, 0.0, -0.3, 0.2, 0.0, -0.1, -0.3]
+
+ # Convert into pixels (undistorted) with the following info.
+ scale = 0.01 # arcsec / pix
+ shift = [1.0, 1.0] # pix
+
+ for ss in range(len(times)):
+ dt = times[ss] - lis['t0']
+
+ x = lis['x0']
+ y = lis['y0']
+ t = np.ones(N_stars) * times[ss]
+
+ # Convert into pixels
+ xp = (x / -scale) + shift[0] # -1 from switching to increasing to West (right)
+ yp = (y / scale) + shift[1]
+ xpe = lis['x0_err'] / scale
+ ype = lis['y0_err'] / scale
+
+ # Distort the positions
+ trans = transforms.PolyTransform(1, xy_trans[ss][0], xy_trans[ss][1], mag_offset=mag_trans[ss])
+ xd, yd = trans.evaluate(xp, yp)
+ md = trans.evaluate_mag(lis['m0'])
+
+ # Perturb with small errors (0.1 pix)
+ xd += np.random.randn(N_stars) * 0.1
+ yd += np.random.randn(N_stars) * 0.1
+ md += np.random.randn(N_stars) * 0.02
+ xde = xpe
+ yde = ype
+ mde = lis['m0_err']
+
+ # fig, ax = plt.subplots()
+ # ax.scatter(x0, y0, s=2, label='Reference')
+ # ax.scatter(xd, yd, s=2, label='Starlist')
+ # ax.set_xlabel('X (pix)')
+ # ax.set_ylabel('Y (pix)')
+ # ax.legend()
+ # plt.show()
+
+ # Save the new list as a starlist.
+ new_lis = starlists.StarList([lis['name'], md, mde, xd, xde, yd, yde, t],
+ names=('name', 'm', 'me', 'x', 'xe', 'y', 'ye', 't'))
+
+ new_lis.write(f'{test_data_path}/random_{ss}.fits', overwrite=True)
+
+ return (xy_trans,mag_trans)
+
+def make_fake_starlists_poly0_vel(seed=-1):
+ # If seed >=0, then set random seed to that value
+ if seed >= 0:
+ np.random.seed(seed=seed)
+
+ N_stars = 200
+
+ x0 = np.random.rand(N_stars) * 10.0 # arcsec (increasing to East)
+ y0 = np.random.rand(N_stars) * 10.0 # arcsec
+ x0e = np.ones(N_stars) * 1.0e-4 # arcsec
+ y0e = np.ones(N_stars) * 1.0e-4 # arcsec
+ vx = np.random.randn(N_stars) * 5.0 # mas / yr
+ vy = np.random.randn(N_stars) * 5.0 # mas / yr
+ vxe = np.ones(N_stars) * 0.05 # mas / yr
+ vye = np.ones(N_stars) * 0.05 # mas / yr
+ m0 = (np.random.rand(N_stars) * 8) + 9 # mag
+ m0e = np.random.randn(N_stars) * 0.05 # mag
+ t0 = np.ones(N_stars) * 2019.5
+
+ # Make all the errors positive
+ x0e = np.abs(x0e)
+ y0e = np.abs(y0e)
+ m0e = np.abs(m0e)
+ vxe = np.abs(vxe)
+ vye = np.abs(vye)
+
+ name = [f'star_{ii:03d}' for ii in range(N_stars)]
+
+ # Make an StarList
+ lis = starlists.StarList([name, m0, m0e, x0, x0e, y0, y0e, vx, vxe, vy, vye, t0],
+ names = ('name', 'm0', 'm0_err', 'x0', 'x0_err', 'y0', 'y0_err',
+ 'vx', 'vx_err', 'vy', 'vy_err', 't0'))
+
+ sdx = np.argsort(m0)
+ lis = lis[sdx]
+
+ # Save original positions as reference (1st) list
+ # in a StarList format (with velocities).
+ lis.write(f'{test_data_path}/random_vel_ref.fits', overwrite=True)
+
+ ##########
+ # Propogate to new times and distort.
+ ##########
+ # Make 4 new starlists with different epochs and transformations.
+ times = [2018.5, 2019.0, 2019.5, 2020.0, 2020.5, 2021.0, 2021.5, 2022.0]
+ xy_trans = [[[ 6.5], [ 10.1]],
+ [[100.3], [ 50.5]],
+ [[ 0.0], [ 0.0]],
+ [[250.0], [-250.0]],
+ [[ 50.0], [ -31.0]],
+ [[ 78.0], [ 45.0]],
+ [[-13.0], [ 150]],
+ [[ 94.0], [-182.0]]]
+ mag_trans = [0.1, 0.4, 0.0, -0.3, 0.2, 0.0, -0.1, -0.3]
+
+ # Convert into pixels (undistorted) with the following info.
+ scale = 0.01 # arcsec / pix
+ shift = [1.0, 1.0] # pix
+
+ for ss in range(len(times)):
+ dt = times[ss] - lis['t0']
+
+ x = lis['x0'] + (lis['vx']/1e3) * dt
+ y = lis['y0'] + (lis['vy']/1e3) * dt
+ t = np.ones(N_stars) * times[ss]
+
+ # Convert into pixels
+ xp = (x / -scale) + shift[0] # -1 from switching to increasing to West (right)
+ yp = (y / scale) + shift[1]
+ xpe = lis['x0_err'] / scale
+ ype = lis['y0_err'] / scale
+
+ # Distort the positions
+ trans = transforms.PolyTransform(0, xy_trans[ss][0], xy_trans[ss][1], mag_offset=mag_trans[ss])
+ xd, yd = trans.evaluate(xp, yp)
+ md = trans.evaluate_mag(lis['m0'])
+
+ # Perturb with small errors (0.1 pix)
+ xd += np.random.randn(N_stars) * xpe
+ yd += np.random.randn(N_stars) * ype
+ md += np.random.randn(N_stars) * 0.02
+ xde = xpe
+ yde = ype
+ mde = lis['m0_err']
+
+ # Save the new list as a starlist.
+ new_lis = starlists.StarList([lis['name'], md, mde, xd, xde, yd, yde, t],
+ names=('name', 'm', 'me', 'x', 'xe', 'y', 'ye', 't'))
+
+ new_lis.write(f'{test_data_path}/random_vel_p0_{ss}.fits', overwrite=True)
+
+ return (xy_trans, mag_trans)
+
+
+def make_fake_starlists_poly1_vel(seed=-1):
+ # If seed >=0, then set random seed to that value
+ if seed >= 0:
+ np.random.seed(seed=seed)
+
+ N_stars = 200
+
+ x0 = np.random.rand(N_stars) * 10.0 # arcsec (increasing to East)
+ y0 = np.random.rand(N_stars) * 10.0 # arcsec
+ x0e = np.ones(N_stars) * 1.0e-4 # arcsec
+ y0e = np.ones(N_stars) * 1.0e-4 # arcsec
+ vx = np.random.randn(N_stars) * 5.0 # mas / yr
+ vy = np.random.randn(N_stars) * 5.0 # mas / yr
+ vxe = np.ones(N_stars) * 0.05 # mas / yr
+ vye = np.ones(N_stars) * 0.05 # mas / yr
+ m0 = (np.random.rand(N_stars) * 8) + 9 # mag
+ m0e = np.random.randn(N_stars) * 0.05 # mag
+ t0 = np.ones(N_stars) * 2019.5
+
+ # Make all the errors positive
+ x0e = np.abs(x0e)
+ y0e = np.abs(y0e)
+ m0e = np.abs(m0e)
+ vxe = np.abs(vxe)
+ vye = np.abs(vye)
+
+ name = [f'star_{ii:03d}' for ii in range(N_stars)]
+
+ # Make an StarList
+ lis = starlists.StarList([name, m0, m0e, x0, x0e, y0, y0e, vx, vxe, vy, vye, t0],
+ names = ('name', 'm0', 'm0_err', 'x0', 'x0_err', 'y0', 'y0_err',
+ 'vx', 'vx_err', 'vy', 'vy_err', 't0'))
+
+ sdx = np.argsort(m0)
+ lis = lis[sdx]
+
+ # Save original positions as reference (1st) list
+ # in a StarList format (with velocities).
+ lis.write(f'{test_data_path}/random_vel_ref.fits', overwrite=True)
+
+ ##########
+ # Propogate to new times and distort.
+ ##########
+ # Make 4 new starlists with different epochs and transformations.
+ times = [2018.5, 2019.0, 2019.5, 2020.0, 2020.5, 2021.0, 2021.5, 2022.0]
+ xy_trans = [[[ 6.5, 0.99, 1e-5], [ 10.1, 1e-5, 0.99]],
+ [[100.3, 0.98, 1e-5], [ 50.5, 9e-6, 1.001]],
+ [[ 0.0, 1.00, 0.0], [ 0.0, 0.0, 1.000]],
+ [[250.0, 1.01, 2e-5], [-250.0, 1e-5, 0.98]],
+ [[ 50.0, 1.01, 1e-5], [ -31.0, 1e-5, 1.000]],
+ [[ 78.0, 0.98, 0.0 ], [ 45.0, 9e-6, 1.001]],
+ [[-13.0, 0.99, 1e-5], [ 150, 2e-5, 1.002]],
+ [[ 94.0, 1.00, 9e-6], [-182.0, 0.0, 0.99]]]
+ mag_trans = [0.1, 0.4, 0.0, -0.3, 0.2, 0.0, -0.1, -0.3]
+
+ # Convert into pixels (undistorted) with the following info.
+ scale = 0.01 # arcsec / pix
+ shift = [1.0, 1.0] # pix
+
+ for ss in range(len(times)):
+ dt = times[ss] - lis['t0']
+
+ x = lis['x0'] + (lis['vx']/1e3) * dt
+ y = lis['y0'] + (lis['vy']/1e3) * dt
+ t = np.ones(N_stars) * times[ss]
+
+ # Convert into pixels
+ xp = (x / -scale) + shift[0] # -1 from switching to increasing to West (right)
+ yp = (y / scale) + shift[1]
+ xpe = lis['x0_err'] / scale
+ ype = lis['y0_err'] / scale
+
+ # Distort the positions
+ trans = transforms.PolyTransform(1, xy_trans[ss][0], xy_trans[ss][1], mag_offset=mag_trans[ss])
+ xd, yd = trans.evaluate(xp, yp)
+ md = trans.evaluate_mag(lis['m0'])
+
+ # Perturb with small errors (0.1 mas)
+ xd += np.random.randn(N_stars) * xpe
+ yd += np.random.randn(N_stars) * ype
+ md += np.random.randn(N_stars) * 0.02
+ xde = xpe
+ yde = ype
+ mde = lis['m0_err']
+
+ # Save the new list as a starlist.
+ new_lis = starlists.StarList([lis['name'], md, mde, xd, xde, yd, yde, t],
+ names=('name', 'm', 'me', 'x', 'xe', 'y', 'ye', 't'))
+
+ new_lis.write(f'{test_data_path}/random_vel_{ss}.fits', overwrite=True)
+
+ return (xy_trans, mag_trans)
+
+def make_fake_starlists_poly1_acc(seed=-1):
+ # If seed >=0, then set random seed to that value
+ if seed >= 0:
+ np.random.seed(seed=seed)
+
+ N_stars = 200
+
+ x0 = np.random.rand(N_stars) * 10.0 # arcsec (increasing to East)
+ y0 = np.random.rand(N_stars) * 10.0 # arcsec
+ x0e = np.ones(N_stars) * 1.0e-4 # arcsec
+ y0e = np.ones(N_stars) * 1.0e-4 # arcsec
+ vx = np.random.randn(N_stars) * 5.0 # mas / yr
+ vy = np.random.randn(N_stars) * 5.0 # mas / yr
+ vxe = np.ones(N_stars) * 0.1 # mas / yr
+ vye = np.ones(N_stars) * 0.1 # mas / yr
+ ax = np.random.randn(N_stars) * 0.5 # mas / yr^2
+ ay = np.random.randn(N_stars) * 0.5 # mas / yr^2
+ axe = np.ones(N_stars) * 0.01 # mas / yr^2
+ aye = np.ones(N_stars) * 0.01 # mas / yr^2
+ m0 = (np.random.rand(N_stars) * 8) + 9 # mag
+ m0e = np.random.randn(N_stars) * 0.05 # mag
+ t0 = np.ones(N_stars) * 2019.5
+
+ # Make all the errors positive
+ x0e = np.abs(x0e)
+ y0e = np.abs(y0e)
+ m0e = np.abs(m0e)
+ vxe = np.abs(vxe)
+ vye = np.abs(vye)
+ axe = np.abs(axe)
+ aye = np.abs(aye)
+
+ name = ['star_{0:03d}'.format(ii) for ii in range(N_stars)]
+
+ # Make an StarList
+ lis = starlists.StarList([name, m0, m0e,
+ x0, x0e, y0, y0e,
+ vx, vxe, vy, vye,
+ ax, axe, ay, aye,
+ t0],
+ names = ('name', 'm0', 'm0_err',
+ 'x0', 'x0_err', 'y0', 'y0_err',
+ 'vx0', 'vx0_err', 'vy0', 'vy0_err',
+ 'ax', 'ax_err', 'ay', 'ay_err',
+ 't0'))
+
+ sdx = np.argsort(m0)
+ lis = lis[sdx]
+
+ # Save original positions as reference (1st) list
+ # in a StarList format (with velocities).
+ lis.write(f'{test_data_path}/random_acc_ref.fits', overwrite=True)
+
+ ##########
+ # Propogate to new times and distort.
+ ##########
+ # Make 4 new starlists with different epochs and transformations.
+ times = [2018.5, 2019.0, 2019.5, 2020.0, 2020.5, 2021.0, 2021.5, 2022.0]
+ xy_trans = [[[ 6.5, 0.99, 1e-5], [ 10.1, 1e-5, 0.99]],
+ [[100.3, 0.98, 1e-5], [ 50.5, 9e-6, 1.001]],
+ [[ 0.0, 1.00, 0.0], [ 0.0, 0.0, 1.000]],
+ [[250.0, 0.97, 2e-5], [-250.0, 1e-5, 1.001]],
+ [[ 50.0, 1.01, 1e-5], [ -31.0, 1e-5, 1.000]],
+ [[ 78.0, 0.98, 0.0 ], [ 45.0, 9e-6, 1.001]],
+ [[-13.0, 0.99, 1e-5], [ 150, 2e-5, 1.002]],
+ [[ 94.0, 1.00, 9e-6], [-182.0, 0.0, 0.99]]]
+ mag_trans = [0.1, 0.4, 0.0, -0.3, 0.2, 0.0, -0.1, -0.3]
+
+ # Convert into pixels (undistorted) with the following info.
+ scale = 0.01 # arcsec / pix
+ shift = [1.0, 1.0] # pix
+
+ for ss in range(len(times)):
+ dt = times[ss] - lis['t0']
+
+ x = lis['x0'] + (lis['vx0']/1e3) * dt + 0.5*(lis['ax']/1e3) * dt**2
+ y = lis['y0'] + (lis['vy0']/1e3) * dt + 0.5*(lis['ay']/1e3) * dt**2
+ t = np.ones(N_stars) * times[ss]
+
+ # Convert into pixels
+ xp = (x / -scale) + shift[0] # -1 from switching to increasing to West (right)
+ yp = (y / scale) + shift[1]
+ xpe = lis['x0_err'] / scale
+ ype = lis['y0_err'] / scale
+
+ # Distort the positions
+ trans = transforms.PolyTransform(1, xy_trans[ss][0], xy_trans[ss][1], mag_offset=mag_trans[ss])
+ xd, yd = trans.evaluate(xp, yp)
+ md = trans.evaluate_mag(lis['m0'])
+
+ # Perturb with small errors (0.1 pix)
+ xd += np.random.randn(N_stars) * xpe
+ yd += np.random.randn(N_stars) * ype
+ md += np.random.randn(N_stars) * 0.02
+ xde = xpe
+ yde = ype
+ mde = lis['m0_err']
+
+ # Save the new list as a starlist.
+ new_lis = starlists.StarList([lis['name'], md, mde, xd, xde, yd, yde, t],
+ names=('name', 'm', 'me', 'x', 'xe', 'y', 'ye', 't'))
+
+ new_lis.write(f'{test_data_path}/random_acc_{ss}.fits', overwrite=True)
+
+ return (xy_trans, mag_trans)
+
+def make_fake_starlists_poly1_par(seed=-1):
+ # If seed >=0, then set random seed to that value
+ if seed >= 0:
+ np.random.seed(seed=seed)
+
+ N_stars = 200
+
+ x0 = np.random.rand(N_stars) * 10.0 # arcsec (increasing to East)
+ y0 = np.random.rand(N_stars) * 10.0 # arcsec
+ x0e = np.random.randn(N_stars) * 5.0e-4 # arcsec
+ y0e = np.random.randn(N_stars) * 5.0e-4 # arcsec
+ vx = np.random.randn(N_stars) * 5.0 # mas / yr
+ vy = np.random.randn(N_stars) * 5.0 # mas / yr
+ vxe = np.random.randn(N_stars) * 0.1 # mas / yr
+ vye = np.random.randn(N_stars) * 0.1 # mas / yr
+ pi = np.random.randn(N_stars) * 0.5 # mas
+ pie = np.random.randn(N_stars) * 0.01 # mas
+ m0 = (np.random.rand(N_stars) * 8) + 9 # mag
+ m0e = np.random.randn(N_stars) * 0.05 # mag
+ t0 = np.ones(N_stars) * 2019.5
+
+ # Make all the errors positive
+ x0e = np.abs(x0e)
+ y0e = np.abs(y0e)
+ m0e = np.abs(m0e)
+ vxe = np.abs(vxe)
+ vye = np.abs(vye)
+ pie = np.abs(pie)
+
+ name = ['star_{0:03d}'.format(ii) for ii in range(N_stars)]
+
+ # Make an StarList
+ lis = starlists.StarList([name, m0, m0e,
+ x0, x0e, y0, y0e,
+ vx, vxe, vy, vye,
+ pi, pie,
+ t0],
+ names = ('name', 'm0', 'm0_err',
+ 'x0', 'x0_err', 'y0', 'y0_err',
+ 'vx', 'vx_err', 'vy', 'vy_err',
+ 'pi', 'pi_err',
+ 't0'))
+
+ sdx = np.argsort(m0)
+ lis = lis[sdx]
+
+ # Save original positions as reference (1st) list
+ # in a StarList format (with velocities).
+ lis.write(f'{test_data_path}/random_par_ref.fits', overwrite=True)
+
+ ##########
+ # Propogate to new times and distort.
+ ##########
+ # Make 4 new starlists with different epochs and transformations.
+ '''times = [2018.5, 2019.5, 2020.5, 2021.5]
+ xy_trans = [[[ 6.5, 0.99, 1e-5], [ 10.1, 1e-5, 0.99]],
+ [[100.3, 0.98, 1e-5], [ 50.5, 9e-6, 1.001]],
+ [[ 0.0, 1.00, 0.0], [ 0.0, 0.0, 1.0]],
+ [[250.0, 0.97, 2e-5], [-250.0, 1e-5, 1.001]]]
+ mag_trans = [0.1, 0.4, 0.0, -0.3]'''
+
+ times = [2018.5, 2019.0, 2019.5, 2020.0, 2020.5, 2021.0, 2021.5, 2022.0]
+ xy_trans = [[[ 6.5, 0.99, 1e-5], [ 10.1, 1e-5, 0.99]],
+ [[100.3, 0.98, 1e-5], [ 50.5, 9e-6, 1.001]],
+ [[ 0.0, 1.00, 0.0], [ 0.0, 0.0, 1.0]],
+ [[250.0, 0.97, 2e-5], [-250.0, 1e-5, 1.001]],
+ [[ 50.0, 1.00, 0.0], [ -31.0, 0.0, 1.000]],
+ [[ 78.0, 1.00, 0.0 ], [ 45.0, 0.0, 1.00]],
+ [[-13.0, 1.00, 0.0], [ 150, 0.0, 1.00]],
+ [[ 94.0, 1.00, 0.0], [-182.0, 0.0, 1.00]]]
+ mag_trans = [0.1, 0.4, 0.0, -0.3, 0.0, 0.0, 0.0, 0.0]
+
+ # Convert into pixels (undistorted) with the following info.
+ scale = 0.01 # arcsec / pix
+ shift = [1.0, 1.0] # pix
+
+ for ss in range(len(times)):
+ dt = times[ss] - lis['t0']
+
+ par_mod = motion_model.Parallax(pa=0,ra=18.0, dec=-30.0)
+ par_mod_dat = par_mod.get_batch_pos_at_time(dt+lis['t0'], x0=lis['x0'],vx=lis['vx']/1e3, pi=lis['pi'],
+ y0=lis['y0'], vy=lis['vy']/1e3, t0=lis['t0'])
+ x,y = par_mod_dat[0], par_mod_dat[1]
+ t = np.ones(N_stars) * times[ss]
+
+ # Convert into pixels
+ xp = (x / -scale) + shift[0] # -1 from switching to increasing to West (right)
+ yp = (y / scale) + shift[1]
+ xpe = lis['x0_err'] / scale
+ ype = lis['y0_err'] / scale
+
+ # Distort the positions
+ trans = transforms.PolyTransform(1, xy_trans[ss][0], xy_trans[ss][1], mag_offset=mag_trans[ss])
+ xd, yd = trans.evaluate(xp, yp)
+ md = trans.evaluate_mag(lis['m0'])
+
+ # Perturb with small errors (0.1 pix)
+ xd += np.random.randn(N_stars) * 0.1
+ yd += np.random.randn(N_stars) * 0.1
+ md += np.random.randn(N_stars) * 0.02
+ xde = xpe
+ yde = ype
+ mde = lis['m0_err']
+
+ # Save the new list as a starlist.
+ new_lis = starlists.StarList([lis['name'], md, mde, xd, xde, yd, yde, t],
+ names=('name', 'm', 'me', 'x', 'xe', 'y', 'ye', 't'))
+
+ new_lis.write(f'{test_data_path}/random_par_{ss}.fits', overwrite=True)
+
+ return (xy_trans, mag_trans)
+
+
+def _bruteforce_determine_motion_models(startable, motion_models, fixed_params_dict, verbose=False):
+ """
+ Reference implementation of align.determine_motion_models(), kept here only
+ as ground truth for test_determine_motion_models_vectorized: a plain,
+ unambiguous per-star Python loop (the same algorithm the vectorized version
+ in align.py replaced, for performance, with whole-column numpy ops).
+ """
+ if all(isinstance(mm, str) for mm in motion_models):
+ mm_map = motion_model.motion_model_map()
+ motion_models = [mm_map[mm] for mm in motion_models]
+
+ motion_models_possible = []
+ for mm in motion_models:
+ required_columns = mm.fit_param_names + mm.fixed_param_names
+ req_col_in_table = [col for col in required_columns if (col in startable.colnames)]
+ req_col_in_dict = [col for col in required_columns if (col in fixed_params_dict.keys())]
+ req_cols = startable[req_col_in_table]
+ if all((col in startable.colnames) or (col in fixed_params_dict.keys()) for col in required_columns):
+ motion_models_possible.append((mm, req_col_in_table, req_cols, req_col_in_dict))
+
+ motion_model_used = []
+ n_params = []
+ for k in range(len(startable)):
+ for mm, req_col_in_table, req_cols, req_col_in_dict in motion_models_possible[::-1]:
+ if all(np.isfinite(req_cols[col][k]) for col in req_col_in_table if np.issubdtype(req_cols[col].dtype, np.number)) \
+ and all(np.isfinite(fixed_params_dict[col]) for col in req_col_in_dict if np.issubdtype(np.array(fixed_params_dict[col]).dtype, np.number)):
+ motion_model_used.append(mm.name)
+ n_params.append(mm.n_params)
+ break
+
+ return motion_model_used, n_params
+
+
+def test_determine_motion_models_vectorized():
+ """
+ align.determine_motion_models() was rewritten to use whole-column numpy
+ operations instead of a Python loop over every star (a major bottleneck
+ for large mosaics). Check the vectorized version against a brute-force
+ per-star reference on a table that exercises: an always-finite fallback
+ model (Empty), a model needing table columns to be finite (Fixed), and a
+ model needing both table columns and a fixed_params_dict entry to be
+ finite (Linear, gated on 't0').
+ """
+ rng = np.random.default_rng(42)
+ n_stars = 200
+
+ x0 = rng.uniform(-10, 10, n_stars)
+ y0 = rng.uniform(-10, 10, n_stars)
+ vx = rng.uniform(-1, 1, n_stars)
+ vy = rng.uniform(-1, 1, n_stars)
+
+ # Sprinkle in some non-finite values so all three models get exercised.
+ x0[::7] = np.nan # these rows can only ever be 'Empty'
+ vx[::5] = np.inf # these rows (minus the ones above) can only be 'Fixed'
+ vy[1::11] = np.nan
+
+ table = Table({'x0': x0, 'y0': y0, 'vx': vx, 'vy': vy})
+
+ for fixed_params_dict in [{'t0': 2020.0}, {'t0': np.inf}, {}]:
+ motion_models = ['Empty', 'Fixed', 'Linear']
+
+ got_used, got_n = align.determine_motion_models(
+ table, motion_models=motion_models, fixed_params_dict=dict(fixed_params_dict), verbose=False
+ )
+ want_used, want_n = _bruteforce_determine_motion_models(
+ table, motion_models=motion_models, fixed_params_dict=dict(fixed_params_dict), verbose=False
+ )
+
+ assert got_used == want_used
+ assert got_n == want_n
+ # Sanity check: with fixed_params_dict containing a finite t0, at least
+ # some stars should have resolved to each of the three models.
+ if fixed_params_dict.get('t0') == 2020.0:
+ assert set(got_used) == {'Empty', 'Fixed', 'Linear'}
+
+
+def test_update_old_and_new_names():
+ """
+ align.update_old_and_new_names() used to find the max existing name length
+ by looping over every row in the reference table. It now reads the length
+ straight off the fixed-width numpy dtype. Check both the "no widening
+ needed" and "widening needed" branches against the original per-row logic.
+ """
+ n_old = 50
+ old_names = np.array([f'{i:03d}_star' for i in range(n_old)]) # 8 chars each
+ name_in_list = np.array([f'star_{i}' for i in range(n_old)]).reshape(-1, 1) # 6-7 chars
+
+ ref_table = Table({'name': old_names, 'name_in_list': name_in_list})
+ idx_ref_new = np.array([5, 12, 30])
+ list_index = 0
+
+ def _bruteforce_update_old_and_new_names(ref_table, list_index, idx_ref_new):
+ new_names = [f"{list_index:3d}_{name}" for name in ref_table['name_in_list'][idx_ref_new, list_index]]
+ new_name_len_max = np.max([len(new_name) for new_name in new_names])
+ old_names = ref_table['name']
+ old_name_len = [len(old_name) for old_name in old_names]
+ old_name_len_max = np.max(old_name_len)
+ if new_name_len_max > old_name_len_max:
+ all_names = old_names.astype('U{0:d}'.format(new_name_len_max))
+ else:
+ all_names = old_names
+ all_names[idx_ref_new] = new_names
+ return all_names
+
+ # Case 1: new names are no longer than existing ones -- no widening needed.
+ got = align.update_old_and_new_names(ref_table.copy(), list_index, idx_ref_new)
+ want = _bruteforce_update_old_and_new_names(ref_table.copy(), list_index, idx_ref_new)
+ assert list(got) == list(want)
+
+ # Case 2: new names are longer than any existing name -- dtype must widen.
+ # Widen name_in_list's dtype explicitly first -- assigning a longer string
+ # into a narrower fixed-width numpy array would silently truncate it.
+ ref_table2 = ref_table.copy()
+ wide_name_in_list = ref_table2['name_in_list'].astype('U40')
+ wide_name_in_list[idx_ref_new[0], 0] = 'a_much_much_longer_star_name'
+ ref_table2.replace_column('name_in_list', wide_name_in_list)
+ got2 = align.update_old_and_new_names(ref_table2.copy(), list_index, idx_ref_new)
+ want2 = _bruteforce_update_old_and_new_names(ref_table2.copy(), list_index, idx_ref_new)
+ assert list(got2) == list(want2)
+
+
+if __name__ == '__main__':
+ import pickle
+ with open(f'{test_data_path}/my_gaia.pkl', 'rb') as f:
+ my_gaia = pickle.load(f)
+ with open(f'{test_data_path}/list_of_starlists.pkl', 'rb') as f:
+ list_of_starlists = pickle.load(f)
+ ra_deg, dec_deg = 18.0, -30.0
+ my_gaia.remove_column('motion_model_used')
+ msc = align.MosaicToRef(my_gaia, list_of_starlists, iters=3,
+ dr_tol=[0.2, 0.1, 0.08], dm_tol=[5,5,5],
+ outlier_tol=[None, None, 3], mag_lim=[6, 20],
+ trans_class=transforms.PolyTransform,
+ trans_args=[{'order': 1}, {'order': 1}, {'order': 1}],
+ motion_models=['Linear','Parallax'],
+ fixed_params_dict = {'ra':ra_deg, 'dec':dec_deg, 'pa':0.0, 'obsLocation':'earth'},
+ use_ref_new=True,
+ update_ref_orig=False,
+ mag_trans=True,
+ trans_weights='both,std',
+ init_guess_mode='name', verbose=3)
+ msc.fit()
+ for i in range(msc.ref_table['x'].shape[1]):
+ plt.scatter(msc.ref_table['x'][:, i], msc.ref_table['y'][:, i])
+ plt.show()
+ plot_stars(msc.ref_table, msc.ref_table['name'][:3])
\ No newline at end of file
diff --git a/flystar/tests/A.lis b/flystar/tests/test_data/A.lis
similarity index 100%
rename from flystar/tests/A.lis
rename to flystar/tests/test_data/A.lis
diff --git a/flystar/tests/B.lis b/flystar/tests/test_data/B.lis
similarity index 100%
rename from flystar/tests/B.lis
rename to flystar/tests/test_data/B.lis
diff --git a/flystar/tests/C.lis b/flystar/tests/test_data/C.lis
similarity index 100%
rename from flystar/tests/C.lis
rename to flystar/tests/test_data/C.lis
diff --git a/flystar/tests/D.lis b/flystar/tests/test_data/D.lis
similarity index 100%
rename from flystar/tests/D.lis
rename to flystar/tests/test_data/D.lis
diff --git a/flystar/tests/E.lis b/flystar/tests/test_data/E.lis
similarity index 100%
rename from flystar/tests/E.lis
rename to flystar/tests/test_data/E.lis
diff --git a/flystar/tests/F.lis b/flystar/tests/test_data/F.lis
similarity index 100%
rename from flystar/tests/F.lis
rename to flystar/tests/test_data/F.lis
diff --git a/flystar/tests/coveragerc b/flystar/tests/test_data/coveragerc
similarity index 100%
rename from flystar/tests/coveragerc
rename to flystar/tests/test_data/coveragerc
diff --git a/flystar/tests/test_data/list_of_starlists.pkl b/flystar/tests/test_data/list_of_starlists.pkl
new file mode 100644
index 0000000..3662f0f
Binary files /dev/null and b/flystar/tests/test_data/list_of_starlists.pkl differ
diff --git a/flystar/tests/mb10364_data/2011_10_31_F606W_MATCHUP_XYMEEE_final.calib b/flystar/tests/test_data/mb10364_data/2011_10_31_F606W_MATCHUP_XYMEEE_final.calib
similarity index 100%
rename from flystar/tests/mb10364_data/2011_10_31_F606W_MATCHUP_XYMEEE_final.calib
rename to flystar/tests/test_data/mb10364_data/2011_10_31_F606W_MATCHUP_XYMEEE_final.calib
diff --git a/flystar/tests/mb10364_data/2012_09_25_F606W_MATCHUP_XYMEEE_final.calib b/flystar/tests/test_data/mb10364_data/2012_09_25_F606W_MATCHUP_XYMEEE_final.calib
similarity index 100%
rename from flystar/tests/mb10364_data/2012_09_25_F606W_MATCHUP_XYMEEE_final.calib
rename to flystar/tests/test_data/mb10364_data/2012_09_25_F606W_MATCHUP_XYMEEE_final.calib
diff --git a/flystar/tests/mb10364_data/2013_10_24_F606W_MATCHUP_XYMEEE_final.calib b/flystar/tests/test_data/mb10364_data/2013_10_24_F606W_MATCHUP_XYMEEE_final.calib
similarity index 100%
rename from flystar/tests/mb10364_data/2013_10_24_F606W_MATCHUP_XYMEEE_final.calib
rename to flystar/tests/test_data/mb10364_data/2013_10_24_F606W_MATCHUP_XYMEEE_final.calib
diff --git a/flystar/tests/mb10364_data/my_gaia.fits b/flystar/tests/test_data/mb10364_data/my_gaia.fits
similarity index 100%
rename from flystar/tests/mb10364_data/my_gaia.fits
rename to flystar/tests/test_data/mb10364_data/my_gaia.fits
diff --git a/flystar/tests/test_data/my_gaia.pkl b/flystar/tests/test_data/my_gaia.pkl
new file mode 100644
index 0000000..58fa1c8
Binary files /dev/null and b/flystar/tests/test_data/my_gaia.pkl differ
diff --git a/flystar/tests/ref.lis b/flystar/tests/test_data/ref.lis
similarity index 100%
rename from flystar/tests/ref.lis
rename to flystar/tests/test_data/ref.lis
diff --git a/flystar/tests/ref_vel.lis b/flystar/tests/test_data/ref_vel.lis
similarity index 99%
rename from flystar/tests/ref_vel.lis
rename to flystar/tests/test_data/ref_vel.lis
index 4d223b0..fc191bb 100644
--- a/flystar/tests/ref_vel.lis
+++ b/flystar/tests/test_data/ref_vel.lis
@@ -1,4 +1,4 @@
-name x y m xe ye me t0 vx vy vxe vye
+name x y m xe ye me t0 vx vy vx_err vy_err
gaia_1150 -63.98457260029581 -30.67278228118061 13.628200000000001 0.00014609621924194742 0.00014585407086906515 0.0115 2010.5 0.0 0.0 0.1 0.1
gaia_1162 0.47637231898572985 -79.79611824529178 14.6439 0.00011419811781207949 0.00011415029792639667 0.0084 2010.5 0.0 0.0 0.1 0.1
gaia_1166 8.546170748636236 -47.35893234401765 14.696900000000001 0.00013283068515276605 0.00013260913293195234 0.0041 2010.5 0.0 0.0 0.1 0.1
diff --git a/flystar/tests/test_catalog.fits b/flystar/tests/test_data/test_catalog.fits
similarity index 100%
rename from flystar/tests/test_catalog.fits
rename to flystar/tests/test_data/test_catalog.fits
diff --git a/flystar/tests/test_match.py b/flystar/tests/test_match.py
index 594f0b9..80ac59f 100644
--- a/flystar/tests/test_match.py
+++ b/flystar/tests/test_match.py
@@ -1,4 +1,4 @@
-from flystar import match, starlists, transforms
+from flystar import align, match, starlists, transforms
import numpy as np
import pdb
from astropy.table import Table
@@ -164,7 +164,7 @@ def test_generic_match():
n2 = np.array(['S11', 'S12', 'S13', 'S14', 'S15',
'S16', 'S17', 'S18', 'S19'])
-
+
list1 = Table([n1, x1, y1, m1],
names=('name', 'x', 'y', 'm'))
list2 = Table([n2, x2, y2, m2],
@@ -173,11 +173,9 @@ def test_generic_match():
starlist1 = starlists.StarList.from_table(list1)
starlist2 = starlists.StarList.from_table(list2)
- out = match.generic_match(starlist1, starlist2, init_mode='triangle',
+ out = align.generic_match(starlist1, starlist2, init_mode='triangle',
model=transforms.PolyTransform, order_dr=(1, 1.0),
dr_final=1.0,
xy_match=(None, None, None, None, None, None, None, None),
m_match=(None, None, None, None), sigma_match=None,
n_bright=8, verbose=True)
-
-
diff --git a/flystar/tests/test_motion_model.py b/flystar/tests/test_motion_model.py
new file mode 100644
index 0000000..797c412
--- /dev/null
+++ b/flystar/tests/test_motion_model.py
@@ -0,0 +1,488 @@
+from flystar import motion_model
+import numpy as np
+import matplotlib.pyplot as plt
+from scipy.optimize import curve_fit
+
+def within_error(true_val, fit_val, fit_err, n_sigma=3):
+ return np.abs(true_val - fit_val) <= n_sigma*fit_err
+
+def test_Fixed():
+ # Test handling of a single star
+ true_params = {'x0': 1.0, 'y0':0.5, 'x0_err':0.1, 'y0_err':0.1}
+ mod = motion_model.Fixed()
+ param_list = mod.fit_param_names
+ # Confirm return of proper values for single t and array t
+ x_t, y_t = mod.model(
+ 0.0,
+ fit_params=np.array([true_params['x0'], true_params['y0']]).T
+ )
+ assert x_t==true_params['x0']
+ assert y_t==true_params['y0']
+ x_t, y_t = mod.model(
+ [0.0,2025.0,10000],
+ fit_params=np.array([true_params['x0'], true_params['y0']]).T
+ )
+ assert (x_t==true_params['x0']).all()
+ assert (y_t==true_params['y0']).all()
+
+ # Check behavior of model
+ x0_batch = np.random.uniform(-2.0,2.0, 50)
+ y0_batch = np.random.uniform(-2.0,2.0, 50)
+ x0_err_batch = np.repeat(0.1, 50)
+ y0_err_batch = np.repeat(0.1, 50)
+ # Single epoch
+ t_batch=2020.0
+ x_t_batch, y_t_batch, x_err_t_batch, y_err_t_batch = mod.model(
+ t_batch,
+ fit_params=np.array([x0_batch, y0_batch]).T,
+ fit_param_errs=np.array([x0_err_batch, y0_err_batch]).T
+ )
+ assert (x_t_batch==x0_batch).all()
+ assert (y_t_batch==y0_batch).all()
+ assert (x_err_t_batch==x0_err_batch).all()
+ assert (y_err_t_batch==y0_err_batch).all()
+ # Multiple times
+ t_batch = np.arange(2015.0,2025.0, 0.5)
+ x_t_batch, y_t_batch, x_err_t_batch, y_err_t_batch = mod.model(
+ t_batch,
+ fit_params=np.array([x0_batch, y0_batch]).T,
+ fit_param_errs=np.array([x0_err_batch, y0_err_batch]).T
+ )
+ assert (x_t_batch==np.array([np.repeat(x0_batch_i, len(t_batch)) for x0_batch_i in x0_batch])).all()
+ assert (y_t_batch==np.array([np.repeat(y0_batch_i, len(t_batch)) for y0_batch_i in y0_batch])).all()
+ assert (x_err_t_batch==np.array([np.repeat(x0_err_batch_i, len(t_batch)) for x0_err_batch_i in x0_err_batch])).all()
+ assert (y_err_t_batch==np.array([np.repeat(y0_err_batch_i, len(t_batch)) for y0_err_batch_i in y0_err_batch])).all()
+
+ # Test fitter
+ t = np.arange(2015.0,2025.0, 0.5)
+ # Get values from model and add scatter
+ x_true, y_true = mod.model(
+ t,
+ fit_params=np.array([true_params['x0'], true_params['y0']])
+ )
+ x_sim = np.random.normal(x_true, true_params['x0_err'])
+ y_sim = np.random.normal(y_true, true_params['y0_err'])
+ xe = np.ones_like(t)*true_params['x0_err']
+ ye = np.ones_like(t)*true_params['y0_err']
+ # Run fit
+ params, param_errs = mod.fit(
+ t,
+ x_sim,y_sim,
+ xe=xe,
+ ye=ye
+ )
+
+ x_wt = 1. / xe**2
+ y_wt = 1. / ye**2
+ x_wt_norm = x_wt / np.sum(x_wt)
+ y_wt_norm = y_wt / np.sum(y_wt)
+ x_mean = np.average(x_sim, weights=x_wt)
+ y_mean = np.average(y_sim, weights=y_wt)
+ x_std = (np.sum(x_wt_norm**2 * xe**2))**0.5
+ y_std = (np.sum(y_wt_norm**2 * ye**2))**0.5
+
+ # Confirm true value is within error bar of fit value
+ assert np.all([within_error(true_params[param_list[i]], params[i], param_errs[i]) for i in range(len(params))])
+ np.testing.assert_allclose(params[0], x_mean, atol=1e-5)
+ np.testing.assert_allclose(params[1], y_mean, atol=1e-5)
+ np.testing.assert_allclose(param_errs[0], x_std, atol=1e-5)
+ np.testing.assert_allclose(param_errs[1], y_std, atol=1e-5)
+
+
+def test_Linear():
+ # Test handling of a single star
+ true_params = {'x0': 1.0, 'y0':0.5, 'x0_err':0.1, 'y0_err':0.1,
+ 'vx':0.2, 'vy':0.5, 'vx_err':0.05, 'vy_err':0.05,
+ 't0':2025.0}
+ mod = motion_model.Linear()
+ param_list = mod.fit_param_names
+ # Confirm return of proper values for single t=t0 and array t
+ x_t, y_t = mod.model(
+ t=true_params['t0'],
+ fit_params=np.array([true_params[p] for p in param_list]).T,
+ fixed_params_dict={'t0': true_params['t0']}
+ )
+ assert x_t==true_params['x0']
+ assert y_t==true_params['y0']
+ t_arr = np.array([2010.0,true_params['t0'],2030.0])
+ x_t, y_t = mod.model(
+ t=t_arr,
+ fit_params=np.array([true_params[p] for p in param_list]).T,
+ fixed_params_dict={'t0': true_params['t0']}
+ )
+ assert (x_t==(true_params['x0'] + (t_arr-true_params['t0'])*true_params['vx'])).all()
+ assert (y_t==(true_params['y0'] + (t_arr-true_params['t0'])*true_params['vy'])).all()
+
+ # Check behavior of model
+ x0_batch = np.random.uniform(-2.0,2.0, 50)
+ y0_batch = np.random.uniform(-2.0,2.0, 50)
+ vx_batch = np.random.uniform(-2.0,2.0, 50)
+ vy_batch = np.random.uniform(-2.0,2.0, 50)
+ x0_err_batch = np.repeat(0.1, 50)
+ y0_err_batch = np.repeat(0.1, 50)
+ vx_err_batch = np.repeat(0.05, 50)
+ vy_err_batch = np.repeat(0.05, 50)
+ t0_batch = np.repeat(2025.0,50)
+ # Single epoch
+ t_batch=2020.0
+ x_t_batch, y_t_batch, x_err_t_batch, y_err_t_batch = mod.model(
+ t=t_batch,
+ fit_params=np.array([x0_batch, vx_batch, y0_batch, vy_batch]).T,
+ fit_param_errs=np.array([x0_err_batch, vx_err_batch, y0_err_batch, vy_err_batch]).T,
+ fixed_params_dict={'t0': t0_batch}
+ )
+
+ np.testing.assert_allclose(x_t_batch, (x0_batch+(t_batch-t0_batch)*vx_batch), atol=1e-5)
+ np.testing.assert_allclose(y_t_batch, (y0_batch+(t_batch-t0_batch)*vy_batch), atol=1e-5)
+ np.testing.assert_allclose(x_err_t_batch, np.hypot(x0_err_batch, (t_batch-t0_batch)*vx_err_batch), atol=1e-5)
+ np.testing.assert_allclose(y_err_t_batch, np.hypot(y0_err_batch, (t_batch-t0_batch)*vy_err_batch), atol=1e-5)
+
+ # Multiple times
+ t_batch = np.arange(2015.0,2025.0, 0.5)
+ x_t_batch, y_t_batch, x_err_t_batch, y_err_t_batch = mod.model(
+ t=t_batch,
+ fit_params=np.array([x0_batch, vx_batch, y0_batch, vy_batch]).T,
+ fit_param_errs=np.array([x0_err_batch, vx_err_batch, y0_err_batch, vy_err_batch]).T,
+ fixed_params_dict={'t0': t0_batch}
+ )
+ np.testing.assert_allclose(x_t_batch, np.array([x0_batch[i] + (t_batch-t0_batch[i])*vx_batch[i] for i in range(len(x0_batch))]), atol=1e-5)
+ np.testing.assert_allclose(y_t_batch, np.array([y0_batch[i] + (t_batch-t0_batch[i])*vy_batch[i] for i in range(len(x0_batch))]), atol=1e-5)
+ np.testing.assert_allclose(x_err_t_batch, np.array([np.hypot(x0_err_batch[i], (t_batch-t0_batch[i])*vx_err_batch[i]) for i in range(len(x0_batch))]), atol=1e-5)
+ np.testing.assert_allclose(y_err_t_batch, np.array([np.hypot(y0_err_batch[i], (t_batch-t0_batch[i])*vy_err_batch[i]) for i in range(len(x0_batch))]), atol=1e-5)
+
+ # Test fitter
+ t = np.arange(2015.0,2025.0, 0.5)
+ # Get values from model and add scatter
+ x_true, y_true = mod.model(
+ t=t,
+ fit_params=np.array([true_params[p] for p in param_list]).T,
+ fixed_params_dict={'t0': true_params['t0']}
+ )
+ x_sim = np.random.normal(x_true, 0.05)
+ y_sim = np.random.normal(y_true, 0.05)
+ # Run fit
+ xe = np.ones_like(t)*0.05
+ ye = np.ones_like(t)*0.05
+
+ def linear(t, x0, vx):
+ return x0 + vx * t
+
+ for absolute_sigma in [True, False]:
+ for weighting in ['std', 'var']:
+ for use_scipy in [True, False]:
+ params, param_errs = mod.fit(
+ t=t,
+ x=x_sim,
+ y=y_sim,
+ xe=xe,
+ ye=ye,
+ fixed_params_dict={'t0': true_params['t0']},
+ weighting=weighting,
+ use_scipy=use_scipy,
+ absolute_sigma=absolute_sigma
+ )
+
+ # Scipy
+ xe_scipy = xe**0.5 if weighting=='std' else xe
+ ye_scipy = ye**0.5 if weighting=='std' else ye
+ x_popt, x_pcov = curve_fit(
+ linear,
+ t - true_params['t0'],
+ x_sim,
+ sigma=xe_scipy,
+ absolute_sigma=absolute_sigma,
+ p0=[np.mean(x_sim), 0.0]
+ )
+ y_popt, y_pcov = curve_fit(
+ linear,
+ t - true_params['t0'],
+ y_sim,
+ sigma=ye_scipy,
+ absolute_sigma=absolute_sigma,
+ p0=[np.mean(y_sim), 0.0]
+ )
+ np.testing.assert_allclose(params[:2], x_popt, atol=1e-5)
+ np.testing.assert_allclose(param_errs[:2], np.sqrt(np.diag(x_pcov)), atol=1e-5)
+ np.testing.assert_allclose(params[2:], y_popt, atol=1e-5)
+ np.testing.assert_allclose(param_errs[2:], np.sqrt(np.diag(y_pcov)), atol=1e-5)
+
+ # Test fitter with bootstrap
+ t = np.arange(2015.0, 2025.0, 0.5)
+ # Get values from model and add scatter
+ x_true, y_true = mod.model(
+ t=t,
+ fit_params=np.array([true_params[p] for p in param_list]).T,
+ fixed_params_dict={'t0': true_params['t0']}
+ )
+ x_true_err, y_true_err = np.ones_like(t)*0.05, np.ones_like(t)*0.05
+ x_sim = np.random.normal(x_true, x_true_err)
+ y_sim = np.random.normal(y_true, y_true_err)
+ # Run fit
+ params, param_errs = mod.fit(t, x_sim, y_sim, x_true_err, y_true_err, fixed_params_dict={'t0': true_params['t0']}, bootstrap=10, seed=42)
+ # Confirm true value is within error bar of fit value
+ assert np.all([within_error(true_params[param_list[i]], params[i], param_errs[i]) for i in range(len(params))])
+
+
+def test_Acceleration():
+ # Test handling of a single star
+ true_params = {'x0': 1.0, 'y0':0.5, 'x0_err':0.1, 'y0_err':0.1,
+ 'vx0':0.2, 'vy0':0.5, 'vx0_err':0.05, 'vy0_err':0.05,
+ 'ax':0.1, 'ay':-0.1, 'ax_err':0.02, 'ay_err':0.02,
+ 't0':2025.0}
+ mod = motion_model.Acceleration()
+ param_list = mod.fit_param_names
+ # Confirm return of proper values for single t=t0 and array t
+ x_t, y_t = mod.model(
+ t=true_params['t0'],
+ fit_params=np.array([true_params[p] for p in param_list]).T,
+ fixed_params_dict={'t0': true_params['t0']}
+ )
+ np.testing.assert_allclose(x_t, true_params['x0'])
+ np.testing.assert_allclose(y_t, true_params['y0'])
+ t_arr = np.array([2010.0, true_params['t0'], 2030.0])
+ x_t, y_t = mod.model(
+ t=t_arr,
+ fit_params=np.array([true_params[p] for p in param_list]).T,
+ fixed_params_dict={'t0': true_params['t0']}
+ )
+ np.testing.assert_allclose(x_t, true_params['x0'] + (t_arr-true_params['t0'])*true_params['vx0'] + 0.5*(t_arr-true_params['t0'])**2*true_params['ax'])
+ np.testing.assert_allclose(y_t, true_params['y0'] + (t_arr-true_params['t0'])*true_params['vy0'] + 0.5*(t_arr-true_params['t0'])**2*true_params['ay'])
+
+ # Check behavior of model
+ x0_batch = np.random.uniform(-2.0,2.0, 50)
+ y0_batch = np.random.uniform(-2.0,2.0, 50)
+ vx0_batch = np.random.uniform(-2.0,2.0, 50)
+ vy0_batch = np.random.uniform(-2.0,2.0, 50)
+ ax_batch = np.random.uniform(-1.0,1.0, 50)
+ ay_batch = np.random.uniform(-1.0,1.0, 50)
+ x0_err_batch = np.repeat(0.1, 50)
+ y0_err_batch = np.repeat(0.1, 50)
+ vx0_err_batch = np.repeat(0.05, 50)
+ vy0_err_batch = np.repeat(0.05, 50)
+ ax_err_batch = np.repeat(0.02, 50)
+ ay_err_batch = np.repeat(0.02, 50)
+ t0_batch = np.repeat(2025.0,50)
+ # Single epoch
+ t_batch=2020.0
+ x_t_batch, y_t_batch, x_err_t_batch, y_err_t_batch = mod.model(
+ t=t_batch,
+ fit_params=np.array([x0_batch, vx0_batch, ax_batch, y0_batch, vy0_batch, ay_batch]).T,
+ fit_param_errs=np.array([x0_err_batch, vx0_err_batch, ax_err_batch, y0_err_batch, vy0_err_batch, ay_err_batch]).T,
+ fixed_params_dict={'t0': t0_batch}
+ )
+ np.testing.assert_allclose(x_t_batch, x0_batch + (t_batch-t0_batch)*vx0_batch + 0.5*(t_batch-t0_batch)**2*ax_batch)
+ np.testing.assert_allclose(y_t_batch, y0_batch + (t_batch-t0_batch)*vy0_batch + 0.5*(t_batch-t0_batch)**2*ay_batch)
+ np.testing.assert_allclose(x_err_t_batch, np.sqrt(x0_err_batch**2 + ((t_batch-t0_batch)*vx0_err_batch)**2 +
+ (0.5*(t_batch-t0_batch)**2*ax_err_batch)**2))
+ np.testing.assert_allclose(y_err_t_batch, np.sqrt(y0_err_batch**2 + ((t_batch-t0_batch)*vy0_err_batch)**2 +
+ (0.5*(t_batch-t0_batch)**2*ay_err_batch)**2))
+
+ # Multiple times
+ t_batch = np.arange(2015.0,2025.0, 0.5)
+ x_t_batch, y_t_batch, x_err_t_batch, y_err_t_batch = mod.model(
+ t=t_batch,
+ fit_params=np.array([x0_batch, vx0_batch, ax_batch, y0_batch, vy0_batch, ay_batch]).T,
+ fit_param_errs=np.array([x0_err_batch, vx0_err_batch, ax_err_batch, y0_err_batch, vy0_err_batch, ay_err_batch]).T,
+ fixed_params_dict={'t0': t0_batch}
+ )
+ np.testing.assert_allclose(x_t_batch, np.array([x0_batch[i] + (t_batch-t0_batch[i])*vx0_batch[i] + 0.5*(t_batch-t0_batch[i])**2*ax_batch[i] for i in range(len(x0_batch))]))
+ np.testing.assert_allclose(y_t_batch, np.array([y0_batch[i] + (t_batch-t0_batch[i])*vy0_batch[i] + 0.5*(t_batch-t0_batch[i])**2*ay_batch[i] for i in range(len(x0_batch))]))
+ np.testing.assert_allclose(x_err_t_batch, np.array([np.sqrt(x0_err_batch[i]**2 + ((t_batch-t0_batch[i])*vx0_err_batch[i])**2 + (0.5*(t_batch-t0_batch[i])**2*ax_err_batch[i])**2) for i in range(len(x0_batch))]))
+ np.testing.assert_allclose(y_err_t_batch, np.array([np.sqrt(y0_err_batch[i]**2 + ((t_batch-t0_batch[i])*vy0_err_batch[i])**2 + (0.5*(t_batch-t0_batch[i])**2*ay_err_batch[i])**2) for i in range(len(x0_batch))]))
+
+ # Test fitter
+ t = np.arange(2015.0,2025.0, 0.5)
+ # Get values from model and add scatter
+ x_true, y_true = mod.model(
+ t=t,
+ fit_params=np.array([true_params[p] for p in param_list]).T,
+ fixed_params_dict={'t0': true_params['t0']}
+ )
+ x_true_err = np.sqrt(true_params['x0_err']**2 + ((t - true_params['t0']) * true_params['vx0_err'])**2 +
+ (0.5*(t - true_params['t0'])**2 * true_params['ax_err'])**2)
+ y_true_err = np.sqrt(true_params['y0_err']**2 + ((t - true_params['t0']) * true_params['vy0_err'])**2 +
+ (0.5*(t - true_params['t0'])**2 * true_params['ay_err'])**2)
+ x_sim = np.random.normal(x_true, x_true_err)
+ y_sim = np.random.normal(y_true, y_true_err)
+ # Run fit
+ mod_fit = motion_model.Acceleration()
+ params, param_errs = mod_fit.fit(
+ t=t,
+ x=x_sim,
+ y=y_sim,
+ xe=x_true_err,
+ ye=y_true_err,
+ fixed_params_dict={'t0': true_params['t0']}
+ )
+ # Confirm true value is within error bar of fit value
+ assert np.all([within_error(true_params[param_list[i]], params[i], param_errs[i]) for i in range(len(params))])
+
+#@pytest.mark.skip(reason="not written")
+def test_Parallax():
+ # Test handling of a single star
+ true_params = {'x0': 1.0, 'y0':-0.5, 'x0_err':0.1, 'y0_err':0.1,
+ 'vx':-0.2, 'vy':0.5, 'vx_err':0.05, 'vy_err':0.05,
+ 'pi':0.5, 'ra':17.76, 'dec':-28.933, 'pa':0,
+ 't0':2020.0, 'obsLocation': 'earth'}
+ mod = motion_model.Parallax()
+ param_list = mod.fit_param_names
+ fixed_params_dict = {
+ 't0': true_params['t0'],
+ 'ra': true_params['ra'],
+ 'dec': true_params['dec'],
+ 'pa': true_params['pa'],
+ 'obsLocation': true_params['obsLocation']
+ }
+
+ # Test fitter
+ t = np.arange(2015.0,2025.0, 0.5)
+ # Get values from model and add scatter
+ x_true, y_true = mod.model(
+ t=t,
+ fit_params=np.array([true_params[p] for p in param_list]).T,
+ fixed_params_dict=fixed_params_dict
+ )
+ x_true_err, y_true_err = np.ones_like(t)*true_params['x0_err'], np.ones_like(t)*true_params['y0_err']
+ x_sim = np.random.normal(x_true, x_true_err)
+ y_sim = np.random.normal(y_true, y_true_err)
+ # Run fit
+ params, param_errs = mod.fit(t, x_sim,y_sim, x_true_err, y_true_err, fixed_params_dict=fixed_params_dict)
+
+ x_model, y_model = mod.model(
+ t=t,
+ fit_params=params,
+ fixed_params_dict=fixed_params_dict
+ )
+ plt.clf()
+ fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 5))
+ ax1.plot(t, x_model, color='C3', lw=2, label='Model x')
+ ax1.plot(t, x_true, color='C0', ls='--', label='True x')
+ ax1.errorbar(t, x_sim, yerr=x_true_err, fmt='o', color='C0', label='Sim x')
+ ax1.set_xlabel('t')
+ ax1.set_ylabel('x')
+ ax1.legend()
+ ax2.plot(t, y_model, color='C3', lw=2, label='Model y')
+ ax2.plot(t, y_true, color='C0', ls='--', label='True y')
+ ax2.errorbar(t, y_sim, yerr=y_true_err, fmt='o', color='C0', label='Sim y')
+ ax2.set_xlabel('t')
+ ax2.set_ylabel('y')
+ ax2.legend()
+ plt.tight_layout()
+
+ # Confirm true value is within error bar of fit value
+ assert np.all([within_error(true_params[param_list[i]], params[i], param_errs[i]) for i in range(len(params))])
+
+def test_Parallax_PA():
+ # Set PA=0 model
+ x0, y0 = 2.0, -1.0
+ vx, vy = 0.2, 0.5
+ ra, dec = 17.76, -28.933
+ pi = 0.5
+ mod_pa0 = motion_model.Parallax()
+ # Set PA=90 model with equivalent parameters in that frame
+ mod_pa90 = motion_model.Parallax()
+
+ t_set = np.arange(2018, 2024, 0.01)
+ t0 = 2020.0
+ dat_pa0 = mod_pa0.model(
+ t = t_set,
+ fit_params = np.array([x0, vx, y0, vy, pi]).T,
+ fixed_params_dict = {'t0': t0, 'ra': ra, 'dec': dec, 'pa': 0}
+ )
+ dat_pa90 = mod_pa90.model(
+ t = t_set,
+ fit_params = np.array([y0, vy, -x0, -vx, pi]).T,
+ fixed_params_dict = {'t0': t0, 'ra': ra, 'dec': dec, 'pa': 90}
+ )
+ np.testing.assert_allclose(dat_pa0[0], -dat_pa90[1], atol=1e-10)
+ np.testing.assert_allclose(dat_pa0[1], dat_pa90[0], atol=1e-10)
+
+
+def test_motion_model_param_names_dedup():
+ """
+ motion_model_param_names() used to re-expand fit_param_names/fixed_param_names
+ once per input entry even when the same motion model repeated thousands of
+ times (e.g. align.py passing one entry per star). It now dedups the input
+ first. Check a heavily-duplicated input still gives the same result as the
+ plain unique input.
+ """
+ repeated_names = ['Fixed', 'Linear'] * 5000
+ got = motion_model.motion_model_param_names(repeated_names, with_errors=True, with_fixed=True)
+ want = motion_model.motion_model_param_names(['Fixed', 'Linear'], with_errors=True, with_fixed=True)
+ assert got == want
+
+ # Order of first appearance should still control the output order.
+ reordered = ['Linear', 'Fixed'] * 3000
+ got_reordered = motion_model.motion_model_param_names(reordered, with_errors=True, with_fixed=True)
+ want_reordered = motion_model.motion_model_param_names(['Linear', 'Fixed'], with_errors=True, with_fixed=True)
+ assert got_reordered == want_reordered
+ assert got_reordered != got # different first-seen order -> different param order
+
+ # Mixing model classes with their string names should still be correct.
+ mixed = [motion_model.Fixed, 'Fixed', motion_model.Linear, 'Linear'] * 100
+ got_mixed = motion_model.motion_model_param_names(mixed, with_errors=True, with_fixed=True)
+ assert got_mixed == want
+
+ # with_errors=False / with_fixed=False should still behave as before.
+ got_no_extras = motion_model.motion_model_param_names(repeated_names, with_errors=False, with_fixed=False)
+ want_no_extras = motion_model.motion_model_param_names(['Fixed', 'Linear'], with_errors=False, with_fixed=False)
+ assert got_no_extras == want_no_extras
+
+
+def test_Fixed_run_fit_batch():
+ """
+ Fixed.run_fit_batch() vectorizes run_fit() across many stars at once
+ (closed-form weighted average, no iterative optimizer needed) instead of
+ fitting star by star. Check it against a per-star loop calling fit()
+ directly, across a battery of randomized cases: full epochs, ragged
+ (different numbers of valid epochs per star), a star with exactly one
+ valid epoch (degree_of_freedom == 0), a star with zero valid epochs (not
+ enough data), var/std weighting, and absolute_sigma True/False.
+ """
+ rng = np.random.default_rng(3)
+ n_stars = 40
+ n_epochs = 6
+
+ t = np.tile(np.arange(n_epochs) + 2020.0, (n_stars, 1))
+ x = rng.normal(100, 5, size=(n_stars, n_epochs))
+ y = rng.normal(-50, 5, size=(n_stars, n_epochs))
+ xe = rng.uniform(0.01, 0.5, size=(n_stars, n_epochs))
+ ye = rng.uniform(0.01, 0.5, size=(n_stars, n_epochs))
+
+ valid = rng.random((n_stars, n_epochs)) > 0.3
+ valid[0, :] = False # zero valid epochs -- not enough data
+ valid[1, :] = False
+ valid[1, 2] = True # exactly one valid epoch -- degree_of_freedom == 0
+ valid[2, :] = True # fully detected, for a clean baseline case
+
+ for weighting, absolute_sigma in [('var', True), ('std', True), ('var', False)]:
+ mod = motion_model.Fixed()
+ got_params, got_errs, got_chi2x, got_chi2y = mod.run_fit_batch(
+ t, x, y, xe, ye, valid, weighting=weighting, absolute_sigma=absolute_sigma,
+ fill_value=np.nan, verbose=False
+ )
+
+ want_params = np.full((n_stars, 2), np.nan)
+ want_errs = np.full((n_stars, 2), np.inf)
+ want_chi2x = np.full(n_stars, np.nan)
+ want_chi2y = np.full(n_stars, np.nan)
+ for i in range(n_stars):
+ idx = np.flatnonzero(valid[i])
+ params, errs, chi2x, chi2y = mod.fit(
+ t=t[i][idx], x=x[i][idx], y=y[i][idx], xe=xe[i][idx], ye=ye[i][idx],
+ weighting=weighting, absolute_sigma=absolute_sigma, use_scipy=True,
+ fill_value=np.nan, return_chi2=True, bootstrap=0, verbose=False
+ )
+ want_params[i] = params
+ want_errs[i] = errs
+ want_chi2x[i] = chi2x
+ want_chi2y[i] = chi2y
+
+ np.testing.assert_allclose(got_params, want_params, rtol=1e-10, atol=1e-10, equal_nan=True,
+ err_msg=f"weighting={weighting} absolute_sigma={absolute_sigma}: params mismatch")
+ np.testing.assert_allclose(got_errs, want_errs, rtol=1e-10, atol=1e-10, equal_nan=True,
+ err_msg=f"weighting={weighting} absolute_sigma={absolute_sigma}: errs mismatch")
+ np.testing.assert_allclose(got_chi2x, want_chi2x, rtol=1e-10, atol=1e-10, equal_nan=True,
+ err_msg=f"weighting={weighting} absolute_sigma={absolute_sigma}: chi2x mismatch")
+ np.testing.assert_allclose(got_chi2y, want_chi2y, rtol=1e-10, atol=1e-10, equal_nan=True,
+ err_msg=f"weighting={weighting} absolute_sigma={absolute_sigma}: chi2y mismatch")
\ No newline at end of file
diff --git a/flystar/tests/test_starlist.py b/flystar/tests/test_starlist.py
index 5113c43..568c26d 100644
--- a/flystar/tests/test_starlist.py
+++ b/flystar/tests/test_starlist.py
@@ -1,16 +1,17 @@
from astropy.table import Table
from flystar.starlists import StarList
import os, pdb
+import flystar
-test_dir = os.path.dirname(__file__)
+test_data_path = f'{flystar.__path__[0]}/tests/test_data'
def make_star_list():
# User input
- cat_file = test_dir + '/A.lis'
+ cat_file = f'{test_data_path}/A.lis'
# Read and arrange the test input
- cat_tab = Table.read(cat_file, format='ascii', delimiter='\s')
+ cat_tab = Table.read(cat_file, format='ascii', delimiter=r'\s')
# Copy columns from the input file.
# Note that all of these inputs will be numpy arrays.
@@ -25,7 +26,7 @@ def make_star_list():
# Name is a unique name for each star and is a 1D array.
starlist_time = 2011.1
- starlist_name = 'A.lis'
+ starlist_name = f'{test_data_path}/A.lis'
# Generate the starlist
starlist = StarList(name=name_in, x=x_in, y=y_in, m=m_in, xe=xe_in,
diff --git a/flystar/tests/test_startable.py b/flystar/tests/test_startable.py
index 9051fb8..77bb8ef 100644
--- a/flystar/tests/test_startable.py
+++ b/flystar/tests/test_startable.py
@@ -1,20 +1,22 @@
+import os
+import pdb
+import pytest
+import flystar
+import numpy as np
from astropy.table import Table
from astropy import table
+from flystar import motion_model
from flystar.startables import StarTable
from flystar.starlists import StarList
-import numpy as np
-import pytest
-import os
-import pdb
-test_dir = os.path.dirname(__file__)
+test_data_path = f'{flystar.__path__[0]}/tests/test_data'
def test_StarTable_init1():
"""
Test creation of new StarTable.
"""
# User input
- cat_file = test_dir + '/test_catalog.fits'
+ cat_file = f'{test_data_path}/test_catalog.fits'
# Read and arrange the test input
cat_tab = Table.read(cat_file)
@@ -39,9 +41,14 @@ def test_StarTable_init1():
starlist_names = np.array(['file1', 'file2', 'file3', 'file4', 'file5', 'file6', 'file7', 'file8'])
# Generate the startable
- startable = StarTable(name=name_in, x=x_in, y=y_in, m=m_in, xe=xe_in, ye=ye_in, me=me_in,
- ref_list=1,
- list_times=starlist_times, list_names=starlist_names)
+ startable = StarTable(
+ name=name_in,
+ x=x_in, y=y_in, m=m_in,
+ xe=xe_in, ye=ye_in, me=me_in,
+ ref_list=1,
+ list_times=starlist_times,
+ list_names=starlist_names
+ )
# Now put in some assertions to make sure all our startable columns
# have the right dimensions.
@@ -55,7 +62,7 @@ def test_StarTable_init1():
assert len(startable['name']) == N_stars
assert startable.meta['list_times'][0] == starlist_times[0]
assert type(startable) == StarTable
-
+
return
def test_StarTable_init2():
@@ -65,8 +72,8 @@ def test_StarTable_init2():
Also double check that we can add a second list to it using add_starlist and
we can get_starlist() as well.
"""
- list_file1 = 'A.lis'
- list_file2 = 'B.lis'
+ list_file1 = f'{test_data_path}/A.lis'
+ list_file2 = f'{test_data_path}/B.lis'
list1 = StarList.from_lis_file(list_file1)
list2 = StarList.from_lis_file(list_file2)
@@ -75,7 +82,6 @@ def test_StarTable_init2():
assert len(tab) == len(list1)
-
return
def test_combine_lists():
@@ -93,20 +99,25 @@ def test_combine_lists():
x_avg_0 = t['x'][0, :].mean()
t.combine_lists('x', mask_val=-100000)
assert t['x0'][0] == x_avg_0
- assert t['x0'][-1] == pytest.approx(2108.855, 0.001)
+ np.testing.assert_allclose(t['x0'][-1], 2108.855, rtol=1e-3)
# Test 3: Trying calling the same thing a second time and make sure the
# answers don't change and we didn't break anything.
t.combine_lists('x', mask_val=-100000)
assert t['x0'][0] == x_avg_0
- assert t['x0'][-1] == pytest.approx(2108.855, 0.001)
-
+ np.testing.assert_allclose(t['x0'][-1], 2108.855, rtol=1e-3)
+
# Test 4: weighted average of x.
x_wgt_0 = 1.0 / t['xe'][0, :]**2
x_avg_0 = np.average(t['x'][0, :], weights=x_wgt_0)
t.combine_lists('x', mask_val=-100000, weights_col='xe')
- assert t['x0'][0] == x_avg_0
-
+ # A weighted-mean reduction over a 2D array's axis=1 (as combine_lists
+ # does internally) doesn't reproduce a 1D np.average() call bit-for-bit
+ # -- that's a numpy summation-order quirk (also true of the original
+ # numpy.ma-based implementation for a plain np.average, just not for
+ # np.ma.average specifically), not a precision issue worth chasing.
+ np.testing.assert_allclose(t['x0'][0], x_avg_0)
+
x_wgt_last = 1.0 / t['xe'][-1, :]**2
x_avg_last = np.average(t['x'][-1, [2,7]], weights=x_wgt_last[[2,7]])
assert t['x0'][-1] == pytest.approx(x_avg_last)
@@ -115,14 +126,14 @@ def test_combine_lists():
# Test 5: make sure mask_list is working.
##########
# Test 5ai: Non-masked, weighted_m=False
- tt.combine_lists_xym(weighted_xy=True, weighted_m=False, mask_lists=False)
+ tt.combine_lists_xym(weighted_xy=True, weighted_m=False, mask_lists=None)
assert np.arange(1.8, 38, 4) == pytest.approx(tt['x0'].data)
assert np.arange(1.8, 38, 4) == pytest.approx(tt['y0'].data)
avg_m = -2.5 * np.log10((4 * 10**-0.4 + 1)/5)
assert avg_m * np.ones(10) == pytest.approx(tt['m0'].data)
# Test 5aii: Non-masked, weighted_m=True
- tt.combine_lists_xym(weighted_xy=True, weighted_m=True, mask_lists=False)
+ tt.combine_lists_xym(weighted_xy=True, weighted_m=True, mask_lists=None)
assert np.arange(1.8, 38, 4) == pytest.approx(tt['x0'].data)
assert np.arange(1.8, 38, 4) == pytest.approx(tt['y0'].data)
avg_m_weight = 0.9391744564422395
@@ -141,13 +152,408 @@ def test_combine_lists():
assert np.ones(10) == pytest.approx(tt['m0'].data)
# Test 5c: Things that should break the code.
- with pytest.raises(RuntimeError):
- t.combine_lists_xym(weighted_xy=True, weighted_m=True, mask_lists=np.arange(2))
- with pytest.raises(RuntimeError):
+ # with pytest.raises(RuntimeError):
+ # This would not break the code anymore
+ # t.combine_lists_xym(weighted_xy=True, weighted_m=True, mask_lists=np.arange(2))
+ with pytest.raises(AssertionError):
t.combine_lists_xym(weighted_xy=True, weighted_m=True, mask_lists=True)
return
+def test_combine_lists_select_stars():
+ """
+ combine_lists()/combine_lists_xym() gained a select_stars parameter so
+ align.update_ref_table_aggregates() can recompute averages only for the
+ rows that changed, instead of the whole (potentially huge, ever-growing)
+ ref_table every time it's called. Check that:
+ - computing with select_stars over a subset gives the same numbers as
+ a full recompute, for that subset.
+ - rows outside select_stars are left completely untouched, even if
+ their underlying per-epoch data changed after the last full
+ recompute.
+ """
+ t = make_star_table()
+
+ # Seed x0/x0_err and m0/m0_err with a full computation first.
+ t.combine_lists('x', weights_col='xe', mask_val=-100000)
+ t.combine_lists('m', weights_col='me', mask_val=-100000, ismag=True)
+ x0_before = t['x0'].copy()
+ x0_err_before = t['x0_err'].copy()
+ m0_before = t['m0'].copy()
+
+ # Mutate the underlying per-epoch data for every star...
+ rng = np.random.default_rng(0)
+ t['x'] = t['x'] + rng.uniform(-5, 5, t['x'].shape)
+ t['m'] = t['m'] + rng.uniform(-0.5, 0.5, t['m'].shape)
+
+ # ...but only recompute a subset of rows.
+ select = np.zeros(len(t), dtype=bool)
+ select[[1, 3, 5, 7]] = True
+
+ t.combine_lists('x', weights_col='xe', mask_val=-100000, select_stars=select)
+ t.combine_lists('m', weights_col='me', mask_val=-100000, ismag=True, select_stars=select)
+
+ # A fresh full recompute on the same (mutated) data is ground truth.
+ t_full = make_star_table()
+ t_full['x'] = t['x']
+ t_full['m'] = t['m']
+ t_full.combine_lists('x', weights_col='xe', mask_val=-100000)
+ t_full.combine_lists('m', weights_col='me', mask_val=-100000, ismag=True)
+
+ # Selected rows should match the fresh full recompute (allowing for
+ # floating-point reduction-order noise between a sliced vs. full array).
+ np.testing.assert_allclose(t['x0'][select], t_full['x0'][select], rtol=1e-12)
+ np.testing.assert_allclose(t['x0_err'][select], t_full['x0_err'][select], rtol=1e-12)
+ np.testing.assert_allclose(t['m0'][select], t_full['m0'][select], rtol=1e-12)
+
+ # Unselected rows should be untouched -- still equal to the pre-mutation
+ # values, not the (different) values the new data would produce.
+ np.testing.assert_array_equal(t['x0'][~select], x0_before[~select])
+ np.testing.assert_array_equal(t['x0_err'][~select], x0_err_before[~select])
+ np.testing.assert_array_equal(t['m0'][~select], m0_before[~select])
+
+ # combine_lists_xym should thread select_stars through consistently too.
+ tt = make_tiny_star_table()
+ tt.combine_lists_xym(weighted_xy=True, weighted_m=True)
+ x0_before_tt = tt['x0'].copy()
+ tt['x'] = tt['x'] + 100.0 # move every star
+ select_tt = np.array([True, False] * 5)
+ tt.combine_lists_xym(weighted_xy=True, weighted_m=True, select_stars=select_tt)
+ assert not np.allclose(tt['x0'][select_tt], x0_before_tt[select_tt]) # these moved
+ np.testing.assert_array_equal(tt['x0'][~select_tt], x0_before_tt[~select_tt]) # these didn't
+
+ # Edge case: an all-False selection should be a safe no-op.
+ t2 = make_star_table()
+ t2.combine_lists('x', weights_col='xe', mask_val=-100000)
+ x0_snapshot = t2['x0'].copy()
+ none_selected = np.zeros(len(t2), dtype=bool)
+ t2.combine_lists('x', weights_col='xe', mask_val=-100000, select_stars=none_selected)
+ np.testing.assert_array_equal(t2['x0'], x0_snapshot)
+
+ return
+
+
+def _bruteforce_combine_lists(startable, col_name_in, weights_col=None, mask_val=None,
+ mask_lists=None, ismag=False, sigma=3):
+ """
+ Reference implementation of StarTable.combine_lists(), kept here only as
+ ground truth for test_combine_lists_vectorized: the original numpy.ma
+ -based implementation that the vectorized (plain-numpy) version replaced,
+ for performance (numpy.ma carries heavy per-operation overhead compared
+ to explicit boolean-mask arithmetic on plain arrays).
+ """
+ from astropy.stats import sigma_clip as _sigma_clip
+
+ if mask_lists is not None:
+ mask_lists = np.atleast_1d(mask_lists)
+ list_indices = np.array([i for i in np.arange(startable[col_name_in].data.shape[1]) if i not in mask_lists])
+ else:
+ list_indices = np.arange(startable[col_name_in].data.shape[1])
+
+ val_2d = np.ma.masked_invalid(startable[col_name_in].data[:, list_indices])
+
+ if ismag:
+ val_2d = 10**(-0.4 * val_2d)
+
+ if mask_val:
+ val_2d = np.ma.masked_values(val_2d, mask_val)
+
+ if sigma:
+ val_2d_clip = _sigma_clip(val_2d, sigma=sigma, maxiters=5, axis=1)
+ else:
+ val_2d_clip = val_2d
+
+ if weights_col in startable.colnames:
+ err_2d = np.ma.masked_invalid(startable[weights_col].data[:, list_indices])
+ if ismag:
+ err_2d = 0.4 * np.log(10) * val_2d * err_2d
+ unified_mask = val_2d_clip.mask | err_2d.mask
+ val_2d_clip.mask = unified_mask
+ err_2d.mask = unified_mask
+ wgt_2d = np.ma.masked_invalid(1. / err_2d**2)
+ avg = np.ma.average(val_2d_clip, weights=wgt_2d, axis=1)
+ std = np.ma.sqrt(1. / np.ma.sum(wgt_2d, axis=1))
+ else:
+ avg = np.ma.mean(val_2d_clip, axis=1)
+ std = np.ma.std(val_2d_clip, axis=1)
+
+ std = np.ma.masked_where(std == 0., std)
+
+ if ismag:
+ std = 2.5 / np.log(10) * std / avg
+ avg = -2.5 * np.ma.log10(avg)
+
+ avg = avg.filled(np.nan)
+ std = std.filled(np.inf)
+ return avg, std
+
+
+def test_combine_lists_vectorized():
+ """
+ StarTable.combine_lists() was rewritten to use plain numpy arithmetic
+ with explicit boolean masks instead of numpy.ma (which carries heavy
+ per-operation overhead -- mask bookkeeping and generic dispatch on every
+ arithmetic op -- and was a measurable chunk of align.py's runtime for
+ large mosaics). Check the vectorized version against the original
+ numpy.ma-based reference across a battery of randomized tables that
+ exercise: weighted/unweighted, magnitude conversion, mask_lists,
+ mask_val, sigma clipping, all-invalid rows, and rows with exactly one
+ valid epoch.
+ """
+ rng = np.random.default_rng(7)
+
+ for trial in range(20):
+ n_stars = 60
+ n_epochs = 5
+
+ x = rng.normal(100, 5, size=(n_stars, n_epochs))
+ xe = rng.uniform(0.001, 0.05, size=(n_stars, n_epochs))
+
+ # Sprinkle in missing epochs (NaN), a sentinel mask value, and some
+ # gross outliers for sigma clipping to catch.
+ x[rng.random((n_stars, n_epochs)) < 0.25] = np.nan
+ xe[np.isnan(x)] = np.nan
+ sentinel_mask = rng.random((n_stars, n_epochs)) < 0.05
+ x[sentinel_mask] = -100000
+ outlier_mask = rng.random((n_stars, n_epochs)) < 0.05
+ x[outlier_mask] += rng.choice([-1, 1], size=outlier_mask.sum()) * rng.uniform(50, 200, size=outlier_mask.sum())
+
+ # A few rows with zero, or exactly one, valid epoch -- edge cases for
+ # "no data" and "std of a single point."
+ x[0, :] = np.nan
+ xe[0, :] = np.nan
+ x[1, 1:] = np.nan
+ xe[1, 1:] = np.nan
+
+ t_weighted = Table({'x': x.copy(), 'xe': xe.copy()})
+ t_unweighted = Table({'x': x.copy()})
+
+ for use_weights, ismag, mask_lists, sigma in [
+ (True, False, None, 3),
+ (False, False, None, 3),
+ (True, True, None, 3),
+ (True, False, [2], 3),
+ (True, False, None, None),
+ ]:
+ t = t_weighted if use_weights else t_unweighted
+ kwargs = dict(mask_val=-100000, mask_lists=mask_lists, ismag=ismag, sigma=sigma)
+ if use_weights:
+ kwargs['weights_col'] = 'xe'
+
+ want_avg, want_std = _bruteforce_combine_lists(t, 'x', **kwargs)
+
+ t_copy = Table({k: t[k].copy() for k in t.colnames})
+ t_copy.__class__ = StarTable # combine_lists is a StarTable method
+ t_copy.combine_lists('x', **kwargs)
+ got_avg = np.asarray(t_copy['x0'])
+ got_std = np.asarray(t_copy['x0_err'])
+
+ np.testing.assert_allclose(got_avg, want_avg, rtol=1e-10, atol=1e-10, equal_nan=True,
+ err_msg=f"trial={trial} use_weights={use_weights} ismag={ismag} mask_lists={mask_lists} sigma={sigma}: avg mismatch")
+ np.testing.assert_allclose(got_std, want_std, rtol=1e-10, atol=1e-10, equal_nan=True,
+ err_msg=f"trial={trial} use_weights={use_weights} ismag={ismag} mask_lists={mask_lists} sigma={sigma}: std mismatch")
+
+
+def test_combine_lists_weight_fallback():
+ """
+ Regression test for StarTable.combine_lists()'s handling of stars whose
+ weighting column (e.g. 'xe'/'ye'/'me') is entirely invalid (inf) in
+ every epoch. The contract:
+ - if a star has at least one epoch with a real, finite weight, only
+ those epoch(s) are used (epochs with an invalid weight are simply
+ dropped, even if their raw value is finite) -- the reported error
+ is a real, finite propagated uncertainty.
+ - if a star has NO usable weight anywhere but does have at least one
+ finite raw value, the mean falls back to an (unweighted-in-spirit)
+ average of the valid value(s) -- but the reported error MUST be
+ exactly np.inf, never a fabricated finite number, since the true
+ uncertainty was never actually known. This is the exact bug that
+ motivated this refactor: a fake weight=1 fallback elsewhere in this
+ codebase once leaked a finite x0_err=1.0 into real output for
+ months, undetected.
+ - if a star has no valid raw value at all, the mean is nan and the
+ error is inf (nothing to fall back to).
+ - a column with no weights_col at all (the plain unweighted branch,
+ untouched by this refactor) still handles inf/nan correctly.
+
+ All expected numbers below were derived by hand (or, for the weighted
+ cases, via the same textbook inverse-variance formula the production
+ code implements: wgt = 1/err**2, avg = weighted mean, std =
+ sqrt(1/sum(wgt))) and cross-checked against the implementation before
+ being hardcoded here, so a future refactor that silently changes the
+ fallback's arithmetic (and not just its inf/nan-ness) will also be caught.
+ """
+ nan, inf = np.nan, np.inf
+
+ ##########
+ # Non-magnitude column ('x'/'xe'), one star per case, sigma clipping
+ # disabled so every number below is exact (not subject to outlier
+ # rejection on tiny synthetic rows).
+ ##########
+ names = np.array(['case1_baseline', 'case2_partial', 'case3a_fallback_single',
+ 'case3b_fallback_multi', 'case4_no_data', 'case5_composite'])
+
+ # case1_baseline: every epoch has a valid value AND a valid weight --
+ # sanity check that normal weighted averaging is unaffected.
+ # case2_partial: epoch 1 has a finite raw value (999) but an inf weight
+ # -- it must be excluded, leaving only epochs 0, 2, 3 to average, with a
+ # real (finite) propagated error.
+ # case3a_fallback_single: only epoch 0 has a finite value; every weight
+ # is inf. Falls back to that single value; error must be exactly inf.
+ # case3b_fallback_multi: epochs 0, 1 have finite values (5, 9); every
+ # weight is inf. Falls back to the unweighted mean of the two valid
+ # values (7.0); error must be exactly inf.
+ # case4_no_data: no valid value anywhere and no usable weight -- nothing
+ # to fall back to, so mean is nan and error is inf.
+ # case5_composite: combines four different conditions in one row --
+ # epoch 0 is an invalid (nan) value with a valid-looking weight, epoch 1
+ # is a valid value with an inf (unusable) weight, epoch 2 is a valid
+ # value with a real, usable weight, epoch 3 is an invalid (inf) value
+ # with a valid-looking weight. Since epoch 2 gives this star a real,
+ # non-zero weight sum, this is NOT a fallback star -- it should reduce
+ # to the ordinary weighted case using only epoch 2.
+ x = np.array([
+ [10., 20., 30., 40.],
+ [10., 999., 20., 30.],
+ [7., nan, nan, nan],
+ [5., 9., nan, nan],
+ [nan, nan, nan, nan],
+ [nan, 50., 60., inf],
+ ])
+ xe = np.array([
+ [1., 2., 3., 4.],
+ [1., inf, 2., 3.],
+ [inf, inf, inf, inf],
+ [inf, inf, inf, inf],
+ [inf, inf, inf, inf],
+ [0.5, inf, 1.0, nan],
+ ])
+
+ t = StarTable(name=names, x=x.copy(), y=x.copy(), m=np.ones_like(x),
+ xe=xe.copy(), ye=xe.copy())
+ t.combine_lists('x', weights_col='xe', sigma=None)
+
+ i1, i2, i3a, i3b, i4, i5 = range(6)
+
+ # Case 1: baseline, all weights valid -- ordinary weighted average.
+ wgt1 = 1. / xe[i1]**2
+ avg1 = np.average(x[i1], weights=wgt1)
+ std1 = np.sqrt(1. / wgt1.sum())
+ np.testing.assert_allclose(t['x0'][i1], avg1, rtol=1e-12)
+ np.testing.assert_allclose(t['x0_err'][i1], std1, rtol=1e-12)
+ assert np.isfinite(t['x0_err'][i1])
+
+ # Case 2: epoch 1 (value 999, weight inf) must be excluded -- average
+ # matches using only the epochs with a real, finite weight (0, 2, 3),
+ # and the error is finite (real weight info exists), not inf.
+ idx2 = [0, 2, 3]
+ wgt2 = 1. / xe[i2][idx2]**2
+ avg2 = np.average(x[i2][idx2], weights=wgt2)
+ std2 = np.sqrt(1. / wgt2.sum())
+ np.testing.assert_allclose(t['x0'][i2], avg2, rtol=1e-12)
+ np.testing.assert_allclose(t['x0_err'][i2], std2, rtol=1e-12)
+ assert np.isfinite(t['x0_err'][i2])
+ assert not np.isinf(t['x0_err'][i2])
+
+ # Case 3a: single valid value, all weights inf -- fallback mean is just
+ # that one value; error must be EXACTLY inf (not merely large).
+ assert t['x0'][i3a] == 7.0
+ assert t['x0_err'][i3a] == np.inf
+ assert np.isinf(t['x0_err'][i3a])
+
+ # Case 3b: two valid values (5, 9), all weights inf -- fallback mean is
+ # their plain (unweighted) average, 7.0; error must be EXACTLY inf.
+ # This is the core regression case for today's fix.
+ assert t['x0'][i3b] == pytest.approx(7.0)
+ assert t['x0_err'][i3b] == np.inf
+ assert np.isinf(t['x0_err'][i3b])
+
+ # Case 4: no valid value anywhere -- mean is nan, error is inf.
+ assert np.isnan(t['x0'][i4])
+ assert t['x0_err'][i4] == np.inf
+
+ # Case 5: composite row -- only epoch 2 (value 60, weight 1.0) carries
+ # real weight, so the star reduces to an ordinary weighted case using
+ # only that epoch, exactly as if epochs 0, 1, 3 didn't exist.
+ assert t['x0'][i5] == pytest.approx(60.0)
+ assert t['x0_err'][i5] == pytest.approx(1.0)
+ assert np.isfinite(t['x0_err'][i5])
+
+ ##########
+ # Magnitude column ('m'/'me', ismag=True) -- same fallback contract, but
+ # exercised through the flux-space conversion pipeline.
+ ##########
+ m_names = np.array(['mag_baseline', 'mag_fallback_single', 'mag_fallback_multi'])
+ m_vals = np.array([
+ [10., 12., 14.],
+ [15., nan, nan],
+ [12.0, 14.0, nan],
+ ])
+ m_errs = np.array([
+ [0.05, 0.1, 0.2],
+ [inf, inf, inf],
+ [inf, inf, inf],
+ ])
+ tm = StarTable(name=m_names, x=np.ones_like(m_vals), y=np.ones_like(m_vals),
+ m=m_vals.copy(), me=m_errs.copy())
+ tm.combine_lists('m', weights_col='me', ismag=True, sigma=None)
+
+ # mag_baseline: every epoch has a valid value and a valid error -- the
+ # refactor must not have changed ordinary weighted-in-flux averaging.
+ val_flux = 10**(-0.4 * m_vals[0])
+ err_flux = 0.4 * np.log(10) * val_flux * m_errs[0]
+ wgt = 1. / err_flux**2
+ avg_flux = np.average(val_flux, weights=wgt)
+ std_flux = np.sqrt(1. / wgt.sum())
+ avg_mag = -2.5 * np.log10(avg_flux)
+ std_mag = 2.5 / np.log(10) * std_flux / avg_flux
+ np.testing.assert_allclose(tm['m0'][0], avg_mag, rtol=1e-10)
+ np.testing.assert_allclose(tm['m0_err'][0], std_mag, rtol=1e-10)
+ assert np.isfinite(tm['m0_err'][0])
+
+ # mag_fallback_single: one valid magnitude (15.0), every weight inf --
+ # fallback mean is that value; error must be EXACTLY inf.
+ np.testing.assert_allclose(tm['m0'][1], 15.0, rtol=1e-10)
+ assert tm['m0_err'][1] == np.inf
+
+ # mag_fallback_multi: two DIFFERENT valid magnitudes (12.0, 14.0), every
+ # weight inf. Averaging magnitudes is physically a flux-space average,
+ # not a plain arithmetic mean of the mag values themselves -- so
+ # independently reproduce that here (a plain, equally-weighted mean of
+ # the *flux* values, since that's the space val_2d is already in when
+ # ismag=True) and require flystar's result to match it, rather than
+ # asserting some simpler (and wrong) unweighted-in-mag-space expectation.
+ flux2 = 10**(-0.4 * m_vals[2, :2])
+ avg_flux2 = flux2.mean()
+ avg_mag2 = -2.5 * np.log10(avg_flux2)
+ np.testing.assert_allclose(tm['m0'][2], avg_mag2, rtol=1e-10)
+ assert tm['m0_err'][2] == np.inf
+
+ ##########
+ # No weights_col at all -- the plain unweighted branch, untouched by
+ # this refactor, but still deserving direct inf/nan regression coverage.
+ ##########
+ names_uw = np.array(['one_nan_two_valid', 'all_nan'])
+ x_uw = np.array([
+ [10., nan, 30.],
+ [nan, nan, nan],
+ ])
+ t_uw = StarTable(name=names_uw, x=x_uw.copy(), y=x_uw.copy(), m=np.ones_like(x_uw))
+ t_uw.combine_lists('x', sigma=None)
+
+ # One nan among three epochs -- mean and std computed from the two
+ # valid values only (10, 30): mean 20, population std of residuals 10.
+ assert t_uw['x0'][0] == pytest.approx(20.0)
+ assert t_uw['x0_err'][0] == pytest.approx(10.0)
+ assert t_uw.meta['x0'] == 'not_weighted'
+
+ # All epochs nan -- nothing to average; mean nan, error inf.
+ assert np.isnan(t_uw['x0'][1])
+ assert t_uw['x0_err'][1] == np.inf
+
+ return
+
+
def test_add_starlist():
"""
Test the startables.combine_lists() functionality.
@@ -168,78 +574,79 @@ def test_add_starlist():
t.add_starlist(x=x_new, y=y_new, m=m_new, xe=xe_new, ye=ye_new, me=me_new,
meta={'list_times': t_new})
- assert len(t) == len(t_orig)
+ np.testing.assert_equal(len(t), len(t_orig))
expected_shape = np.array(t_orig['x'].shape)
expected_shape[1] += 1
-
- assert len(t['x'].shape) == len(expected_shape)
- assert t['x'].shape[0] == expected_shape[0]
+
+ np.testing.assert_equal(len(t['x'].shape), len(expected_shape))
+ np.testing.assert_equal(t['x'].shape[0], expected_shape[0])
assert t['x'].shape[1] == expected_shape[1]
- assert len(t['y'].shape) == len(expected_shape)
- assert t['y'].shape[0] == expected_shape[0]
+ np.testing.assert_equal(len(t['y'].shape), len(expected_shape))
+ np.testing.assert_equal(t['y'].shape[0], expected_shape[0])
assert t['y'].shape[1] == expected_shape[1]
- assert len(t['m'].shape) == len(expected_shape)
- assert t['m'].shape[0] == expected_shape[0]
+ np.testing.assert_equal(len(t['m'].shape), len(expected_shape))
+ np.testing.assert_equal(t['m'].shape[0], expected_shape[0])
assert t['m'].shape[1] == expected_shape[1]
- assert len(t['xe'].shape) == len(expected_shape)
- assert t['xe'].shape[0] == expected_shape[0]
- assert t['xe'].shape[1] == expected_shape[1]
+ np.testing.assert_equal(len(t['xe'].shape), len(expected_shape))
+ np.testing.assert_equal(t['xe'].shape[0], expected_shape[0])
+ np.testing.assert_equal(t['xe'].shape[1], expected_shape[1])
- assert len(t['ye'].shape) == len(expected_shape)
- assert t['ye'].shape[0] == expected_shape[0]
- assert t['ye'].shape[1] == expected_shape[1]
-
- assert len(t['me'].shape) == len(expected_shape)
- assert t['me'].shape[0] == expected_shape[0]
- assert t['me'].shape[1] == expected_shape[1]
-
- assert len(t['name']) == len(t_orig['name'])
- assert len(t.meta['list_times']) == expected_shape[1]
- assert t.meta['n_lists'] == 9
+ np.testing.assert_equal(len(t['ye'].shape), len(expected_shape))
+ np.testing.assert_equal(t['ye'].shape[0], expected_shape[0])
+ np.testing.assert_equal(t['ye'].shape[1], expected_shape[1])
+ np.testing.assert_equal(len(t['me'].shape), len(expected_shape))
+ np.testing.assert_equal(t['me'].shape[0], expected_shape[0])
+ np.testing.assert_equal(t['me'].shape[1], expected_shape[1])
+ np.testing.assert_equal(len(t['name']), len(t_orig['name']))
+ np.testing.assert_equal(len(t.meta['list_times']), expected_shape[1])
+ np.testing.assert_equal(t.meta['n_lists'], 9)
# Test 2: Add as starlist rather than with keywords.
- starlist = StarList(name=t_orig['name'], x=x_new, y=y_new, m=m_new,
- xe=xe_new, ye=ye_new, me=me_new, list_time=2001.0, list_name='A.lis')
+ starlist = StarList(
+ name=t_orig['name'],
+ x=x_new, y=y_new, m=m_new,
+ xe=xe_new, ye=ye_new, me=me_new,
+ list_time=2001.0, list_name='A.lis'
+ )
t = make_star_table()
t.add_starlist(starlist=starlist)
- assert len(t) == len(t_orig)
+ np.testing.assert_equal(len(t), len(t_orig))
expected_shape = np.array(t_orig['x'].shape)
expected_shape[1] += 1
-
- assert len(t['x'].shape) == len(expected_shape)
- assert t['x'].shape[0] == expected_shape[0]
- assert t['x'].shape[1] == expected_shape[1]
- assert len(t['y'].shape) == len(expected_shape)
- assert t['y'].shape[0] == expected_shape[0]
- assert t['y'].shape[1] == expected_shape[1]
+ np.testing.assert_equal(len(t['x'].shape), len(expected_shape))
+ np.testing.assert_equal(t['x'].shape[0], expected_shape[0])
+ np.testing.assert_equal(t['x'].shape[1], expected_shape[1])
- assert len(t['m'].shape) == len(expected_shape)
- assert t['m'].shape[0] == expected_shape[0]
- assert t['m'].shape[1] == expected_shape[1]
+ np.testing.assert_equal(len(t['y'].shape), len(expected_shape))
+ np.testing.assert_equal(t['y'].shape[0], expected_shape[0])
+ np.testing.assert_equal(t['y'].shape[1], expected_shape[1])
- assert len(t['xe'].shape) == len(expected_shape)
- assert t['xe'].shape[0] == expected_shape[0]
- assert t['xe'].shape[1] == expected_shape[1]
+ np.testing.assert_equal(len(t['m'].shape), len(expected_shape))
+ np.testing.assert_equal(t['m'].shape[0], expected_shape[0])
+ np.testing.assert_equal(t['m'].shape[1], expected_shape[1])
- assert len(t['ye'].shape) == len(expected_shape)
- assert t['ye'].shape[0] == expected_shape[0]
- assert t['ye'].shape[1] == expected_shape[1]
+ np.testing.assert_equal(len(t['xe'].shape), len(expected_shape))
+ np.testing.assert_equal(t['xe'].shape[0], expected_shape[0])
+ np.testing.assert_equal(t['xe'].shape[1], expected_shape[1])
+ np.testing.assert_equal(len(t['ye'].shape), len(expected_shape))
+ np.testing.assert_equal(t['ye'].shape[0], expected_shape[0])
+ np.testing.assert_equal(t['ye'].shape[1], expected_shape[1])
- assert len(t['me'].shape) == len(expected_shape)
- assert t['me'].shape[0] == expected_shape[0]
- assert t['me'].shape[1] == expected_shape[1]
+ np.testing.assert_equal(len(t['me'].shape), len(expected_shape))
+ np.testing.assert_equal(t['me'].shape[0], expected_shape[0])
+ np.testing.assert_equal(t['me'].shape[1], expected_shape[1])
- assert len(t['name']) == len(t_orig['name'])
- assert len(t.meta['list_times']) == expected_shape[1]
- assert t.meta['n_lists'] == 9
+ np.testing.assert_equal(len(t['name']), len(t_orig['name']))
+ np.testing.assert_equal(len(t.meta['list_times']), expected_shape[1])
+ np.testing.assert_equal(t.meta['n_lists'], 9)
return
@@ -255,13 +662,13 @@ def test_get_starlist():
assert t['x'][0,2] == t_list['x'][0]
assert type(t_list) == StarList
assert len(t_list['x'].shape) == 1
-
+
return
def test_combine_1col():
# User input
- cat_file = test_dir + '/test_catalog.fits'
+ cat_file = f'{test_data_path}/test_catalog.fits'
# Read and arrange the test input
cat_tab = Table.read(cat_file)
@@ -287,11 +694,11 @@ def test_combine_1col():
t.combine_lists('x', weights_col='xe')
- assert t['x0'][0] == t['x'][0]
+ np.testing.assert_equal(t['x0'][0], t['x'][0])
return
-def test_fit_velocities():
+def test_fit_motion_models():
tab = make_star_table()
tt = make_tiny_star_table()
@@ -303,155 +710,99 @@ def test_fit_velocities():
tab = table.vstack((tab1, tab2, tab3))
tab.meta = tab1.meta
- tab.fit_velocities(verbose=True)
+ tab.fit_motion_models(verbose=True, mask_value=-100000.)
# Test creation of new variables
- assert len(tab['vx']) == len(tab)
- assert len(tab['vy']) == len(tab)
- assert len(tab['vxe']) == len(tab)
- assert len(tab['vye']) == len(tab)
- assert len(tab['n_vfit']) == len(tab)
- assert tab.meta['n_vfit_bootstrap'] == 0
+ np.testing.assert_equal(len(tab['vx']), len(tab))
+ np.testing.assert_equal(len(tab['vy']), len(tab))
+ np.testing.assert_equal(len(tab['vx_err']), len(tab))
+ np.testing.assert_equal(len(tab['vy_err']), len(tab))
+ np.testing.assert_equal(len(tab['n_fit']), len(tab))
+ np.testing.assert_equal(tab.meta['n_bootstrap'], 0)
# Test no-fit for stars with N<2 epochs.
n_epochs = (tab['x'] >= 0).sum(axis=1)
idx = np.where(n_epochs < 2)[0]
- assert (tab['vx'][idx] == 0).all()
- assert (tab['vxe'][idx] == 0).all()
- assert (tab['n_vfit'][idx] == 2).all()
+ np.testing.assert_equal((tab['vx'][idx] == 0).all(), True)
+ np.testing.assert_equal((tab['vx_err'][idx] == 0).all(), True)
+ np.testing.assert_equal((tab['n_fit'][idx] == 2).all(), True)
# Test that the velocity errors were calculated.
- assert (tab['vxe'][0:100] > 0).all()
- assert (tab['x0e'][0:100] > 0).all()
- assert (tab['vye'][0:100] > 0).all()
- assert (tab['y0e'][0:100] > 0).all()
- assert np.isfinite(tab['x0']).all()
- assert np.isfinite(tab['vx']).all()
- assert np.isfinite(tab['y0']).all()
- assert np.isfinite(tab['vy']).all()
- assert np.isfinite(tab['x0e']).all()
- assert np.isfinite(tab['vxe']).all()
- assert np.isfinite(tab['y0e']).all()
- assert np.isfinite(tab['vye']).all()
+ np.testing.assert_equal((~(tab['vx_err'][0:100] < 0)).all(), True)
+ np.testing.assert_equal((~(tab['x0_err'][0:100] < 0)).all(), True)
+ np.testing.assert_equal((~(tab['vy_err'][0:100] < 0)).all(), True)
+ np.testing.assert_equal((~(tab['y0_err'][0:100] < 0)).all(), True)
##########
# Test running a second time. We should get the same results.
##########
vx_orig = tab['vx']
x0_orig = tab['x0']
- vxe_orig = tab['vxe']
- x0e_orig = tab['x0e']
- tab.fit_velocities(verbose=False)
+ vxe_orig = tab['vx_err']
+ x0e_orig = tab['x0_err']
+ tab.fit_motion_models(verbose=False, mask_value=-100000.)
- assert (vx_orig == tab['vx']).all()
- assert (x0_orig == tab['x0']).all()
- assert (vxe_orig == tab['vxe']).all()
- assert (x0e_orig == tab['x0e']).all()
+ np.testing.assert_allclose(tab['vx'], vx_orig)
+ np.testing.assert_allclose(tab['x0'], x0_orig)
+ np.testing.assert_allclose(tab['vx_err'], vxe_orig)
+ np.testing.assert_allclose(tab['x0_err'], x0e_orig)
##########
# Test fixed_t0 functionality
##########
fixed_t0 = tab['t0'] + np.random.normal(size=len(tab))
- tab.fit_velocities(fixed_t0=fixed_t0)
-
- assert(np.sum(abs(tab['t0'] - fixed_t0)) == 0)
+ tab.fit_motion_models(verbose=False, mask_value=-100000., fixed_params_dict={'t0': fixed_t0})
+ np.testing.assert_allclose(tab['t0'], fixed_t0)
##########
# Test bootstrap
##########
tab_b = table.vstack((tab1, tab2, tab3))
tab_b.meta = tab1.meta
- tab_b.fit_velocities(verbose=True, bootstrap=50)
-
- assert tab_b.meta['n_vfit_bootstrap'] == 50
- assert tab_b['x0e'][0] > tab['x0e'][0]
- assert tab_b['vxe'][0] > tab['vxe'][0]
- assert tab_b['y0e'][0] > tab['y0e'][0]
- assert tab_b['vye'][0] > tab['vye'][0]
+ tab_b.fit_motion_models(verbose=True, bootstrap=50)
+
+ np.testing.assert_equal(tab_b.meta['n_bootstrap'], 50)
+ np.testing.assert_array_less(tab['x0_err'][0], tab_b['x0_err'][0])
+ np.testing.assert_array_less(tab['vx_err'][0], tab_b['vx_err'][0])
+ np.testing.assert_array_less(tab['y0_err'][0], tab_b['y0_err'][0])
+ np.testing.assert_array_less(tab['vy_err'][0], tab_b['vy_err'][0])
##########
# Test what happens with no velocity errors
##########
- tab.remove_columns(['xe', 'ye', 'x0', 'y0', 'x0e', 'y0e', 'vx', 'vy', 'vxe', 'vye', 'n_vfit'])
- tab.fit_velocities(verbose=False)
-
- assert len(tab['vx']) == len(tab)
- assert len(tab['vy']) == len(tab)
- assert len(tab['vxe']) == len(tab)
- assert len(tab['vye']) == len(tab)
- assert len(tab['n_vfit']) == len(tab)
- assert (tab['vxe'][0:100] > 0).all()
- assert (tab['x0e'][0:100] > 0).all()
- assert (tab['vye'][0:100] > 0).all()
- assert (tab['y0e'][0:100] > 0).all()
+ tab.remove_columns(['xe', 'ye', 'x0', 'y0', 'x0_err', 'y0_err', 'vx', 'vy', 'vx_err', 'vy_err', 'n_fit'])
+ tab.fit_motion_models(verbose=False)
+
+ np.testing.assert_equal(len(tab['vx']), len(tab))
+ np.testing.assert_equal(len(tab['vy']), len(tab))
+ np.testing.assert_equal(len(tab['vx_err']), len(tab))
+ np.testing.assert_equal(len(tab['vy_err']), len(tab))
+ np.testing.assert_equal(len(tab['n_fit']), len(tab))
+ np.testing.assert_equal((~(tab['vx_err'][0:100] < 0)).all(), True)
+ np.testing.assert_equal((~(tab['x0_err'][0:100] < 0)).all(), True)
+ np.testing.assert_equal((~(tab['vy_err'][0:100] < 0)).all(), True)
+ np.testing.assert_equal((~(tab['y0_err'][0:100] < 0)).all(), True)
#########
# Test mask_list
#########
# Test 5a: Masked
- tt.fit_velocities(bootstrap=0, verbose=False, mask_lists=[1])
- assert np.arange(2.25, 48, 5) == pytest.approx(tt['x0'].data)
- assert np.arange(2.25, 48, 5) == pytest.approx(tt['y0'].data)
- assert np.zeros(10) == pytest.approx(tt['x0e'].data)
- assert np.zeros(10) == pytest.approx(tt['y0e'].data)
- assert np.ones(10) == pytest.approx(tt['vx'].data)
- assert np.ones(10) == pytest.approx(tt['vy'].data)
- assert np.zeros(10) == pytest.approx(tt['vxe'].data)
- assert np.zeros(10) == pytest.approx(tt['vye'].data)
- assert 2017.25 * np.ones(10) == pytest.approx(tt['t0'].data)
-
- # Test 5b: Things that should break the code.
- with pytest.raises(RuntimeError):
- tt.fit_velocities(bootstrap=0, verbose=False, mask_lists=np.arange(2))
- with pytest.raises(RuntimeError):
- tt.fit_velocities(bootstrap=0, verbose=False, mask_lists=True)
+ print("Testing Masked List")
+ tt.fit_motion_models(verbose=False, mask_lists=[1])
+ np.testing.assert_allclose(np.arange(2.25, 48, 5), tt['x0'].data)
+ np.testing.assert_allclose(np.arange(2.25, 48, 5), tt['y0'].data)
+ np.testing.assert_allclose(np.full(10, 0.05), tt['x0_err'].data)
+ np.testing.assert_allclose(np.full(10, 0.05), tt['y0_err'].data)
+ np.testing.assert_allclose(np.ones(10), tt['vx'].data)
+ np.testing.assert_allclose(np.ones(10), tt['vy'].data)
+ np.testing.assert_allclose(np.full(10, 0.03380617), tt['vx_err'].data)
+ np.testing.assert_allclose(np.full(10, 0.03380617), tt['vy_err'].data)
+ np.testing.assert_allclose(2017.25 * np.ones(10), tt['t0'].data)
return
-def test_fit_velocities_1epoch():
- ##########
- # Test: only 1 epoch
- ##########
- tab = make_star_table_1epoch()
-
- # We don't need the entire table... lets just
- # pull a small subset for faster testing.
- tab1 = tab[0:100]
- tab2 = tab[10000:10100]
- tab3 = tab[-100:]
- tab_1 = table.vstack((tab1, tab2, tab3))
-
- tab_1.fit_velocities(verbose=False)
-
- assert 'n_vfit' in tab_1.colnames
- assert 't0' in tab_1.colnames
- assert 'x0' in tab_1.colnames
- assert 'y0' in tab_1.colnames
- assert 'vx' in tab_1.colnames
- assert 'vy' in tab_1.colnames
- assert 'x0e' in tab_1.colnames
- assert 'y0e' in tab_1.colnames
- assert 'vxe' in tab_1.colnames
- assert 'vye' in tab_1.colnames
-
-
- assert (tab_1['x0'] == tab_1['x'][:,0]).all()
- assert (tab_1['y0'] == tab_1['y'][:,0]).all()
- assert (tab_1['x0e'] == tab_1['xe'][:,0]).all()
- assert (tab_1['y0e'] == tab_1['ye'][:,0]).all()
-
- assert(tab_1['vx'] == 0).all()
- assert(tab_1['vy'] == 0).all()
- assert(tab_1['vxe'] == 0).all()
- assert(tab_1['vye'] == 0).all()
-
- assert(tab_1['t0'] == 2001.0).all()
- assert(tab_1['n_vfit'] == 1).all()
-
- return
-def test_fit_velocities_2epoch():
-
+def test_fit_motion_model_2epoch():
##########
# Test: only 2 epoch2
##########
@@ -463,37 +814,91 @@ def test_fit_velocities_2epoch():
tab2 = tab[10000:10100]
tab3 = tab[-100:]
tab_2 = table.vstack((tab1, tab2, tab3))
+ tab_2.meta=tab1.meta
- tab_2.fit_velocities(verbose=False)
+ tab_2.fit_motion_models(verbose=False, mask_value=-100000.)
- assert 'n_vfit' in tab_2.colnames
- assert 't0' in tab_2.colnames
- assert 'x0' in tab_2.colnames
- assert 'y0' in tab_2.colnames
- assert 'vx' in tab_2.colnames
- assert 'vy' in tab_2.colnames
- assert 'x0e' in tab_2.colnames
- assert 'y0e' in tab_2.colnames
- assert 'vxe' in tab_2.colnames
- assert 'vye' in tab_2.colnames
+ assert all([_ in tab_2.colnames for _ in ['n_fit', 't0', 'x0', 'y0', 'vx', 'vy', 'x0_err', 'y0_err', 'vx_err', 'vy_err']])
# 2 detections
+ print(tab1.meta)
np.testing.assert_almost_equal(tab_2['x0'][0], tab_2['x'][0,0], 1)
- assert tab_2['n_vfit'][0] == 2
-
+ np.testing.assert_equal(tab_2['n_fit'][0], 2)
+
# 1 detection
- assert tab_2['x0'][100] == tab_2['x'][100, 0]
- assert tab_2['n_vfit'][100] == 1
-
+ np.testing.assert_equal(tab_2['x0'][100], tab_2['x'][100, 0])
+ np.testing.assert_equal(tab_2['n_fit'][100], 1)
+
# 0 detections
- assert tab_2['x0'][-1] == 0
- assert tab_2['n_vfit'][-1] == 0
-
+ np.testing.assert_equal(np.isnan(tab_2['x0'][-1]), True)
+ np.testing.assert_equal(tab_2['n_fit'][-1], 0)
+
+ return
+
+
+def test_multiprocessing():
+ rng = np.random.default_rng(42)
+ N = 10000
+ x = rng.random((N, 5))
+ y = rng.random((N, 5))
+ m = rng.random((N, 5))
+ xe = rng.random((N, 5))
+ ye = rng.random((N, 5))
+ t = np.arange(5) + 2026
+ fixed_params_dict = [None for _ in range(N)]
+ weighting = 'var'
+ fill_value = np.nan
+ verbose = True
+
+ st1 = StarTable(
+ name=np.arange(N),
+ x=x,
+ y=y,
+ m=m,
+ xe=xe,
+ ye=ye
+ )
+ st1.meta['list_times'] = t
+
+ st2 = StarTable(
+ name=np.arange(N),
+ x=x,
+ y=y,
+ m=m,
+ xe=xe,
+ ye=ye
+ )
+ st2.meta['list_times'] = t
+
+ st1.fit_motion_models(
+ motion_models=['Linear'],
+ weighting=weighting,
+ use_scipy=True,
+ absolute_sigma=True,
+ bootstrap=0,
+ fill_value=fill_value,
+ verbose=verbose
+ )
+
+ st2.fit_motion_models(
+ motion_models=['Linear'],
+ weighting=weighting,
+ use_scipy=True,
+ absolute_sigma=True,
+ bootstrap=0,
+ fill_value=fill_value,
+ processes=10,
+ verbose=verbose
+ )
+
+ for key in ['x0', 'x0_err', 'y0', 'y0_err', 'vx', 'vx_err', 'vy', 'vy_err', 'chi2_x', 'chi2_y', 'n_params', 't0']:
+ np.testing.assert_array_equal(st1[key], st2[key], err_msg=f"Mismatch in {key} between single and multi-processing runs.")
return
+
def make_star_table():
# User input
- cat_file = test_dir + '/test_catalog.fits'
+ cat_file = f'{test_data_path}/test_catalog.fits'
# Read and arrange the test input
cat_tab = Table.read(cat_file)
@@ -514,15 +919,21 @@ def make_star_table():
starlist_names = np.array(['file1', 'file2', 'file3', 'file4', 'file5', 'file6', 'file7', 'file8'])
# Generate the startable
- startable = StarTable(name=name_in, x=x_in, y=y_in, m=m_in, xe=xe_in, ye=ye_in, me=me_in, n=n_in,
- ref_list=1,
- list_times=starlist_times, list_names=starlist_names)
+ startable = StarTable(
+ name=name_in,
+ x=x_in, y=y_in, m=m_in,
+ xe=xe_in, ye=ye_in, me=me_in,
+ n=n_in,
+ ref_list=1
+ )
+ startable.meta['list_times'] = starlist_times
+ startable.meta['list_names'] = starlist_names
return startable
def make_star_table_1epoch():
# User input
- cat_file = test_dir + '/test_catalog.fits'
+ cat_file = f'{test_data_path}/test_catalog.fits'
# Read and arrange the test input
cat_tab = Table.read(cat_file)
@@ -550,8 +961,8 @@ def make_star_table_1epoch():
return startable
def make_star_table_2epoch():
- # User inpup
- cat_file = test_dir + '/test_catalog.fits'
+ # User input
+ cat_file = f'{test_data_path}/test_catalog.fits'
# Read and arrange the test input
cat_tab = Table.read(cat_file)
@@ -605,3 +1016,7 @@ def make_tiny_star_table():
xe=xe_in, ye=ye_in, me=me_in)
return startable
+
+
+if __name__ == "__main__":
+ test_combine_lists()
\ No newline at end of file
diff --git a/flystar/tests/test_transforms.py b/flystar/tests/test_transforms.py
index ea7c423..11338ad 100644
--- a/flystar/tests/test_transforms.py
+++ b/flystar/tests/test_transforms.py
@@ -22,9 +22,9 @@ def compare_evaluate_errors():
xe = np.abs(np.random.randn(100) * 0.1)
ye = np.abs(np.random.randn(100) * 0.1)
- xe_new1 = foo._evaluate_error2(x, y, xe, ye, foo.px.parameters)
+ # xe_new1 = foo._evaluate_error2(x, y, xe, ye, foo.px.parameters)
- xe_new2, ye_new2 = foo._evaluate_error(x, y, xe, ye)
+ xe_new2, ye_new2 = foo.evaluate_error(x, y, xe, ye)
# BROKEN
diff --git a/flystar/transforms.py b/flystar/transforms.py
index 0a1885a..bdf8cb3 100755
--- a/flystar/transforms.py
+++ b/flystar/transforms.py
@@ -1,11 +1,14 @@
-from astropy.modeling import models, fitting
+import os
+import re
+import copy
+import datetime
import numpy as np
-from scipy.interpolate import LSQBivariateSpline as spline
-from scipy import stats
-from astropy.table import Table
import collections
-import re
-import pdb
+from flystar import motion_model
+from astropy.table import Table
+from astropy.modeling import models, fitting
+from scipy import stats
+from scipy.interpolate import LSQBivariateSpline as spline
class Transform2D(object):
'''
@@ -112,21 +115,39 @@ def evaluate_starlist(self, star_list):
new_list['xe'] = vals[0]
new_list['ye'] = vals[1]
- # Velocities (if they exist)
- if 'vx' in new_list.colnames:
+ # Velocities (if they exist and no more complex motion model used)
+ complex_motion_model = ('motion_model_input' in new_list.colnames)
+ if complex_motion_model:
+ # If the only motion models used are Fixed and Linear, we can still transform velocities.
+ motion_models_unique = list(np.unique(starlist_f['motion_model_input']))
+ if 'Linear' in motion_models_unique:
+ motion_models_unique.remove('Linear')
+ if 'Fixed' in motion_models_unique:
+ motion_models_unique.remove('Fixed')
+ if len(motion_models_unique)==0:
+ complex_motion_model=False
+ # Cannot transform more complex motion models - set values to nan
+ if complex_motion_model:
+ motion_params = motion_model.motion_model_param_names(new_list['motion_model_input'], with_errors=True, with_fixed=False)
+ for param in motion_params:
+ if param in new_list.colnames:
+ new_list[param] = np.nan
+
+ if ('vx' in new_list.colnames) and (not complex_motion_model):
+ # For velocity only, no problem
vals = self.evaluate_vel(star_list['x'], star_list['y'],
star_list['vx'], star_list['vy'])
new_list['vx'] = vals[0]
new_list['vy'] = vals[1]
# Velocity errors (if they exist)
- if 'vxe' in new_list.colnames:
+ if 'vx_err' in new_list.colnames:
vals = self.evaluate_vel_error(star_list['x'], star_list['y'],
star_list['vx'], star_list['vy'],
star_list['xe'], star_list['ye'],
- star_list['vxe'], star_list['vye'])
- new_list['vxe'] = vals[0]
- new_list['vye'] = vals[1]
+ star_list['vx_err'], star_list['vy_err'])
+ new_list['vx_err'] = vals[0]
+ new_list['vy_err'] = vals[1]
return new_list
@@ -201,7 +222,7 @@ def evaluate(self, x, y):
yn = self.py[0] + self.py[1]*x + self.py[2]*y
return xn, yn
- def evaluate_error(self, x, y):
+ def evaluate_error(self, x, y, xe, ye):
"""
Transform positional uncertainties.
@@ -226,7 +247,7 @@ def evaluate_error(self, x, y):
"""
xe_new = np.hypot(self.px[1] * xe, self.px[2] * ye)
- xe_new = np.hpyot(self.px[1] * xe, self.px[2] * ye)
+ ye_new = np.hpyot(self.px[1] * xe, self.px[2] * ye)
return xe_new, ye_new
@@ -254,14 +275,14 @@ def __init__(self, order, px, py, pxerr=None, pyerr=None, mag_offset=0.0):
Parameters
----------
- px : list or array [a0, a1, a2, ...]
+ order : int
+ The order of the transformation. 0 = 2 free parameters, 1 = 6 free parameters.
+
+ px : list or array [a0, a1, a2, ...]
coefficients to transform input x coordinates into output x' coordinates.
py : list or array [b0, b1, b2, ...]
coefficients to transform input y coordinates into output y' coordinates.
-
- order : int
- The order of the transformation. 0 = 2 free parameters, 1 = 6 free parameters.
pxerr : array or list
array or list of errors of the coefficients to transform input x coordinates
@@ -288,7 +309,7 @@ def __init__(self, order, px, py, pxerr=None, pyerr=None, mag_offset=0.0):
px_dict = PolyTransform.make_param_dict(px, self.poly_order, isY=False)
py_dict = PolyTransform.make_param_dict(py, self.poly_order, isY=True)
- fixed_params = {'c0_0': False, 'c1_0': True, 'c1_1': True}
+ fixed_params = {'c0_0': False, 'c1_0': True, 'c0_1': True} #, 'c1_1':True}
self.px = models.Polynomial2D(self.poly_order, **px_dict, fixed=fixed_params)
self.py = models.Polynomial2D(self.poly_order, **py_dict, fixed=fixed_params)
else:
@@ -312,7 +333,7 @@ def make_param_dict(initial_param, order, isY=False):
a0 + a1*x + a2*y + a3*x^2 + a4*x*y + a5*y^2 + a6*x^3 + a7*x^2*y + a8*x*y^2 + a9*y^3
- and conver this into a dictionary where:
+ and convert this into a dictionary where:
c0_0 = a0
c1_0 = a1
@@ -580,7 +601,7 @@ def derive_transform(cls, x, y, xref, yref, order, m=None, mref=None,
init_gx = PolyTransform.make_param_dict(init_gx, poly_order, isY=False)
init_gy = PolyTransform.make_param_dict(init_gy, poly_order, isY=True)
- fixed_params = {'c0_0': False, 'c1_0': True, 'c1_1': True, 'c0_1': True}
+ fixed_params = {'c0_0': False, 'c1_0': True, 'c0_1': True} #, 'c1_1':True}
p_init_x = models.Polynomial2D(poly_order, **init_gx, fixed=fixed_params)
p_init_y = models.Polynomial2D(poly_order, **init_gy, fixed=fixed_params)
else:
@@ -592,6 +613,7 @@ def derive_transform(cls, x, y, xref, yref, order, m=None, mref=None,
fit_p = fitting.LinearLSQFitter()
+ #pdb.set_trace()
px = fit_p(p_init_x, x, y, xref, weights=weights)
py = fit_p(p_init_y, x, y, yref, weights=weights)
@@ -646,7 +668,7 @@ def from_file(cls, trans_file):
return trans_obj
- def to_file(self, trans_file):
+ def to_file(self, transform, outFile):
"""
Given a transformation object, write out the coefficients in a text file
(readable by java align). Outfile name is specified by user.
@@ -657,9 +679,9 @@ def to_file(self, trans_file):
Parameters:
----------
- trans_file : str
- The name of the output file to save the coefficients and meta data to.
- This file can be read back in with
+ transform : PolyTransform
+ The transformation object containing the coefficients and meta data to save.
+ This object can be recreated with
trans_obj = PolyTransfrom.from_file(trans_file).
@@ -675,7 +697,7 @@ def to_file(self, trans_file):
# Write output
_out = open(outFile, 'w')
-
+
# Write the header. DO NOT CHANGE, HARDCODED IN JAVA ALIGN
_out.write('## Date: {0}\n'.format(datetime.date.today()) )
_out.write('## File: {0}, Reference: {1}\n'.format(starlist, reference) )
diff --git a/pyproject.toml b/pyproject.toml
index 513457b..7700e98 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -5,9 +5,14 @@ readme = "README.rst"
authors = [{name="Jessica Lu", email="jlu.astro@berkeley.edu"},
{name="Matt Hosek", email="mwhosek@astro.ucla.edu"}]
license = {text="BSD 3-Clause License"}
-dependencies = ["numpy", "astropy>=3.2"]
-#dynamic = ["version"]
-version = "0.1"
+dependencies = ["numpy", "astropy>=3.2", "scipy", "matplotlib", "tqdm", "joblib", "pandas"]
+requires-python = ">=3.9"
+dynamic = ["version"]
+#version = "0.1"
+
+[project.optional-dependencies]
+docs = ["sphinx-astropy"]
+test = ["pytest-astropy"]
[project.urls]
homepage = "https://github.com/MovingUniverseLab/flystar"
@@ -15,9 +20,6 @@ homepage = "https://github.com/MovingUniverseLab/flystar"
[build-system]
requires = ["setuptools",
"setuptools_scm",
- "wheel",
- "extension-helpers",
- "oldest-supported-numpy",
- "cython==0.29.14"]
+ "wheel"]
build-backend = 'setuptools.build_meta'
diff --git a/setup.cfg b/setup.cfg
index 0bf235e..9bcfc97 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -9,7 +9,7 @@ description = FlyStar
long_description = file: README.rst
long_description_content_type = text/x-rst
edit_on_github = False
-github_project = astropy/astropy
+github_project = MovingUniverseLab/flystar
[options]
zip_safe = False
@@ -19,10 +19,6 @@ setup_requires = setuptools_scm
install_requires =
astropy
-[options.entry_points]
-console_scripts =
- astropy-package-template-example = packagename.example_mod:main
-
[options.extras_require]
test =
pytest-astropy
@@ -37,7 +33,7 @@ testpaths = "flystar" "docs"
astropy_header = true
doctest_plus = enabled
text_file_format = rst
-addopts = --doctest-rst
+#addopts = --doctest-rst
[coverage:run]
omit =