Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions notebooks/crds_reference_files/crds_reference_files.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
"source": [
"import os\n",
"import copy\n",
"from pathlib import Path\n",
"\n",
"import crds\n",
"from crds.client import api\n",
"\n",
"import numpy as np\n",
"import roman_datamodels as rdm\n",
Expand Down Expand Up @@ -281,7 +285,7 @@
"id": "d4bfb5ba",
"metadata": {},
"source": [
"Let's explore the set of maping associated with our selected context."
"Let's check if we have the context."
]
},
{
Expand All @@ -294,7 +298,39 @@
"pmap = crds.get_default_context(\"roman\")\n",
"print(\"Current pmap:\", pmap)\n",
"\n",
"# Use the correct method for your version\n",
"# Typical location of the pmap in the cache\n",
"cache = Path(os.environ.get(\"CRDS_PATH\", \"\"))\n",
"print(cache)\n",
"possible_paths = [\n",
" cache / \"mappings\" / \"roman\" / pmap,\n",
" cache / \"mappings\" / pmap,\n",
"]\n",
"\n",
"local_pmap = any(p.exists() for p in possible_paths)\n",
"print(local_pmap)\n",
"if local_pmap:\n",
" print(\"Found at:\", next(p for p in possible_paths if p.exists()))\n",
"else:\n",
" print(f\"Downloading mappings rules for {pmap} ...\")\n",
" api.dump_mappings(pmap)\n",
" "
]
},
{
"cell_type": "markdown",
"id": "96374747",
"metadata": {},
"source": [
"Now let's explore the set of mappings associated with our selected context."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "93571828",
"metadata": {},
"outputs": [],
"source": [
"ctx = crds.get_symbolic_mapping(pmap)\n",
"\n",
"maps = ctx.mapping_names()\n",
Expand Down Expand Up @@ -475,7 +511,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "catalog",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an intentional change to the kernel display name?

"language": "python",
"name": "python3"
},
Expand All @@ -489,7 +525,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.14"
"version": "3.12.13"
}
},
"nbformat": 4,
Expand Down
47 changes: 0 additions & 47 deletions notebooks/romanisim/romanisim.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,53 +92,6 @@
"ndd.setup_env(result)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import sys\n",
"import importlib.util\n",
"\n",
"try:\n",
" import notebook_data_dependencies as ndd\n",
" local = True\n",
"except ImportError:\n",
" local = False\n",
"\n",
"# If running locally Get the directory with the script\n",
"if not local:\n",
" notebook_dir = os.getcwd()\n",
" shared_path = os.path.abspath(\n",
" os.path.join(notebook_dir, '..', '..', 'shared', 'notebook_data_dependencies.py')\n",
" )\n",
"\n",
" if os.path.exists(shared_path):\n",
" print(f\"Loading notebook_data_dependencies from shared location: {shared_path}\")\n",
" spec = importlib.util.spec_from_file_location(\"notebook_data_dependencies\", shared_path)\n",
" ndd = importlib.util.module_from_spec(spec)\n",
" sys.modules['notebook_data_dependencies'] = ndd # Optional: makes subsequent imports work\n",
" spec.loader.exec_module(ndd)\n",
" else:\n",
" raise FileNotFoundError(f\"Local install script not found at {shared_path}\")\n",
"\n",
"if not local:\n",
" print(\"Running local data dependency installation...\")\n",
" result = ndd.install_files(packages=['stpsf'])\n",
"\n",
" # Update environment variables (if necessary) and print reference data paths\n",
" print('Reference data paths set to:')\n",
" for k, v in result.items():\n",
" if not v['pre_installed']:\n",
" os.environ[k] = v['path']\n",
" print(f\"\\t{k} = {v['path']}\")\n",
"\n",
"else:\n",
" print(\"Running on RNN — data already available, skipping local install.\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
Loading