From 7a48a9e726d1112b960095dda2c88de40fc497e6 Mon Sep 17 00:00:00 2001 From: Mark Stephenson Date: Thu, 5 Sep 2024 17:16:40 -0600 Subject: [PATCH] Issue #177: Specify satellite property with function --- .../examples/satellite_configuration.ipynb | 372 ++++++++++-------- docs/source/release_notes.rst | 3 +- examples/satellite_configuration.ipynb | 33 +- src/bsk_rl/obs/observations.py | 28 +- tests/unittest/obs/test_observations.py | 9 + 5 files changed, 266 insertions(+), 179 deletions(-) diff --git a/docs/build/doctrees/nbsphinx/examples/satellite_configuration.ipynb b/docs/build/doctrees/nbsphinx/examples/satellite_configuration.ipynb index 49d92500..e25137a6 100644 --- a/docs/build/doctrees/nbsphinx/examples/satellite_configuration.ipynb +++ b/docs/build/doctrees/nbsphinx/examples/satellite_configuration.ipynb @@ -22,10 +22,10 @@ "execution_count": 1, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:40.882273Z", - "iopub.status.busy": "2024-07-24T21:34:40.882137Z", - "iopub.status.idle": "2024-07-24T21:34:41.786905Z", - "shell.execute_reply": "2024-07-24T21:34:41.786628Z" + "iopub.execute_input": "2024-09-05T23:14:01.779598Z", + "iopub.status.busy": "2024-09-05T23:14:01.779502Z", + "iopub.status.idle": "2024-09-05T23:14:02.701234Z", + "shell.execute_reply": "2024-09-05T23:14:02.700984Z" } }, "outputs": [], @@ -60,10 +60,10 @@ "execution_count": 2, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:41.788687Z", - "iopub.status.busy": "2024-07-24T21:34:41.788546Z", - "iopub.status.idle": "2024-07-24T21:34:41.792257Z", - "shell.execute_reply": "2024-07-24T21:34:41.792023Z" + "iopub.execute_input": "2024-09-05T23:14:02.703091Z", + "iopub.status.busy": "2024-09-05T23:14:02.702951Z", + "iopub.status.idle": "2024-09-05T23:14:02.706639Z", + "shell.execute_reply": "2024-09-05T23:14:02.706359Z" } }, "outputs": [ @@ -79,6 +79,7 @@ " 'K': 7.0,\n", " 'Ki': -1,\n", " 'P': 35.0,\n", + " 'utc_init': 'this value will be set by the world model',\n", " 'batteryStorageCapacity': 288000.0,\n", " 'storedCharge_Init': ()>,\n", " 'disturbance_vector': None,\n", @@ -92,7 +93,7 @@ " 'rwElecToMechEfficiency': 0.5,\n", " 'panelArea': 1.0,\n", " 'panelEfficiency': 0.2,\n", - " 'nHat_B': array([0, 1, 0]),\n", + " 'nHat_B': array([ 0, 0, -1]),\n", " 'mass': 330,\n", " 'width': 1.38,\n", " 'depth': 1.04,\n", @@ -128,10 +129,10 @@ "execution_count": 3, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:41.793560Z", - "iopub.status.busy": "2024-07-24T21:34:41.793468Z", - "iopub.status.idle": "2024-07-24T21:34:41.795325Z", - "shell.execute_reply": "2024-07-24T21:34:41.795107Z" + "iopub.execute_input": "2024-09-05T23:14:02.722844Z", + "iopub.status.busy": "2024-09-05T23:14:02.722743Z", + "iopub.status.idle": "2024-09-05T23:14:02.724798Z", + "shell.execute_reply": "2024-09-05T23:14:02.724548Z" } }, "outputs": [], @@ -157,10 +158,10 @@ "execution_count": 4, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:41.796629Z", - "iopub.status.busy": "2024-07-24T21:34:41.796543Z", - "iopub.status.idle": "2024-07-24T21:34:41.799108Z", - "shell.execute_reply": "2024-07-24T21:34:41.798858Z" + "iopub.execute_input": "2024-09-05T23:14:02.726090Z", + "iopub.status.busy": "2024-09-05T23:14:02.725999Z", + "iopub.status.idle": "2024-09-05T23:14:02.729346Z", + "shell.execute_reply": "2024-09-05T23:14:02.729121Z" } }, "outputs": [ @@ -176,12 +177,13 @@ " 'K': 7.0,\n", " 'Ki': -1,\n", " 'P': 35.0,\n", + " 'utc_init': 'this value will be set by the world model',\n", " 'batteryStorageCapacity': 288000.0,\n", - " 'storedCharge_Init': 123758.95341279234,\n", + " 'storedCharge_Init': 175814.5740879145,\n", " 'disturbance_vector': None,\n", - " 'dragCoeff': 2.3832155508538335,\n", + " 'dragCoeff': 2.3155383948829646,\n", " 'basePowerDraw': 0.0,\n", - " 'wheelSpeeds': array([-1251.96556198, 850.86373309, -917.42936045]),\n", + " 'wheelSpeeds': array([-859.96088583, 612.72791736, 421.02742349]),\n", " 'maxWheelSpeed': inf,\n", " 'u_max': 0.2,\n", " 'rwBasePower': 0.4,\n", @@ -189,16 +191,16 @@ " 'rwElecToMechEfficiency': 0.5,\n", " 'panelArea': 1.0,\n", " 'panelEfficiency': 0.2,\n", - " 'nHat_B': array([0, 1, 0]),\n", + " 'nHat_B': array([ 0, 0, -1]),\n", " 'mass': 300,\n", " 'width': 1.38,\n", " 'depth': 1.04,\n", " 'height': 1.58,\n", - " 'sigma_init': array([0.0430067 , 0.34331748, 0.10427181]),\n", - " 'omega_init': array([-3.83620414e-05, 2.24808726e-05, -1.90589544e-05]),\n", + " 'sigma_init': array([0.6431582 , 0.23032644, 0.95034286]),\n", + " 'omega_init': array([5.09693263e-05, 3.00321772e-05, 4.46990691e-05]),\n", " 'rN': None,\n", " 'vN': None,\n", - " 'oe': ,\n", + " 'oe': ,\n", " 'mu': 398600436000000.0,\n", " 'thrusterPowerDraw': 0.0}" ] @@ -209,7 +211,7 @@ } ], "source": [ - "sat._generate_sat_args() # Called by the environment on reset()\n", + "sat.generate_sat_args() # Called by the environment on reset()\n", "sat.sat_args" ] }, @@ -225,10 +227,10 @@ "execution_count": 5, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:41.800473Z", - "iopub.status.busy": "2024-07-24T21:34:41.800397Z", - "iopub.status.idle": "2024-07-24T21:34:41.802784Z", - "shell.execute_reply": "2024-07-24T21:34:41.802528Z" + "iopub.execute_input": "2024-09-05T23:14:02.730549Z", + "iopub.status.busy": "2024-09-05T23:14:02.730460Z", + "iopub.status.idle": "2024-09-05T23:14:02.732692Z", + "shell.execute_reply": "2024-09-05T23:14:02.732483Z" } }, "outputs": [ @@ -236,15 +238,15 @@ "name": "stdout", "output_type": "stream", "text": [ - "New value of dragCoeff: 2.091322691788745\n", - "New value of dragCoeff: 2.1916455994466144\n", - "New value of dragCoeff: 2.1931448930420028\n" + "New value of dragCoeff: 2.0666266827825757\n", + "New value of dragCoeff: 2.0607169644423444\n", + "New value of dragCoeff: 2.235847389370373\n" ] } ], "source": [ "for _ in range(3):\n", - " sat._generate_sat_args() # Called by the environment on reset()\n", + " sat.generate_sat_args() # Called by the environment on reset()\n", " print(\"New value of dragCoeff:\", sat.sat_args[\"dragCoeff\"])" ] }, @@ -279,19 +281,19 @@ "execution_count": 6, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:41.804053Z", - "iopub.status.busy": "2024-07-24T21:34:41.803972Z", - "iopub.status.idle": "2024-07-24T21:34:41.888262Z", - "shell.execute_reply": "2024-07-24T21:34:41.887908Z" + "iopub.execute_input": "2024-09-05T23:14:02.733899Z", + "iopub.status.busy": "2024-09-05T23:14:02.733814Z", + "iopub.status.idle": "2024-09-05T23:14:02.834357Z", + "shell.execute_reply": "2024-09-05T23:14:02.834058Z" } }, "outputs": [ { "data": { "text/plain": [ - "{'sat_props': {'wheel_speeds': array([ -91.1769426 , -139.79132721, 126.87155476]),\n", - " 'battery_charge_fraction': 0.39674425105578415,\n", - " 'r_BN_P_normd': array([ 0.56358151, 0.65925869, -0.45960455])}}" + "{'sat_props': {'wheel_speeds': array([ -98.25914859, 96.84060819, -108.0979901 ]),\n", + " 'battery_charge_fraction': 0.4832853371493886,\n", + " 'r_BN_P_normd': array([-0.21526909, -0.69402168, -0.65990575])}}" ] }, "execution_count": 6, @@ -338,10 +340,10 @@ "execution_count": 7, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:41.889927Z", - "iopub.status.busy": "2024-07-24T21:34:41.889802Z", - "iopub.status.idle": "2024-07-24T21:34:42.044612Z", - "shell.execute_reply": "2024-07-24T21:34:42.044318Z" + "iopub.execute_input": "2024-09-05T23:14:02.835902Z", + "iopub.status.busy": "2024-09-05T23:14:02.835773Z", + "iopub.status.idle": "2024-09-05T23:14:03.009766Z", + "shell.execute_reply": "2024-09-05T23:14:03.009502Z" } }, "outputs": [ @@ -378,6 +380,53 @@ "observation" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Alternatively, define the property with a function that takes the satellite object as an argument." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-05T23:14:03.011212Z", + "iopub.status.busy": "2024-09-05T23:14:03.011124Z", + "iopub.status.idle": "2024-09-05T23:14:03.341046Z", + "shell.execute_reply": "2024-09-05T23:14:03.340762Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'sat_props': {'meaning_of_life': 42.0}}" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "class CustomSatPropsSatellite(sats.Satellite):\n", + " observation_spec = [\n", + " obs.SatProperties(dict(prop=\"meaning_of_life\", fn=lambda sat: 42))\n", + " ]\n", + " action_spec = [act.Drift()]\n", + " dyn_type = dyn.BasicDynamicsModel\n", + " fsw_type = fsw.BasicFSWModel\n", + "\n", + "env = SatelliteTasking(\n", + " satellite=CustomSatPropsSatellite(\"BespokeSat-1\", {}, obs_type=dict),\n", + " log_level=\"CRITICAL\",\n", + ")\n", + "observation, _ = env.reset()\n", + "observation" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -391,31 +440,31 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:42.046069Z", - "iopub.status.busy": "2024-07-24T21:34:42.045979Z", - "iopub.status.idle": "2024-07-24T21:34:42.280201Z", - "shell.execute_reply": "2024-07-24T21:34:42.279945Z" + "iopub.execute_input": "2024-09-05T23:14:03.342608Z", + "iopub.status.busy": "2024-09-05T23:14:03.342487Z", + "iopub.status.idle": "2024-09-05T23:14:03.600575Z", + "shell.execute_reply": "2024-09-05T23:14:03.600309Z" } }, "outputs": [ { "data": { "text/plain": [ - "{'target': {'target_0': {'priority': 0.00447096459014007,\n", + "{'target': {'target_0': {'priority': 0.8375222183770862,\n", " 'opportunity_open_normd': 0.0,\n", - " 'prop_2': array([-2371090.2318378 , 3950241.04424896, 4410743.29777727])},\n", - " 'target_1': {'priority': 0.5445509726619846,\n", - " 'opportunity_open_normd': 0.0,\n", - " 'prop_2': array([-2384178.32784938, 4088065.31925611, 4276043.08252414])},\n", - " 'target_2': {'priority': 0.5473339037146863,\n", - " 'opportunity_open_normd': 0.0,\n", - " 'prop_2': array([-2532959.31617917, 4187791.47953476, 4089942.37985651])}}}" + " 'prop_2': array([4932343.65632124, 3167393.80713778, 2514183.87927638])},\n", + " 'target_1': {'priority': 0.2571342858370993,\n", + " 'opportunity_open_normd': 0.01583909427857832,\n", + " 'prop_2': array([4335214.72548668, 3048107.03092835, 3549155.05760857])},\n", + " 'target_2': {'priority': 0.017678840590354183,\n", + " 'opportunity_open_normd': 0.014417949081877348,\n", + " 'prop_2': array([4175551.75611481, 3421156.99697575, 3397352.25111296])}}}" ] }, - "execution_count": 8, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -461,24 +510,24 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:42.281601Z", - "iopub.status.busy": "2024-07-24T21:34:42.281520Z", - "iopub.status.idle": "2024-07-24T21:34:42.577488Z", - "shell.execute_reply": "2024-07-24T21:34:42.577233Z" + "iopub.execute_input": "2024-09-05T23:14:03.602026Z", + "iopub.status.busy": "2024-09-05T23:14:03.601942Z", + "iopub.status.idle": "2024-09-05T23:14:03.916705Z", + "shell.execute_reply": "2024-09-05T23:14:03.916415Z" } }, "outputs": [ { "data": { "text/plain": [ - "{'eclipse': [4740.0, 5610.0],\n", - " 'sat_props': {'battery_charge_fraction': 0.7664749518821514}}" + "{'eclipse': [2970.0, 5100.0],\n", + " 'sat_props': {'battery_charge_fraction': 0.8697790253738951}}" ] }, - "execution_count": 9, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -519,13 +568,13 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:42.578832Z", - "iopub.status.busy": "2024-07-24T21:34:42.578756Z", - "iopub.status.idle": "2024-07-24T21:34:42.928852Z", - "shell.execute_reply": "2024-07-24T21:34:42.928581Z" + "iopub.execute_input": "2024-09-05T23:14:03.918027Z", + "iopub.status.busy": "2024-09-05T23:14:03.917944Z", + "iopub.status.idle": "2024-09-05T23:14:04.283584Z", + "shell.execute_reply": "2024-09-05T23:14:04.283288Z" } }, "outputs": [ @@ -535,7 +584,7 @@ "(Box(-1e+16, 1e+16, (3,), float64), Box(-1e+16, 1e+16, (3,), float64))" ] }, - "execution_count": 10, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -559,23 +608,23 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:42.930284Z", - "iopub.status.busy": "2024-07-24T21:34:42.930204Z", - "iopub.status.idle": "2024-07-24T21:34:43.650718Z", - "shell.execute_reply": "2024-07-24T21:34:43.650461Z" + "iopub.execute_input": "2024-09-05T23:14:04.284987Z", + "iopub.status.busy": "2024-09-05T23:14:04.284901Z", + "iopub.status.idle": "2024-09-05T23:14:05.049875Z", + "shell.execute_reply": "2024-09-05T23:14:05.049604Z" } }, "outputs": [ { "data": { "text/plain": [ - "array([1.44000000e+03, 3.30000000e+03, 8.49202876e-01])" + "array([4.41000000e+03, 8.70000000e+02, 6.52484256e-01])" ] }, - "execution_count": 11, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -595,13 +644,13 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:43.652126Z", - "iopub.status.busy": "2024-07-24T21:34:43.652045Z", - "iopub.status.idle": "2024-07-24T21:34:43.654190Z", - "shell.execute_reply": "2024-07-24T21:34:43.653960Z" + "iopub.execute_input": "2024-09-05T23:14:05.051401Z", + "iopub.status.busy": "2024-09-05T23:14:05.051314Z", + "iopub.status.idle": "2024-09-05T23:14:05.053450Z", + "shell.execute_reply": "2024-09-05T23:14:05.053216Z" } }, "outputs": [ @@ -611,7 +660,7 @@ "['eclipse[0]', 'eclipse[1]', 'sat_props.battery_charge_fraction']" ] }, - "execution_count": 12, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -633,13 +682,13 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:43.655513Z", - "iopub.status.busy": "2024-07-24T21:34:43.655425Z", - "iopub.status.idle": "2024-07-24T21:34:44.772950Z", - "shell.execute_reply": "2024-07-24T21:34:44.772669Z" + "iopub.execute_input": "2024-09-05T23:14:05.054805Z", + "iopub.status.busy": "2024-09-05T23:14:05.054728Z", + "iopub.status.idle": "2024-09-05T23:14:05.790705Z", + "shell.execute_reply": "2024-09-05T23:14:05.790453Z" } }, "outputs": [ @@ -647,175 +696,168 @@ "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,575 \u001b[0m\u001b[m \u001b[0m\u001b[93mWARNING \u001b[0m\u001b[93mCreating logger for new env on PID=39723. Old environments in process may now log times incorrectly.\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,393 \u001b[0m\u001b[m \u001b[0m\u001b[93mWARNING \u001b[0m\u001b[93mCreating logger for new env on PID=51118. Old environments in process may now log times incorrectly.\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,656 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[mResetting environment with seed=3153827384\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,673 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[mResetting environment with seed=210898688\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,724 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[mSatellites requiring retasking: ['ActSat-1']\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,741 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[mEnvironment reset\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,724 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[mEnvironment reset\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,741 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[93;1m=== STARTING STEP ===\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,724 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[93;1m=== STARTING STEP ===\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,742 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[maction_charge tasked for 120.0 seconds\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,725 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[maction_charge tasked for 120.0 seconds\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,742 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[msetting timed terminal event at 120.0\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,725 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[msetting timed terminal event at 120.0\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,750 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<120.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[mtimed termination at 120.0 for action_charge\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,732 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<120.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[mtimed termination at 120.0 for action_charge\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,750 \u001b[0m\u001b[mdata.base \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<120.00> \u001b[0m\u001b[mData reward: {'ActSat-1': 0.0}\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,732 \u001b[0m\u001b[mdata.base \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<120.00> \u001b[0m\u001b[mData reward: {'ActSat-1': 0.0}\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,750 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<120.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[mSatellite ActSat-1 requires retasking\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,733 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<120.00> \u001b[0m\u001b[mSatellites requiring retasking: ['ActSat-1']\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,751 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<120.00> \u001b[0m\u001b[mStep reward: 0.0\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,733 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<120.00> \u001b[0m\u001b[mStep reward: 0.0\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,751 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<120.00> \u001b[0m\u001b[93;1m=== STARTING STEP ===\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,733 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<120.00> \u001b[0m\u001b[93;1m=== STARTING STEP ===\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,751 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<120.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[maction_desat tasked for 60.0 seconds\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,733 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<120.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[maction_desat tasked for 60.0 seconds\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,751 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<120.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[msetting timed terminal event at 180.0\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,733 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<120.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[msetting timed terminal event at 180.0\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,755 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<180.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[mtimed termination at 180.0 for action_desat\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,737 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<180.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[mtimed termination at 180.0 for action_desat\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,756 \u001b[0m\u001b[mdata.base \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<180.00> \u001b[0m\u001b[mData reward: {'ActSat-1': 0.0}\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,737 \u001b[0m\u001b[mdata.base \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<180.00> \u001b[0m\u001b[mData reward: {'ActSat-1': 0.0}\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,756 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<180.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[mSatellite ActSat-1 requires retasking\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,738 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<180.00> \u001b[0m\u001b[mSatellites requiring retasking: ['ActSat-1']\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,756 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<180.00> \u001b[0m\u001b[mStep reward: 0.0\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,738 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<180.00> \u001b[0m\u001b[mStep reward: 0.0\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,756 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<180.00> \u001b[0m\u001b[93;1m=== STARTING STEP ===\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,738 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<180.00> \u001b[0m\u001b[93;1m=== STARTING STEP ===\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,757 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<180.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[maction_charge tasked for 600.0 seconds\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,738 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<180.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[maction_charge tasked for 600.0 seconds\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,757 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<180.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[msetting timed terminal event at 780.0\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,739 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<180.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[msetting timed terminal event at 780.0\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,788 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<780.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[mtimed termination at 780.0 for action_charge\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,770 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<780.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[mtimed termination at 780.0 for action_charge\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,788 \u001b[0m\u001b[mdata.base \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<780.00> \u001b[0m\u001b[mData reward: {'ActSat-1': 0.0}\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,770 \u001b[0m\u001b[mdata.base \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<780.00> \u001b[0m\u001b[mData reward: {'ActSat-1': 0.0}\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,788 \u001b[0m\u001b[36msats.satellite.ActSat-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<780.00> \u001b[0m\u001b[36mActSat-1: \u001b[0m\u001b[mSatellite ActSat-1 requires retasking\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,771 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<780.00> \u001b[0m\u001b[mSatellites requiring retasking: ['ActSat-1']\u001b[0m\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[90;3m2024-07-24 14:34:44,771 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<780.00> \u001b[0m\u001b[mStep reward: 0.0\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,789 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<780.00> \u001b[0m\u001b[mStep reward: 0.0\u001b[0m\n" ] } ], @@ -854,13 +896,13 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:44.774954Z", - "iopub.status.busy": "2024-07-24T21:34:44.774831Z", - "iopub.status.idle": "2024-07-24T21:34:44.776828Z", - "shell.execute_reply": "2024-07-24T21:34:44.776597Z" + "iopub.execute_input": "2024-09-05T23:14:05.792293Z", + "iopub.status.busy": "2024-09-05T23:14:05.792176Z", + "iopub.status.idle": "2024-09-05T23:14:05.794227Z", + "shell.execute_reply": "2024-09-05T23:14:05.794002Z" } }, "outputs": [ @@ -870,7 +912,7 @@ "Discrete(3)" ] }, - "execution_count": 14, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -881,13 +923,13 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:44.778335Z", - "iopub.status.busy": "2024-07-24T21:34:44.778221Z", - "iopub.status.idle": "2024-07-24T21:34:44.780021Z", - "shell.execute_reply": "2024-07-24T21:34:44.779791Z" + "iopub.execute_input": "2024-09-05T23:14:05.795667Z", + "iopub.status.busy": "2024-09-05T23:14:05.795547Z", + "iopub.status.idle": "2024-09-05T23:14:05.797548Z", + "shell.execute_reply": "2024-09-05T23:14:05.797317Z" } }, "outputs": [ @@ -897,7 +939,7 @@ "['action_charge', 'action_desat', 'action_charge']" ] }, - "execution_count": 15, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -919,13 +961,13 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 17, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:44.781400Z", - "iopub.status.busy": "2024-07-24T21:34:44.781306Z", - "iopub.status.idle": "2024-07-24T21:34:45.001787Z", - "shell.execute_reply": "2024-07-24T21:34:45.001533Z" + "iopub.execute_input": "2024-09-05T23:14:05.798861Z", + "iopub.status.busy": "2024-09-05T23:14:05.798761Z", + "iopub.status.idle": "2024-09-05T23:14:06.987771Z", + "shell.execute_reply": "2024-09-05T23:14:06.987462Z" } }, "outputs": [ @@ -933,35 +975,28 @@ "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,782 \u001b[0m\u001b[m \u001b[0m\u001b[93mWARNING \u001b[0m\u001b[93mCreating logger for new env on PID=39723. Old environments in process may now log times incorrectly.\u001b[0m\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[90;3m2024-07-24 14:34:44,922 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[mResetting environment with seed=3420713384\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:05,800 \u001b[0m\u001b[m \u001b[0m\u001b[93mWARNING \u001b[0m\u001b[93mCreating logger for new env on PID=51118. Old environments in process may now log times incorrectly.\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,923 \u001b[0m\u001b[mscene.targets \u001b[0m\u001b[mINFO \u001b[0m\u001b[mGenerating 1000 targets\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:06,143 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[mResetting environment with seed=681202688\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,999 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[mSatellites requiring retasking: ['ActSat-2']\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:06,144 \u001b[0m\u001b[mscene.targets \u001b[0m\u001b[mINFO \u001b[0m\u001b[mGenerating 1000 targets\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:44,999 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[mEnvironment reset\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:06,985 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[mEnvironment reset\u001b[0m\n" ] }, { @@ -970,7 +1005,7 @@ "['action_image_0', 'action_image_1', 'action_image_2']" ] }, - "execution_count": 16, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -1006,13 +1041,13 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 18, "metadata": { "execution": { - "iopub.execute_input": "2024-07-24T21:34:45.003207Z", - "iopub.status.busy": "2024-07-24T21:34:45.003109Z", - "iopub.status.idle": "2024-07-24T21:34:45.067013Z", - "shell.execute_reply": "2024-07-24T21:34:45.066789Z" + "iopub.execute_input": "2024-09-05T23:14:06.989248Z", + "iopub.status.busy": "2024-09-05T23:14:06.989134Z", + "iopub.status.idle": "2024-09-05T23:14:07.089231Z", + "shell.execute_reply": "2024-09-05T23:14:07.088974Z" } }, "outputs": [ @@ -1020,70 +1055,77 @@ "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:45,003 \u001b[0m\u001b[36msats.satellite.ActSat-2 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mActSat-2: \u001b[0m\u001b[mFinding opportunity windows from 0.00 to 600.00 seconds\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:06,989 \u001b[0m\u001b[36msats.satellite.ActSat-2 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mActSat-2: \u001b[0m\u001b[mFinding opportunity windows from 0.00 to 600.00 seconds\u001b[0m\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[90;3m2024-09-05 17:14:07,010 \u001b[0m\u001b[36msats.satellite.ActSat-2 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mActSat-2: \u001b[0m\u001b[mFinding opportunity windows from 600.00 to 1200.00 seconds\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:45,025 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[93;1m=== STARTING STEP ===\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:07,031 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[93;1m=== STARTING STEP ===\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:45,025 \u001b[0m\u001b[mact.discrete_actions \u001b[0m\u001b[93mWARNING \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[93mAction 'Target(tgt-157)' is not an integer. Will attempt to use compatible set_action_override method.\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:07,031 \u001b[0m\u001b[mact.discrete_actions \u001b[0m\u001b[93mWARNING \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[93mAction 'Target(tgt-902)' is not an integer. Will attempt to use compatible set_action_override method.\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:45,026 \u001b[0m\u001b[36msats.satellite.ActSat-2 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mActSat-2: \u001b[0m\u001b[mTarget(tgt-157) tasked for imaging\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:07,032 \u001b[0m\u001b[36msats.satellite.ActSat-2 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mActSat-2: \u001b[0m\u001b[mTarget(tgt-902) tasked for imaging\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:45,026 \u001b[0m\u001b[36msats.satellite.ActSat-2 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mActSat-2: \u001b[0m\u001b[mTarget(tgt-157) window enabled: 488.9 to 598.6\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:07,033 \u001b[0m\u001b[36msats.satellite.ActSat-2 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mActSat-2: \u001b[0m\u001b[mTarget(tgt-902) window enabled: 692.8 to 790.8\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:45,027 \u001b[0m\u001b[36msats.satellite.ActSat-2 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mActSat-2: \u001b[0m\u001b[msetting timed terminal event at 598.6\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:07,033 \u001b[0m\u001b[36msats.satellite.ActSat-2 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mActSat-2: \u001b[0m\u001b[msetting timed terminal event at 790.8\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:45,063 \u001b[0m\u001b[36msats.satellite.ActSat-2 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<491.00> \u001b[0m\u001b[36mActSat-2: \u001b[0m\u001b[mimaged Target(tgt-157)\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:07,085 \u001b[0m\u001b[36msats.satellite.ActSat-2 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<695.00> \u001b[0m\u001b[36mActSat-2: \u001b[0m\u001b[mimaged Target(tgt-902)\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:45,064 \u001b[0m\u001b[mdata.base \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<491.00> \u001b[0m\u001b[mData reward: {'ActSat-2': 0.4288952737667253}\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:07,087 \u001b[0m\u001b[mdata.base \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<695.00> \u001b[0m\u001b[mData reward: {'ActSat-2': 0.018502967690236294}\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:45,065 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<491.00> \u001b[0m\u001b[mSatellites requiring retasking: ['ActSat-2']\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:07,087 \u001b[0m\u001b[36msats.satellite.ActSat-2 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<695.00> \u001b[0m\u001b[36mActSat-2: \u001b[0m\u001b[mSatellite ActSat-2 requires retasking\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[90;3m2024-07-24 14:34:45,065 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<491.00> \u001b[0m\u001b[mStep reward: 0.4288952737667253\u001b[0m\n" + "\u001b[90;3m2024-09-05 17:14:07,087 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<695.00> \u001b[0m\u001b[mStep reward: 0.018502967690236294\u001b[0m\n" ] } ], diff --git a/docs/source/release_notes.rst b/docs/source/release_notes.rst index 7d4aec92..56898790 100644 --- a/docs/source/release_notes.rst +++ b/docs/source/release_notes.rst @@ -5,7 +5,8 @@ Development Version ------------------- *Release Date: MMM. DD, YYYY* -* None. +* Add ability in :class:`~bsk_rl.obs.SatProperties` to define new observations with + a custom function. Version 1.0.1 ------------- diff --git a/examples/satellite_configuration.ipynb b/examples/satellite_configuration.ipynb index 364cced5..7464dda3 100644 --- a/examples/satellite_configuration.ipynb +++ b/examples/satellite_configuration.ipynb @@ -93,7 +93,7 @@ "metadata": {}, "outputs": [], "source": [ - "sat._generate_sat_args() # Called by the environment on reset()\n", + "sat.generate_sat_args() # Called by the environment on reset()\n", "sat.sat_args" ] }, @@ -111,7 +111,7 @@ "outputs": [], "source": [ "for _ in range(3):\n", - " sat._generate_sat_args() # Called by the environment on reset()\n", + " sat.generate_sat_args() # Called by the environment on reset()\n", " print(\"New value of dragCoeff:\", sat.sat_args[\"dragCoeff\"])" ] }, @@ -207,6 +207,35 @@ "observation" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Alternatively, define the property with a function that takes the satellite object as an argument." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "class CustomSatPropsSatellite(sats.Satellite):\n", + " observation_spec = [\n", + " obs.SatProperties(dict(prop=\"meaning_of_life\", fn=lambda sat: 42))\n", + " ]\n", + " action_spec = [act.Drift()]\n", + " dyn_type = dyn.BasicDynamicsModel\n", + " fsw_type = fsw.BasicFSWModel\n", + "\n", + "env = SatelliteTasking(\n", + " satellite=CustomSatPropsSatellite(\"BespokeSat-1\", {}, obs_type=dict),\n", + " log_level=\"CRITICAL\",\n", + ")\n", + "observation, _ = env.reset()\n", + "observation" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/src/bsk_rl/obs/observations.py b/src/bsk_rl/obs/observations.py index ce3f1cbb..beae7871 100644 --- a/src/bsk_rl/obs/observations.py +++ b/src/bsk_rl/obs/observations.py @@ -177,9 +177,7 @@ def get_obs(self) -> Any: class SatProperties(Observation): """Add arbitrary `dynamics` and `fsw` .""" - def __init__( - self, *obs_properties: dict[str, Union[str, float]], name="sat_props" - ) -> None: + def __init__(self, *obs_properties: dict[str, Any], name="sat_props") -> None: """Include properties from ``fsw`` and ``dynamics`` in the observation. For each desired property, a dictionary specifying the property name and settings @@ -203,13 +201,14 @@ def __init__( * ``module`` `optional`: Module (dynamics or fsw) that holds the property. Can be inferred if ``None``. * ``norm`` `optional`: Value to normalize property by. Defaults to 1.0. * ``name`` `optional`: Name of the observation element. Defaults to the value of ``prop``. + * ``fn`` `optional`: Alternatively, call a function that takes the satellite as an argument. name: Name of the observation. """ super().__init__(name=name) for obs_property in obs_properties: for key in obs_property: - if key not in ["prop", "module", "norm", "name"]: + if key not in ["prop", "module", "norm", "name", "fn"]: raise ValueError(f"Invalid property key: {key}") if "norm" not in obs_property: obs_property["norm"] = 1.0 @@ -226,7 +225,7 @@ def reset_post_sim_init(self) -> None: :meta private: """ for obs_property in self.obs_properties: - if "module" not in obs_property: + if "module" not in obs_property and "fn" not in obs_property: for module in ["dynamics", "fsw"]: if hasattr(getattr(self.satellite, module), obs_property["prop"]): obs_property["module"] = module @@ -242,11 +241,14 @@ def get_obs(self) -> dict[str, Any]: obs = {} for obs_property in self.obs_properties: prop = obs_property["prop"] - module = obs_property["module"] - norm = obs_property["norm"] - value = getattr(getattr(self.satellite, module), prop) + if "fn" in obs_property: + value = obs_property["fn"](self.satellite) + else: + module = obs_property["module"] + value = getattr(getattr(self.satellite, module), prop) if isinstance(value, list): value = np.array(value) + norm = obs_property["norm"] obs[obs_property["name"]] = value / norm return obs @@ -326,7 +328,7 @@ def __init__( to the the observation. Properties are optionally normalized by some factor. Each observation is a dictionary with the keys: - * ``name``: Name of the observation element. + * ``name`` `optional`: Name of the observation element. * ``fn`` `optional`: Function to calculate property, in the form ``fn(satellite, opportunity)``. If not provided, the key ``prop`` will be used to look up a preset function: @@ -358,6 +360,7 @@ def __init__( if "norm" not in prop_spec: prop_spec["norm"] = 1.0 + # Determine observation function if "fn" not in prop_spec: try: prop_spec["fn"] = self._fn_map[prop_spec["prop"]] @@ -366,9 +369,12 @@ def __init__( f"Property prop={prop_spec['prop']} is not predefined and no `fn` was provided." ) else: - if "prop" in prop_spec: - logger.warning("Ignoring `prop` key when `fn` is provided.") + if "prop" in prop_spec and prop_spec["prop"] in self._fn_map: + logger.warning( + f"Ignoring default function for `{prop_spec['prop']}` when `fn` is provided." + ) + # Determine best name if "name" not in prop_spec: if "prop" in prop_spec: prop_spec["name"] = prop_spec["prop"] diff --git a/tests/unittest/obs/test_observations.py b/tests/unittest/obs/test_observations.py index 52464082..a689101a 100644 --- a/tests/unittest/obs/test_observations.py +++ b/tests/unittest/obs/test_observations.py @@ -123,6 +123,15 @@ def test_get_obs(self): ob.satellite = MagicMock(dynamics=MagicMock(hello=6.0)) assert ob.get_obs() == {"hello_prop": 3.0} + def test_get_obs_fn(self): + mock_fn = MagicMock(return_value=3.0) + ob = obs.SatProperties( + dict(prop="hello", fn=mock_fn), + ) + ob.satellite = MagicMock() + assert ob.get_obs() == {"hello": 3.0} + mock_fn.assert_called_once_with(ob.satellite) + class TestTime: def test_detect_norm(self):