Repository navigation
Add SPHEREx Spectrophotometry Tool notebook #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,872
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| # Requires source extractor, which requires a conda install | ||
| tutorials/spherex/spherex_source_discovery/spherex_source_discovery_tool_demo.md | ||
| # Requires spherex-pipelines and tractor, which require a conda install | ||
| tutorials/spherex/spherex_spectrophotometry/spherex_spectrophotometry_tool.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
tutorials/spherex/spherex_spectrophotometry/build-spherex_spt-env.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Create a conda environment using conda-spherex_spt.yml, and an associated Jupyter kernel. | ||
| # Then install tractor-spherex and spherex-pipelines, which conda-spherex_spt.yml can't handle due to --no-build-isolation and --no-deps flags. | ||
| # | ||
| # Usage: ./build-spherex_spt-env.sh [args...] | ||
| # On Fornax, all arguments are passed through to setup-conda-env unchanged. | ||
| # | ||
| # If not running on Fornax, first create and activate the env, then run this script to install the rest. For example: | ||
| # conda env create -f conda-spherex_spt.yml | ||
| # conda activate spherex_spt | ||
| # python -m ipykernel install --name spherex_spt --user # optional: Jupyter kernel | ||
| # ./build-spherex_spt-env.sh | ||
|
|
||
| # Exit immediately if any command encounters a problem. | ||
| set -euo pipefail | ||
|
|
||
| # The Fornax command setup-conda-env (below) will name the env based on the filename syntax conda-{ENV_NAME}.yml. | ||
| # We expect conda-spherex_spt.yml, so the env name will be "spherex_spt". | ||
| ENV_NAME=spherex_spt | ||
|
|
||
| # If the command 'setup-conda-env' exists, we're on Fornax. | ||
| if command -v setup-conda-env >/dev/null; then | ||
| # Fornax: create the env and kernel based on conda-spherex_spt.yml. | ||
| setup-conda-env "$@" || exit $? | ||
|
|
||
| # Activate the env so we can use the numpy and swig libraries we've installed. | ||
| # setup-conda-env may have installed to $ENV_DIR or $USER_ENV_DIR, so check both. | ||
| env_path="$USER_ENV_DIR/$ENV_NAME" | ||
| [[ -d "$env_path" ]] || env_path="$ENV_DIR/$ENV_NAME" | ||
| eval "$(micromamba shell hook --shell bash)" | ||
| micromamba activate "$env_path" | ||
| else | ||
| # Elsewhere: expect the env from conda-spherex_spt.yml to already be active. | ||
| env_path="${CONDA_PREFIX:?activate the $ENV_NAME env first}" | ||
| fi | ||
|
|
||
| # Use uv pip if available (Fornax), else pip. | ||
| if command -v uv >/dev/null; then | ||
| pip_install=(uv pip install --python "$env_path") | ||
| else | ||
| pip_install=("$env_path/bin/python" -m pip install) | ||
| fi | ||
|
|
||
| # Install tractor-spherex (spherex-pipelines dependency). | ||
| # Use --no-build-isolation to use pre-installed numpy and swig (conda-spherex_spt.yml). | ||
| "${pip_install[@]}" --no-build-isolation git+https://github.com/Caltech-IPAC/tractor-spherex.git@066680f05b889c554f4dd30e8211ee957d66d56f | ||
|
|
||
| # Install spherex-pipelines (public tag 7.1.1+public.1). | ||
| # Without --no-deps it would try to install lsst_daf_butler[postgres], which brings in psycopg2, which requires a compiler. | ||
| # Instead, conda-spherex_spt.yml installs psycopg2-binary (and other spherex-pipelines dependencies) and we skip here using --no-deps. | ||
| # SETUPTOOLS_SCM_PRETEND_VERSION works around a known spherex-pipelines issue: setuptools_scm cannot parse | ||
| # public tags such as 7.1.1+public.1, so building from them fails. Remove it once a fix is released. | ||
| SETUPTOOLS_SCM_PRETEND_VERSION=7.1.1+public.1 \ | ||
| "${pip_install[@]}" --no-deps git+https://github.com/Caltech-IPAC/spherex-pipelines.git@2cd6ca41e5c204a0e1b3ecf803c666fcd052f469 | ||
49 changes: 49 additions & 0 deletions
49
tutorials/spherex/spherex_spectrophotometry/conda-spherex_spt.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Environment for SPHEREx notebooks. | ||
| # Additional installs are needed for Spectrophotometry Tool notebook (see build-spherex_spt-env.sh). | ||
| name: spherex_spt | ||
| channels: | ||
| - conda-forge | ||
| dependencies: | ||
| - python>=3.11.0,<=3.13 # >=3.11.0 required by spherex-pipelines. kete doesn't provide wheels for >3.13. | ||
| - pip | ||
| # ---- spherex-pipelines dependencies | ||
| - astrometry # must install astrometry before spherex-pipelines. Not available on PyPI. | ||
| - alive-progress | ||
| - astropy | ||
| - click>8.3.0 # pin required by spherex-pipelines. | ||
| - gwcs | ||
| - healpy>=1.17.1 # pin required by spherex-pipelines | ||
| - ipywidgets | ||
| - joblib | ||
| - matplotlib | ||
| - numba | ||
| - numpy | ||
| - parsl | ||
| - photutils | ||
| - psycopg2-binary # lsst_daf_butler needs psycopg2 but that requires a compiler. Use psycopg2-binary instead. | ||
| - pyarrow | ||
| - pydantic>=2.3,<3 # pin required by spherex-pipelines | ||
| - regions | ||
| - reproject | ||
| - scikit-image | ||
| - scikit-learn | ||
| - scipy>=1.6 # pin required by spherex-pipelines | ||
| - sep | ||
| - sqlalchemy | ||
| - spiceypy | ||
| - swig==4.4.1 # swig==4.5.0 breaks tractor-spherex install | ||
| - tenacity | ||
| - tqdm | ||
| # ---- Additional libraries used in Spectrophotometry Tool notebook | ||
| - astroquery | ||
| - pyvo | ||
| - specutils | ||
| - s3fs | ||
|
|
||
| - pip: | ||
| # ---- spherex-pipelines dependencies not available on conda-forge | ||
| - opencv-python-headless # required by tractor-spherex | ||
| - kete<2.0 # pin required by spherex-pipelines. | ||
| - lsst_ctrl_mpexec | ||
| - lsst_pipe_base | ||
| - lsst_daf_butler |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am surprised that this hack is needed when you build from the hash only, but since it's spelt out to be just a temp workaround I suppose it is all OK.
OTOH, I wonder how we plan to notice a new release and what our process should be updating the notebook and associated files.