rubin-sim 2.6.1.dev2__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.
- batch/compile_prenight_metadata_cache.sh +34 -0
- batch/run_auxtel_prenight_sims.sh +163 -0
- batch/run_prenight_sims.sh +239 -0
- docs/.gitignore +3 -0
- docs/Makefile +32 -0
- docs/api.rst +25 -0
- docs/conf.py +8 -0
- docs/data-api.rst +12 -0
- docs/data-download.rst +70 -0
- docs/developer.rst +14 -0
- docs/documenteer.toml +11 -0
- docs/index.rst +22 -0
- docs/installation.rst +76 -0
- docs/introduction.rst +37 -0
- docs/maf-api-batches.rst +12 -0
- docs/maf-api-db.rst +12 -0
- docs/maf-api-maf-contrib.rst +12 -0
- docs/maf-api-maps.rst +12 -0
- docs/maf-api-metricbundles.rst +12 -0
- docs/maf-api-metrics.rst +12 -0
- docs/maf-api-plots.rst +12 -0
- docs/maf-api-run-comparison.rst +12 -0
- docs/maf-api-slicers.rst +12 -0
- docs/maf-api-stackers.rst +12 -0
- docs/maf-api-utils.rst +12 -0
- docs/maf-api.rst +22 -0
- docs/maf.rst +60 -0
- docs/metric_list.py +49 -0
- docs/moving-objects-api.rst +12 -0
- docs/moving-objects.rst +22 -0
- docs/phot-utils-api.rst +12 -0
- docs/phot-utils.rst +11 -0
- docs/prenight.rst +117 -0
- docs/protoarchive.rst +276 -0
- docs/satellite-constellations-api.rst +12 -0
- docs/satellite-constellations.rst +13 -0
- docs/selfcal-api.rst +12 -0
- docs/selfcal.rst +15 -0
- docs/sim-archive-api.rst +12 -0
- docs/skybrightness-api.rst +12 -0
- docs/skybrightness.rst +23 -0
- docs/user-guide.rst +28 -0
- docs/vseqarchive-architecture.rst +438 -0
- docs/vseqarchive-setup.rst +238 -0
- docs/vseqarchive.rst +225 -0
- rubin_sim/__init__.py +7 -0
- rubin_sim/data/__init__.py +1 -0
- rubin_sim/data/rs_download_data.py +155 -0
- rubin_sim/maf/__init__.py +34 -0
- rubin_sim/maf/batches/__init__.py +18 -0
- rubin_sim/maf/batches/altaz_batch.py +161 -0
- rubin_sim/maf/batches/col_map_dict.py +274 -0
- rubin_sim/maf/batches/common.py +388 -0
- rubin_sim/maf/batches/ddf_batch.py +728 -0
- rubin_sim/maf/batches/filterchange_batch.py +182 -0
- rubin_sim/maf/batches/glance_batch.py +591 -0
- rubin_sim/maf/batches/hourglass_batch.py +79 -0
- rubin_sim/maf/batches/info_batch.py +114 -0
- rubin_sim/maf/batches/metadata_batch.py +558 -0
- rubin_sim/maf/batches/moving_objects_batch.py +1587 -0
- rubin_sim/maf/batches/openshutter_batch.py +100 -0
- rubin_sim/maf/batches/radar_limited.py +1100 -0
- rubin_sim/maf/batches/science_radar_batch.py +1910 -0
- rubin_sim/maf/batches/skycoverage.py +155 -0
- rubin_sim/maf/batches/slew_batch.py +146 -0
- rubin_sim/maf/batches/srd_batch.py +637 -0
- rubin_sim/maf/batches/time_batch.py +757 -0
- rubin_sim/maf/batches/time_sci_batch.py +105 -0
- rubin_sim/maf/batches/visitdepth_batch.py +485 -0
- rubin_sim/maf/db/__init__.py +2 -0
- rubin_sim/maf/db/add_run.py +34 -0
- rubin_sim/maf/db/results_db.py +1074 -0
- rubin_sim/maf/db/tracking_db.py +332 -0
- rubin_sim/maf/ddf_dir.py +53 -0
- rubin_sim/maf/generate_ss.py +218 -0
- rubin_sim/maf/glance_dir.py +58 -0
- rubin_sim/maf/maf_contrib/__init__.py +25 -0
- rubin_sim/maf/maf_contrib/calculate_lsst_field_visibility_astropy.py +170 -0
- rubin_sim/maf/maf_contrib/depth_limited_num_gal_metric.py +109 -0
- rubin_sim/maf/maf_contrib/example_new_metrics.py +40 -0
- rubin_sim/maf/maf_contrib/filter_pair_t_gaps_metric.py +208 -0
- rubin_sim/maf/maf_contrib/grb_transient_metric.py +249 -0
- rubin_sim/maf/maf_contrib/gw170817_det_metric.py +72 -0
- rubin_sim/maf/maf_contrib/intervals_between_obs_metric.py +68 -0
- rubin_sim/maf/maf_contrib/kne_metrics.py +473 -0
- rubin_sim/maf/maf_contrib/lss_metrics.py +45 -0
- rubin_sim/maf/maf_contrib/lss_obs_strategy/__init__.py +3 -0
- rubin_sim/maf/maf_contrib/lss_obs_strategy/constants_for_pipeline.py +73 -0
- rubin_sim/maf/maf_contrib/lss_obs_strategy/galaxy_counts_metric_extended.py +205 -0
- rubin_sim/maf/maf_contrib/lss_obs_strategy/galaxy_counts_with_pixel_calibration.py +171 -0
- rubin_sim/maf/maf_contrib/lv_dwarfs/__init__.py +1 -0
- rubin_sim/maf/maf_contrib/lv_dwarfs/lv_dwarfs_metrics.py +388 -0
- rubin_sim/maf/maf_contrib/microlensing_metric.py +593 -0
- rubin_sim/maf/maf_contrib/num_obs_in_survey_time_overlap_metric.py +43 -0
- rubin_sim/maf/maf_contrib/periodic_metric.py +51 -0
- rubin_sim/maf/maf_contrib/periodic_star_metric.py +186 -0
- rubin_sim/maf/maf_contrib/periodic_star_modulation_metric.py +236 -0
- rubin_sim/maf/maf_contrib/presto_color_kne_pop_metric.py +441 -0
- rubin_sim/maf/maf_contrib/selfcal_uniformity_metric.py +171 -0
- rubin_sim/maf/maf_contrib/star_count_mass_metric.py +64 -0
- rubin_sim/maf/maf_contrib/star_count_metric.py +56 -0
- rubin_sim/maf/maf_contrib/star_counts/__init__.py +8 -0
- rubin_sim/maf/maf_contrib/star_counts/abs_mag.py +324 -0
- rubin_sim/maf/maf_contrib/star_counts/coords.py +99 -0
- rubin_sim/maf/maf_contrib/star_counts/readme.txt +1 -0
- rubin_sim/maf/maf_contrib/star_counts/spec_type.py +91 -0
- rubin_sim/maf/maf_contrib/star_counts/starcount.py +30 -0
- rubin_sim/maf/maf_contrib/star_counts/starcount_bymass.py +93 -0
- rubin_sim/maf/maf_contrib/star_counts/stellardensity.py +59 -0
- rubin_sim/maf/maf_contrib/static_probes_fom_summary_metric.py +386 -0
- rubin_sim/maf/maf_contrib/tdes_pop_metric.py +362 -0
- rubin_sim/maf/maf_contrib/transient_ascii_sed_metric.py +652 -0
- rubin_sim/maf/maf_contrib/triplet_metric.py +156 -0
- rubin_sim/maf/maf_contrib/var_depth_metric.py +157 -0
- rubin_sim/maf/maf_contrib/xrb_metrics.py +523 -0
- rubin_sim/maf/maf_contrib/young_stellar_objects_metric.py +200 -0
- rubin_sim/maf/maf_night_report.py +200 -0
- rubin_sim/maf/make_fbs_tracking_db.py +90 -0
- rubin_sim/maf/maps/__init__.py +8 -0
- rubin_sim/maf/maps/base_map.py +72 -0
- rubin_sim/maf/maps/create_gaia_density_map.py +158 -0
- rubin_sim/maf/maps/dust_map.py +66 -0
- rubin_sim/maf/maps/dust_map_3d.py +190 -0
- rubin_sim/maf/maps/ebv_3d_hp.py +170 -0
- rubin_sim/maf/maps/ebv_hp.py +64 -0
- rubin_sim/maf/maps/gal_coords_map.py +22 -0
- rubin_sim/maf/maps/galactic_plane_priority_maps.py +210 -0
- rubin_sim/maf/maps/stellar_density_map.py +73 -0
- rubin_sim/maf/maps/trilegal_map.py +82 -0
- rubin_sim/maf/metadata_dir.py +90 -0
- rubin_sim/maf/metric_bundles/__init__.py +3 -0
- rubin_sim/maf/metric_bundles/metric_bundle.py +816 -0
- rubin_sim/maf/metric_bundles/metric_bundle_group.py +834 -0
- rubin_sim/maf/metric_bundles/mo_metric_bundle.py +646 -0
- rubin_sim/maf/metrics/__init__.py +52 -0
- rubin_sim/maf/metrics/agn_time_lag_metric.py +118 -0
- rubin_sim/maf/metrics/agnstructure.py +141 -0
- rubin_sim/maf/metrics/area_summary_metrics.py +120 -0
- rubin_sim/maf/metrics/base_metric.py +215 -0
- rubin_sim/maf/metrics/brown_dwarf_metric.py +162 -0
- rubin_sim/maf/metrics/cadence_metrics.py +400 -0
- rubin_sim/maf/metrics/calibration_metrics.py +618 -0
- rubin_sim/maf/metrics/chip_vendor_metric.py +43 -0
- rubin_sim/maf/metrics/color_slope_metrics.py +189 -0
- rubin_sim/maf/metrics/cosmology_summary_metrics.py +1212 -0
- rubin_sim/maf/metrics/coverage_metric.py +48 -0
- rubin_sim/maf/metrics/crowding_metric.py +255 -0
- rubin_sim/maf/metrics/cumulative_metric.py +46 -0
- rubin_sim/maf/metrics/dcr_metric.py +93 -0
- rubin_sim/maf/metrics/exgal_m5.py +57 -0
- rubin_sim/maf/metrics/fft_metric.py +27 -0
- rubin_sim/maf/metrics/galactic_plane_metrics.py +375 -0
- rubin_sim/maf/metrics/galplane_time_sampling_metrics.py +236 -0
- rubin_sim/maf/metrics/hourglass_metric.py +130 -0
- rubin_sim/maf/metrics/incremental_template_metric.py +255 -0
- rubin_sim/maf/metrics/kuiper_metrics.py +26 -0
- rubin_sim/maf/metrics/mo_metrics.py +1496 -0
- rubin_sim/maf/metrics/mo_summary_metrics.py +464 -0
- rubin_sim/maf/metrics/night_pointing_metric.py +70 -0
- rubin_sim/maf/metrics/optimal_m5_metric.py +94 -0
- rubin_sim/maf/metrics/pair_metric.py +69 -0
- rubin_sim/maf/metrics/periodic_detect_metric.py +133 -0
- rubin_sim/maf/metrics/phase_gap_metric.py +172 -0
- rubin_sim/maf/metrics/qso_number_counts_metric.py +138 -0
- rubin_sim/maf/metrics/scaling_metrics.py +148 -0
- rubin_sim/maf/metrics/schedview_metrics.py +39 -0
- rubin_sim/maf/metrics/season_metrics.py +344 -0
- rubin_sim/maf/metrics/simple_metrics.py +546 -0
- rubin_sim/maf/metrics/sky_sat_metric.py +18 -0
- rubin_sim/maf/metrics/sn_cadence_metric.py +104 -0
- rubin_sim/maf/metrics/sn_n_sn_metric.py +1364 -0
- rubin_sim/maf/metrics/sn_sl_metric.py +216 -0
- rubin_sim/maf/metrics/sn_snr_metric.py +715 -0
- rubin_sim/maf/metrics/snr_weight.py +24 -0
- rubin_sim/maf/metrics/star_density.py +77 -0
- rubin_sim/maf/metrics/string_count_metric.py +95 -0
- rubin_sim/maf/metrics/summary_metrics.py +201 -0
- rubin_sim/maf/metrics/surfb_metric.py +175 -0
- rubin_sim/maf/metrics/technical_metrics.py +271 -0
- rubin_sim/maf/metrics/tgaps.py +412 -0
- rubin_sim/maf/metrics/tomography_models.py +2034 -0
- rubin_sim/maf/metrics/transient_metrics.py +268 -0
- rubin_sim/maf/metrics/uniformity_metrics.py +418 -0
- rubin_sim/maf/metrics/use_metrics.py +55 -0
- rubin_sim/maf/metrics/vector_metrics.py +190 -0
- rubin_sim/maf/metrics/visit_groups_metric.py +341 -0
- rubin_sim/maf/metrics/weak_lensing_systematics_metric.py +210 -0
- rubin_sim/maf/plots/__init__.py +14 -0
- rubin_sim/maf/plots/hg_plotters.py +1117 -0
- rubin_sim/maf/plots/hourglass_plotters.py +120 -0
- rubin_sim/maf/plots/mo_plotters.py +358 -0
- rubin_sim/maf/plots/nd_plotters.py +220 -0
- rubin_sim/maf/plots/neo_distance_plotter.py +140 -0
- rubin_sim/maf/plots/night_pointing_plotter.py +96 -0
- rubin_sim/maf/plots/oned_plotters.py +114 -0
- rubin_sim/maf/plots/perceptual_rainbow.py +30 -0
- rubin_sim/maf/plots/plot_handler.py +766 -0
- rubin_sim/maf/plots/skyproj_plotters.py +540 -0
- rubin_sim/maf/plots/spatial_plotters.py +1029 -0
- rubin_sim/maf/plots/special_plotters.py +256 -0
- rubin_sim/maf/plots/two_d_plotters.py +177 -0
- rubin_sim/maf/plots/xyplotter.py +37 -0
- rubin_sim/maf/run_comparison/__init__.py +5 -0
- rubin_sim/maf/run_comparison/archive.py +584 -0
- rubin_sim/maf/run_comparison/gather_summaries.py +125 -0
- rubin_sim/maf/run_comparison/microlensing_compare.py +514 -0
- rubin_sim/maf/run_comparison/radar_plot.py +202 -0
- rubin_sim/maf/run_comparison/summary_plots.py +710 -0
- rubin_sim/maf/run_moving_calc.py +239 -0
- rubin_sim/maf/run_moving_fractions.py +128 -0
- rubin_sim/maf/run_moving_join.py +103 -0
- rubin_sim/maf/run_selfcal_metric.py +92 -0
- rubin_sim/maf/scimaf_dir.py +87 -0
- rubin_sim/maf/show_maf.py +227 -0
- rubin_sim/maf/slicers/__init__.py +13 -0
- rubin_sim/maf/slicers/base_slicer.py +513 -0
- rubin_sim/maf/slicers/base_spatial_slicer.py +202 -0
- rubin_sim/maf/slicers/healpix_sdss_slicer.py +118 -0
- rubin_sim/maf/slicers/healpix_slicer.py +189 -0
- rubin_sim/maf/slicers/healpix_subset_slicer.py +293 -0
- rubin_sim/maf/slicers/hourglass_slicer.py +37 -0
- rubin_sim/maf/slicers/mo_slicer.py +171 -0
- rubin_sim/maf/slicers/movie_slicer.py +288 -0
- rubin_sim/maf/slicers/nd_slicer.py +147 -0
- rubin_sim/maf/slicers/one_d_slicer.py +210 -0
- rubin_sim/maf/slicers/time_interval_slicers.py +283 -0
- rubin_sim/maf/slicers/uni_slicer.py +57 -0
- rubin_sim/maf/slicers/user_points_slicer.py +141 -0
- rubin_sim/maf/stackers/__init__.py +13 -0
- rubin_sim/maf/stackers/base_stacker.py +221 -0
- rubin_sim/maf/stackers/coord_stackers.py +224 -0
- rubin_sim/maf/stackers/date_stackers.py +192 -0
- rubin_sim/maf/stackers/general_stackers.py +683 -0
- rubin_sim/maf/stackers/get_col_info.py +104 -0
- rubin_sim/maf/stackers/label_stackers.py +114 -0
- rubin_sim/maf/stackers/m5_optimal_stacker.py +126 -0
- rubin_sim/maf/stackers/mo_phase.py +265 -0
- rubin_sim/maf/stackers/mo_stackers.py +486 -0
- rubin_sim/maf/stackers/n_follow_stacker.py +187 -0
- rubin_sim/maf/stackers/neo_dist_stacker.py +126 -0
- rubin_sim/maf/stackers/sdss_stackers.py +30 -0
- rubin_sim/maf/stackers/sn_stacker.py +152 -0
- rubin_sim/maf/stackers/teff_stacker.py +154 -0
- rubin_sim/maf/utils/__init__.py +6 -0
- rubin_sim/maf/utils/astrometry_utils.py +93 -0
- rubin_sim/maf/utils/generate_fov_map.py +58 -0
- rubin_sim/maf/utils/get_date_version.py +28 -0
- rubin_sim/maf/utils/maf_utils.py +212 -0
- rubin_sim/maf/utils/opsim_utils.py +259 -0
- rubin_sim/maf/utils/output_utils.py +34 -0
- rubin_sim/maf/utils/sn_n_sn_utils.py +894 -0
- rubin_sim/maf/utils/sn_utils.py +369 -0
- rubin_sim/maf/utils/stellar_mags.py +197 -0
- rubin_sim/maf/web/__init__.py +2 -0
- rubin_sim/maf/web/favicon.ico +0 -0
- rubin_sim/maf/web/maf_run_results.py +645 -0
- rubin_sim/maf/web/maf_tracking.py +139 -0
- rubin_sim/maf/web/sorttable.js +496 -0
- rubin_sim/maf/web/templates/allmetricresults.html +72 -0
- rubin_sim/maf/web/templates/configs.html +28 -0
- rubin_sim/maf/web/templates/macros.html +243 -0
- rubin_sim/maf/web/templates/master.html +294 -0
- rubin_sim/maf/web/templates/metricselect.html +91 -0
- rubin_sim/maf/web/templates/multicolor.html +147 -0
- rubin_sim/maf/web/templates/results.html +82 -0
- rubin_sim/maf/web/templates/runselect.html +58 -0
- rubin_sim/maf/web/templates/stats.html +50 -0
- rubin_sim/moving_objects/__init__.py +8 -0
- rubin_sim/moving_objects/base_obs.py +468 -0
- rubin_sim/moving_objects/cheby_fits.py +689 -0
- rubin_sim/moving_objects/cheby_values.py +231 -0
- rubin_sim/moving_objects/chebyshev_utils.py +365 -0
- rubin_sim/moving_objects/direct_obs.py +376 -0
- rubin_sim/moving_objects/make_lsst_obs.py +282 -0
- rubin_sim/moving_objects/ooephemerides.py +643 -0
- rubin_sim/moving_objects/orbits.py +507 -0
- rubin_sim/moving_objects/pre_generate.py +37 -0
- rubin_sim/moving_objects/utils.py +61 -0
- rubin_sim/phot_utils/__init__.py +7 -0
- rubin_sim/phot_utils/bandpass.py +425 -0
- rubin_sim/phot_utils/photometric_parameters.py +449 -0
- rubin_sim/phot_utils/physical_parameters.py +50 -0
- rubin_sim/phot_utils/predicted_zeropoints.py +245 -0
- rubin_sim/phot_utils/sed.py +1773 -0
- rubin_sim/phot_utils/sed_utils.py +52 -0
- rubin_sim/phot_utils/signaltonoise.py +695 -0
- rubin_sim/phot_utils/spectral_resampling.py +161 -0
- rubin_sim/satellite_constellations/__init__.py +3 -0
- rubin_sim/satellite_constellations/basis_function.py +40 -0
- rubin_sim/satellite_constellations/model_observatory.py +157 -0
- rubin_sim/satellite_constellations/sat_utils.py +488 -0
- rubin_sim/selfcal/__init__.py +4 -0
- rubin_sim/selfcal/generate_catalog.py +188 -0
- rubin_sim/selfcal/offsets.py +119 -0
- rubin_sim/selfcal/solver.py +143 -0
- rubin_sim/selfcal/star_tools.py +42 -0
- rubin_sim/sim_archive/__init__.py +14 -0
- rubin_sim/sim_archive/conda_packages.py +65 -0
- rubin_sim/sim_archive/future_vsarch.py +480 -0
- rubin_sim/sim_archive/make_snapshot.py +255 -0
- rubin_sim/sim_archive/prenight.py +216 -0
- rubin_sim/sim_archive/prenightindex.py +229 -0
- rubin_sim/sim_archive/prototype.py +1029 -0
- rubin_sim/sim_archive/sim_archive.py +680 -0
- rubin_sim/sim_archive/tempdb.py +56 -0
- rubin_sim/sim_archive/util.py +146 -0
- rubin_sim/sim_archive/vseqarchive.py +965 -0
- rubin_sim/sim_archive/vseqmetadata.py +1721 -0
- rubin_sim/skybrightness/__init__.py +5 -0
- rubin_sim/skybrightness/allsky_db.py +93 -0
- rubin_sim/skybrightness/data/ESO_Spectra/eso_tools.py +505 -0
- rubin_sim/skybrightness/data/solarSpec/package.py +22 -0
- rubin_sim/skybrightness/generate_hdf5.py +243 -0
- rubin_sim/skybrightness/interp_components.py +798 -0
- rubin_sim/skybrightness/sky_model.py +771 -0
- rubin_sim/skybrightness/twilight_func.py +83 -0
- rubin_sim/skybrightness/utils.py +91 -0
- rubin_sim-2.6.1.dev2.dist-info/METADATA +95 -0
- rubin_sim-2.6.1.dev2.dist-info/RECORD +387 -0
- rubin_sim-2.6.1.dev2.dist-info/WHEEL +5 -0
- rubin_sim-2.6.1.dev2.dist-info/entry_points.txt +24 -0
- rubin_sim-2.6.1.dev2.dist-info/licenses/LICENSE +674 -0
- rubin_sim-2.6.1.dev2.dist-info/top_level.txt +5 -0
- sql/make_vseqmeta.sql +251 -0
- tests/data/test_data.py +26 -0
- tests/data/test_ddf_grid.py +17 -0
- tests/maf/test_3x2fom.py +68 -0
- tests/maf/test_archive.py +162 -0
- tests/maf/test_basemetrics.py +99 -0
- tests/maf/test_batchcommon.py +36 -0
- tests/maf/test_batches.py +159 -0
- tests/maf/test_cadencemetrics.py +388 -0
- tests/maf/test_calibrationmetrics.py +242 -0
- tests/maf/test_color_slopes.py +71 -0
- tests/maf/test_cosmology_summaries.py +20 -0
- tests/maf/test_gathersummaries.py +48 -0
- tests/maf/test_healpixslicer.py +439 -0
- tests/maf/test_healpixsubsetslicer.py +273 -0
- tests/maf/test_hgplotters.py +145 -0
- tests/maf/test_hourglassmetric.py +33 -0
- tests/maf/test_io.py +187 -0
- tests/maf/test_json.py +169 -0
- tests/maf/test_maps.py +199 -0
- tests/maf/test_metricbundle.py +69 -0
- tests/maf/test_mometrics.py +422 -0
- tests/maf/test_movieslicer.py +216 -0
- tests/maf/test_ndslicer.py +240 -0
- tests/maf/test_neodistanceplotter.py +41 -0
- tests/maf/test_onedslicer.py +245 -0
- tests/maf/test_opsimutils.py +80 -0
- tests/maf/test_plotters.py +134 -0
- tests/maf/test_resultsdb.py +145 -0
- tests/maf/test_schedviewmetrics.py +14 -0
- tests/maf/test_simplemetrics.py +200 -0
- tests/maf/test_snmetrics.py +335 -0
- tests/maf/test_snmetrics_nsn.py +123 -0
- tests/maf/test_stackers.py +423 -0
- tests/maf/test_stellarmags.py +50 -0
- tests/maf/test_stringcount.py +26 -0
- tests/maf/test_summary_plots.py +197 -0
- tests/maf/test_summarymetrics.py +82 -0
- tests/maf/test_technicalmetrics.py +267 -0
- tests/maf/test_templatemetrics.py +86 -0
- tests/maf/test_timeintervalslicers.py +97 -0
- tests/maf/test_trackingdb.py +88 -0
- tests/maf/test_unislicer.py +116 -0
- tests/maf/test_vectormetrics.py +225 -0
- tests/maf/test_visitgroupsmetric.py +181 -0
- tests/moving_objects/test_camera.py +39 -0
- tests/moving_objects/test_chebyfits.py +188 -0
- tests/moving_objects/test_chebyshevutils.py +76 -0
- tests/moving_objects/test_chebyvalues.py +245 -0
- tests/moving_objects/test_ephemerides.py +219 -0
- tests/moving_objects/test_orbits.py +170 -0
- tests/moving_objects/test_sed_data.py +61 -0
- tests/phot_utils/test_approximatebandpasses.py +91 -0
- tests/phot_utils/test_photometricparameters.py +268 -0
- tests/phot_utils/test_photometry.py +61 -0
- tests/phot_utils/test_predicted_zeropoints.py +53 -0
- tests/phot_utils/test_read_bandpasses.py +29 -0
- tests/phot_utils/test_sed.py +368 -0
- tests/phot_utils/test_snr.py +370 -0
- tests/satellite_constellations/test_satellites.py +36 -0
- tests/sim_archive/test_make_snapshot.py +24 -0
- tests/sim_archive/test_prototype_sim_archive.py +204 -0
- tests/sim_archive/test_vseqarchive.py +947 -0
- tests/skybrightness/test_skymodel.py +359 -0
|
@@ -0,0 +1,894 @@
|
|
|
1
|
+
__all__ = (
|
|
2
|
+
"LcfastNew",
|
|
3
|
+
"LoadReference",
|
|
4
|
+
"GetReference",
|
|
5
|
+
"SnRate",
|
|
6
|
+
"CovColor",
|
|
7
|
+
"load_sne_cached",
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
import warnings
|
|
12
|
+
|
|
13
|
+
import numpy as np
|
|
14
|
+
import pandas as pd
|
|
15
|
+
from astropy.cosmology import FlatLambdaCDM
|
|
16
|
+
from astropy.table import Table
|
|
17
|
+
from rubin_scheduler.data import get_data_dir
|
|
18
|
+
from scipy.interpolate import RegularGridInterpolator
|
|
19
|
+
|
|
20
|
+
from rubin_sim.maf.utils import m52snr
|
|
21
|
+
|
|
22
|
+
warnings.filterwarnings("ignore", category=RuntimeWarning)
|
|
23
|
+
|
|
24
|
+
steradian2_sqdeg = 180.0**2 / np.pi**2
|
|
25
|
+
# Mpc^3 -> Mpc^3/sr
|
|
26
|
+
norm = 1.0 / (4.0 * np.pi)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class LcfastNew:
|
|
30
|
+
"""
|
|
31
|
+
class to simulate supernovae light curves in a fast way
|
|
32
|
+
The method relies on templates and broadcasting to increase speed
|
|
33
|
+
|
|
34
|
+
Parameters
|
|
35
|
+
---------------
|
|
36
|
+
reference_lc : `scipy.interpolate.RegularGridData`
|
|
37
|
+
lc reference files
|
|
38
|
+
x1 : `float`
|
|
39
|
+
SN stretch
|
|
40
|
+
color : `float`
|
|
41
|
+
SN color
|
|
42
|
+
telescope : Telescope()
|
|
43
|
+
telescope for the study
|
|
44
|
+
mjd_col : `str`, optional
|
|
45
|
+
name of the MJD col in data to simulate
|
|
46
|
+
filter_col : `str`, optional
|
|
47
|
+
name of the filter col in data to simulate
|
|
48
|
+
exptime_col : `str`, optional
|
|
49
|
+
name of the exposure time col in data to simulate
|
|
50
|
+
m5_col : `str`, optional
|
|
51
|
+
name of the fiveSigmaDepth col in data to simulate
|
|
52
|
+
season_col : `str`, optional
|
|
53
|
+
name of the season col in data to simulate
|
|
54
|
+
snr_min : `float`, optional
|
|
55
|
+
minimal Signal-to-Noise Ratio to apply on LC points
|
|
56
|
+
light_output : `bool`, optional
|
|
57
|
+
to get a lighter output (ie lower number of cols)
|
|
58
|
+
bluecutoff : `float`, optional
|
|
59
|
+
blue cutoff for SN
|
|
60
|
+
redcutoff : `float`, optional
|
|
61
|
+
red cutoff for SN
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
def __init__(
|
|
65
|
+
self,
|
|
66
|
+
reference_lc,
|
|
67
|
+
x1,
|
|
68
|
+
color,
|
|
69
|
+
mjd_col="observationStartMJD",
|
|
70
|
+
filter_col="filter",
|
|
71
|
+
exptime_col="visitExposureTime",
|
|
72
|
+
m5_col="fiveSigmaDepth",
|
|
73
|
+
season_col="season",
|
|
74
|
+
nexp_col="numExposures",
|
|
75
|
+
seeing_col="seeingFwhmEff",
|
|
76
|
+
snr_min=5.0,
|
|
77
|
+
light_output=True,
|
|
78
|
+
ebvof_mw=-1.0,
|
|
79
|
+
bluecutoff=380.0,
|
|
80
|
+
redcutoff=800.0,
|
|
81
|
+
):
|
|
82
|
+
# grab all vals
|
|
83
|
+
self.filter_col = filter_col
|
|
84
|
+
self.mjd_col = mjd_col
|
|
85
|
+
self.m5_col = m5_col
|
|
86
|
+
self.exptime_col = exptime_col
|
|
87
|
+
self.season_col = season_col
|
|
88
|
+
self.nexp_col = nexp_col
|
|
89
|
+
self.seeing_col = seeing_col
|
|
90
|
+
|
|
91
|
+
self.x1 = x1
|
|
92
|
+
self.color = color
|
|
93
|
+
self.light_output = light_output
|
|
94
|
+
self.ebvof_mw = ebvof_mw
|
|
95
|
+
|
|
96
|
+
# Loading reference file
|
|
97
|
+
self.reference_lc = reference_lc
|
|
98
|
+
|
|
99
|
+
# This cutoffs are used to select observations:
|
|
100
|
+
# phase = (mjd - DayMax)/(1.+z)
|
|
101
|
+
# selection: min_rf_phase < phase < max_rf_phase
|
|
102
|
+
# and blue_cutoff < mean_rest_frame < red_cutoff
|
|
103
|
+
# where mean_rest_frame = telescope.mean_wavelength/(1.+z)
|
|
104
|
+
self.blue_cutoff = bluecutoff
|
|
105
|
+
self.red_cutoff = redcutoff
|
|
106
|
+
|
|
107
|
+
# SN parameters for Fisher matrix estimation
|
|
108
|
+
self.param__fisher = ["x0", "x1", "daymax", "color"]
|
|
109
|
+
|
|
110
|
+
self.snr_min = snr_min
|
|
111
|
+
|
|
112
|
+
def __call__(self, obs, ebvof_mw, gen_par=None, bands="grizy"):
|
|
113
|
+
"""Simulation of the light curve
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
Parameters
|
|
117
|
+
-----------
|
|
118
|
+
obs : `np.ndarray`, (N,)
|
|
119
|
+
array of observations
|
|
120
|
+
ebvof_mw : `float`
|
|
121
|
+
E(B-V) for MW
|
|
122
|
+
gen_par : `np.ndarray`, optional
|
|
123
|
+
simulation parameters (default: None)
|
|
124
|
+
bands : `str`, optional
|
|
125
|
+
filters to consider for simulation (default: grizy)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
Returns
|
|
129
|
+
--------
|
|
130
|
+
table : `astropy.Table`
|
|
131
|
+
columns: band, flux, fluxerr, snr_m5,flux_e,zp,zpsys,time
|
|
132
|
+
metadata : SNID,RA,Dec,DayMax,X1,Color,z
|
|
133
|
+
"""
|
|
134
|
+
|
|
135
|
+
if len(obs) == 0:
|
|
136
|
+
return None
|
|
137
|
+
|
|
138
|
+
# result in this df
|
|
139
|
+
tab_tot = pd.DataFrame()
|
|
140
|
+
|
|
141
|
+
# loop on the bands
|
|
142
|
+
for band in bands:
|
|
143
|
+
idx = obs[self.filter_col] == band
|
|
144
|
+
if len(obs[idx]) > 0:
|
|
145
|
+
tab_tot = pd.concat(
|
|
146
|
+
[tab_tot, self.process_band(obs[idx], ebvof_mw, band, gen_par)],
|
|
147
|
+
ignore_index=True,
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
# return produced LC
|
|
151
|
+
return tab_tot
|
|
152
|
+
|
|
153
|
+
def process_band(self, sel_obs, ebvof_mw, band, gen_par):
|
|
154
|
+
"""LC simulation of a set of obs corresponding to a band
|
|
155
|
+
The idea is to use python broadcasting so as to estimate
|
|
156
|
+
all the requested values (flux, flux error, Fisher components, ...)
|
|
157
|
+
in a single path (i.e no loop!)
|
|
158
|
+
|
|
159
|
+
Parameters
|
|
160
|
+
---------------
|
|
161
|
+
sel_obs : `np.ndarray`
|
|
162
|
+
array of observations
|
|
163
|
+
band : `str`
|
|
164
|
+
band of observations
|
|
165
|
+
gen_par : `np.ndarray``
|
|
166
|
+
simulation parameters
|
|
167
|
+
|
|
168
|
+
Returns
|
|
169
|
+
-------
|
|
170
|
+
table : `astropy.Table`
|
|
171
|
+
astropy table with fields corresponding to LC components
|
|
172
|
+
"""
|
|
173
|
+
|
|
174
|
+
# if there are no observations in this filter: return None
|
|
175
|
+
if len(sel_obs) == 0:
|
|
176
|
+
return None
|
|
177
|
+
|
|
178
|
+
# Get the fluxes (from griddata reference)
|
|
179
|
+
|
|
180
|
+
# xi = MJD-T0
|
|
181
|
+
xi = sel_obs[self.mjd_col] - gen_par["daymax"][:, np.newaxis]
|
|
182
|
+
|
|
183
|
+
# yi = redshift simulated values
|
|
184
|
+
# requested to avoid interpolation problems near boundaries
|
|
185
|
+
yi = np.round(gen_par["z"], 4)
|
|
186
|
+
# yi = gen_par['z']
|
|
187
|
+
|
|
188
|
+
# p = phases of LC points = xi/(1.+z)
|
|
189
|
+
p = xi / (1.0 + yi[:, np.newaxis])
|
|
190
|
+
yi_arr = np.ones_like(p) * yi[:, np.newaxis]
|
|
191
|
+
|
|
192
|
+
# get fluxes
|
|
193
|
+
pts = (p, yi_arr)
|
|
194
|
+
fluxes_obs = self.reference_lc.flux[band](pts)
|
|
195
|
+
|
|
196
|
+
# Fisher components estimation
|
|
197
|
+
|
|
198
|
+
d_flux = {}
|
|
199
|
+
|
|
200
|
+
# loop on Fisher parameters
|
|
201
|
+
for val in self.param__fisher:
|
|
202
|
+
d_flux[val] = self.reference_lc.param[band][val](pts)
|
|
203
|
+
|
|
204
|
+
# Fisher matrix components estimation
|
|
205
|
+
# loop on SN parameters (x0,x1,color)
|
|
206
|
+
# estimate: dF/dxi*dF/dxj
|
|
207
|
+
derivative_for__fisher = {}
|
|
208
|
+
for ia, vala in enumerate(self.param__fisher):
|
|
209
|
+
for jb, valb in enumerate(self.param__fisher):
|
|
210
|
+
if jb >= ia:
|
|
211
|
+
derivative_for__fisher[vala + valb] = d_flux[vala] * d_flux[valb]
|
|
212
|
+
|
|
213
|
+
flag = self.get_flag(sel_obs, gen_par, fluxes_obs, band, p)
|
|
214
|
+
flag_idx = np.argwhere(flag)
|
|
215
|
+
|
|
216
|
+
# now apply the flag to select LC points - masked arrays
|
|
217
|
+
fluxes = self.marray(fluxes_obs, flag)
|
|
218
|
+
phases = self.marray(p, flag)
|
|
219
|
+
z_vals = gen_par["z"][flag_idx[:, 0]]
|
|
220
|
+
daymax_vals = gen_par["daymax"][flag_idx[:, 0]]
|
|
221
|
+
fisher__mat = {}
|
|
222
|
+
for key, vals in derivative_for__fisher.items():
|
|
223
|
+
fisher__mat[key] = self.marray(vals, flag)
|
|
224
|
+
|
|
225
|
+
ndata = len(fluxes[~fluxes.mask])
|
|
226
|
+
|
|
227
|
+
if ndata <= 0:
|
|
228
|
+
return pd.DataFrame()
|
|
229
|
+
|
|
230
|
+
nvals = len(phases)
|
|
231
|
+
# masked - tile arrays
|
|
232
|
+
|
|
233
|
+
cols = [
|
|
234
|
+
self.mjd_col,
|
|
235
|
+
self.season_col,
|
|
236
|
+
self.m5_col,
|
|
237
|
+
self.exptime_col,
|
|
238
|
+
self.nexp_col,
|
|
239
|
+
self.seeing_col,
|
|
240
|
+
"night",
|
|
241
|
+
]
|
|
242
|
+
|
|
243
|
+
# take columns common with obs cols
|
|
244
|
+
colcoms = set(cols).intersection(sel_obs.dtype.names)
|
|
245
|
+
|
|
246
|
+
masked_tile = {}
|
|
247
|
+
for vv in list(colcoms):
|
|
248
|
+
masked_tile[vv] = self.tarray(sel_obs[vv], nvals, flag)
|
|
249
|
+
|
|
250
|
+
# mag_obs = np.ma.array(mag_obs, mask=~flag)
|
|
251
|
+
|
|
252
|
+
# put data in a pandas df
|
|
253
|
+
lc = pd.DataFrame()
|
|
254
|
+
|
|
255
|
+
lc["flux"] = fluxes[~fluxes.mask]
|
|
256
|
+
lc["mag"] = -2.5 * np.log10(lc["flux"] / 3631.0)
|
|
257
|
+
lc["phase"] = phases[~phases.mask]
|
|
258
|
+
lc["band"] = ["LSST::" + band] * len(lc)
|
|
259
|
+
lc["zp"] = self.reference_lc.zp[band]
|
|
260
|
+
lc["zp"] = 2.5 * np.log10(3631)
|
|
261
|
+
lc["zpsys"] = "ab"
|
|
262
|
+
lc["z"] = z_vals
|
|
263
|
+
lc["daymax"] = daymax_vals
|
|
264
|
+
|
|
265
|
+
for key, vals in masked_tile.items():
|
|
266
|
+
lc[key] = vals[~vals.mask]
|
|
267
|
+
|
|
268
|
+
lc["time"] = lc[self.mjd_col]
|
|
269
|
+
lc.loc[:, "x1"] = self.x1
|
|
270
|
+
lc.loc[:, "color"] = self.color
|
|
271
|
+
|
|
272
|
+
# estimate errors
|
|
273
|
+
lc["snr_m5"] = m52snr(lc["mag"], lc["fiveSigmaDepth"])
|
|
274
|
+
lc["fluxerr_photo"] = lc["flux"] / lc["snr_m5"]
|
|
275
|
+
lc["magerr"] = (2.5 / np.log(10.0)) / lc["snr_m5"]
|
|
276
|
+
|
|
277
|
+
# Fisher matrix components
|
|
278
|
+
for key, vals in fisher__mat.items():
|
|
279
|
+
lc.loc[:, "F_{}".format(key)] = vals[~vals.mask] / (lc["fluxerr_photo"].values ** 2)
|
|
280
|
+
|
|
281
|
+
lc.loc[:, "n_aft"] = (np.sign(lc["phase"]) == 1) & (lc["snr_m5"] >= self.snr_min)
|
|
282
|
+
lc.loc[:, "n_bef"] = (np.sign(lc["phase"]) == -1) & (lc["snr_m5"] >= self.snr_min)
|
|
283
|
+
|
|
284
|
+
lc.loc[:, "n_phmin"] = lc["phase"] <= -5.0
|
|
285
|
+
lc.loc[:, "n_phmax"] = lc["phase"] >= 20
|
|
286
|
+
|
|
287
|
+
# if len(lc) > 0.:
|
|
288
|
+
# lc = self.dust_corrections(lc, ebvof_mw)
|
|
289
|
+
|
|
290
|
+
# remove lc points with no detectable flux
|
|
291
|
+
idx = lc["mag"] < lc["fiveSigmaDepth"] + 0.5
|
|
292
|
+
lc_flux = lc[idx]
|
|
293
|
+
|
|
294
|
+
return lc_flux
|
|
295
|
+
|
|
296
|
+
def get_flag(self, sel_obs, gen_par, fluxes_obs, band, p):
|
|
297
|
+
"""Method to flag events corresponding to selection criteria
|
|
298
|
+
|
|
299
|
+
Parameters
|
|
300
|
+
---------------
|
|
301
|
+
sel_obs : `np.ndarray``
|
|
302
|
+
observations
|
|
303
|
+
gen_par : `np.ndarray`
|
|
304
|
+
simulation parameters
|
|
305
|
+
fluxes_obs : `np.ndarray`
|
|
306
|
+
LC fluxes
|
|
307
|
+
band : `str`
|
|
308
|
+
filter
|
|
309
|
+
p : `np.ndarray``
|
|
310
|
+
LC phases
|
|
311
|
+
"""
|
|
312
|
+
# remove LC points outside the restframe phase range
|
|
313
|
+
min_rf_phase = gen_par["minRFphase"][:, np.newaxis]
|
|
314
|
+
max_rf_phase = gen_par["maxRFphase"][:, np.newaxis]
|
|
315
|
+
flag = (p >= min_rf_phase) & (p <= max_rf_phase)
|
|
316
|
+
|
|
317
|
+
# remove LC points outside the (blue-red) range
|
|
318
|
+
mean_restframe_wavelength = np.array([self.reference_lc.mean_wavelength[band]] * len(sel_obs))
|
|
319
|
+
mean_restframe_wavelength = np.tile(mean_restframe_wavelength, (len(gen_par), 1)) / (
|
|
320
|
+
1.0 + gen_par["z"][:, np.newaxis]
|
|
321
|
+
)
|
|
322
|
+
# flag &= (mean_restframe_wavelength > 0.) & (
|
|
323
|
+
# mean_restframe_wavelength < 1000000.)
|
|
324
|
+
flag &= (mean_restframe_wavelength > self.blue_cutoff) & (mean_restframe_wavelength < self.red_cutoff)
|
|
325
|
+
|
|
326
|
+
# remove points with neg flux
|
|
327
|
+
flag &= fluxes_obs > 1.0e-10
|
|
328
|
+
|
|
329
|
+
return flag
|
|
330
|
+
|
|
331
|
+
def marray(self, val, flag):
|
|
332
|
+
"""method to estimate a masked array
|
|
333
|
+
|
|
334
|
+
Parameters
|
|
335
|
+
---------------
|
|
336
|
+
val : `np.ndarray`
|
|
337
|
+
flag : `np.ndarray`
|
|
338
|
+
mask for values
|
|
339
|
+
|
|
340
|
+
Returns
|
|
341
|
+
----------
|
|
342
|
+
masked_array : `np.ma.array`
|
|
343
|
+
the masked array
|
|
344
|
+
|
|
345
|
+
"""
|
|
346
|
+
return np.ma.array(val, mask=~flag)
|
|
347
|
+
|
|
348
|
+
def tarray(self, arr, nvals, flag):
|
|
349
|
+
"""method to estimate a masked tiled array
|
|
350
|
+
|
|
351
|
+
Parameters
|
|
352
|
+
---------------
|
|
353
|
+
val : `np.ndarray`
|
|
354
|
+
nvals : `int`
|
|
355
|
+
number of tiles
|
|
356
|
+
flag : np.ndarray`
|
|
357
|
+
|
|
358
|
+
Returns
|
|
359
|
+
----------
|
|
360
|
+
masked_tiles : `np.ma.array`
|
|
361
|
+
the masked tiled array
|
|
362
|
+
"""
|
|
363
|
+
|
|
364
|
+
vv = np.ma.array(np.tile(arr, (nvals, 1)), mask=~flag)
|
|
365
|
+
return vv
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
def load_sne_cached(gamma_name="gamma_WFD.hdf5"):
|
|
369
|
+
"""Load up the SNe lightcurve files with a simple function
|
|
370
|
+
that caches the result so each metric
|
|
371
|
+
doesn't need to load it on it's own
|
|
372
|
+
"""
|
|
373
|
+
need_data = True
|
|
374
|
+
if hasattr(load_sne_cached, "data"):
|
|
375
|
+
# Only return data if the current gamma file matches
|
|
376
|
+
# the loaded gamma file
|
|
377
|
+
if load_sne_cached.gammaName == gamma_name:
|
|
378
|
+
need_data = False
|
|
379
|
+
if need_data:
|
|
380
|
+
load_sne_cached.data = LoadReference(gamma_name=gamma_name).ref
|
|
381
|
+
load_sne_cached.gammaName = gamma_name
|
|
382
|
+
return load_sne_cached.data
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
class LoadReference:
|
|
386
|
+
"""class to load template files requested for LCFast
|
|
387
|
+
These files should be stored in a reference_files
|
|
388
|
+
The files should be part of the rubin_sim_data/maf/SNe_dat files.
|
|
389
|
+
They are also available for download from
|
|
390
|
+
https://me.lsst.eu/gris/DESC_SN_pipeline/.
|
|
391
|
+
|
|
392
|
+
Parameters
|
|
393
|
+
---------------
|
|
394
|
+
templateDir : `str`, optional
|
|
395
|
+
where to put the files (default: reference_files)
|
|
396
|
+
gammaName : `str`, optional
|
|
397
|
+
The name of the gamma file (for photometric zeropoint and
|
|
398
|
+
SNR calculation information).
|
|
399
|
+
Note that these are similar to, but not necessarily the same as,
|
|
400
|
+
the current expected
|
|
401
|
+
LSST zeropoints and SNR gamma values.
|
|
402
|
+
"""
|
|
403
|
+
|
|
404
|
+
def __init__(
|
|
405
|
+
self,
|
|
406
|
+
template_dir=None,
|
|
407
|
+
gamma_name="gamma_WFD.hdf5",
|
|
408
|
+
):
|
|
409
|
+
if template_dir is None:
|
|
410
|
+
sims_maf_contrib_dir = get_data_dir()
|
|
411
|
+
template_dir = os.path.join(sims_maf_contrib_dir, "maf/SNe_data")
|
|
412
|
+
|
|
413
|
+
x1_colors = [(-2.0, 0.2), (0.0, 0.0)]
|
|
414
|
+
|
|
415
|
+
lc_reference = {}
|
|
416
|
+
|
|
417
|
+
list_files = [gamma_name]
|
|
418
|
+
for j in range(len(x1_colors)):
|
|
419
|
+
x1 = x1_colors[j][0]
|
|
420
|
+
color = x1_colors[j][1]
|
|
421
|
+
fname = "LC_{}_{}_380.0_800.0_ebvofMW_0.0_vstack.hdf5".format(x1, color)
|
|
422
|
+
list_files += [fname]
|
|
423
|
+
|
|
424
|
+
# gamma_reference
|
|
425
|
+
self.gamma_reference = os.path.join(template_dir, gamma_name)
|
|
426
|
+
|
|
427
|
+
# print('Loading reference files')
|
|
428
|
+
|
|
429
|
+
resultdict = {}
|
|
430
|
+
|
|
431
|
+
for j in range(len(x1_colors)):
|
|
432
|
+
x1 = x1_colors[j][0]
|
|
433
|
+
color = x1_colors[j][1]
|
|
434
|
+
fname = "{}/LC_{}_{}_380.0_800.0_ebvofMW_0.0_vstack.hdf5".format(template_dir, x1, color)
|
|
435
|
+
resultdict[j] = GetReference(fname, self.gamma_reference)
|
|
436
|
+
|
|
437
|
+
for j in range(len(x1_colors)):
|
|
438
|
+
if resultdict[j] is not None:
|
|
439
|
+
lc_reference[x1_colors[j]] = resultdict[j]
|
|
440
|
+
|
|
441
|
+
self.ref = lc_reference
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
class GetReference:
|
|
445
|
+
"""Class to load reference data used for the fast SN simulator
|
|
446
|
+
|
|
447
|
+
Parameters
|
|
448
|
+
----------------
|
|
449
|
+
lcName : `str`
|
|
450
|
+
name of the reference file to load (lc)
|
|
451
|
+
gammaName : `str`
|
|
452
|
+
name of the reference file to load (gamma)
|
|
453
|
+
tel_par : `dict`
|
|
454
|
+
telescope parameters
|
|
455
|
+
param_Fisher : `list` [`str`], optional
|
|
456
|
+
list of SN parameter for Fisher estimation to consider
|
|
457
|
+
(default: ['x0', 'x1', 'color', 'daymax'])
|
|
458
|
+
|
|
459
|
+
Notes
|
|
460
|
+
-----
|
|
461
|
+
After instantiations, the following dict can be accessed:
|
|
462
|
+
mag_to_flux_e_sec : Interp1D of mag to flux(e.sec-1) conversion
|
|
463
|
+
flux : dict of RegularGridInterpolator of fluxes
|
|
464
|
+
(key: filters, (x,y)=(phase, z), result=flux)
|
|
465
|
+
fluxerr : dict of RegularGridInterpolator of flux errors
|
|
466
|
+
(key: filters, (x,y)=(phase, z), result=fluxerr)
|
|
467
|
+
param : dict of dict of RegularGridInterpolator of flux derivatives
|
|
468
|
+
wrt SN parameters
|
|
469
|
+
(key: filters plus param_Fisher parameters; (x,y)=(phase, z),
|
|
470
|
+
result=flux derivatives)
|
|
471
|
+
gamma : dict of RegularGridInterpolator of gamma values (key: filters)
|
|
472
|
+
"""
|
|
473
|
+
|
|
474
|
+
def __init__(self, lc_name, gamma_name, param__fisher=["x0", "x1", "color", "daymax"]):
|
|
475
|
+
# Load the file - lc reference
|
|
476
|
+
if not os.path.exists(lc_name):
|
|
477
|
+
raise FileExistsError(f"{lc_name} does not exist - NSN metric cannot run")
|
|
478
|
+
|
|
479
|
+
# Load the file - gamma values
|
|
480
|
+
if not os.path.exists(gamma_name):
|
|
481
|
+
raise FileExistsError("gamma file {} does not exist - NSN metric cannot run")
|
|
482
|
+
|
|
483
|
+
lc_ref_tot = Table.from_pandas(pd.read_hdf(lc_name))
|
|
484
|
+
idx = lc_ref_tot["z"] > 0.005
|
|
485
|
+
lc_ref_tot = np.copy(lc_ref_tot[idx])
|
|
486
|
+
|
|
487
|
+
# Load references needed for the following
|
|
488
|
+
self.lc_ref = {}
|
|
489
|
+
self.gamma_ref = {}
|
|
490
|
+
self.gamma = {}
|
|
491
|
+
self.m5_ref = {}
|
|
492
|
+
self.mag_to_flux_e_sec = {}
|
|
493
|
+
self.mag_to_flux = {}
|
|
494
|
+
self.zp = {}
|
|
495
|
+
self.mean_wavelength = {}
|
|
496
|
+
|
|
497
|
+
self.flux = {}
|
|
498
|
+
self.fluxerr = {}
|
|
499
|
+
self.param = {}
|
|
500
|
+
|
|
501
|
+
bands = np.unique(lc_ref_tot["band"])
|
|
502
|
+
|
|
503
|
+
method = "linear"
|
|
504
|
+
|
|
505
|
+
# for each band: load data to be used for interpolation
|
|
506
|
+
for band in bands:
|
|
507
|
+
idx = lc_ref_tot["band"] == band
|
|
508
|
+
lc_sel = Table(lc_ref_tot[idx])
|
|
509
|
+
|
|
510
|
+
lc_sel["z"] = lc_sel["z"].data.round(decimals=2)
|
|
511
|
+
lc_sel["phase"] = lc_sel["phase"].data.round(decimals=1)
|
|
512
|
+
|
|
513
|
+
"""
|
|
514
|
+
select phases between -20 and 50 only
|
|
515
|
+
"""
|
|
516
|
+
idx = lc_sel["phase"] < 60.0
|
|
517
|
+
idx &= lc_sel["phase"] > -20.0
|
|
518
|
+
lc_sel = lc_sel[idx]
|
|
519
|
+
|
|
520
|
+
# these reference data will be used for griddata interp.
|
|
521
|
+
self.lc_ref[band] = lc_sel
|
|
522
|
+
self.gamma_ref[band] = lc_sel["gamma"][0]
|
|
523
|
+
self.m5_ref[band] = np.unique(lc_sel["m5"])[0]
|
|
524
|
+
|
|
525
|
+
# Another interpolator, faster than griddata:
|
|
526
|
+
# regulargridinterpolator
|
|
527
|
+
|
|
528
|
+
# Fluxes and errors
|
|
529
|
+
zmin, zmax, zstep, nz = self.lim_vals(lc_sel, "z")
|
|
530
|
+
phamin, phamax, phastep, npha = self.lim_vals(lc_sel, "phase")
|
|
531
|
+
|
|
532
|
+
zv = np.linspace(zmin, zmax, nz)
|
|
533
|
+
phav = np.linspace(phamin, phamax, npha)
|
|
534
|
+
|
|
535
|
+
print("Loading ", lc_name, band, len(lc_sel), npha, nz)
|
|
536
|
+
index = np.lexsort((lc_sel["z"], lc_sel["phase"]))
|
|
537
|
+
flux = np.reshape(lc_sel[index]["flux"], (npha, nz))
|
|
538
|
+
fluxerr = np.reshape(lc_sel[index]["fluxerr"], (npha, nz))
|
|
539
|
+
|
|
540
|
+
self.flux[band] = RegularGridInterpolator(
|
|
541
|
+
(phav, zv), flux, method=method, bounds_error=False, fill_value=-1.0
|
|
542
|
+
)
|
|
543
|
+
self.fluxerr[band] = RegularGridInterpolator(
|
|
544
|
+
(phav, zv), fluxerr, method=method, bounds_error=False, fill_value=-1.0
|
|
545
|
+
)
|
|
546
|
+
|
|
547
|
+
# Flux derivatives
|
|
548
|
+
self.param[band] = {}
|
|
549
|
+
for par in param__fisher:
|
|
550
|
+
valpar = np.reshape(lc_sel[index]["d{}".format(par)], (npha, nz))
|
|
551
|
+
self.param[band][par] = RegularGridInterpolator(
|
|
552
|
+
(phav, zv),
|
|
553
|
+
valpar,
|
|
554
|
+
method=method,
|
|
555
|
+
bounds_error=False,
|
|
556
|
+
fill_value=0.0,
|
|
557
|
+
)
|
|
558
|
+
|
|
559
|
+
# gamma estimator
|
|
560
|
+
|
|
561
|
+
rec = Table.read(gamma_name, path="gamma_{}".format(band))
|
|
562
|
+
self.zp = rec.meta["zp"]
|
|
563
|
+
self.mean_wavelength = rec.meta["mean_wavelength"]
|
|
564
|
+
|
|
565
|
+
rec["mag"] = rec["mag"].data.round(decimals=4)
|
|
566
|
+
rec["single_exptime"] = rec["single_exptime"].data.round(decimals=4)
|
|
567
|
+
|
|
568
|
+
magmin, magmax, magstep, nmag = self.lim_vals(rec, "mag")
|
|
569
|
+
expmin, expmax, expstep, nexpo = self.lim_vals(rec, "single_exptime")
|
|
570
|
+
nexpmin, nexpmax, nexpstep, nnexp = self.lim_vals(rec, "nexp")
|
|
571
|
+
mag = np.linspace(magmin, magmax, nmag)
|
|
572
|
+
exp = np.linspace(expmin, expmax, nexpo)
|
|
573
|
+
nexp = np.linspace(nexpmin, nexpmax, nnexp)
|
|
574
|
+
|
|
575
|
+
index = np.lexsort((rec["nexp"], np.round(rec["single_exptime"], 4), rec["mag"]))
|
|
576
|
+
gammab = np.reshape(rec[index]["gamma"], (nmag, nexpo, nnexp))
|
|
577
|
+
fluxb = np.reshape(rec[index]["flux_e_sec"], (nmag, nexpo, nnexp))
|
|
578
|
+
self.gamma[band] = RegularGridInterpolator(
|
|
579
|
+
(mag, exp, nexp),
|
|
580
|
+
gammab,
|
|
581
|
+
method="linear",
|
|
582
|
+
bounds_error=False,
|
|
583
|
+
fill_value=0.0,
|
|
584
|
+
)
|
|
585
|
+
|
|
586
|
+
self.mag_to_flux[band] = RegularGridInterpolator(
|
|
587
|
+
(mag, exp, nexp),
|
|
588
|
+
fluxb,
|
|
589
|
+
method="linear",
|
|
590
|
+
bounds_error=False,
|
|
591
|
+
fill_value=0.0,
|
|
592
|
+
)
|
|
593
|
+
|
|
594
|
+
def lim_vals(self, lc, field):
|
|
595
|
+
"""Get unique values of a field in a table
|
|
596
|
+
|
|
597
|
+
Parameters
|
|
598
|
+
----------
|
|
599
|
+
lc : `astropy.Table`
|
|
600
|
+
astropy Table (here probably a LC)
|
|
601
|
+
field : `str`
|
|
602
|
+
name of the field of interest
|
|
603
|
+
|
|
604
|
+
Returns
|
|
605
|
+
-------
|
|
606
|
+
vmin : `float`
|
|
607
|
+
min value of the field
|
|
608
|
+
vmax : `float`
|
|
609
|
+
max value of the field
|
|
610
|
+
vstep : `float`
|
|
611
|
+
step value for this field (median)
|
|
612
|
+
nvals : `int`
|
|
613
|
+
number of unique values
|
|
614
|
+
"""
|
|
615
|
+
|
|
616
|
+
lc.sort(field)
|
|
617
|
+
vals = np.unique(lc[field].data.round(decimals=4))
|
|
618
|
+
# print(vals)
|
|
619
|
+
vmin = np.min(vals)
|
|
620
|
+
vmax = np.max(vals)
|
|
621
|
+
vstep = np.median(vals[1:] - vals[:-1])
|
|
622
|
+
|
|
623
|
+
return vmin, vmax, vstep, len(vals)
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
class SnRate:
|
|
627
|
+
r"""Estimate production rates of typeIa SN
|
|
628
|
+
Available rates: Ripoche, Perrett, Dilday
|
|
629
|
+
|
|
630
|
+
Parameters
|
|
631
|
+
----------
|
|
632
|
+
rate : `str`, optional
|
|
633
|
+
type of rate chosen (Ripoche, Perrett, Dilday)
|
|
634
|
+
H0 : `float`, optional
|
|
635
|
+
Hubble constant value :math:`H_{0}`
|
|
636
|
+
Om0 : `float`, optional
|
|
637
|
+
matter density value :math:`\Omega_{0}`
|
|
638
|
+
min_rf_phase : `float`, optional
|
|
639
|
+
min rest-frame phase
|
|
640
|
+
max_rf_phase : `float`, optional
|
|
641
|
+
max rest-frame phase
|
|
642
|
+
"""
|
|
643
|
+
|
|
644
|
+
def __init__(self, rate="Perrett", h0=70, om0=0.25, min_rf_phase=-15.0, max_rf_phase=30.0):
|
|
645
|
+
self.astropy_cosmo = FlatLambdaCDM(H0=h0, Om0=om0)
|
|
646
|
+
self.rate = rate
|
|
647
|
+
self.min_rf_phase = min_rf_phase
|
|
648
|
+
self.max_rf_phase = max_rf_phase
|
|
649
|
+
|
|
650
|
+
def __call__(
|
|
651
|
+
self,
|
|
652
|
+
zmin=0.1,
|
|
653
|
+
zmax=0.2,
|
|
654
|
+
dz=0.01,
|
|
655
|
+
survey_area=9.6,
|
|
656
|
+
bins=None,
|
|
657
|
+
account_for_edges=False,
|
|
658
|
+
duration=140.0,
|
|
659
|
+
duration_z=None,
|
|
660
|
+
):
|
|
661
|
+
"""
|
|
662
|
+
Parameters
|
|
663
|
+
----------------
|
|
664
|
+
zmin : `float`, optional
|
|
665
|
+
minimal redshift (default : 0.1)
|
|
666
|
+
zmax : `float`, optional
|
|
667
|
+
max redshift (default : 0.2)
|
|
668
|
+
dz : `float`, optional
|
|
669
|
+
redshift bin (default : 0.001)
|
|
670
|
+
survey_area : `float`, optional
|
|
671
|
+
area of the survey (:math:`deg^{2}`)
|
|
672
|
+
bins : `list` [`float`], optional
|
|
673
|
+
redshift bins
|
|
674
|
+
account_for_edges : `bool`
|
|
675
|
+
to account for season edges.
|
|
676
|
+
If true, duration of the survey will be reduced by
|
|
677
|
+
(1+z)*(maf_rf_phase-min_rf_phase)/365.25
|
|
678
|
+
duration : `float`, optional
|
|
679
|
+
survey duration (in days)
|
|
680
|
+
duration_z : `list` [`float`], optional
|
|
681
|
+
survey duration (as a function of z)
|
|
682
|
+
|
|
683
|
+
Returns
|
|
684
|
+
-----------
|
|
685
|
+
zz : `list` [`float`]
|
|
686
|
+
redshift values
|
|
687
|
+
rate : `list` [`float`]
|
|
688
|
+
production rate
|
|
689
|
+
err_rate : `list` [`float`]
|
|
690
|
+
production rate error
|
|
691
|
+
nsn : `list` [`float`]
|
|
692
|
+
number of SN
|
|
693
|
+
err_nsn : `list` [`float`]
|
|
694
|
+
error on the number of SN
|
|
695
|
+
"""
|
|
696
|
+
|
|
697
|
+
if bins is None:
|
|
698
|
+
thebins = np.arange(zmin, zmax + dz, dz)
|
|
699
|
+
zz = 0.5 * (thebins[1:] + thebins[:-1])
|
|
700
|
+
else:
|
|
701
|
+
zz = bins
|
|
702
|
+
thebins = bins
|
|
703
|
+
|
|
704
|
+
rate, err_rate = self.sn_rate(zz)
|
|
705
|
+
|
|
706
|
+
area = survey_area / steradian2_sqdeg
|
|
707
|
+
# or area= self.survey_area/41253.
|
|
708
|
+
|
|
709
|
+
dvol = norm * self.astropy_cosmo.comoving_volume(thebins).value
|
|
710
|
+
|
|
711
|
+
dvol = dvol[1:] - dvol[:-1]
|
|
712
|
+
|
|
713
|
+
if account_for_edges:
|
|
714
|
+
margin = (1.0 + zz) * (self.max_rf_phase - self.min_rf_phase) / 365.25
|
|
715
|
+
effective_duration = duration / 365.25 - margin
|
|
716
|
+
effective_duration[effective_duration <= 0.0] = 0.0
|
|
717
|
+
else:
|
|
718
|
+
# duration in days!
|
|
719
|
+
effective_duration = duration / 365.25
|
|
720
|
+
if duration_z is not None:
|
|
721
|
+
effective_duration = duration_z(zz) / 365.25
|
|
722
|
+
|
|
723
|
+
normz = 1.0 + zz
|
|
724
|
+
nsn = rate * area * dvol * effective_duration / normz
|
|
725
|
+
err_nsn = err_rate * area * dvol * effective_duration / normz
|
|
726
|
+
|
|
727
|
+
return zz, rate, err_rate, nsn, err_nsn
|
|
728
|
+
|
|
729
|
+
def ripoche_rate(self, z):
|
|
730
|
+
"""The SNLS SNIa rate according to the (unpublished)
|
|
731
|
+
Ripoche et al study.
|
|
732
|
+
|
|
733
|
+
Parameters
|
|
734
|
+
--------------
|
|
735
|
+
z : `float`
|
|
736
|
+
redshift
|
|
737
|
+
|
|
738
|
+
Returns
|
|
739
|
+
----------
|
|
740
|
+
rate : `float`
|
|
741
|
+
error_rate : `float`
|
|
742
|
+
"""
|
|
743
|
+
rate = 1.53e-4 * 0.343
|
|
744
|
+
expn = 2.14
|
|
745
|
+
my_z = np.copy(z)
|
|
746
|
+
my_z[my_z > 1.0] = 1.0
|
|
747
|
+
rate_sn = rate * np.power((1 + my_z) / 1.5, expn)
|
|
748
|
+
return rate_sn, 0.2 * rate_sn
|
|
749
|
+
|
|
750
|
+
def perrett_rate(self, z):
|
|
751
|
+
"""The SNLS SNIa rate according to (Perrett et al, 201?)
|
|
752
|
+
|
|
753
|
+
Parameters
|
|
754
|
+
--------------
|
|
755
|
+
z : `float`
|
|
756
|
+
redshift
|
|
757
|
+
|
|
758
|
+
Returns
|
|
759
|
+
----------
|
|
760
|
+
rate : `float`
|
|
761
|
+
error_rate : `float`
|
|
762
|
+
"""
|
|
763
|
+
rate = 0.17e-4
|
|
764
|
+
expn = 2.11
|
|
765
|
+
err_rate = 0.03e-4
|
|
766
|
+
err_expn = 0.28
|
|
767
|
+
my_z = np.copy(z)
|
|
768
|
+
rate_sn = rate * np.power(1 + my_z, expn)
|
|
769
|
+
err_rate_sn = np.power(1 + my_z, 2.0 * expn) * np.power(err_rate, 2.0)
|
|
770
|
+
err_rate_sn += np.power(rate_sn * np.log(1 + my_z) * err_expn, 2.0)
|
|
771
|
+
|
|
772
|
+
return rate_sn, np.power(err_rate_sn, 0.5)
|
|
773
|
+
|
|
774
|
+
def dilday_rate(self, z):
|
|
775
|
+
"""The Dilday rate according to
|
|
776
|
+
|
|
777
|
+
Parameters
|
|
778
|
+
--------------
|
|
779
|
+
z : `float`
|
|
780
|
+
redshift
|
|
781
|
+
|
|
782
|
+
Returns
|
|
783
|
+
----------
|
|
784
|
+
rate : `float`
|
|
785
|
+
error_rate : `float`
|
|
786
|
+
"""
|
|
787
|
+
|
|
788
|
+
rate = 2.6e-5
|
|
789
|
+
expn = 1.5
|
|
790
|
+
# err_rate = 0.01
|
|
791
|
+
err_expn = 0.6
|
|
792
|
+
my_z = np.copy(z)
|
|
793
|
+
my_z[my_z > 1.0] = 1.0
|
|
794
|
+
rate_sn = rate * np.power(1 + my_z, expn)
|
|
795
|
+
err_rate_sn = rate_sn * np.log(1 + my_z) * err_expn
|
|
796
|
+
return rate_sn, err_rate_sn
|
|
797
|
+
|
|
798
|
+
def sn_rate(self, z):
|
|
799
|
+
"""SN rate estimation
|
|
800
|
+
|
|
801
|
+
Parameters
|
|
802
|
+
--------------
|
|
803
|
+
z : `float`
|
|
804
|
+
redshift
|
|
805
|
+
|
|
806
|
+
Returns
|
|
807
|
+
----------
|
|
808
|
+
rate : `float`
|
|
809
|
+
error_rate : `float`
|
|
810
|
+
"""
|
|
811
|
+
if self.rate == "Ripoche":
|
|
812
|
+
return self.ripoche_rate(z)
|
|
813
|
+
if self.rate == "Perrett":
|
|
814
|
+
return self.perrett_rate(z)
|
|
815
|
+
if self.rate == "Dilday":
|
|
816
|
+
return self.dilday_rate(z)
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
class CovColor:
|
|
820
|
+
"""
|
|
821
|
+
class to estimate CovColor from lc using Fisher matrix element
|
|
822
|
+
|
|
823
|
+
Parameters
|
|
824
|
+
---------------
|
|
825
|
+
lc : `pandas.DataFrame`
|
|
826
|
+
lc to process. Should contain the Fisher matrix components
|
|
827
|
+
ie the sum of the derivative of the fluxes wrt SN parameters
|
|
828
|
+
"""
|
|
829
|
+
|
|
830
|
+
def __init__(self, lc):
|
|
831
|
+
self.cov_colorcolor = self.var_color(lc)
|
|
832
|
+
|
|
833
|
+
def var_color(self, lc):
|
|
834
|
+
"""
|
|
835
|
+
Method to estimate the variance color from matrix element
|
|
836
|
+
|
|
837
|
+
Parameters
|
|
838
|
+
--------------
|
|
839
|
+
lc : `pandas.DataFrame`
|
|
840
|
+
data to process containing the derivative of the
|
|
841
|
+
flux with respect to SN parameters
|
|
842
|
+
|
|
843
|
+
Returns
|
|
844
|
+
----------
|
|
845
|
+
Cov_colorcolor : `float`
|
|
846
|
+
"""
|
|
847
|
+
a1 = lc["F_x0x0"]
|
|
848
|
+
a2 = lc["F_x0x1"]
|
|
849
|
+
a3 = lc["F_x0daymax"]
|
|
850
|
+
a4 = lc["F_x0color"]
|
|
851
|
+
|
|
852
|
+
b1 = a2
|
|
853
|
+
b2 = lc["F_x1x1"]
|
|
854
|
+
b3 = lc["F_x1daymax"]
|
|
855
|
+
b4 = lc["F_x1color"]
|
|
856
|
+
|
|
857
|
+
c1 = a3
|
|
858
|
+
c2 = b3
|
|
859
|
+
c3 = lc["F_daymaxdaymax"]
|
|
860
|
+
c4 = lc["F_daymaxcolor"]
|
|
861
|
+
|
|
862
|
+
d1 = a4
|
|
863
|
+
d2 = b4
|
|
864
|
+
d3 = c4
|
|
865
|
+
d4 = lc["F_colorcolor"]
|
|
866
|
+
|
|
867
|
+
det_m = a1 * self.det(b2, b3, b4, c2, c3, c4, d2, d3, d4)
|
|
868
|
+
det_m -= b1 * self.det(a2, a3, a4, c2, c3, c4, d2, d3, d4)
|
|
869
|
+
det_m += c1 * self.det(a2, a3, a4, b2, b3, b4, d2, d3, d4)
|
|
870
|
+
det_m -= d1 * self.det(a2, a3, a4, b2, b3, b4, c2, c3, c4)
|
|
871
|
+
|
|
872
|
+
res = -a3 * b2 * c1 + a2 * b3 * c1 + a3 * b1 * c2 - a1 * b3 * c2 - a2 * b1 * c3 + a1 * b2 * c3
|
|
873
|
+
|
|
874
|
+
return res / det_m
|
|
875
|
+
|
|
876
|
+
def det(self, a1, a2, a3, b1, b2, b3, c1, c2, c3):
|
|
877
|
+
"""
|
|
878
|
+
Method to estimate the det of a matrix from its values
|
|
879
|
+
|
|
880
|
+
Parameters
|
|
881
|
+
-------------
|
|
882
|
+
Values of the matrix
|
|
883
|
+
(a1 a2 a3)
|
|
884
|
+
(b1 b2 b3)
|
|
885
|
+
(c1 c2 c3)
|
|
886
|
+
|
|
887
|
+
Returns
|
|
888
|
+
-----------
|
|
889
|
+
det value
|
|
890
|
+
"""
|
|
891
|
+
resp = a1 * b2 * c3 + b1 * c2 * a3 + c1 * a2 * b3
|
|
892
|
+
resm = a3 * b2 * c1 + b3 * c2 * a1 + c3 * a2 * b1
|
|
893
|
+
|
|
894
|
+
return resp - resm
|