diff --git a/.gitmodules b/.gitmodules index a8ad3419..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "tutorials/simulated-data/OpenUniverse2024/fsps"] - path = tutorials/simulated-data/OpenUniverse2024/fsps - url = https://github.com/cconroy20/fsps.git diff --git a/tox.ini b/tox.ini index ec08db7a..5171dead 100644 --- a/tox.ini +++ b/tox.ini @@ -58,7 +58,7 @@ install_command = # Adding back the default install command; commented out version for clear cases, more complex one if we need to add more conditional skips # !oldestdeps: python -I -m pip install {opts} {packages} # fsps has issues installing on windows; dealing with it here - !oldestdeps: bash -c "if python -c 'import platform; print(platform.platform())' | grep -i win; then sed -i -e 's|fsps|\#fsps|g' tutorial_requirements.txt; elif [[ $CIRCLECI == true ]]; then sed -i -e 's|fsps|\#fsps|g' tutorial_requirements.txt; fi && python -I -m pip install $@" + !oldestdeps: bash -c "if python -c 'import platform; print(platform.platform())' | grep -i win; then sed -i -e 's|fsps|\#fsps|g' tutorial_requirements.txt; fi && python -I -m pip install $@" commands = diff --git a/tutorial_requirements.txt b/tutorial_requirements.txt index a62cbc2c..70b4983c 100644 --- a/tutorial_requirements.txt +++ b/tutorial_requirements.txt @@ -30,6 +30,8 @@ scikit-learn gdown astro-sedpy astro-prospector +dynesty<2.0.0 +fsps seaborn regions # For supporting myst-based notebooks, lower pin as we need a bugfix from that release diff --git a/tutorials/simulated-data/OpenUniverse2024/fsps b/tutorials/simulated-data/OpenUniverse2024/fsps deleted file mode 160000 index 82a87350..00000000 --- a/tutorials/simulated-data/OpenUniverse2024/fsps +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 82a873508d500ca353bbb922459bf928498f7a72 diff --git a/tutorials/simulated-data/OpenUniverse2024/openuniverse2024_SED_fit.md b/tutorials/simulated-data/OpenUniverse2024/openuniverse2024_SED_fit.md index 07a369fb..8c101abe 100644 --- a/tutorials/simulated-data/OpenUniverse2024/openuniverse2024_SED_fit.md +++ b/tutorials/simulated-data/OpenUniverse2024/openuniverse2024_SED_fit.md @@ -69,7 +69,7 @@ starttime = time.time() # %pip install numpy pandas h5py matplotlib seaborn pyarrow gdown # FSPS + Prospector + SEDPY+ dynasty are required for SED modeling # If you have trouble installing FSPS, you can skip SED modeling. -# %pip install astro-prospector astro-sedpy "dynesty<2.0.0" fsps +# %pip install astro-prospector astro-sedpy "dynesty<2.0.0" fsps pyarrow gdown ``` ```{code-cell} ipython3 @@ -194,7 +194,7 @@ def assemble_SN_data(sn_flux_file, galaxy_flux_file, galaxy_info_file, *, region galaxy_info_file : str S3 path to the corresponding galaxy info parquet (physical parameters). region : str, optional - S3 region, default to 'us-east-1' where Fornax is located. + S3 region, default to 'us-east-1' where Fornax is located. Returns ------- @@ -738,8 +738,8 @@ Choose this option if you: - do not need to change the fitting configuration --- -Both paths produce the same variables — `df_small`, `obs_list`, and `outputs` — so all of the downstream analysis and plotting cells will work identically. -If you are following this notebook for the first time, start with **Option B** by leaving `RUN_FITS = FALSE`to get a sense of the workflow, and come back later to experiment with **Option A** when you are ready to explore the full fitting process. +Both paths produce the same variables — `df_small`, `obs_list`, and `outputs` — so all of the downstream analysis and plotting cells will work identically. +If you are following this notebook for the first time, start with **Option B** by leaving `RUN_FITS = False`to get a sense of the workflow, and come back later to experiment with **Option A** when you are ready to explore the full fitting process. --- @@ -1200,40 +1200,51 @@ obs_list[0] +++ :::{caution} -This step runs Prospector on a small subset of galaxies and writes a new `sn_fits.h5` file. It can take **30+ minutes** depending on machine and number of CPUs. If you only want to explore results, **skip this step** and go to **3B** below. If you are sure you want to run this section yourself, change the RUN_FITS variable below to "True" +This step runs Prospector on a small subset of galaxies and writes a new `sn_fits.h5` file. + +It can take **30+ minutes** depending on machine and number of CPUs. +If you only want to explore results, **skip this step** and go to **3B** below. + +If you are sure you want to run this section yourself, change the RUN_FITS variable "True". ::: -```{code-cell} ipython3 -# This notebook uses [FSPS](https://github.com/cconroy20/fsps) to fit SEDs. -#FSPS requires installation which includes cloning that repo to get the data files. -#This repo ([irsa-tutorials](https://github.com/Caltech-IPAC/irsa-tutorials/)) includes FSPS as a submodule to make things a little easier. -#If you have cloned this repo, running the following cell will complete the setup. -#If not, either clone this repo and then run the cell or else follow the full instructions at the FSPS link instead. +#### FSPS installation and setup -if RUN_FITS: +This notebook uses [FSPS](https://github.com/cconroy20/fsps) to fit SEDs. +You will need to download this repo and set the path correcly. The full size will a few GBs. +The following cell will have some simple commands to do the downloading and basic setup. +Please uncomment these lines or otherwise follow the instructions on the FSPS link instead. - # Clone FSPS if not already available (only needed once). - # FSPS contains stellar population synthesis libraries used by Prospector. - # The first time this is run it will clone the FSPS repo and - # download more than 1 GB of code and data files. - # Idempotent unless there is a new FSPS commit in this repo (expect rarely). - !git submodule update --init +Fornax users can ignore this cell altogether, both the data and the environment variable is set up for the IRSA environment. - # Set the environment variable pointing to the cloned fsps directory. - from pathlib import Path - os.environ["SPS_HOME"] = f"{Path().cwd() / 'fsps'}" +```{code-cell} ipython3 +#if RUN_FITS: +# +# # Download the FSPS repository if not already available (only needed once). +# !git clone --depth=1 https://github.com/cconroy20/fsps +# +# # Set the environment variable pointing to the cloned fsps directory. +# from pathlib import Path +# os.environ["SPS_HOME"] = f"{Path().cwd() / 'fsps'}" +``` + +Now that the the data is downloaded and path is properly set, do the import and verifications: - # Now import fsps cleanly - import fsps, prospect.sources.galaxy_basis as gb #some hack required because of a bug in prospector +```{code-cell} ipython3 +if RUN_FITS: + import fsps + import prospect.sources.galaxy_basis as gb gb.fsps = fsps # inject fsps into the module namespace - #verify this setup worked + # verify this setup worked sp = fsps.StellarPopulation() print("Available FSPS libraries:", sp.libraries) from prospect.models import SpecModel from prospect.fitting import lnprobfn, fit_model ``` +#### Running the fits + ```{code-cell} ipython3 if RUN_FITS: