pz-rail-astro-tools 1.0.0__py3-none-any.whl → 1.0.2__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.0
3
+ Version: 1.0.2
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,5 +1,5 @@
1
1
  rail/astro_tools/__init__.py,sha256=c0yzN5jMhByii01h_mjOWipeProO8vludBsO09dJkmc,377
2
- rail/astro_tools/_version.py,sha256=DGJ4pj32xs3_DRJhSzQwCiRNnAQrMgo09USYpyMZsKc,411
2
+ rail/astro_tools/_version.py,sha256=BGgbj7AHZwtVw29XgDIjcG5woR-f3jQy2X-ArcRT22E,411
3
3
  rail/creation/degraders/grid_selection.py,sha256=QCs7ZpLJ_GdJnIIt0WF09mBLeqsrzQ2CiDo0h0Hd3dQ,12438
4
4
  rail/creation/degraders/lsst_error_model.py,sha256=WWQxPO3w1S6sALQxl7x7_mUI1f3o1eOGpBk3Yzi-1Q0,1969
5
5
  rail/creation/degraders/observing_condition_degrader.py,sha256=jelIfFHzrgmRmRARm5uC36ZohepfMHq5djWT5wGEaZI,19987
@@ -13,9 +13,10 @@ rail/examples_data/creation_data/data/survey_conditions/DC2-dr6-galcounts-i20-i2
13
13
  rail/examples_data/creation_data/data/survey_conditions/DC2-mask-neg-nside-128.fits,sha256=79Kg4xRP4WHlOCcS-3SKqf9aP_LZRAq-izIM0DFL6bw,1581120
14
14
  rail/examples_data/creation_data/data/survey_conditions/minion_1016_dc2_Median_airmass_i_and_nightlt1825_HEAL.fits,sha256=twvyce70G3h1MQnGGFQJG9wZc8UbuNqXc6mjtiuaL1s,1581120
15
15
  rail/examples_data/creation_data/data/survey_conditions/minion_1016_dc2_Median_fiveSigmaDepth_i_and_nightlt1825_HEAL.fits,sha256=RbMMFSVJQxGhZnL4BnISE9VTNljfTZwV6Bax6NxverY,1581120
16
- rail/tools/photometry_tools.py,sha256=aAIfD_CsYvJappbh6FR2GLt2eeQdMg59N5VuLD5QTjg,18419
17
- pz_rail_astro_tools-1.0.0.dist-info/LICENSE,sha256=tLMEN21HbzvT-7umOVVvPjaJZbQxCa-2bAeYLwG5Q04,1102
18
- pz_rail_astro_tools-1.0.0.dist-info/METADATA,sha256=Bej2Sj-dvJIdSZQybbbiiHtZ-z3mU8snKUOydzVFcFg,3947
19
- pz_rail_astro_tools-1.0.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
20
- pz_rail_astro_tools-1.0.0.dist-info/top_level.txt,sha256=6R6sqn-85I8YZTzmB9gv7sqckB2QaOTHbu-QLGTWBRE,5
21
- pz_rail_astro_tools-1.0.0.dist-info/RECORD,,
16
+ rail/examples_data/testdata/rubin_dm_dc2_example2.pq,sha256=_Iihbbcz1A332QAkaMiFacT4QAbBQBMTOwpfrS7AclE,25884
17
+ rail/tools/photometry_tools.py,sha256=GdqHWoYzkbQTQoEWvkz1qNZjJbJCFgQUR39d4xuz1cI,19216
18
+ pz_rail_astro_tools-1.0.2.dist-info/LICENSE,sha256=tLMEN21HbzvT-7umOVVvPjaJZbQxCa-2bAeYLwG5Q04,1102
19
+ pz_rail_astro_tools-1.0.2.dist-info/METADATA,sha256=YooFUgTa8FAlMqG7boZeO2dQ6yaa8Gaaf7GeeYZD4xA,3947
20
+ pz_rail_astro_tools-1.0.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
21
+ pz_rail_astro_tools-1.0.2.dist-info/top_level.txt,sha256=6R6sqn-85I8YZTzmB9gv7sqckB2QaOTHbu-QLGTWBRE,5
22
+ pz_rail_astro_tools-1.0.2.dist-info/RECORD,,
@@ -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.2'
16
+ __version_tuple__ = version_tuple = (1, 0, 2)
@@ -13,6 +13,7 @@ from ceci.config import StageParameter as Param
13
13
  from rail.core.data import PqHandle
14
14
  from rail.core.stage import RailStage
15
15
  from rail.core.data import PqHandle, Hdf5Handle
16
+ from rail.core.common_params import SHARED_PARAMS
16
17
 
17
18
  import hyperbolic # https://github.com/jlvdb/hyperbolic
18
19
 
@@ -20,8 +21,6 @@ dustmaps_config = tables_io.lazy_modules.lazyImport('dustmaps.config')
20
21
  dustmaps_sfd = tables_io.lazy_modules.lazyImport('dustmaps.sfd')
21
22
 
22
23
 
23
-
24
-
25
24
  # default column names in DC2
26
25
  LSST_BANDS = 'ugrizy'
27
26
  DEFAULT_MAG_COLS = [f"mag_{band}_lsst" for band in LSST_BANDS]
@@ -333,7 +332,7 @@ class HyperbolicMagnitudes(PhotometryManipulator):
333
332
  Input table with photometry (magnitudes or flux columns and their respective
334
333
  uncertainties) as defined by the configuration.
