pz-rail-astro-tools 1.0.0__tar.gz → 1.0.1__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 (46) hide show
  1. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/PKG-INFO +1 -1
  2. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/pz_rail_astro_tools.egg-info/PKG-INFO +1 -1
  3. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/pz_rail_astro_tools.egg-info/SOURCES.txt +1 -0
  4. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/astro_tools/_version.py +2 -2
  5. pz_rail_astro_tools-1.0.1/src/rail/examples_data/testdata/rubin_dm_dc2_example2.pq +0 -0
  6. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/tools/photometry_tools.py +33 -11
  7. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/tests/astro_tools/test_core.py +7 -5
  8. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/.copier-answers.yml +0 -0
  9. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/.github/ISSUE_TEMPLATE/0-general_issue.md +0 -0
  10. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/.github/ISSUE_TEMPLATE/1-bug_report.md +0 -0
  11. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/.github/ISSUE_TEMPLATE/2-feature_request.md +0 -0
  12. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/.github/pull_request_template.md +0 -0
  13. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/.github/workflows/add-issue-to-project-tracker.yml +0 -0
  14. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/.github/workflows/linting.yml +0 -0
  15. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/.github/workflows/publish-to-pypi.yml +0 -0
  16. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/.github/workflows/smoke-test.yml +0 -0
  17. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/.github/workflows/testing-and-coverage.yml +0 -0
  18. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/.gitignore +0 -0
  19. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/.pre-commit-config.yaml +0 -0
  20. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/LICENSE +0 -0
  21. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/README.md +0 -0
  22. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/environment.yml +0 -0
  23. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/pyproject.toml +0 -0
  24. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/setup.cfg +0 -0
  25. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/setup.py +0 -0
  26. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/pz_rail_astro_tools.egg-info/dependency_links.txt +0 -0
  27. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/pz_rail_astro_tools.egg-info/requires.txt +0 -0
  28. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/pz_rail_astro_tools.egg-info/top_level.txt +0 -0
  29. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/astro_tools/__init__.py +0 -0
  30. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/creation/degraders/grid_selection.py +0 -0
  31. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/creation/degraders/lsst_error_model.py +0 -0
  32. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/creation/degraders/observing_condition_degrader.py +0 -0
  33. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/creation/degraders/photometric_errors.py +0 -0
  34. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/creation/degraders/spectroscopic_degraders.py +0 -0
  35. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/creation/degraders/spectroscopic_selections.py +0 -0
  36. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/creation/engines/gcr_engine.py +0 -0
  37. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/examples_data/creation_data/data/HSC_grid_settings.pkl +0 -0
  38. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/examples_data/creation_data/data/hsc_ratios_and_specz.hdf5 +0 -0
  39. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/examples_data/creation_data/data/survey_conditions/DC2-dr6-galcounts-i20-i25.3-nside-128.fits +0 -0
  40. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/examples_data/creation_data/data/survey_conditions/DC2-mask-neg-nside-128.fits +0 -0
  41. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/examples_data/creation_data/data/survey_conditions/minion_1016_dc2_Median_airmass_i_and_nightlt1825_HEAL.fits +0 -0
  42. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/src/rail/examples_data/creation_data/data/survey_conditions/minion_1016_dc2_Median_fiveSigmaDepth_i_and_nightlt1825_HEAL.fits +0 -0
  43. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/tests/astro_tools/gcr_test_data/schema.yaml +0 -0
  44. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/tests/astro_tools/gcr_test_data/test_object_tract_4850.hdf5 +0 -0
  45. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/tests/astro_tools/test_degraders.py +0 -0
  46. {pz_rail_astro_tools-1.0.0 → pz_rail_astro_tools-1.0.1}/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.0
3
+ Version: 1.0.1
4
4
  Author-email: "LSST Dark Energy Science Collaboration (DESC)" <lsst-desc-rail-admin@slac.stanford.edu>
5
5
  License: MIT License
6
6
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pz-rail-astro-tools
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Author-email: "LSST Dark Energy Science Collaboration (DESC)" <lsst-desc-rail-admin@slac.stanford.edu>
5
5
  License: MIT License
6
6
 
@@ -35,6 +35,7 @@ src/rail/examples_data/creation_data/data/survey_conditions/DC2-dr6-galcounts-i2
35
35
  src/rail/examples_data/creation_data/data/survey_conditions/DC2-mask-neg-nside-128.fits
36
36
  src/rail/examples_data/creation_data/data/survey_conditions/minion_1016_dc2_Median_airmass_i_and_nightlt1825_HEAL.fits
