Skip to content

Commit

Permalink
Changes to get notebook running
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Shirley committed May 17, 2024
1 parent ec05eb8 commit dca196e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 227 deletions.
29 changes: 14 additions & 15 deletions examples/cosmos_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@
"metadata": {},
"outputs": [],
"source": [
"lephare_config_file = \"./data/COSMOS.para\"\n",
"lephare_config = lp.read_config(lephare_config_file)\n",
"lephare_config = lp.default_cosmos_config\n",
"# For useable science results you must use a denser redshift grid by commenting out the following line which will revert to the config dz of 0.01.\n",
"lephare_config['Z_STEP']=lp.keyword('Z_STEP', \".1,0.,7.\")\n",
"lephare_config['Z_STEP']= \".1,0.,7.\"\n",
"nobj=100 # Increase to run on more objects. Set to -1 to run on all.\n",
"\n",
"lp.data_retrieval.get_auxiliary_data(keymap=lephare_config, additional_files=[\"examples/COSMOS.in\",\"examples/output.para\"])"
Expand All @@ -68,16 +67,7 @@
"metadata": {},
"outputs": [],
"source": [
"lephare_config['AUTO_ADAPT'].value"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"bands=lephare_config['FILTER_LIST'].value.split(',')\n",
"bands=lephare_config['FILTER_LIST'].split(',')\n",
"len(bands)"
]
},
Expand Down Expand Up @@ -139,7 +129,7 @@
" nondetect_val=np.nan,\n",
" model=\"lephare.pkl\",\n",
" hdf5_groupname=\"\",\n",
" lephare_config=lp.keymap_to_string_dict(lephare_config),\n",
" lephare_config=lephare_config,\n",
" bands=flux_cols,\n",
" err_bands=flux_err_cols,\n",
" ref_band=flux_cols[0],\n",
Expand Down Expand Up @@ -175,6 +165,15 @@
"lephare_estimated = estimate_lephare.estimate(data)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lephare_config[\"AUTO_ADAPT\"] "
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -188,7 +187,7 @@
"metadata": {},
"outputs": [],
"source": [
"indx = 0\n",
"indx = 1\n",
"zgrid = np.linspace(0,7,1000)\n",
"plt.plot(zgrid, np.squeeze(lephare_estimated.data[indx].pdf(zgrid)), label='Estimated PDF')\n",
"plt.axvline(x=data['redshift'][indx], color='r', label='True redshift')\n",
Expand Down
210 changes: 0 additions & 210 deletions examples/data/COSMOS.para

This file was deleted.

4 changes: 2 additions & 2 deletions src/rail/estimation/algos/lephare.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import importlib

# We start with the COSMOS default and override with LSST specific values.
lsst_default_config=lp.default_cosmos_config
lsst_default_config=lp.default_cosmos_config.copy()
lsst_default_config.update({'CAT_IN': 'bidon',
'ERR_SCALE': '0.02,0.02,0.02,0.02,0.02,0.02',
'FILTER_CALIB': '0,0,0,0,0,0',
Expand Down Expand Up @@ -206,8 +206,8 @@ class LephareEstimator(CatEstimator):

def __init__(self, args, comm=None):
CatEstimator.__init__(self, args, comm=comm)
self.lephare_config = self.config["lephare_config"]
CatEstimator.open_model(self, **self.config)
self.lephare_config = self.model["lephare_config"]

Check warning on line 210 in src/rail/estimation/algos/lephare.py

View check run for this annotation

Codecov / codecov/patch

src/rail/estimation/algos/lephare.py#L210

Added line #L210 was not covered by tests
Z_STEP=self.model["lephare_config"]["Z_STEP"]
self.lephare_config["Z_STEP"]=Z_STEP
self.dz = float(Z_STEP.split(",")[0])
Expand Down

0 comments on commit dca196e

Please sign in to comment.