|
47 | 47 | "\n", |
48 | 48 | "This notebook walks through brief examples of common use cases.\n", |
49 | 49 | "\n", |
| 50 | + "The cell below will check to ensure ancillary reference files for `pandeia` package are installed. If not, it will download the ancillary reference files and install them under your home directory (i.e., `${HOME}/refdata/`).\n", |
| 51 | + "\n", |
| 52 | + "### Local Run Settings\n", |
| 53 | + "\n", |
| 54 | + "If you want to run the notebook in your local machine, refer to the information in [local installation](../../markdown/local-run.md) instructions before proceeding with the notebook. The instructions provide inportant information about setting up your environment, installing dependnecies, and adding to your working directory scripts to help with the reference data installation.\n", |
| 55 | + "\n", |
| 56 | + "Depending on which (if any) reference data are missing, this cell may take several minutes to execute.\n", |
| 57 | + "\n", |
| 58 | + "### On the Roman Research Nexus\n", |
| 59 | + "\n", |
| 60 | + "If you are working on the Nexus, then the ancillary reference data are pre-installed and this cell will execute instantly." |
| 61 | + ] |
| 62 | + }, |
| 63 | + { |
| 64 | + "cell_type": "code", |
| 65 | + "execution_count": null, |
| 66 | + "id": "2e7fbfae", |
| 67 | + "metadata": {}, |
| 68 | + "outputs": [], |
| 69 | + "source": [ |
| 70 | + "import os\n", |
| 71 | + "import sys\n", |
| 72 | + "import importlib.util\n", |
| 73 | + "\n", |
| 74 | + "try:\n", |
| 75 | + " import notebook_data_dependencies as ndd\n", |
| 76 | + " local = True\n", |
| 77 | + "except ImportError:\n", |
| 78 | + " local = False\n", |
| 79 | + "\n", |
| 80 | + "# If running locally Get the directory with the script\n", |
| 81 | + "if not local:\n", |
| 82 | + " notebook_dir = os.getcwd()\n", |
| 83 | + " shared_path = os.path.abspath(\n", |
| 84 | + " os.path.join(notebook_dir, '..', '..', 'shared', 'notebook_data_dependencies.py')\n", |
| 85 | + " )\n", |
| 86 | + "\n", |
| 87 | + " if os.path.exists(shared_path):\n", |
| 88 | + " print(f\"Loading notebook_data_dependencies from shared location: {shared_path}\")\n", |
| 89 | + " spec = importlib.util.spec_from_file_location(\"notebook_data_dependencies\", shared_path)\n", |
| 90 | + " ndd = importlib.util.module_from_spec(spec)\n", |
| 91 | + " sys.modules['notebook_data_dependencies'] = ndd # Optional: makes subsequent imports work\n", |
| 92 | + " spec.loader.exec_module(ndd)\n", |
| 93 | + " else:\n", |
| 94 | + " raise FileNotFoundError(f\"Local install script not found at {shared_path}\")\n", |
| 95 | + "\n", |
| 96 | + "if not local:\n", |
| 97 | + " print(\"Running local data dependency installation...\")\n", |
| 98 | + " result = ndd.install_files(packages=['pandeia'])\n", |
| 99 | + "\n", |
| 100 | + " # Update environment variables (if necessary) and print reference data paths\n", |
| 101 | + " print('Reference data paths set to:')\n", |
| 102 | + " for k, v in result.items():\n", |
| 103 | + " if not v['pre_installed']:\n", |
| 104 | + " os.environ[k] = v['path']\n", |
| 105 | + " print(f\"\\t{k} = {v['path']}\")\n", |
| 106 | + "\n", |
| 107 | + "else:\n", |
| 108 | + " print(\"Running on RNN — data already available, skipping local install.\")\n" |
| 109 | + ] |
| 110 | + }, |
| 111 | + { |
| 112 | + "cell_type": "markdown", |
| 113 | + "id": "b8e2590e", |
| 114 | + "metadata": {}, |
| 115 | + "source": [ |
50 | 116 | "## Imports\n", |
51 | 117 | "\n", |
52 | 118 | "Besides the Pandeia-related imports, we will use `scipy.optimize.minimize_scalar` to help with optimizing signal-to-noise ratios (SNRs), `scipy.interpolate.interp1d` to calculate a desired target magnitude for a given observing setup and `numpy` to handle numerical computing." |
|
0 commit comments