pz-rail-astro-tools 1.0.4__tar.gz → 1.0.6__tar.gz

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.

Files changed (51) hide show
  1. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/PKG-INFO +2 -1
  2. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/pyproject.toml +1 -0
  3. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/pz_rail_astro_tools.egg-info/PKG-INFO +2 -1
  4. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/pz_rail_astro_tools.egg-info/SOURCES.txt +4 -2
  5. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/pz_rail_astro_tools.egg-info/requires.txt +1 -0
  6. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/astro_tools/__init__.py +2 -0
  7. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/astro_tools/_version.py +2 -2
  8. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/creation/degraders/photometric_errors.py +16 -4
  9. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/creation/degraders/spectroscopic_degraders.py +9 -4
  10. pz_rail_astro_tools-1.0.6/src/rail/creation/degraders/unrec_bl_model.py +136 -0
  11. {pz_rail_astro_tools-1.0.4/src/rail/pipelines/utility → pz_rail_astro_tools-1.0.6/src/rail/pipelines/degradation}/apply_phot_errors.py +2 -0
  12. pz_rail_astro_tools-1.0.6/src/rail/pipelines/degradation/blending.py +28 -0
  13. {pz_rail_astro_tools-1.0.4/src/rail/pipelines/utility → pz_rail_astro_tools-1.0.6/src/rail/pipelines/degradation}/spectroscopic_selection_pipeline.py +6 -6
  14. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/tools/photometry_tools.py +22 -20
  15. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/tests/astro_tools/test_degraders.py +40 -1
  16. pz_rail_astro_tools-1.0.6/tests/astro_tools/test_pipline.py +16 -0
  17. pz_rail_astro_tools-1.0.4/tests/astro_tools/test_pipline.py +0 -15
  18. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/.copier-answers.yml +0 -0
  19. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/.github/ISSUE_TEMPLATE/0-general_issue.md +0 -0
  20. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/.github/ISSUE_TEMPLATE/1-bug_report.md +0 -0
  21. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/.github/ISSUE_TEMPLATE/2-feature_request.md +0 -0
  22. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/.github/pull_request_template.md +0 -0
  23. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/.github/workflows/add-issue-to-project-tracker.yml +0 -0
  24. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/.github/workflows/linting.yml +0 -0
  25. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/.github/workflows/publish-to-pypi.yml +0 -0
  26. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/.github/workflows/smoke-test.yml +0 -0
  27. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/.github/workflows/testing-and-coverage.yml +0 -0
  28. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/.gitignore +0 -0
  29. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/.pre-commit-config.yaml +0 -0
  30. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/LICENSE +0 -0
  31. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/README.md +0 -0
  32. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/environment.yml +0 -0
  33. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/setup.cfg +0 -0
  34. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/setup.py +0 -0
  35. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/pz_rail_astro_tools.egg-info/dependency_links.txt +0 -0
  36. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/pz_rail_astro_tools.egg-info/top_level.txt +0 -0
  37. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/creation/degraders/grid_selection.py +0 -0
  38. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/creation/degraders/observing_condition_degrader.py +0 -0
  39. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/creation/degraders/spectroscopic_selections.py +0 -0
  40. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/creation/engines/gcr_engine.py +0 -0
  41. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/examples_data/creation_data/data/HSC_grid_settings.pkl +0 -0
  42. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/examples_data/creation_data/data/hsc_ratios_and_specz.hdf5 +0 -0
  43. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/examples_data/creation_data/data/survey_conditions/DC2-dr6-galcounts-i20-i25.3-nside-128.fits +0 -0
  44. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/examples_data/creation_data/data/survey_conditions/DC2-mask-neg-nside-128.fits +0 -0
  45. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/examples_data/creation_data/data/survey_conditions/minion_1016_dc2_Median_airmass_i_and_nightlt1825_HEAL.fits +0 -0
  46. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/examples_data/creation_data/data/survey_conditions/minion_1016_dc2_Median_fiveSigmaDepth_i_and_nightlt1825_HEAL.fits +0 -0
  47. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/src/rail/examples_data/testdata/rubin_dm_dc2_example2.pq +0 -0
  48. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/tests/astro_tools/gcr_test_data/schema.yaml +0 -0
  49. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/tests/astro_tools/gcr_test_data/test_object_tract_4850.hdf5 +0 -0
  50. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/tests/astro_tools/test_core.py +0 -0
  51. {pz_rail_astro_tools-1.0.4 → pz_rail_astro_tools-1.0.6}/tests/astro_tools/test_gcr_engine.py +0 -0