37
37
  src/rail/examples_data/creation_data/data/survey_conditions/minion_1016_dc2_Median_fiveSigmaDepth_i_and_nightlt1825_HEAL.fits
38
+ src/rail/examples_data/testdata/rubin_dm_dc2_example2.pq
38
39
  src/rail/tools/photometry_tools.py
39
40
  tests/astro_tools/test_core.py
40
41
  tests/astro_tools/test_degraders.py
@@ -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.0'
16
- __version_tuple__ = version_tuple = (1, 0, 0)
15
+ __version__ = version = '1.0.1'
16
+ __version_tuple__ = version_tuple = (1, 0, 1)
@@ -20,8 +20,6 @@ dustmaps_config = tables_io.lazy_modules.lazyImport('dustmaps.config')
20
20
  dustmaps_sfd = tables_io.lazy_modules.lazyImport('dustmaps.sfd')
21
21
 
22
22
 
23
-
24
-
25
23
  # default column names in DC2
26
24
  LSST_BANDS = 'ugrizy'
27
25
  DEFAULT_MAG_COLS = [f"mag_{band}_lsst" for band in LSST_BANDS]
@@ -412,13 +410,13 @@ class LSSTFluxToMagConverter(RailStage):
412
410
  return self.get_handle('output')
413
411
 
414
412
 
415
- class Dereddener(RailStage):
413
+ class DustMapBase(RailStage):
416
414
  """Utility stage that does dereddening
417
415
 
418
416
  Note: set copy_all_cols=True to copy all
419
417
  columns in data, copy_cols will be ignored
420
418
  """
421
- name = 'Dereddener'
419
+ name = 'DustMapBase'
422
420
 
423
421
  config_options = RailStage.config_options.copy()
424
422
  config_options.update(bands='ugrizy')
@@ -429,8 +427,8 @@ class Dereddener(RailStage):
429
427
  config_options.update(copy_cols=[])
430
428
  config_options.update(copy_all_cols=False)
431
429
 
432
- inputs = [('input', Hdf5Handle)]
433
- outputs = [('output', Hdf5Handle)]
430
+ inputs = [('input', PqHandle)]
431
+ outputs = [('output', PqHandle)]
434
432
 
435
433
  def fetch_map(self):
436
434
  dust_map_dict = dict(sfd=dustmaps_sfd)
@@ -439,12 +437,15 @@ class Dereddener(RailStage):
439
437
  except KeyError as msg: # pragma: no cover
440
438
  raise KeyError(f"Unknown dustmap {self.config.dustmap_name}, options are {list(dust_map_dict.keys())}") from msg
441
439
 
442
- if os.path.exists(os.path.join(self.config.dustmap_dir, self.config.dustmap_name)): # pragma: no cover
440
+ dustmap_dir = os.path.expandvars(self.config.dustmap_dir)
441
+ dustmap_path = os.path.join(dustmap_dir, self.config.dustmap_name)
442
+ if os.path.exists(dustmap_path): # pragma: no cover
443
443
  # already downloaded, return
444
444
  return
445
445
 
446
446
  dust_map_config = dustmaps_config.config
447
- dust_map_config['data_dir'] = self.config.dustmap_dir
447
+ # dust_map_config['data_dir'] = self.config.dustmap_dir
448
+ dust_map_config['data_dir'] = dustmap_dir
448
449
  fetch_func = dust_map_submod.fetch
449
450
  fetch_func()
450
451
 
@@ -455,7 +456,7 @@ class Dereddener(RailStage):
455
456
  def run(self):
456
457
  data = self.get_data('input', allow_missing=True)
457
458
  out_data = {}
458
- coords = SkyCoord(data['ra'], data['decl'], unit = 'deg',frame='fk5')
459
+ coords = SkyCoord(data['ra'], data['dec'], unit = 'deg',frame='fk5')
459
460
  dust_map_dict = dict(sfd=dustmaps_sfd.SFDQuery)
460
461
  try:
461
462
  dust_map_class = dust_map_dict[self.config.dustmap_name]
@@ -469,7 +470,7 @@ class Dereddener(RailStage):
469
470
  for i, band_ in enumerate(self.config.bands):
470
471
  band_mag_name = self.config.mag_name.format(band=band_)
471
472
  mag_vals = data[band_mag_name]
