pz-rail-astro-tools 1.0.4__py3-none-any.whl → 1.0.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pz-rail-astro-tools might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pz-rail-astro-tools
3
- Version: 1.0.4
3
+ Version: 1.0.5
4
4
  Author-email: "LSST Dark Energy Science Collaboration (DESC)" <lsst-desc-rail-admin@slac.stanford.edu>
5
5
  License: MIT License
6
6
 
@@ -43,6 +43,7 @@ Requires-Dist: photerr
43
43
  Requires-Dist: dustmaps
44
44
  Requires-Dist: pz-hyperbolic-temp
45
45
  Requires-Dist: lsstdesc-gcr-catalogs
46
+ Requires-Dist: FoFCatalogMatching
46
47
  Provides-Extra: dev
47
48
  Requires-Dist: tables-io[full] ; extra == 'dev'
48
49
  Requires-Dist: pytest ; extra == 'dev'
@@ -1,10 +1,12 @@
1
- rail/astro_tools/__init__.py,sha256=io9H1Oj-nETawIrXSg3nE_upqDBA7R_7emoN7dO7BMU,322
2
- rail/astro_tools/_version.py,sha256=9acUHRb1fq-uv5dr49LlEh189daKw4-SeypW5NxDolA,411
1
+ rail/astro_tools/__init__.py,sha256=4J-E0Ug0RP3Y38g8kJ6auAPDPEI4Osf19tuSOAACfxk,432
2
+ rail/astro_tools/_version.py,sha256=ClFIlbf5O23dVWC6oD6t3m2n6nB22IOt3V9t-YX_mG0,411
3
+ rail/creation/degraders/bl_demo.ipynb,sha256=GgaIU1hH_6WgnAJxWDzg79j-fO3_bvjOXbwRIzdAgnM,5633
3
4
  rail/creation/degraders/grid_selection.py,sha256=gJKM0AYdG-HgvjTS3ovupbyoB5bxKhZn9FAAb94pQXY,12429
4
5
  rail/creation/degraders/observing_condition_degrader.py,sha256=y6Nal_kSdAz6N8amY4oV6mQ3upa2nIgVbV9P6F0PKwA,19977
5
- rail/creation/degraders/photometric_errors.py,sha256=aOe6bfI0vg1qDIylm8Uziv1MDDoHkgcdm7vv2s0N1zE,3840
6
- rail/creation/degraders/spectroscopic_degraders.py,sha256=2OhT6ZfD2KVqsQauFKkJZezuuyQtZEcysNVw0acGLns,5019
6
+ rail/creation/degraders/photometric_errors.py,sha256=xeLI5dH4P-kseClMsy7vTes6EBXh2Ca8_-9-nnFt3b0,4396
7
+ rail/creation/degraders/spectroscopic_degraders.py,sha256=27kylHksXf4MhgdfefSL7C2S3WCK-0YQ1Oc8dOHIBhc,5350
7
8
  rail/creation/degraders/spectroscopic_selections.py,sha256=TXlghBWLAniokbUpgw4IQVf3y3R6BwralS0ddiVgMp4,22205
9
+ rail/creation/degraders/unrec_bl_model.py,sha256=mfc3WMfX5QEqZqdeaCRek4I44MYlcXEx-1CkrHSbEIA,3870
8
10
  rail/creation/engines/gcr_engine.py,sha256=LSp599uQGu8GcFNUmib792ScQwSB_Og8VxPLTt9aSNU,2981
9
11
  rail/examples_data/creation_data/data/HSC_grid_settings.pkl,sha256=zpJoSR9TSnDyL64DPXivIMam3fn6GOZoyoJoeBj2LAk,141
10
12
  rail/examples_data/creation_data/data/hsc_ratios_and_specz.hdf5,sha256=liH54wuuuHxToqjoAwQ_fFmEefk3haNweVThMwdDKN4,13823712
@@ -13,11 +15,12 @@ rail/examples_data/creation_data/data/survey_conditions/DC2-mask-neg-nside-128.f
13
15
  rail/examples_data/creation_data/data/survey_conditions/minion_1016_dc2_Median_airmass_i_and_nightlt1825_HEAL.fits,sha256=twvyce70G3h1MQnGGFQJG9wZc8UbuNqXc6mjtiuaL1s,1581120
