Skip to content

Commit 1b5279f

Browse files
committed
modify to use file in data dir
1 parent 1460bcc commit 1b5279f

1 file changed

Lines changed: 32 additions & 9 deletions

File tree

MPC/RFL_Solar_System_MPC_Retrieval.ipynb

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,16 @@
105105
"outputs": [],
106106
"source": [
107107
"targets = []\n",
108-
"with open('Rubin_First_Look_Solar_System_Discovery_Designations.csv', 'r') as f:\n",
108+
"path = '/rubin/cst_repos/tutorial-notebooks-data/data/'\n",
109+
"input_file = path + 'Rubin_First_Look_Solar_System_Discovery_Designations.csv'\n",
110+
"with open(input_file, 'r') as f:\n",
109111
" for line in f.readlines():\n",
110112
" desig = line.strip().split(',')\n",
111-
" targets.append(desig[0])\n",
112-
"#print(targets[1:])"
113+
" if desig[0][0:1] != 'u':\n",
114+
" targets.append(desig[0])\n",
115+
"assert len(targets) == 2098\n",
116+
"print('Number of targets: ', len(targets))\n",
117+
"print('Example target names: ', targets[0], targets[1], targets[2])"
113118
]
114119
},
115120
{
@@ -161,11 +166,13 @@
161166
"metadata": {},
162167
"outputs": [],
163168
"source": [
164-
"column_names = ['designation', 'absolute_magnitude', 'semimajor_axis', 'eccentricity', 'inclination', 'argument_of_perihelion', 'ascending_node', 'peri_time', 'nobs_total']\n",
169+
"column_names = ['designation', 'absolute_magnitude', 'semimajor_axis',\n",
170+
" 'eccentricity', 'inclination', 'argument_of_perihelion',\n",
171+
" 'ascending_node', 'peri_time', 'nobs_total']\n",
165172
"\n",
166173
"discovery_orbits = pd.DataFrame(columns=column_names)\n",
167174
"\n",
168-
"for obj in targets[1:]:\n",
175+
"for i, obj in enumerate(targets[1:]):\n",
169176
" response = requests.get(\"https://data.minorplanetcenter.net/api/get-orb\", json={\"desig\": obj})\n",
170177
" if response.ok:\n",
171178
" mpc_orb = response.json()[0]['mpc_orb']\n",
@@ -184,7 +191,19 @@
184191
" else:\n",
185192
" print(\"Error: \", response.status_code, response.content)\n",
186193
" discovery_orbits = pd.concat([discovery_orbits, next_orb_df], ignore_index=True)\n",
187-
"discovery_orbits['orbit_type_int'] = discovery_orbits['orbit_type_int'].apply(np.int64)\n",
194+
" if (i == 10) or (i == 100) or (i == 1000):\n",
195+
" print(i, ' out of ', len(targets), ' done')\n",
196+
"\n",
197+
"discovery_orbits['orbit_type_int'] = discovery_orbits['orbit_type_int'].apply(np.int64)"
198+
]
199+
},
200+
{
201+
"cell_type": "code",
202+
"execution_count": null,
203+
"id": "7ed39608-4486-4b07-95ef-cc217aaa7595",
204+
"metadata": {},
205+
"outputs": [],
206+
"source": [
188207
"discovery_orbits"
189208
]
190209
},
@@ -232,7 +251,7 @@
232251
"a, e, inc = discovery_orbits[\"semimajor_axis\"], discovery_orbits[\"eccentricity\"], discovery_orbits[\"inclination\"]\n",
233252
"inner_orbits = discovery_orbits[a < 7]\n",
234253
"outer_orbits = discovery_orbits[a >= 7]\n",
235-
" \n",
254+
"\n",
236255
"orbit_type_map = {\n",
237256
" 0: \"Atira\",\n",
238257
" 1: \"Aten\",\n",
@@ -354,8 +373,9 @@
354373
"\n",
355374
"discovery_observations = pd.DataFrame(columns=column_names_trunc)\n",
356375
"\n",
357-
"for obj in targets[1:]:\n",
358-
" response = requests.get(\"https://data.minorplanetcenter.net/api/get-obs\", json={\"desigs\": [obj], \"output_format\":[\"ADES_DF\"]})\n",
376+
"for i, obj in enumerate(targets[1:]):\n",
377+
" response = requests.get(\"https://data.minorplanetcenter.net/api/get-obs\",\n",
378+
" json={\"desigs\": [obj], \"output_format\":[\"ADES_DF\"]})\n",
359379
" if response.ok:\n",
360380
" ades_df = pd.DataFrame(response.json()[0]['ADES_DF'])\n",
361381
" else:\n",
@@ -382,6 +402,9 @@
382402
" discovery_observations['rmsra'] = pd.to_numeric(discovery_observations['rmsra'])\n",
383403
" discovery_observations['mag'] = pd.to_numeric(discovery_observations['mag'])\n",
384404
" discovery_observations['rmsmag'] = pd.to_numeric(discovery_observations['rmsmag'])\n",
405+
" if (i == 10) or (i == 100) or (i == 1000):\n",
406+
" print(i, ' out of ', len(targets), ' done')\n",
407+
"\n",
385408
"len(discovery_observations)"
386409
]
387410
},

0 commit comments

Comments
 (0)