Skip to content

Commit

Permalink
Merge pull request #138 from LSSTDESC/tqz/utils_refactor
Browse files Browse the repository at this point in the history
Utils renaming
  • Loading branch information
ztq1996 authored May 9, 2024
2 parents 6236788 + b015ede commit 66cace4
Show file tree
Hide file tree
Showing 32 changed files with 200 additions and 216 deletions.
12 changes: 6 additions & 6 deletions examples/core_examples/Build_Save_Load_Run_Pipeline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
"import ceci\n",
"import rail\n",
"from rail.core.stage import RailStage\n",
"from rail.creation.degradation.spectroscopic_degraders import LineConfusion\n",
"from rail.creation.degradation.quantityCut import QuantityCut\n",
"from rail.creation.degradation.lsst_error_model import LSSTErrorModel\n",
"from rail.creation.degraders.spectroscopic_degraders import LineConfusion\n",
"from rail.creation.degraders.quantityCut import QuantityCut\n",
"from rail.creation.degraders.lsst_error_model import LSSTErrorModel\n",
"from rail.creation.engines.flowEngine import FlowCreator, FlowPosterior\n",
"from rail.core.data import TableHandle\n",
"from rail.core.stage import RailStage\n",
"from rail.core.util_stages import ColumnMapper, TableConverter"
"from rail.tools.table_tools import ColumnMapper, TableConverter"
]
},
{
Expand Down Expand Up @@ -94,7 +94,7 @@
"metadata": {},
"outputs": [],
"source": [
"from rail.core.utils import find_rail_file\n",
"from rail.utils.path_utils import find_rail_file\n",
"\n",
"flow_file = find_rail_file(\"examples_data/goldenspike_data/data/pretrained_flow.pkl\")\n",
"bands = [\"u\", \"g\", \"r\", \"i\", \"z\", \"y\"]\n",
Expand Down Expand Up @@ -371,7 +371,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.10.0"
},
"vscode": {
"interpreter": {
Expand Down
4 changes: 2 additions & 2 deletions examples/core_examples/FileIO_DataStore.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"metadata": {},
"outputs": [],
"source": [
"from rail.core.utils import find_rail_file\n",
"from rail.utils.path_utils import find_rail_file\n",
"trainFile = find_rail_file('examples_data/testdata/test_dc2_training_9816.hdf5')\n",
"testFile = find_rail_file('examples_data/testdata/test_dc2_validation_9816.hdf5')\n",
"\n",
Expand Down Expand Up @@ -393,7 +393,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.10.0"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/core_examples/FluxtoMag_and_Deredden_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"import tempfile\n",
"from rail.core.stage import RailStage\n",
"from rail.core.data import TableHandle\n",
"from rail.core.utils import find_rail_file\n",
"from rail.tools.util_photometry import LSSTFluxToMagConverter, Dereddener"
"from rail.utils.path_utils import find_rail_file\n",
"from rail.tools.photometry_tools import LSSTFluxToMagConverter, Dereddener"
]
},
{
Expand Down Expand Up @@ -232,7 +232,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.10.0"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/core_examples/Iterate_Tabular_Data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"metadata": {},
"outputs": [],
"source": [
"from rail.core.utils import find_rail_file\n",
"from rail.utils.path_utils import find_rail_file\n",
"pdfs_file = find_rail_file(\"examples_data/testdata/test_dc2_training_9816.hdf5\")"
]
},
Expand Down Expand Up @@ -178,7 +178,7 @@
"metadata": {},
"outputs": [],
"source": [
"from rail.core.util_stages import ColumnMapper"
"from rail.tools.table_tools import ColumnMapper"
]
},
{
Expand Down Expand Up @@ -219,7 +219,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.10.0"
}
},
"nbformat": 4,
Expand Down
211 changes: 105 additions & 106 deletions examples/core_examples/Run_Saved_Pipeline.ipynb
Original file line number Diff line number Diff line change
@@ -1,107 +1,106 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "ec47ab0a",
"metadata": {},
"source": [
"# Run a Saved Pipeline\n",
"\n",
"**Author:** Eric Charles\n",
"\n",
"**Last Run Successfully:** April 26, 2023"
]
},
{
"cell_type": "markdown",
"id": "ff1c1990",
"metadata": {},
"source": [
" \n",
"This notebook shows how to:\n",
"\n",
"1. Load a pipeline from a saved yaml file\n",
"\n",
"2. Run the loaded pipeline"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a29a1b21",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import ceci\n",
"from rail.core.utils import find_rail_file\n",
"\n",
"# To create a catalog, you need a model of what the distrubutions of the colors \n",
"# are--that's what this flow file is:\n",
"flow_file = find_rail_file('examples_data/goldenspike_data/data/pretrained_flow.pkl')\n",
"os.environ['FLOWDIR'] = os.path.dirname(flow_file)"
]
},
{
"cell_type": "markdown",
"id": "deaaff62",
"metadata": {},
"source": [
"Each pipeline file has an associated config file. Whenever ceci reads in a pipeline file called `[name].yml`, it will automatically look for a configuration file `[name]_config.yml` in the same directory.\n",
"\n",
"Here, we read in our `pipe_example.yml` pipeline, which is associated with `pipe_example.config.yml`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2657aca0",
"metadata": {},
"outputs": [],
"source": [
"\n",
"p = ceci.Pipeline.read('pipe_example.yml')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "38e445de",
"metadata": {},
"outputs": [],
"source": [
"p.run()"
]
},
{
"cell_type": "markdown",
"id": "cb8a7120",
"metadata": {},
"source": [
"Yep, that's it."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

"cells": [
{
"cell_type": "markdown",
"id": "ec47ab0a",
"metadata": {},
"source": [
"# Run a Saved Pipeline\n",
"\n",
"**Author:** Eric Charles\n",
"\n",
"**Last Run Successfully:** April 26, 2023"
]
},
{
"cell_type": "markdown",
"id": "ff1c1990",
"metadata": {},
"source": [
" \n",
"This notebook shows how to:\n",
"\n",
"1. Load a pipeline from a saved yaml file\n",
"\n",
"2. Run the loaded pipeline"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a29a1b21",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import ceci\n",
"from rail.utils.path_utils import find_rail_file\n",
"\n",
"# To create a catalog, you need a model of what the distrubutions of the colors \n",
"# are--that's what this flow file is:\n",
"flow_file = find_rail_file('examples_data/goldenspike_data/data/pretrained_flow.pkl')\n",
"os.environ['FLOWDIR'] = os.path.dirname(flow_file)"
]
},
{
"cell_type": "markdown",
"id": "deaaff62",
"metadata": {},
"source": [
"Each pipeline file has an associated config file. Whenever ceci reads in a pipeline file called `[name].yml`, it will automatically look for a configuration file `[name]_config.yml` in the same directory.\n",
"\n",
"Here, we read in our `pipe_example.yml` pipeline, which is associated with `pipe_example.config.yml`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2657aca0",
"metadata": {},
"outputs": [],
"source": [
"\n",
"p = ceci.Pipeline.read('pipe_example.yml')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "38e445de",
"metadata": {},
"outputs": [],
"source": [
"p.run()"
]
},
{
"cell_type": "markdown",
"id": "cb8a7120",
"metadata": {},
"source": [
"Yep, that's it."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
8 changes: 4 additions & 4 deletions examples/core_examples/Useful_Utilities.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"source": [
"# with prefix\n",
"\n",
"print(rail.core.util_stages.ColumnMapper)"
"print(rail.tools.table_tools.ColumnMapper)"
]
},
{
Expand Down Expand Up @@ -228,7 +228,7 @@
"outputs": [],
"source": [
"import os\n",
"from rail.core.utils import RAILDIR\n",
"from rail.utils.path_utils import RAILDIR\n",
"\n",
"flow_file = os.path.join(\n",
" RAILDIR, \"rail/examples_data/goldenspike_data/data/pretrained_flow.pkl\"\n",
Expand All @@ -250,7 +250,7 @@
"metadata": {},
"outputs": [],
"source": [
"from rail.core.utils import find_rail_file\n",
"from rail.utils.path_utils import find_rail_file\n",
"\n",
"flow_file = find_rail_file('examples_data/goldenspike_data/data/pretrained_flow.pkl')"
]
Expand Down Expand Up @@ -585,7 +585,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.10.0"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/core_examples/hyperbolic_magnitude_test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"import rail\n",
"from rail.core.data import TableHandle\n",
"from rail.core.stage import RailStage\n",
"from rail.tools.util_photometry import HyperbolicSmoothing, HyperbolicMagnitudes"
"from rail.tools.photometry_tools import HyperbolicSmoothing, HyperbolicMagnitudes"
]
},
{
Expand Down Expand Up @@ -75,7 +75,7 @@
"metadata": {},
"outputs": [],
"source": [
"from rail.core.utils import find_rail_file\n",
"from rail.utils.path_utils import find_rail_file\n",
"testFile = find_rail_file('examples_data/testdata/test_dc2_training_9816.pq')\n",
"test_mags = DS.read_file(\"test_data\", TableHandle, testFile)"
]
Expand Down Expand Up @@ -237,7 +237,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.10.0"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/core_examples/pipe_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ stages:
name: flow_engine_test
nprocess: 1
- classname: LSSTErrorModel
module_name: rail.creation.degradation.lsst_error_model
module_name: rail.creation.degraders.lsst_error_model
name: lsst_error_model_test
nprocess: 1
- classname: ColumnMapper
module_name: rail.core.utilStages
module_name: rail.tools.table_tools
name: col_remapper_test
nprocess: 1
- classname: TableConverter
module_name: rail.core.utilStages
module_name: rail.tools.table_tools
name: table_conv_test
nprocess: 1
Loading

0 comments on commit 66cace4

Please sign in to comment.