335
334
  parameters : `PqHandle`
336
- Table with smoothing parameters per photometric band, determined by
335
+ Table witdh smoothing parameters per photometric band, determined by
337
336
  `HyperbolicSmoothing`.
338
337
 
339
338
  Returns
@@ -412,16 +411,18 @@ class LSSTFluxToMagConverter(RailStage):
412
411
  return self.get_handle('output')
413
412
 
414
413
 
415
- class Dereddener(RailStage):
414
+ class DustMapBase(RailStage):
416
415
  """Utility stage that does dereddening
417
416
 
418
417
  Note: set copy_all_cols=True to copy all
419
418
  columns in data, copy_cols will be ignored
420
419
  """
421
- name = 'Dereddener'
420
+ name = 'DustMapBase'
422
421
 
423
422
  config_options = RailStage.config_options.copy()
424
423
  config_options.update(bands='ugrizy')
424
+ config_options.update(ra_name='ra')
425
+ config_options.update(dec_name='dec')
425
426
  config_options.update(mag_name="mag_{band}_lsst")
426
427
  config_options.update(band_a_env=[4.81,3.64,2.70,2.06,1.58,1.31])
427
428
  config_options.update(dustmap_name='sfd')
@@ -429,8 +430,8 @@ class Dereddener(RailStage):
429
430
  config_options.update(copy_cols=[])
430
431
  config_options.update(copy_all_cols=False)
431
432
 
432
- inputs = [('input', Hdf5Handle)]
433
- outputs = [('output', Hdf5Handle)]
433
+ inputs = [('input', PqHandle)]
434
+ outputs = [('output', PqHandle)]
434
435
 
435
436
  def fetch_map(self):
436
437
  dust_map_dict = dict(sfd=dustmaps_sfd)
@@ -439,12 +440,15 @@ class Dereddener(RailStage):
439
440
  except KeyError as msg: # pragma: no cover
440
441
  raise KeyError(f"Unknown dustmap {self.config.dustmap_name}, options are {list(dust_map_dict.keys())}") from msg
441
442
 
442
- if os.path.exists(os.path.join(self.config.dustmap_dir, self.config.dustmap_name)): # pragma: no cover
443
+ dustmap_dir = os.path.expandvars(self.config.dustmap_dir)
444
+ dustmap_path = os.path.join(dustmap_dir, self.config.dustmap_name)
445
+ if os.path.exists(dustmap_path): # pragma: no cover
443
446
  # already downloaded, return
444
447
  return
445
448
 
446
449
  dust_map_config = dustmaps_config.config
447
- dust_map_config['data_dir'] = self.config.dustmap_dir
450
+ # dust_map_config['data_dir'] = self.config.dustmap_dir
451
+ dust_map_config['data_dir'] = dustmap_dir
448
452
  fetch_func = dust_map_submod.fetch
449
453
  fetch_func()
450
454
 
@@ -455,7 +459,7 @@ class Dereddener(RailStage):
455
459
  def run(self):
456
460
  data = self.get_data('input', allow_missing=True)
457
461
  out_data = {}
458
- coords = SkyCoord(data['ra'], data['decl'], unit = 'deg',frame='fk5')
462
+ coords = SkyCoord(data[self.config.ra_name], data[self.config.dec_name], unit = 'deg',frame='fk5')
459
463
  dust_map_dict = dict(sfd=dustmaps_sfd.SFDQuery)
460
464
  try:
461
465
  dust_map_class = dust_map_dict[self.config.dustmap_name]
@@ -469,7 +473,7 @@ class Dereddener(RailStage):
469
473
  for i, band_ in enumerate(self.config.bands):
470
474
  band_mag_name = self.config.mag_name.format(band=band_)
471
475
  mag_vals = data[band_mag_name]
472
- out_data[band_mag_name] = mag_vals - ebvvec*self.config.band_a_env[i]
476
+ out_data[band_mag_name] = self._calc_values(mag_vals, ebvvec, self.config.band_a_env[i])
473
477
  band_mag_name_list.append(band_mag_name)
474
478
 
475
479
  # check if copy_all_cols set to true:
@@ -482,7 +486,8 @@ class Dereddener(RailStage):
482
486
  if col_ not in band_mag_name_list:
483
487
  out_data[col_] = data[col_]
484
488
 
485
- self.add_data('output', out_data)
489
+ out_data_pd = pd.DataFrame(out_data)
490
+ self.add_data('output', out_data_pd)
486
491
 
487
492
  def __call__(self, data):
488
493
  """Return a converted table
@@ -500,3 +505,23 @@ class Dereddener(RailStage):
500
505
  self.set_data('input', data)
501
506
  self.run()
502
507
  return self.get_handle('output')
508
+
509
+
510
+ class Dereddener(DustMapBase):
511
+ """Utility stage that does dereddening
512
+
513
+ """
514
+ name = 'Dereddener'
515
+
516
+ def _calc_values(self, mag_vals, ebvvec, band_a_env):
517
+ return mag_vals - ebvvec*band_a_env
518
+
519
+
520
+ class Reddener(DustMapBase):
521
+ """Utility stage that does reddening
522
+
523
+ """
524
+ name = 'Reddener'
525
+
526
+ def _calc_values(self, mag_vals, ebvvec, band_a_env):
527
+ return mag_vals + ebvvec*band_a_env