@@ -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.6
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"
@@ -26,6 +26,7 @@ dependencies = [
26
26
  "dustmaps",
27
27
  "pz-hyperbolic-temp",
28
28
  "lsstdesc-gcr-catalogs",
29
+ "FoFCatalogMatching",
29
30
  ]
30
31
 
31
32
  # On a mac, install optional dependencies with `pip install '.[dev]'` (include the single quotes)
@@ -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.6
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"
@@ -27,6 +27,7 @@ src/rail/creation/degraders/observing_condition_degrader.py
27
27
  src/rail/creation/degraders/photometric_errors.py
28
28
  src/rail/creation/degraders/spectroscopic_degraders.py
29
29
  src/rail/creation/degraders/spectroscopic_selections.py
30
+ src/rail/creation/degraders/unrec_bl_model.py
30
31
  src/rail/creation/engines/gcr_engine.py
31
32
  src/rail/examples_data/creation_data/data/HSC_grid_settings.pkl
32
33
  src/rail/examples_data/creation_data/data/hsc_ratios_and_specz.hdf5
@@ -35,8 +36,9 @@ src/rail/examples_data/creation_data/data/survey_conditions/DC2-mask-neg-nside-1
35
36
  src/rail/examples_data/creation_data/data/survey_conditions/minion_1016_dc2_Median_airmass_i_and_nightlt1825_HEAL.fits
36
37
  src/rail/examples_data/creation_data/data/survey_conditions/minion_1016_dc2_Median_fiveSigmaDepth_i_and_nightlt1825_HEAL.fits
37
38
  src/rail/examples_data/testdata/rubin_dm_dc2_example2.pq
38
- src/rail/pipelines/utility/apply_phot_errors.py
39
- src/rail/pipelines/utility/spectroscopic_selection_pipeline.py
39
+ src/rail/pipelines/degradation/apply_phot_errors.py
40
+ src/rail/pipelines/degradation/blending.py
41
+ src/rail/pipelines/degradation/spectroscopic_selection_pipeline.py
40
42
  src/rail/tools/photometry_tools.py
41
43
  tests/astro_tools/test_core.py
42
44
  tests/astro_tools/test_degraders.py
@@ -8,6 +8,7 @@ photerr
8
8
  dustmaps
9
9
  pz-hyperbolic-temp
10
10
  lsstdesc-gcr-catalogs
11
+ FoFCatalogMatching
11
12
 
12
13
  [dev]
13
14
  tables-io[full]
