Skip to content

Commit

Permalink
Include example of leading visits from archive
Browse files Browse the repository at this point in the history
  • Loading branch information
ehneilsen committed Dec 9, 2024
1 parent 73c3e93 commit f37f294
Showing 1 changed file with 75 additions and 19 deletions.
94 changes: 75 additions & 19 deletions notebooks/introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"import os\n",
"import sys\n",
"import pwd\n",
"import yaml\n",
"from pathlib import Path\n",
"\n",
"username = pwd.getpwuid(os.getuid())[0]\n",
Expand Down Expand Up @@ -142,6 +143,7 @@
"import bokeh.io\n",
"import schedview\n",
"import erfa\n",
"from lsst.resources import ResourcePath\n",
"import uranography.api\n",
"import rubin_sim\n",
"import rubin_scheduler\n",
Expand All @@ -152,7 +154,7 @@
"from rubin_scheduler.scheduler.model_observatory.model_observatory import (\n",
" ModelObservatory,\n",
")\n",
"from IPython.display import HTML, display, Markdown, HTML"
"from IPython.display import HTML, display, Markdown"
]
},
{
Expand Down Expand Up @@ -219,24 +221,6 @@
"bokeh.io.output_notebook()"
]
},
{
"cell_type": "markdown",
"id": "ad4ad7ca-c015-4cb0-93b1-e07aaef57f2a",
"metadata": {},
"source": [
"#### Support display of `matplotlib` plots"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b1d4ecd5-b26b-439d-ad51-4d2d78630221",
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"id": "cbc242c2-dfab-4567-81d2-ef3e247204b3",
Expand Down Expand Up @@ -625,6 +609,78 @@
")"
]
},
{
"cell_type": "markdown",
"id": "e9b33f60-5fa5-4040-818d-d365a09686e6",
"metadata": {},
"source": [
"### Reading from a simulation archive"
]
},
{
"cell_type": "markdown",
"id": "232d1868-9965-42ef-ab5d-1411a8b6efad",
"metadata": {},
"source": [
"Set the simulation we want:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e3e5cb0d-c76a-4cf9-af5b-7def24b23936",
"metadata": {},
"outputs": [],
"source": [
"sim_date = \"2024-11-21\"\n",
"sim_index = 1"
]
},
{
"cell_type": "markdown",
"id": "c87cb1da-5642-4465-b296-32e0d0cc0c12",
"metadata": {},
"source": [
"Find the resource path in the archive we want:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eebe8bec-ee74-4660-9902-54b8de7f2375",
"metadata": {},
"outputs": [],
"source": [
"archive_uri = \"s3://rubin:rubin-scheduler-prenight/opsim/\"\n",
"os.environ[\"LSST_DISABLE_BUCKET_VALIDATION\"] = \"1\"\n",
"os.environ[\"S3_ENDPOINT_URL\"] = \"https://s3dfrgw.slac.stanford.edu/\"\n",
"sim_archive_rp = (\n",
" ResourcePath(archive_uri)\n",
" .join(sim_date, forceDirectory=True)\n",
" .join(f\"{sim_index}\", forceDirectory=True)\n",
")\n",
"sim_archive_metadata = yaml.safe_load(\n",
" sim_archive_rp.join(\"sim_metadata.yaml\").read().decode()\n",
")\n",
"sim_rp = sim_archive_rp.join(sim_archive_metadata[\"files\"][\"observations\"][\"name\"])\n",
"sim_rp"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3c49e053-ced0-4e1c-8aed-408932658c11",
"metadata": {},
"outputs": [],
"source": [
"visits = schedview.collect.opsim.read_opsim(\n",
" opsim_uri=sim_rp,\n",
" start_time=astropy.time.Time(\"2024-11-21 12:00:00Z\"),\n",
" end_time=astropy.time.Time(\"2024-11-22 12:00:00Z\"),\n",
" stackers=schedview.collect.visits.NIGHT_STACKERS,\n",
")"
]
},
{
"cell_type": "markdown",
"id": "646ccf7e-deb1-4015-8a79-c7f0ec580738",
Expand Down

0 comments on commit f37f294

Please sign in to comment.