14
16
  rail/examples_data/creation_data/data/survey_conditions/minion_1016_dc2_Median_fiveSigmaDepth_i_and_nightlt1825_HEAL.fits,sha256=RbMMFSVJQxGhZnL4BnISE9VTNljfTZwV6Bax6NxverY,1581120
15
17
  rail/examples_data/testdata/rubin_dm_dc2_example2.pq,sha256=_Iihbbcz1A332QAkaMiFacT4QAbBQBMTOwpfrS7AclE,25884
16
- rail/pipelines/utility/apply_phot_errors.py,sha256=w3JyYhBdJrnJBmPofziUka4xJI9JwsvX9k-Gkk5t4us,1894
17
- rail/pipelines/utility/spectroscopic_selection_pipeline.py,sha256=-662xtT3pgOXvUVXhnaS-tJa3IGoqA3G-YVC7En54u8,2040
18
- rail/tools/photometry_tools.py,sha256=O9BUq94-_KWEsje1aZ3JBnNIfGx1r91CSkn3HyJUpy4,19080
19
- pz_rail_astro_tools-1.0.4.dist-info/LICENSE,sha256=tLMEN21HbzvT-7umOVVvPjaJZbQxCa-2bAeYLwG5Q04,1102
20
- pz_rail_astro_tools-1.0.4.dist-info/METADATA,sha256=1-qoUBXnSuSWGiyJDMHf7UsqfbuxAaR37Cx7wD0XnK8,4006
21
- pz_rail_astro_tools-1.0.4.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
22
- pz_rail_astro_tools-1.0.4.dist-info/top_level.txt,sha256=6R6sqn-85I8YZTzmB9gv7sqckB2QaOTHbu-QLGTWBRE,5
23
- pz_rail_astro_tools-1.0.4.dist-info/RECORD,,
18
+ rail/pipelines/degradation/apply_phot_errors.py,sha256=vj2avYWxfavORIXzJ7925V9YkuRmRMBSP0C8-DmgkSw,1958
19
+ rail/pipelines/degradation/blending.py,sha256=oxZHy1Tai70wT4g4xnBr24z2LxmR1p_J6lMoTN0nFc8,564
20
+ rail/pipelines/degradation/spectroscopic_selection_pipeline.py,sha256=D0sDi6nrasv5CvQkLXgmMp0QbDrhGFRXzt6sWjlbD68,2028
21
+ rail/tools/photometry_tools.py,sha256=wfKAeMz5T_CYDPC661MHtU1aJXVqomvahZl87KuE7uY,19541
22
+ pz_rail_astro_tools-1.0.5.dist-info/LICENSE,sha256=tLMEN21HbzvT-7umOVVvPjaJZbQxCa-2bAeYLwG5Q04,1102
23
+ pz_rail_astro_tools-1.0.5.dist-info/METADATA,sha256=tbPI6gnnaLabQK0FraTJcEelWyTgVHjAEWdNU-c6iCo,4040
24
+ pz_rail_astro_tools-1.0.5.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
25
+ pz_rail_astro_tools-1.0.5.dist-info/top_level.txt,sha256=6R6sqn-85I8YZTzmB9gv7sqckB2QaOTHbu-QLGTWBRE,5
26
+ pz_rail_astro_tools-1.0.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (72.1.0)
2
+ Generator: setuptools (72.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -4,4 +4,6 @@ from rail.creation.degraders.grid_selection import *
4
4
  from rail.creation.degraders.observing_condition_degrader import *
5
5
  from rail.creation.degraders.spectroscopic_degraders import *
6
6
  from rail.creation.degraders.spectroscopic_selections import *
7
+ from rail.creation.degraders.photometric_errors import *
8
+ from rail.creation.degraders.unrec_bl_model import *
7
9
  from rail.tools.photometry_tools import *
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '1.0.4'
16
- __version_tuple__ = version_tuple = (1, 0, 4)
15
+ __version__ = version = '1.0.5'
16
+ __version_tuple__ = version_tuple = (1, 0, 5)
@@ -0,0 +1,206 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "2610a0f0-0c71-4401-896f-734442bcd66d",
6
+ "metadata": {},
7
+ "source": [
8
+ "## Blending Degrader demo\n",
9
+ "\n",
10
+ "author: Shuang Liang\n",
11
+ "\n",
12
+ "This notebook demonstrate the use of `rail.creation.degradation.unrec_bl_model`, which uses Friends of Friends to finds sources close to each other and merge them into unrecognized blends"
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "code",
17
+ "execution_count": null,
18
+ "id": "f7a6adc3-68e8-4a1d-842f-bfb0960a1c4a",
19
+ "metadata": {},
20
+ "outputs": [],
21
+ "source": [
22
+ "from rail.creation.degraders.unrec_bl_model import UnrecBlModel\n",
23
+ "\n",
24
+ "from rail.core.data import PqHandle\n",
25
+ "from rail.core.stage import RailStage\n",
26
+ "\n",
27
+ "import matplotlib.pyplot as plt\n",
28
+ "import pandas as pd, numpy as np"
29
+ ]
30
+ },
31
+ {
32
+ "cell_type": "code",
33
+ "execution_count": null,
34
+ "id": "6912a740-31ea-4987-b06d-81ff17cd895a",
35
+ "metadata": {},
36
+ "outputs": [],
37
+ "source": [
38
+ "DS = RailStage.data_store\n",
39
+ "DS.__class__.allow_overwrite = True\n"
40
+ ]
41
+ },
42
+ {
43
+ "cell_type": "markdown",
44
+ "id": "a282c2ed-141b-4507-8254-dc8fbc9864dc",
45
+ "metadata": {},
46
+ "source": [
47
+ "### Create a random catalog with ugrizy+YJHF bands as the the true input"
48
+ ]
49
+ },
50
+ {
51
+ "cell_type": "code",
52
+ "execution_count": null,
53
+ "id": "1078bc2a-fc54-41c3-bd30-6c447bb971d4",
54
+ "metadata": {},
55
+ "outputs": [],
56
+ "source": [
57
+ "data = np.random.normal(23, 3, size = (1000,12))\n",
58
+ "data[:, 0] = np.random.uniform(low=0, high=0.03, size=1000)\n",
59
+ "data[:, 1] = np.random.uniform(low=0, high=0.03, size=1000)\n",
60
+ "\n",
61
+ "data_df = pd.DataFrame(data=data, # values\n",
62
+ " columns=['ra', 'dec', 'u', 'g', 'r', 'i', 'z', 'y', 'Y', 'J', 'H', 'F'])\n",
63
+ "\n",
64
+ "data_truth = DS.add_data('input', data_df, PqHandle)"
65
+ ]
66
+ },
67
+ {
68
+ "cell_type": "code",
69
+ "execution_count": null,
70
+ "id": "33c99a4d-8375-4003-9a9a-70fa85a3eb82",
71
+ "metadata": {},
72
+ "outputs": [],
73
+ "source": [
74
+ "#data_df.to_parquet('bl_test.pq')"
75
+ ]
76
+ },
77
+ {
78
+ "cell_type": "code",
79
+ "execution_count": null,
80
+ "id": "a5636721-a734-4746-bd93-8101bc558b6e",
81
+ "metadata": {},
82
+ "outputs": [],
83
+ "source": [
84
+ "plt.scatter(data_truth.data['ra'], data_truth.data['dec'], s=5)\n",
85
+ "plt.xlabel(\"Ra [Deg]\", fontsize=14)\n",
86
+ "plt.ylabel(\"Dec [Deg]\", fontsize=14)\n",
87
+ "plt.show()\n"
88
+ ]
89
+ },
90
+ {
91
+ "cell_type": "markdown",
92
+ "id": "1da27deb-d167-4f38-8c59-f270184d6ab3",
93
+ "metadata": {},
94
+ "source": [
95
+ "### The blending model"
96
+ ]
97
+ },
98
+ {
99
+ "cell_type": "code",
100
+ "execution_count": null,
101
+ "id": "a07f72a0-e24c-4844-90f0-d5a49ac4362b",
102
+ "metadata": {},
103
+ "outputs": [],
104
+ "source": [
105
+ "## radius cut is in arcsecs\n",
106
+ "blModel = UnrecBlModel.make_stage(name='unrec_bl_model', ra_label='ra', dec_label='dec', linking_lengths=1.0, \\\n",
107
+ " bands='ugrizyYJHF')\n",
108
+ "blModel.get_config_dict()\n"
109
+ ]
110
+ },
111
+ {
112
+ "cell_type": "code",
113
+ "execution_count": null,
114
+ "id": "e5f4862a-0621-46d4-8901-7e84b461c424",
115
+ "metadata": {},
116
+ "outputs": [],
117
+ "source": [
118
+ "samples_w_bl = blModel(data_truth)\n",
119
+ "samples_w_bl()\n"
120
+ ]
121
+ },
122
+ {
123
+ "cell_type": "code",
124
+ "execution_count": null,
125
+ "id": "bc5158dd-f474-4731-b847-b4a7358656b9",
126
+ "metadata": {},
127
+ "outputs": [],
128
+ "source": [
129
+ "fig, ax = plt.subplots(figsize=(6, 5), dpi=100)\n",
130
+ "\n",
131
+ "ax.scatter(data_truth.data['ra'], data_truth.data['dec'], s=10, facecolors='none', edgecolors='b', label='Original')\n",
132
+ "ax.scatter(samples_w_bl.data['ra'], samples_w_bl.data['dec'], s=5, c='r', label='w. Unrec-BL')\n",
133
+ "\n",
134
+ "ax.legend(loc=2, fontsize=12)\n",
135
+ "ax.set_xlabel(\"Ra [Deg]\", fontsize=14)\n",
136
+ "ax.set_ylabel(\"Dec [Deg]\", fontsize=14)\n",
137
+ "\n",
138
+ "plt.show()\n"
139
+ ]
140
+ },
141
+ {
142
+ "cell_type": "code",
143
+ "execution_count": null,
144
+ "id": "268b3d37-b7fd-4ac1-8457-2104a87c9e6d",
145
+ "metadata": {},
146
+ "outputs": [],
147
+ "source": [
148
+ "b = 'r'\n",
149
+ "plt.hist(data_truth.data[b], bins=np.linspace(10, 30, 20), label='Original')\n",
150
+ "plt.hist(samples_w_bl.data[b], bins=np.linspace(10, 30, 20), fill=False, label='w. Unrec-BL')\n",
151
+ "\n",
152
+ "plt.xlabel(fr'Magnitude ${b}$', fontsize=14)\n",
153
+ "plt.legend(fontsize=12)\n",
154
+ "plt.show()\n"
155
+ ]
156
+ },
157
+ {
158
+ "cell_type": "code",
159
+ "execution_count": null,
160
+ "id": "a1d51c15-1e04-4b22-9abb-9b267965dbeb",
161
+ "metadata": {},
162
+ "outputs": [],
163
+ "source": [
164
+ "flux = 10**(-(data_truth.data[b]-28.10)/2.5) # r band zp for lsst is 28.10\n",
165
+ "flux_bl = 10**(-(samples_w_bl.data[b]-28.10)/2.5)\n",
166
+ "\n",
167
+ "plt.hist(flux, bins=np.linspace(0, 10000, 40), label='Original')\n",
168
+ "plt.hist(flux_bl, bins=np.linspace(0, 10000, 40), fill=False, label='w. Unrec-BL')\n",
169
+ "\n",
170
+ "plt.xlabel(fr'Flux ${b}$', fontsize=14)\n",
171
+ "plt.yscale('log')\n",
172
+ "plt.legend(fontsize=12)\n",
173
+ "plt.show()\n"
174
+ ]
175
+ },
176
+ {
177
+ "cell_type": "code",
178
+ "execution_count": null,
179
+ "id": "da2b37c8-4667-4ad2-ad09-b1c68d2612b8",
180
+ "metadata": {},
181
+ "outputs": [],
182
+ "source": []
183
+ }
184
+ ],
185
+ "metadata": {
186
+ "kernelspec": {
187
+ "display_name": "Python 3 (ipykernel)",
188
+ "language": "python",
189
+ "name": "python3"
190
+ },
191
+ "language_info": {
192
+ "codemirror_mode": {
193
+ "name": "ipython",
194
+ "version": 3
195
+ },
196
+ "file_extension": ".py",
197
+ "mimetype": "text/x-python",
198
+ "name": "python",
199
+ "nbconvert_exporter": "python",
200
+ "pygments_lexer": "ipython3",
201
+ "version": "3.12.3"
202
+ }
203
+ },
204
+ "nbformat": 4,
205
+ "nbformat_minor": 5
206
+ }
@@ -45,7 +45,7 @@ class PhotoErrorModel(Noisifier):
45
45
  default = val.default_factory()