@@ -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.6'
16
+ __version_tuple__ = version_tuple = (1, 0, 6)
@@ -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,136 @@
1
+ """Model for Creating Unrecognized Blends"""
2
+
3
+ from ceci.config import StageParameter as Param
4
+ from rail.creation.degrader import Degrader
5
+ from rail.core.data import PqHandle
6
+ import numpy as np, pandas as pd
7
+ import FoFCatalogMatching
8
+
9
+
10
+ class UnrecBlModel(Degrader):
11
+ """Model for Creating Unrecognized Blends.
12
+
13
+ Finding objects nearby each other. Merge them into one blended
14
+ Use Friends of Friends for matching. May implement shape matching in the future.
15
+ Take avergaged Ra and Dec for blended source, and sum up fluxes in each band. May implement merged shapes in the future.
16
+
17
+ """
18
+ name = "UnrecBlModel"
19
+ config_options = Degrader.config_options.copy()
20
+ config_options.update(ra_label=Param(str, 'ra', msg='ra column name'),
21
+ dec_label=Param(str, 'dec', msg='dec column name'),
22
+ linking_lengths=Param(float, 1.0, msg='linking_lengths for FoF matching'),
23
+ bands=Param(str, 'ugrizy', msg='name of filters'),
24
+ match_size=Param(bool, False, msg='consider object size for finding blends'),
25
+ match_shape=Param(bool, False, msg='consider object shape for finding blends'),
26
+ obj_size=Param(str, 'obj_size', msg='object size column name'),
27
+ a=Param(str, 'semi_major', msg='semi major axis column name'),
28
+ b=Param(str, 'semi_minor', msg='semi minor axis column name'),
29
+ theta=Param(str, 'orientation', msg='orientation angle column name'))
30
+
31
+ outputs = [("output", PqHandle), ("compInd", PqHandle)]
32
+
33
+ def __call__(self, sample, seed: int = None):
34
+ """The main interface method for ``Degrader``.
35
+
36
+ Applies degradation.
37
+
38
+ This will attach the sample to this `Degrader` (for introspection and
39
+ provenance tracking).
40
+
41
+ Then it will call the run() and finalize() methods, which need to be
42
+ implemented by the sub-classes.
43
+
44
+ The run() method will need to register the data that it creates to this
45
+ Estimator by using ``self.add_data('output', output_data)``.
46
+
47
+ Finally, this will return a PqHandle providing access to that output
48
+ data.
49
+
50
+ Parameters
51
+ ----------
52
+ sample : table-like
53
+ The sample to be degraded
54
+ seed : int, default=None
55
+ An integer to set the numpy random seed
56
+
57
+ Returns
58
+ -------
59
+ output_data : PqHandle
60
+ A handle giving access to a table with degraded sample
61
+ """
62
+ if seed is not None:
63
+ self.config.seed = seed
64
+
65
+ self.set_data("input", sample)
66
+ self.run()
67
+ self.finalize()
68
+
69
+ return {'output':self.get_handle("output"), 'compInd':self.get_handle("compInd")}
70
+
71
+ def __match_bl__(self, data):
72
+
73
+ """Group sources with friends of friends"""
74
+
75
+ ra_label, dec_label = self.config.ra_label, self.config.dec_label
76
+ linking_lengths = self.config.linking_lengths
77
+
78
+ results = FoFCatalogMatching.match({'truth': data}, linking_lengths=linking_lengths, ra_label=ra_label, dec_label=dec_label)
79
+ results.remove_column('catalog_key')
80
+
81
+ results = results.to_pandas(index='row_index')
82
+ results.sort_values(by='row_index', inplace=True)
83
+
84
+ ## adding the group id as the last column to data
85
+ matchData = pd.merge(data, results, left_index=True, right_index=True)
86
+
87
+ return matchData, results
88
+
89
+ def __merge_bl__(self, data):
90
+
91
+ """Merge sources within a group into unrecognized blends."""
92
+
93
+ group_id = data['group_id']
94
+ unique_id = np.unique(group_id)
95
+
96
+ ra_label, dec_label = self.config.ra_label, self.config.dec_label
97
+ cols = [ra_label, dec_label] + [b for b in self.config.bands] + ['group_id']
98
+
99
+ N_rows = len(unique_id)
100
+ N_cols = len(cols)
101
+
102
+ mergeData = np.zeros((N_rows, N_cols))
103
+ for i, id in enumerate(unique_id):
104
+
105
+ this_group = data.query(f'group_id=={id}')
106
+
107
+ ## take the average position for the blended source
108
+ mergeData[i, cols.index(ra_label)] = this_group[ra_label].mean()
109
+ mergeData[i, cols.index(dec_label)] = this_group[dec_label].mean()
110
+
111
+ ## sum up the fluxes into the blended source
112
+ for b in self.config.bands:
113
+ mergeData[i, cols.index(b)] = -2.5*np.log10(np.sum(10**(-this_group[b]/2.5)))
114
+
115
+ mergeData[:,cols.index('group_id')] = unique_id
116
+ mergeData_df = pd.DataFrame(data=mergeData, columns=cols)
117
+ mergeData_df['group_id'] = mergeData_df['group_id'].astype(int)
118
+
119
+ return mergeData_df
120
+
121
+ def run(self):
122
+ """Return pandas DataFrame with blending errors."""
123
+
124
+ # Load the input catalog
125
+ data = self.get_data("input")
126
+
127
+ # Match for close-by objects
128
+ matchData, compInd = self.__match_bl__(data)
129
+
130
+ # Merge matched objects into unrec-bl
131
+ blData = self.__merge_bl__(matchData)
132
+
133
+ # Return the new catalog and component index in original catalog
134
+ self.add_data("output", blData)
135
+ self.add_data("compInd", compInd)
136
+
@@ -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:
@@ -14,6 +14,7 @@ from rail.creation.degraders.spectroscopic_selections import *
14
14
  from rail.creation.degraders.observing_condition_degrader import ObsCondition