472
- out_data[band_mag_name] = mag_vals - ebvvec*self.config.band_a_env[i]
473
+ out_data[band_mag_name] = self._calc_values(mag_vals, ebvvec, self.config.band_a_env[i])
473
474
  band_mag_name_list.append(band_mag_name)
474
475
 
475
476
  # check if copy_all_cols set to true:
@@ -482,7 +483,8 @@ class Dereddener(RailStage):
482
483
  if col_ not in band_mag_name_list:
483
484
  out_data[col_] = data[col_]
484
485
 
485
- self.add_data('output', out_data)
486
+ out_data_pd = pd.DataFrame(out_data)
487
+ self.add_data('output', out_data_pd)
486
488
 
487
489
  def __call__(self, data):
488
490
  """Return a converted table
@@ -500,3 +502,23 @@ class Dereddener(RailStage):
500
502
  self.set_data('input', data)
501
503
  self.run()
502
504
  return self.get_handle('output')
505
+
506
+
507
+ class Dereddener(DustMapBase):
508
+ """Utility stage that does dereddening
509
+
510
+ """
511
+ name = 'Dereddener'
512
+
513
+ def _calc_values(self, mag_vals, ebvvec, band_a_env):
514
+ return mag_vals - ebvvec*band_a_env
515
+
516
+
517
+ class Reddener(DustMapBase):
518
+ """Utility stage that does reddening
519
+
520
+ """
521
+ name = 'Reddener'
522
+
523
+ def _calc_values(self, mag_vals, ebvvec, band_a_env):
524
+ return mag_vals + ebvvec*band_a_env
@@ -20,8 +20,8 @@ from rail.core.data import (
20
20
  TableHandle,
21
21
  )
22
22
  from rail.core.stage import RailStage
23
- from rail.tools.photometry_tools import HyperbolicMagnitudes, HyperbolicSmoothing, PhotometryManipulator, LSSTFluxToMagConverter, Dereddener
24
- from rail.utils.path_utils import RAILDIR
23
+ from rail.tools.photometry_tools import HyperbolicMagnitudes, HyperbolicSmoothing, PhotometryManipulator, LSSTFluxToMagConverter, Dereddener, Reddener
24
+ from rail.utils.path_utils import RAILDIR, find_rail_file
25
25
  #from rail.tools.util_stages import (
26
26
  # LSSTFluxToMagConverter,
27
27
  # Dereddener,
@@ -37,7 +37,7 @@ def test_flux2mag():
37
37
  DS = RailStage.data_store
38
38
  DS.clear()
39
39
 
40
- testFile = os.path.join(RAILDIR, "rail", "examples_data", "testdata", "rubin_dm_dc2_example.pq")
40
+ testFile = find_rail_file(os.path.join("examples_data", "testdata", "rubin_dm_dc2_example2.pq"))
41
41
  test_data = DS.read_file("test_data", TableHandle, testFile)
42
42
 
43
43
  fluxToMag = LSSTFluxToMagConverter.make_stage(name='flux2mag')
@@ -49,10 +49,10 @@ def test_dereddener():
49
49
  DS = RailStage.data_store
50
50
  DS.clear()
51
51
 
52
- testFile = os.path.join(RAILDIR, "rail", "examples_data", "testdata", "rubin_dm_dc2_example.pq")
52
+ testFile = find_rail_file(os.path.join("examples_data", "testdata", "rubin_dm_dc2_example2.pq"))
53
53
  test_data = DS.read_file("test_data", TableHandle, testFile)
54
54
 
55
- fluxToMag = LSSTFluxToMagConverter.make_stage(name='flux2mag', copy_cols=dict(ra='ra', decl='decl'))
55
+ fluxToMag = LSSTFluxToMagConverter.make_stage(name='flux2mag', copy_cols=dict(ra='ra', dec='decl'))
56
56
 
57
57
  is_temp_dir = False
58
58
  dustmap_dir = os.environ.get('RAIL_DUSTMAP_DIR')
@@ -62,10 +62,12 @@ def test_dereddener():
62
62
  is_temp_dir = True
63
63
 
64
64
  dereddener = Dereddener.make_stage(name='dereddner', dustmap_dir=dustmap_dir)
65
+ reddener = Reddener.make_stage(name='reddner', dustmap_dir=dustmap_dir)
65
66
  dereddener.fetch_map()
66
67
 
67
68
  flux_data = fluxToMag(test_data)
68
69
  dered_data = dereddener(flux_data)
70
+ red_data = reddener(flux_data)
69
71
 
70
72
  if is_temp_dir:
71
73
  tmp_dustmap_dir.cleanup()