46
46
  else:
47
47
  default = val.default
48
-
48
+
49
49
  # Add this param to config_options
50
50
  self.config[key] = Param(
51
51
  None, # Let PhotErr handle type checking
@@ -53,6 +53,18 @@ class PhotoErrorModel(Noisifier):
53
53
  msg="See the main docstring for details about this parameter.",
54
54
  required=False,
55
55
  )
56
+
57
+ def reload_pars(self, args):
58
+ """ This is needed b/c the parameters are dynamically defined,
59
+ so we have to reload them _after_ then have been defined """
60
+ copy_args = args.copy()
61
+ if isinstance(args, dict):
62
+ copy_args['config'] = args
63
+ else: # pragma: no cover
64
+ copy_args['config'] = vars(args)
65
+ self.load_configs(copy_args)
66
+ self._io_checked = False
67
+ self.check_io()
56
68
 
57
69
  def _initNoiseModel(self):
58
70
  """
@@ -67,7 +79,6 @@ class PhotoErrorModel(Noisifier):
67
79
  """
68
80
  Add noise to the input catalog
69
81
  """
70
-
71
82
  # Load the input catalog
72
83
  data = self.get_data("input")
73
84
 
@@ -95,10 +106,9 @@ class LSSTErrorModel(PhotoErrorModel):
95
106
  super().__init__(args, **kwargs)
96
107
 
97
108
  self.set_params(peLsstErrorParams)
109
+ self.reload_pars(args)
98
110
  self.peNoiseModel = peLsstErrorModel
99
111
 
100
-
101
-
102
112
 
103
113
  class RomanErrorModel(PhotoErrorModel):
104
114
 
@@ -113,6 +123,7 @@ class RomanErrorModel(PhotoErrorModel):
113
123
  super().__init__(args, **kwargs)
114
124
 
115
125
  self.set_params(peRomanErrorParams)
126
+ self.reload_pars(args)
116
127
  self.peNoiseModel = peRomanErrorModel
117
128
 
118
129
 
@@ -130,4 +141,5 @@ class EuclidErrorModel(PhotoErrorModel):
130
141
  super().__init__(args, **kwargs)
131
142
 
132
143
  self.set_params(peEuclidErrorParams)
144
+ self.reload_pars(args)
133
145
  self.peNoiseModel = peEuclidErrorModel
@@ -2,6 +2,7 @@
2
2
 
3
3
  import numpy as np
4
4
  import pandas as pd
5
+ from ceci.config import StageParameter as Param
5
6
  from rail.creation.selector import Selector
6
7
  from rail.creation.noisifier import Noisifier
7
8
 
@@ -40,9 +41,11 @@ class LineConfusion(Noisifier):
40
41
 
41
42
  name = 'LineConfusion'
42
43
  config_options = Noisifier.config_options.copy()
43
- config_options.update(true_wavelen=float,
44
- wrong_wavelen=float,
45
- frac_wrong=float)
44
+ config_options.update(
45
+ true_wavelen=Param(float, required=True, msg="wavelength of the true emission line"),
46
+ wrong_wavelen=Param(float, required=True, msg="wavelength of the wrong emission line"),
47
+ frac_wrong=Param(float, required=True, msg="fraction of galaxies with confused emission lines"),
48
+ )
46
49
 
47
50
  def __init__(self, args, **kwargs):
48
51
  """