15
15
  from rail.creation.degraders.grid_selection import GridSelection
16
16
  from rail.creation.degraders.photometric_errors import EuclidErrorModel, LSSTErrorModel
17
+ from rail.creation.degraders.unrec_bl_model import UnrecBlModel
17
18
 
18
19
 
19
20
  @pytest.fixture
@@ -74,6 +75,26 @@ def data_with_radec():
74
75
  return DS.add_data("data_with_radec", df, TableHandle, path="dummy_with_radec.pd")
75
76
 
76
77
 
78
+ @pytest.fixture
79
+ def data_for_bl():
80
+ """Some dummy data to use below."""
81
+
82
+ DS = DATA_STORE()
83
+ DS.__class__.allow_overwrite = True
84
+
85
+ # generate random normal data
86
+ columns=['ra', 'dec', 'u', 'g', 'r', 'i', 'z', 'y']
87
+ rng = np.random.default_rng(0)
88
+ x = rng.normal(loc=23, scale=3, size=(1000, len(columns)))
89
+
90
+ # replace positions with constrained values
91
+ x[:, 0] = np.random.uniform(low=0, high=0.02, size=1000)
92
+ x[:, 1] = np.random.uniform(low=0, high=0.02, size=1000)
93
+
94
+ # return data in handle wrapping a pandas DataFrame
95
+ df = pd.DataFrame(x, columns=columns)
96
+ return DS.add_data("data_for_bl", df, TableHandle, path="dummy_for_bl.pd")
97
+
77
98
 
78
99
  @pytest.mark.parametrize("pivot_redshift,errortype", [("fake", TypeError), (-1, ValueError)])
79
100
  def test_InvRedshiftIncompleteness_bad_params(pivot_redshift, errortype):
@@ -396,4 +417,22 @@ def test_EucliErrorModel(data):
396
417
  # Setup the stage
397
418
  degrader = EuclidErrorModel.make_stage()
398
419
 
399
-
420
+
421
+ def test_BLModel(data_for_bl):
422
+ # Setup the stage
423
+
424
+ degrader = UnrecBlModel.make_stage(name='unrec_bl_model', ra_label='ra', dec_label='dec', linking_lengths=1.0, bands='ugrizy', seed=1234)
425
+
426
+ # Apply the degrader and get the data out
427
+ outputs = degrader(data_for_bl)
428
+ degraded_data = outputs['output'].data
429
+ truth_components = outputs['compInd'].data
430
+
431
+ # Check output data has less rows than input data
432
+ assert degraded_data.shape[0] < data_for_bl.data.shape[0]
433
+
434
+ # Check components has the same rows as input data
435
+ assert truth_components.shape[0] == data_for_bl.data.shape[0]
436
+
437
+ os.remove(degrader.get_output(degrader.get_aliased_tag("output"), final_name=True))
438
+ os.remove(degrader.get_output(degrader.get_aliased_tag("compInd"), final_name=True))
@@ -0,0 +1,16 @@
1
+ import os
2
+ from rail.utils.testing_utils import build_and_read_pipeline
3
+
4
+ import pytest
5
+
6
+ @pytest.mark.parametrize(
7
+ "pipeline_class",
8
+ [
9
+ 'rail.pipelines.degradation.apply_phot_errors.ApplyPhotErrorsPipeline',
10
+ 'rail.pipelines.degradation.blending.BlendingPipeline',
11
+ 'rail.pipelines.degradation.spectroscopic_selection_pipeline.SpectroscopicSelectionPipeline',
12
+ ]
13
+ )
14
+ def test_build_and_read_pipeline(pipeline_class):
15
+ build_and_read_pipeline(pipeline_class)
16
+
@@ -1,15 +0,0 @@
1
- import os
2
- from rail.utils.testing_utils import build_and_read_pipeline
3
-
4
- import pytest
5
-
6
- @pytest.mark.parametrize(
7
- "pipeline_class",
8
- [
9
- 'rail.pipelines.utility.apply_phot_errors.ApplyPhotErrorsPipeline',
10
- 'rail.pipelines.utility.spectroscopic_selection_pipeline.SpectroscopicSelectionPipeline',
11
- ]
12
- )
13
- def test_build_and_read_pipeline(pipeline_class):
14
- build_and_read_pipeline(pipeline_class)
15
-