@@ -113,7 +116,9 @@ class InvRedshiftIncompleteness(Selector):
113
116
 
114
117
  name = 'InvRedshiftIncompleteness'
115
118
  config_options = Selector.config_options.copy()
116
- config_options.update(pivot_redshift=float)
119
+ config_options.update(
120
+ pivot_redshift=Param(float, required=True, msg="redshift at which the incompleteness begins"),
121
+ )
117
122
 
118
123
  def __init__(self, args, **kwargs):
119
124
  """
@@ -0,0 +1,98 @@
1
+ """Model for Creating Unrecognized Blends"""
2
+
3
+ from ceci.config import StageParameter as Param
4
+ from rail.creation.degrader import Degrader
5
+ import numpy as np, pandas as pd
6
+ import FoFCatalogMatching
7
+
8
+
9
+ class UnrecBlModel(Degrader):
10
+ """Model for Creating Unrecognized Blends.
11
+
12
+ Finding objects nearby each other. Merge them into one blended
13
+ Use Friends of Friends for matching. May implement shape matching in the future.
14
+ Take avergaged Ra and Dec for blended source, and sum up fluxes in each band. May implement merged shapes in the future.
15
+
16
+ """
17
+ name = "UnrecBlModel"
18
+ config_options = Degrader.config_options.copy()
19
+ config_options.update(ra_label=Param(str, 'ra', msg='ra column name'),
20
+ dec_label=Param(str, 'dec', msg='dec column name'),
21
+ linking_lengths=Param(float, 1.0, msg='linking_lengths for FoF matching'),
22
+ bands=Param(str, 'ugrizy', msg='name of filters'),
23
+ match_size=Param(bool, False, msg='consider object size for finding blends'),
24
+ match_shape=Param(bool, False, msg='consider object shape for finding blends'),
25
+ obj_size=Param(str, 'obj_size', msg='object size column name'),
26
+ a=Param(str, 'semi_major', msg='semi major axis column name'),
27
+ b=Param(str, 'semi_minor', msg='semi minor axis column name'),
28
+ theta=Param(str, 'orientation', msg='orientation angle column name'))
29
+
30
+ def __match_bl__(self, data):
31
+
32
+ """Group sources with friends of friends"""
33
+
34
+ ra_label, dec_label = self.config.ra_label, self.config.dec_label
35
+ linking_lengths = self.config.linking_lengths
36
+
37
+ results = FoFCatalogMatching.match({'truth': data}, linking_lengths=linking_lengths, ra_label=ra_label, dec_label=dec_label)
38
+ results.remove_column('catalog_key')
39
+
40
+ results = results.to_pandas(index='row_index')
41
+ results.sort_values(by='row_index', inplace=True)
42
+
43
+ ## adding the group id as the last column to data
44
+ matchData = pd.merge(data, results, left_index=True, right_index=True)
45
+
46
+ return matchData
47
+
48
+ def __merge_bl__(self, data):
49
+
50
+ """Merge sources within a group into unrecognized blends."""
51
+
52
+ group_id = data['group_id']
53
+ unique_id = np.unique(group_id)
54
+
55
+ ra_label, dec_label = self.config.ra_label, self.config.dec_label
56
+
57
+ cols = list(data.columns)
58
+ ra_ind = cols.index(ra_label)
59
+ dec_ind = cols.index(dec_label)
60
+ bands_ind = {b:cols.index(b) for b in self.config.bands}
61
+
62
+ N_rows = len(unique_id)
63
+ N_cols = len(cols)
64
+
65
+ mergeData = np.zeros((N_rows, N_cols))
66
+
67
+ for i, id in enumerate(unique_id):
68
+
69
+ this_group = data.query(f'group_id=={id}')
70
+
71
+ ## take the average position for the blended source
72
+ mergeData[i, ra_ind] = this_group[ra_label].mean()
73
+ mergeData[i, dec_ind] = this_group[dec_label].mean()
74
+
75
+ ## sum up the fluxes into the blended source
76
+ for b in self.config.bands:
77
+ mergeData[i, bands_ind[b]] = -2.5*np.log10(np.sum(10**(-this_group[b]/2.5)))
78
+
79
+ mergeData[:,-1] = unique_id
80
+ mergeData_df = pd.DataFrame(data=mergeData, columns=cols)
81
+ mergeData_df['group_id'] = mergeData_df['group_id'].astype(int)
82
+
83
+ return mergeData_df
84
+
85
+ def run(self):
86
+ """Return pandas DataFrame with blending errors."""
87
+
88
+ # Load the input catalog
89
+ data = self.get_data("input")
90
+
91
+ # Match for close-by objects
92
+ matchData = self.__match_bl__(data)
93
+
94
+ # Merge matched objects into unrec-bl
95
+ blData = self.__merge_bl__(matchData)
96
+
97
+ # Return the new catalog
98
+ self.add_data("output", blData)
@@ -52,6 +52,7 @@ class ApplyPhotErrorsPipeline(RailPipeline):
52
52
 
53
53
  self.reddener = Reddener.build(
54
54
  dustmap_dir=dustmap_dir,
55
+ copy_all_cols=True,
55
56
  )
56
57
 
57
58
  previous_stage = self.reddener
@@ -68,4 +69,5 @@ class ApplyPhotErrorsPipeline(RailPipeline):
68
69
  self.dereddener_errors = Dereddener.build(
69
70
  dustmap_dir=dustmap_dir,
70
71
  connections=dict(input=previous_stage.io.output),
72
+ copy_all_cols=True,
71
73
  )
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ # Prerquisites, os, and numpy
5
+ import os
6
+ import numpy as np
7
+
8
+ # Various rail modules
9
+ from rail.creation.degraders.unrec_bl_model import UnrecBlModel
10
+
11
+ from rail.core.stage import RailStage, RailPipeline
12
+
13
+ import ceci
14
+
15
+ from rail.core.utils import RAILDIR
16
+
17
+
18
+ class BlendingPipeline(RailPipeline):
19
+
20
+ default_input_dict = dict(input='dummy.in')
21
+
22
+ def __init__(self):
23
+ RailPipeline.__init__(self)
24
+
25
+ DS = RailStage.data_store
26
+ DS.__class__.allow_overwrite = True
27
+
28
+ self.unrec_bl = UnrecBlModel.build()
@@ -16,23 +16,23 @@ from rail.core.utils import RAILDIR
16
16
 
17
17
  SELECTORS = dict(
18
18
  GAMA = dict(
19
- Selector='SpecSelection_GAMA',
19
+ Select='SpecSelection_GAMA',
20
20
  Module='rail.creation.degraders.spectroscopic_selections',
21
21
  ),
22
22
  BOSS = dict(
23
- Selector='SpecSelection_BOSS',
23
+ Select='SpecSelection_BOSS',
24
24
  Module='rail.creation.degraders.spectroscopic_selections',
25
25
  ),
26
26
  VVDSf02 = dict(
27
- Selector='SpecSelection_VVDSf02',
27
+ Select='SpecSelection_VVDSf02',
28
28
  Module='rail.creation.degraders.spectroscopic_selections',
29
29
  ),
30
30
  zCOSMOS = dict(
31
- Selector='SpecSelection_zCOSMOS',
31
+ Select='SpecSelection_zCOSMOS',
32
32
  Module='rail.creation.degraders.spectroscopic_selections',
33
33
  ),
34
34
  HSC = dict(
35
- Selector='SpecSelection_HSC',
35
+ Select='SpecSelection_HSC',
36
36
  Module='rail.creation.degraders.spectroscopic_selections',
37
37
  ),
38
38
  )
@@ -66,7 +66,7 @@ class SpectroscopicSelectionPipeline(RailPipeline):
66
66
  config_pars['colnames'] = colnames
67
67
 
68
68
  for key, val in selectors.items():
69
- the_class = ceci.PipelineStage.get_stage(val['Selector'], val['Module'])
69
+ the_class = ceci.PipelineStage.get_stage(val['Select'], val['Module'])
70
70
  the_selector = the_class.make_and_connect(
71
71
  name=f'select_{key}',
72
72
  **config_pars,
@@ -358,13 +358,15 @@ class LSSTFluxToMagConverter(RailStage):
358
358
  name = 'LSSTFluxToMagConverter'
359
359
 
360
360
  config_options = RailStage.config_options.copy()
361
- config_options.update(bands='ugrizy')
362
- config_options.update(flux_name="{band}_gaap1p0Flux")
363
- config_options.update(flux_err_name="{band}_gaap1p0FluxErr")
364
- config_options.update(mag_name="mag_{band}_lsst")
365
- config_options.update(mag_err_name="mag_err_{band}_lsst")
366
- config_options.update(copy_cols={})
367
- config_options.update(mag_offset=31.4)
361
+ config_options.update(
362
+ bands=Param(str, default='ugrizy', msg="Names of the bands"),
363
+ flux_name=Param(str, default="{band}_gaap1p0Flux", msg="Template for band names"),
364
+ flux_err_name=Param(str, default="{band}_gaap1p0FluxErr", msg="Template for band error column names"),
365
+ mag_name=Param(str, default="mag_{band}_lsst", msg="Template for magnitude column names"),
366
+ mag_err_name=Param(str, default="mag_err_{band}_lsst", msg="Template for magnitude error column names"),
367
+ copy_cols=Param(dict, default={}, msg="Map of other columns to copy"),
368
+ mag_offset=Param(float, default=31.4, msg="Magntidue offset value"),
369
+ )
368
370
 
369
371
  mag_conv = np.log(10)*0.4
370
372
 
@@ -417,16 +419,17 @@ class DustMapBase(RailStage):
417
419
  name = 'DustMapBase'
418
420
 
419
421
  config_options = RailStage.config_options.copy()
420
- config_options.update(bands='ugrizy')
421
- config_options.update(ra_name='ra')
422
- config_options.update(dec_name='dec')
423
- config_options.update(mag_name="mag_{band}_lsst")
424
- config_options.update(band_a_env=[4.81,3.64,2.70,2.06,1.58,1.31])
425
- config_options.update(dustmap_name='sfd')
426
- config_options.update(dustmap_dir=str)
427
- config_options.update(copy_cols=[])
428
- config_options.update(copy_all_cols=False)
429
-
422
+ config_options.update(
423
+ ra_name=Param(str, default='ra', msg="Name of the RA column"),
424
+ dec_name=Param(str, default='dec', msg="Name of the DEC column"),
425
+ mag_name=Param(str, default="mag_{band}_lsst", msg="Template for the magnitude columns"),
426
+ band_a_env=SHARED_PARAMS,
427
+ dustmap_name=Param(str, default='sfd', msg="Name of the dustmap in question"),
428
+ dustmap_dir=Param(str, required=True, msg="Directory with dustmaps"),
429
+ copy_cols=Param(list, default=[], msg="Additional columns to copy"),
430
+ copy_all_cols=Param(bool, default=False, msg="Copy all the columns"),
431
+ )
432
+
430
433
  inputs = [('input', PqHandle)]
431
434
  outputs = [('output', PqHandle)]
432
435
 
@@ -467,10 +470,9 @@ class DustMapBase(RailStage):
467
470
  raise KeyError(f"Unknown dustmap {self.config.dustmap_name}, options are {list(dust_map_dict.keys())}") from msg
468
471
  ebvvec = dust_map(coords)
469
472
  band_mag_name_list=[]
470
- for i, band_ in enumerate(self.config.bands):
471
- band_mag_name = self.config.mag_name.format(band=band_)
473
+ for band_mag_name, a_env_value in self.config.band_a_env.items():
472
474
  mag_vals = data[band_mag_name]
473
- out_data[band_mag_name] = self._calc_values(mag_vals, ebvvec, self.config.band_a_env[i])
475
+ out_data[band_mag_name] = self._calc_values(mag_vals, ebvvec, a_env_value)
474
476
  band_mag_name_list.append(band_mag_name)
475
477
 
476
478
  # check if copy_all_cols set to true: