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,715 @@
|
|
|
1
|
+
__all__ = ("SNSNRMetric",)
|
|
2
|
+
|
|
3
|
+
from collections.abc import Iterable
|
|
4
|
+
|
|
5
|
+
import matplotlib.pylab as plt
|
|
6
|
+
import numpy as np
|
|
7
|
+
import numpy.lib.recfunctions as rf
|
|
8
|
+
from scipy import interpolate
|
|
9
|
+
|
|
10
|
+
import rubin_sim.maf.metrics as metrics
|
|
11
|
+
from rubin_sim.maf.utils.sn_utils import GenerateFakeObservations
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class SNSNRMetric(metrics.BaseMetric):
|
|
15
|
+
"""
|
|
16
|
+
Metric to estimate the detection rate for faint supernovae
|
|
17
|
+
(x1,color) = (-2.0,0.2)
|
|
18
|
+
|
|
19
|
+
Parameters
|
|
20
|
+
----------
|
|
21
|
+
coadd : `bool`, optional
|
|
22
|
+
to make "coaddition" per night (uses snStacker)
|
|
23
|
+
lim_sn : class, optional
|
|
24
|
+
Reference data used to simulate LC points (interpolation)
|
|
25
|
+
names_ref : `str`, optional
|
|
26
|
+
names of the simulator used to produce reference data
|
|
27
|
+
season : `float`, optional
|
|
28
|
+
season num
|
|
29
|
+
z : `float`, optional
|
|
30
|
+
redshift for this study
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def __init__(
|
|
34
|
+
self,
|
|
35
|
+
metric_name="SNSNRMetric",
|
|
36
|
+
mjd_col="observationStartMJD",
|
|
37
|
+
ra_col="fieldRA",
|
|
38
|
+
dec_col="fieldDec",
|
|
39
|
+
filter_col="band",
|
|
40
|
+
m5_col="fiveSigmaDepth",
|
|
41
|
+
exptime_col="visitExposureTime",
|
|
42
|
+
night_col="night",
|
|
43
|
+
obsid_col="observationId",
|
|
44
|
+
nexp_col="numExposures",
|
|
45
|
+
vistime_col="visitTime",
|
|
46
|
+
coadd=True,
|
|
47
|
+
lim_sn=None,
|
|
48
|
+
names_ref=None,
|
|
49
|
+
season=1,
|
|
50
|
+
z=0.01,
|
|
51
|
+
**kwargs,
|
|
52
|
+
):
|
|
53
|
+
self.mjd_col = mjd_col
|
|
54
|
+
self.m5_col = m5_col
|
|
55
|
+
self.filter_col = filter_col
|
|
56
|
+
self.ra_col = ra_col
|
|
57
|
+
self.dec_col = dec_col
|
|
58
|
+
self.exptime_col = exptime_col
|
|
59
|
+
self.season_col = "season"
|
|
60
|
+
self.night_col = night_col
|
|
61
|
+
self.obsid_col = obsid_col
|
|
62
|
+
self.nexp_col = nexp_col
|
|
63
|
+
self.vistime_col = vistime_col
|
|
64
|
+
|
|
65
|
+
cols = [
|
|
66
|
+
self.night_col,
|
|
67
|
+
self.m5_col,
|
|
68
|
+
self.filter_col,
|
|
69
|
+
self.mjd_col,
|
|
70
|
+
self.obsid_col,
|
|
71
|
+
self.nexp_col,
|
|
72
|
+
self.vistime_col,
|
|
73
|
+
self.exptime_col,
|
|
74
|
+
self.season_col,
|
|
75
|
+
]
|
|
76
|
+
if coadd:
|
|
77
|
+
cols += ["coadd"]
|
|
78
|
+
super(SNSNRMetric, self).__init__(col=cols, metric_name=metric_name, **kwargs)
|
|
79
|
+
|
|
80
|
+
self.filter_names = np.array(["u", "g", "r", "i", "z", "y"])
|
|
81
|
+
self.blue_cutoff = 300.0
|
|
82
|
+
self.red_cutoff = 800.0
|
|
83
|
+
self.min_rf_phase = -20.0
|
|
84
|
+
self.max_rf_phase = 40.0
|
|
85
|
+
self.z = z
|
|
86
|
+
self.names_ref = names_ref
|
|
87
|
+
self.season = season
|
|
88
|
+
|
|
89
|
+
# SN DayMax: current date - shift days
|
|
90
|
+
self.shift = 10.0
|
|
91
|
+
|
|
92
|
+
# These are reference LC
|
|
93
|
+
self.lim_sn = lim_sn
|
|
94
|
+
|
|
95
|
+
self.display = False
|
|
96
|
+
|
|
97
|
+
def run(self, data_slice, slice_point=None):
|
|
98
|
+
"""
|
|
99
|
+
run the metric
|
|
100
|
+
|
|
101
|
+
Parameters
|
|
102
|
+
----------
|
|
103
|
+
data_slice : `np.ndarray`, (N,)
|
|
104
|
+
simulation data under study
|
|
105
|
+
|
|
106
|
+
Returns
|
|
107
|
+
-------
|
|
108
|
+
detection rate : `float`
|
|
109
|
+
"""
|
|
110
|
+
good_filters = np.isin(data_slice["filter"], self.filter_names)
|
|
111
|
+
data_slice = data_slice[good_filters]
|
|
112
|
+
if data_slice.size == 0:
|
|
113
|
+
return None
|
|
114
|
+
data_slice.sort(order=self.mjd_col)
|
|
115
|
+
|
|
116
|
+
if self.season != -1:
|
|
117
|
+
seasons = self.season
|
|
118
|
+
else:
|
|
119
|
+
seasons = np.unique(data_slice["season"])
|
|
120
|
+
|
|
121
|
+
if not isinstance(seasons, Iterable):
|
|
122
|
+
seasons = [seasons]
|
|
123
|
+
|
|
124
|
+
self.info_season = None
|
|
125
|
+
for seas in seasons:
|
|
126
|
+
info = self.season_info(data_slice, seas)
|
|
127
|
+
if info is not None and info["season_length"] >= self.shift:
|
|
128
|
+
if self.info_season is None:
|
|
129
|
+
self.info_season = info
|
|
130
|
+
else:
|
|
131
|
+
self.info_season = np.concatenate((self.info_season, info))
|
|
132
|
+
|
|
133
|
+
self.info_season = self.check_seasons(self.info_season)
|
|
134
|
+
if self.info_season is None:
|
|
135
|
+
return 0.0
|
|
136
|
+
|
|
137
|
+
sel = data_slice[np.isin(data_slice["season"], np.array(seasons))]
|
|
138
|
+
|
|
139
|
+
detect_frac = None
|
|
140
|
+
if len(sel) >= 5:
|
|
141
|
+
detect_frac = self.process(sel)
|
|
142
|
+
|
|
143
|
+
if detect_frac is not None:
|
|
144
|
+
return np.median(detect_frac["frac_obs_{}".format(self.names_ref[0])])
|
|
145
|
+
else:
|
|
146
|
+
return 0.0
|
|
147
|
+
|
|
148
|
+
def process(self, sel):
|
|
149
|
+
"""Process one season
|
|
150
|
+
|
|
151
|
+
Parameters
|
|
152
|
+
-----------
|
|
153
|
+
sel : `np.narray`
|
|
154
|
+
array of observations
|
|
155
|
+
season : `int`
|
|
156
|
+
season number
|
|
157
|
+
|
|
158
|
+
Returns
|
|
159
|
+
--------
|
|
160
|
+
record array with the following fields:
|
|
161
|
+
fieldRA (float)
|
|
162
|
+
fieldDec (float)
|
|
163
|
+
season (float)
|
|
164
|
+
band (str)
|
|
165
|
+
frac_obs_name_ref (float)
|
|
166
|
+
"""
|
|
167
|
+
|
|
168
|
+
self.band = np.unique(sel[self.filter_col])[0]
|
|
169
|
+
snr_obs = self.snr_slice(sel) # SNR for observations
|
|
170
|
+
snr_fakes = self.snr_fakes(sel) # SNR for fakes
|
|
171
|
+
detect_frac = self.detection_rate(snr_obs, snr_fakes) # Detection rate
|
|
172
|
+
# snr_obs = np.asarray(snr_obs)
|
|
173
|
+
# snr_fakes = np.asarray(snr_fakes)
|
|
174
|
+
# self.plot(snr_obs, snr_fakes)
|
|
175
|
+
# plt.show()
|
|
176
|
+
detect_frac = np.asarray(detect_frac)
|
|
177
|
+
|
|
178
|
+
return detect_frac
|
|
179
|
+
|
|
180
|
+
def snr_slice(self, data_slice, j=-1, output_q=None):
|
|
181
|
+
"""Estimate SNR for a given data_slice
|
|
182
|
+
|
|
183
|
+
Parameters
|
|
184
|
+
-----------
|
|
185
|
+
data_slice : `np.ndarray`
|
|
186
|
+
j : `int`, optional
|
|
187
|
+
output_q : `int`, optional
|
|
188
|
+
|
|
189
|
+
Returns
|
|
190
|
+
--------
|
|
191
|
+
snr : `np.ndarray` containing
|
|
192
|
+
SNR_name_ref: Signal-To-Noise Ratio estimator
|
|
193
|
+
season : season
|
|
194
|
+
cadence: cadence of the season
|
|
195
|
+
season_length: length of the season
|
|
196
|
+
MJD_min: min MJD of the season
|
|
197
|
+
DayMax: SN max luminosity MJD (aka T0)
|
|
198
|
+
MJD:
|
|
199
|
+
m5_eff: mean m5 of obs passing the min_phase, max_phase cut
|
|
200
|
+
field_ra: mean field RA
|
|
201
|
+
field_dec: mean field Dec
|
|
202
|
+
band: band
|
|
203
|
+
m5: mean m5 (over the season)
|
|
204
|
+
nvisits: median number of visits (per observation) (over the season)
|
|
205
|
+
ExposureTime: median exposure time (per observation) (over the season)
|
|
206
|
+
"""
|
|
207
|
+
|
|
208
|
+
# Get few infos: RA, Dec, nvisits, m5, exptime
|
|
209
|
+
field_ra = np.mean(data_slice[self.ra_col])
|
|
210
|
+
field_dec = np.mean(data_slice[self.dec_col])
|
|
211
|
+
# one visit = 2 exposures
|
|
212
|
+
nvisits = np.median(data_slice[self.nexp_col] / 2.0)
|
|
213
|
+
m5 = np.mean(data_slice[self.m5_col])
|
|
214
|
+
exptime = np.median(data_slice[self.exptime_col])
|
|
215
|
+
data_slice.sort(order=self.mjd_col)
|
|
216
|
+
mjds = data_slice[self.mjd_col]
|
|
217
|
+
band = np.unique(data_slice[self.filter_col])[0]
|
|
218
|
+
|
|
219
|
+
# Define MJDs to consider for metric estimation
|
|
220
|
+
# basically: step of one day between MJDmin and MJDmax
|
|
221
|
+
dates = None
|
|
222
|
+
|
|
223
|
+
for val in self.info_season:
|
|
224
|
+
if dates is None:
|
|
225
|
+
dates = np.arange(val["MJD_min"] + self.shift, val["MJD_max"] + 1.0, 1.0)
|
|
226
|
+
else:
|
|
227
|
+
dates = np.concatenate(
|
|
228
|
+
(
|
|
229
|
+
dates,
|
|
230
|
+
np.arange(val["MJD_min"] + self.shift, val["MJD_max"] + 1.0, 1.0),
|
|
231
|
+
)
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
# SN DayMax: dates-shift where shift is chosen in the input yaml file
|
|
235
|
+
t0_lc = dates - self.shift
|
|
236
|
+
|
|
237
|
+
# for these DayMax, estimate the phases of LC points
|
|
238
|
+
# corresponding to the current data_slice MJDs
|
|
239
|
+
|
|
240
|
+
time_for_lc = -t0_lc[:, None] + mjds
|
|
241
|
+
|
|
242
|
+
phase = time_for_lc / (1.0 + self.z) # phases of LC points
|
|
243
|
+
# flag: select LC points only in between min_rf_phase and max_phase
|
|
244
|
+
phase_max = self.shift / (1.0 + self.z)
|
|
245
|
+
flag = (phase >= self.min_rf_phase) & (phase <= phase_max)
|
|
246
|
+
|
|
247
|
+
# tile m5, MJDs, and seasons to estimate all fluxes and SNR at once
|
|
248
|
+
m5_vals = np.tile(data_slice[self.m5_col], (len(time_for_lc), 1))
|
|
249
|
+
|
|
250
|
+
# estimate fluxes and snr in SNR function
|
|
251
|
+
fluxes_tot, snr = self.snr(time_for_lc, m5_vals, flag, t0_lc)
|
|
252
|
+
|
|
253
|
+
# now save the results in a record array
|
|
254
|
+
_, idx = np.unique(snr["season"], return_inverse=True)
|
|
255
|
+
infos = self.info_season[idx]
|
|
256
|
+
|
|
257
|
+
vars_info = ["cadence", "season_length", "MJD_min"]
|
|
258
|
+
snr = rf.append_fields(snr, vars_info, [infos[name] for name in vars_info])
|
|
259
|
+
snr = rf.append_fields(snr, "DayMax", t0_lc)
|
|
260
|
+
snr = rf.append_fields(snr, "MJD", dates)
|
|
261
|
+
snr = rf.append_fields(snr, "m5_eff", np.mean(np.ma.array(m5_vals, mask=~flag), axis=1))
|
|
262
|
+
global_info = [(field_ra, field_dec, band, m5, nvisits, exptime)] * len(snr)
|
|
263
|
+
names = ["field_ra", "field_dec", "band", "m5", "nvisits", "ExposureTime"]
|
|
264
|
+
global_info = np.rec.fromrecords(global_info, names=names)
|
|
265
|
+
snr = rf.append_fields(snr, names, [global_info[name] for name in names])
|
|
266
|
+
|
|
267
|
+
if output_q is not None:
|
|
268
|
+
output_q.put({j: snr})
|
|
269
|
+
else:
|
|
270
|
+
return snr
|
|
271
|
+
|
|
272
|
+
def season_info(self, data_slice, season):
|
|
273
|
+
"""Get info on seasons for each data_slice
|
|
274
|
+
|
|
275
|
+
Parameters
|
|
276
|
+
----------
|
|
277
|
+
data_slice : `np.ndarray`, (N,)
|
|
278
|
+
array of observations
|
|
279
|
+
|
|
280
|
+
Returns
|
|
281
|
+
-------
|
|
282
|
+
info_season : `np.ndarray`
|
|
283
|
+
season, cadence, season_length, MJDmin, MJDmax
|
|
284
|
+
"""
|
|
285
|
+
|
|
286
|
+
rv = []
|
|
287
|
+
|
|
288
|
+
idx = data_slice[self.season_col] == season
|
|
289
|
+
slice_sel = data_slice[idx]
|
|
290
|
+
if len(slice_sel) < 5:
|
|
291
|
+
return None
|
|
292
|
+
slice_sel.sort(order=self.mjd_col)
|
|
293
|
+
mjds_season = slice_sel[self.mjd_col]
|
|
294
|
+
cadence = np.mean(mjds_season[1:] - mjds_season[:-1])
|
|
295
|
+
mjd_min = np.min(mjds_season)
|
|
296
|
+
mjd_max = np.max(mjds_season)
|
|
297
|
+
season_length = mjd_max - mjd_min
|
|
298
|
+
nvisits = np.median(slice_sel[self.nexp_col])
|
|
299
|
+
m5 = np.median(slice_sel[self.m5_col])
|
|
300
|
+
rv.append((float(season), cadence, season_length, mjd_min, mjd_max, nvisits, m5))
|
|
301
|
+
|
|
302
|
+
info_season = np.rec.fromrecords(
|
|
303
|
+
rv,
|
|
304
|
+
names=[
|
|
305
|
+
"season",
|
|
306
|
+
"cadence",
|
|
307
|
+
"season_length",
|
|
308
|
+
"MJD_min",
|
|
309
|
+
"MJD_max",
|
|
310
|
+
"nvisits",
|
|
311
|
+
"m5",
|
|
312
|
+
],
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
return info_season
|
|
316
|
+
|
|
317
|
+
def snr(self, time_lc, m5_vals, flag, t0_lc):
|
|
318
|
+
"""Estimate SNR vs time
|
|
319
|
+
|
|
320
|
+
Parameters
|
|
321
|
+
-----------
|
|
322
|
+
time_lc : `np.ndarray`, (N,)
|
|
323
|
+
m5_vals : `list` [`float`]
|
|
324
|
+
five-sigme depth values
|
|
325
|
+
flag : `np.ndarray`, (N,)
|
|
326
|
+
flag to be applied (example: selection from phase cut)
|
|
327
|
+
season_vals : `np.ndarray`, (N,)
|
|
328
|
+
season values
|
|
329
|
+
t0_lc : `np.ndarray`, (N,)
|
|
330
|
+
array of T0 for supernovae
|
|
331
|
+
|
|
332
|
+
Returns
|
|
333
|
+
-------
|
|
334
|
+
fluxes_tot : `list` [`float`]
|
|
335
|
+
list of (interpolated) fluxes
|
|
336
|
+
snr_tab : `np.ndarray`, (N,)
|
|
337
|
+
snr_name_ref (float) : Signal-to-Noise values
|
|
338
|
+
season (float) : season num.
|
|
339
|
+
"""
|
|
340
|
+
fluxes_tot = {}
|
|
341
|
+
snr_tab = None
|
|
342
|
+
|
|
343
|
+
for ib, name in enumerate(self.names_ref):
|
|
344
|
+
fluxes = self.lim_sn.fluxes[ib](time_lc)
|
|
345
|
+
if name not in fluxes_tot.keys():
|
|
346
|
+
fluxes_tot[name] = fluxes
|
|
347
|
+
else:
|
|
348
|
+
fluxes_tot[name] = np.concatenate((fluxes_tot[name], fluxes))
|
|
349
|
+
|
|
350
|
+
flux_5sigma = self.lim_sn.mag_to_flux[ib](m5_vals)
|
|
351
|
+
snr = fluxes**2 / flux_5sigma**2
|
|
352
|
+
snr_season = 5.0 * np.sqrt(np.sum(snr * flag, axis=1))
|
|
353
|
+
|
|
354
|
+
if snr_tab is None:
|
|
355
|
+
snr_tab = np.asarray(np.copy(snr_season), dtype=[("SNR_" + name, "f8")])
|
|
356
|
+
else:
|
|
357
|
+
snr_tab = rf.append_fields(snr_tab, "SNR_" + name, np.copy(snr_season))
|
|
358
|
+
"""
|
|
359
|
+
snr_tab = rf.append_fields(
|
|
360
|
+
snr_tab, 'season', np.mean(seasons, axis=1))
|
|
361
|
+
"""
|
|
362
|
+
snr_tab = rf.append_fields(snr_tab, "season", self.get_season(t0_lc))
|
|
363
|
+
|
|
364
|
+
# check if any masked value remaining
|
|
365
|
+
# this would correspond to case where no obs point has been selected
|
|
366
|
+
# ie no points with phase in [phase_min,phase_max]
|
|
367
|
+
# this happens when internight gaps are large
|
|
368
|
+
# (typically larger than shift)
|
|
369
|
+
idmask = np.where(snr_tab.mask)
|
|
370
|
+
if len(idmask) > 0:
|
|
371
|
+
tofill = np.copy(snr_tab["season"])
|
|
372
|
+
season_recover = self.get_season(t0_lc[np.where(snr_tab.mask)])
|
|
373
|
+
tofill[idmask] = season_recover
|
|
374
|
+
snr_tab = np.ma.filled(snr_tab, fill_value=tofill)
|
|
375
|
+
|
|
376
|
+
return fluxes_tot, snr_tab
|
|
377
|
+
|
|
378
|
+
def get_season(self, t0):
|
|
379
|
+
"""
|
|
380
|
+
Estimate the seasons corresponding to t0 values
|
|
381
|
+
|
|
382
|
+
Parameters
|
|
383
|
+
----------
|
|
384
|
+
t0 : `list` [`float`]
|
|
385
|
+
set of t0 values
|
|
386
|
+
|
|
387
|
+
Returns
|
|
388
|
+
--------
|
|
389
|
+
mean_seasons : `list` [`float`]
|
|
390
|
+
list (float) of corresponding seasons
|
|
391
|
+
"""
|
|
392
|
+
|
|
393
|
+
diff_min = t0[:, None] - self.info_season["MJD_min"]
|
|
394
|
+
diff_max = -t0[:, None] + self.info_season["MJD_max"]
|
|
395
|
+
seasons = np.tile(self.info_season["season"], (len(diff_min), 1))
|
|
396
|
+
flag = (diff_min >= 0) & (diff_max >= 0)
|
|
397
|
+
seasons = np.ma.array(seasons, mask=~flag)
|
|
398
|
+
|
|
399
|
+
return np.mean(seasons, axis=1)
|
|
400
|
+
|
|
401
|
+
def snr_fakes(self, data_slice):
|
|
402
|
+
"""Estimate SNR for fake observations
|
|
403
|
+
in the same way as for observations (using SNR_Season)
|
|
404
|
+
|
|
405
|
+
Parameters
|
|
406
|
+
-----------
|
|
407
|
+
data_slice : `np.ndarray`, (N,)
|
|
408
|
+
array of observations
|
|
409
|
+
|
|
410
|
+
Returns
|
|
411
|
+
--------
|
|
412
|
+
snr_tab : `np.ndarray`
|
|
413
|
+
snr_name_ref (float) : Signal-to-Noise values
|
|
414
|
+
season (float) : season num.
|
|
415
|
+
|
|
416
|
+
"""
|
|
417
|
+
|
|
418
|
+
# generate fake observations
|
|
419
|
+
fake_obs = None
|
|
420
|
+
|
|
421
|
+
# idx = (data_slice[self.season_col] == season)
|
|
422
|
+
band = np.unique(data_slice[self.filter_col])[0]
|
|
423
|
+
fake_obs = self.gen_fakes(data_slice, band)
|
|
424
|
+
|
|
425
|
+
# estimate SNR vs MJD
|
|
426
|
+
|
|
427
|
+
snr_fakes = self.snr_slice(fake_obs[fake_obs["filter"] == band])
|
|
428
|
+
|
|
429
|
+
return snr_fakes
|
|
430
|
+
|
|
431
|
+
def gen_fakes(self, slice_sel, band):
|
|
432
|
+
"""Generate fake observations
|
|
433
|
+
according to observing values extracted from simulations
|
|
434
|
+
|
|
435
|
+
Parameters
|
|
436
|
+
----------
|
|
437
|
+
slice_sel : `np.ndarray`, (N,)
|
|
438
|
+
array of observations
|
|
439
|
+
band : `str`
|
|
440
|
+
band to consider
|
|
441
|
+
|
|
442
|
+
Returns
|
|
443
|
+
--------
|
|
444
|
+
fake_obs_season : `np.ndarray`
|
|
445
|
+
array of observations with the following fields
|
|
446
|
+
observationStartMJD (float)
|
|
447
|
+
field_ra (float)
|
|
448
|
+
field_dec (float)
|
|
449
|
+
filter (U1)
|
|
450
|
+
fiveSigmaDepth (float)
|
|
451
|
+
numExposures (float)
|
|
452
|
+
visitExposureTime (float)
|
|
453
|
+
season (int)
|
|
454
|
+
"""
|
|
455
|
+
field_ra = np.mean(slice_sel[self.ra_col])
|
|
456
|
+
field_dec = np.mean(slice_sel[self.dec_col])
|
|
457
|
+
tvisit = 30.0
|
|
458
|
+
|
|
459
|
+
fake_obs = None
|
|
460
|
+
for val in self.info_season:
|
|
461
|
+
cadence = val["cadence"]
|
|
462
|
+
mjd_min = val["MJD_min"]
|
|
463
|
+
season_length = val["season_length"]
|
|
464
|
+
nvisits = val["nvisits"]
|
|
465
|
+
m5 = val["m5"]
|
|
466
|
+
|
|
467
|
+
# build the configuration file
|
|
468
|
+
|
|
469
|
+
config_fake = {}
|
|
470
|
+
config_fake["Ra"] = field_ra
|
|
471
|
+
config_fake["Dec"] = field_dec
|
|
472
|
+
config_fake["bands"] = [band]
|
|
473
|
+
config_fake["Cadence"] = [cadence]
|
|
474
|
+
config_fake["MJD_min"] = [mjd_min]
|
|
475
|
+
config_fake["season_length"] = season_length
|
|
476
|
+
config_fake["nvisits"] = [nvisits]
|
|
477
|
+
m5_nocoadd = m5 - 1.25 * np.log10(float(nvisits) * tvisit / 30.0)
|
|
478
|
+
config_fake["m5"] = [m5_nocoadd]
|
|
479
|
+
config_fake["seasons"] = [val["season"]]
|
|
480
|
+
config_fake["Exposure_Time"] = [30.0]
|
|
481
|
+
config_fake["shift_days"] = 0.0
|
|
482
|
+
fake_obs_season = GenerateFakeObservations(config_fake).Observations
|
|
483
|
+
if fake_obs is None:
|
|
484
|
+
fake_obs = fake_obs_season
|
|
485
|
+
else:
|
|
486
|
+
fake_obs = np.concatenate((fake_obs, fake_obs_season))
|
|
487
|
+
return fake_obs
|
|
488
|
+
|
|
489
|
+
def plot(self, snr_obs, snr_fakes):
|
|
490
|
+
"""Plot SNR vs time
|
|
491
|
+
|
|
492
|
+
Parameters
|
|
493
|
+
----------
|
|
494
|
+
snr_obs : `np.ndarray`, (N,)
|
|
495
|
+
array estimated using snr_slice(observations)
|
|
496
|
+
snr_obs : `np.ndarray`, (N,)
|
|
497
|
+
array estimated using snr_slice(fakes)
|
|
498
|
+
"""
|
|
499
|
+
|
|
500
|
+
fig, ax = plt.subplots(figsize=(10, 7))
|
|
501
|
+
|
|
502
|
+
title = "season {} - {} band - z={}".format(self.season, self.band, self.z)
|
|
503
|
+
fig.suptitle(title)
|
|
504
|
+
ax.plot(
|
|
505
|
+
snr_obs["MJD"],
|
|
506
|
+
snr_obs["SNR_{}".format(self.names_ref[0])],
|
|
507
|
+
label="Simulation",
|
|
508
|
+
)
|
|
509
|
+
ax.plot(
|
|
510
|
+
snr_fakes["MJD"],
|
|
511
|
+
snr_fakes["SNR_{}".format(self.names_ref[0])],
|
|
512
|
+
ls="--",
|
|
513
|
+
label="Fakes",
|
|
514
|
+
)
|
|
515
|
+
|
|
516
|
+
def plot_history(self, fluxes, mjd, flag, snr, t0_lc, dates):
|
|
517
|
+
"""Plot history of lightcurve
|
|
518
|
+
For each MJD, fluxes and snr are plotted
|
|
519
|
+
Each plot may be saved as a png to make a video afterwards
|
|
520
|
+
|
|
521
|
+
Parameters
|
|
522
|
+
----------
|
|
523
|
+
fluxes : `list` [`float`]
|
|
524
|
+
LC fluxes
|
|
525
|
+
mjd : list(float)
|
|
526
|
+
mjds of the fluxes
|
|
527
|
+
flag : array
|
|
528
|
+
flag for selection of fluxes
|
|
529
|
+
snr : list
|
|
530
|
+
signal-to-noise ratio
|
|
531
|
+
t0_lc : list(float)
|
|
532
|
+
list of T0 supernovae
|
|
533
|
+
dates : list(float)
|
|
534
|
+
date of the display (mjd)
|
|
535
|
+
"""
|
|
536
|
+
|
|
537
|
+
import matplotlib.pyplot as plt
|
|
538
|
+
|
|
539
|
+
plt.ion()
|
|
540
|
+
fig, ax = plt.subplots(ncols=1, nrows=2)
|
|
541
|
+
fig.canvas.draw()
|
|
542
|
+
|
|
543
|
+
colors = ["b", "r"]
|
|
544
|
+
myls = ["-", "--"]
|
|
545
|
+
tot_label = []
|
|
546
|
+
fontsize = 12
|
|
547
|
+
mjd_ma = np.ma.array(mjd, mask=~flag)
|
|
548
|
+
fluxes_ma = {}
|
|
549
|
+
for key, val in fluxes.items():
|
|
550
|
+
fluxes_ma[key] = np.ma.array(val, mask=~flag)
|
|
551
|
+
key = list(fluxes.keys())[0]
|
|
552
|
+
jmax = len(fluxes_ma[key])
|
|
553
|
+
tot_label = []
|
|
554
|
+
tot_label_snr = []
|
|
555
|
+
min_flux = []
|
|
556
|
+
max_flux = []
|
|
557
|
+
|
|
558
|
+
for j in range(jmax):
|
|
559
|
+
for ib, name in enumerate(fluxes_ma.keys()):
|
|
560
|
+
tot_label.append(
|
|
561
|
+
ax[0].errorbar(
|
|
562
|
+
mjd_ma[j],
|
|
563
|
+
fluxes_ma[name][j],
|
|
564
|
+
marker="s",
|
|
565
|
+
color=colors[ib],
|
|
566
|
+
ls=myls[ib],
|
|
567
|
+
label=name,
|
|
568
|
+
)
|
|
569
|
+
)
|
|
570
|
+
|
|
571
|
+
tot_label_snr.append(
|
|
572
|
+
ax[1].errorbar(
|
|
573
|
+
snr["MJD"][:j],
|
|
574
|
+
snr["SNR_" + name][:j],
|
|
575
|
+
color=colors[ib],
|
|
576
|
+
label=name,
|
|
577
|
+
)
|
|
578
|
+
)
|
|
579
|
+
fluxx = fluxes_ma[name][j]
|
|
580
|
+
fluxx = fluxx[~fluxx.mask]
|
|
581
|
+
if len(fluxx) >= 2:
|
|
582
|
+
min_flux.append(np.min(fluxx))
|
|
583
|
+
max_flux.append(np.max(fluxx))
|
|
584
|
+
else:
|
|
585
|
+
min_flux.append(0.0)
|
|
586
|
+
max_flux.append(200.0)
|
|
587
|
+
|
|
588
|
+
min_fluxes = np.min(min_flux)
|
|
589
|
+
max_fluxes = np.max(max_flux)
|
|
590
|
+
|
|
591
|
+
tot_label.append(
|
|
592
|
+
ax[0].errorbar(
|
|
593
|
+
[t0_lc[j], t0_lc[j]],
|
|
594
|
+
[min_fluxes, max_fluxes],
|
|
595
|
+
color="k",
|
|
596
|
+
label="DayMax",
|
|
597
|
+
)
|
|
598
|
+
)
|
|
599
|
+
tot_label.append(
|
|
600
|
+
ax[0].errorbar(
|
|
601
|
+
[dates[j], dates[j]],
|
|
602
|
+
[min_fluxes, max_fluxes],
|
|
603
|
+
color="k",
|
|
604
|
+
ls="--",
|
|
605
|
+
label="Current MJD",
|
|
606
|
+
)
|
|
607
|
+
)
|
|
608
|
+
fig.canvas.flush_events()
|
|
609
|
+
# plt.savefig('{}/{}_{}.png'.format(dir_save, 'snr', 1000 + j))
|
|
610
|
+
if j != jmax - 1:
|
|
611
|
+
ax[0].clear()
|
|
612
|
+
tot_label = []
|
|
613
|
+
tot_label_snr = []
|
|
614
|
+
|
|
615
|
+
labs = [ll.get_label() for ll in tot_label]
|
|
616
|
+
ax[0].legend(tot_label, labs, ncol=1, loc="best", prop={"size": fontsize}, frameon=False)
|
|
617
|
+
ax[0].set_ylabel("Flux [e.sec$^{-1}$]", fontsize=fontsize)
|
|
618
|
+
|
|
619
|
+
ax[1].set_xlabel("MJD", fontsize=fontsize)
|
|
620
|
+
ax[1].set_ylabel("SNR", fontsize=fontsize)
|
|
621
|
+
ax[1].legend()
|
|
622
|
+
labs = [ll.get_label() for ll in tot_label_snr]
|
|
623
|
+
ax[1].legend(
|
|
624
|
+
tot_label_snr,
|
|
625
|
+
labs,
|
|
626
|
+
ncol=1,
|
|
627
|
+
loc="best",
|
|
628
|
+
prop={"size": fontsize},
|
|
629
|
+
frameon=False,
|
|
630
|
+
)
|
|
631
|
+
for i in range(2):
|
|
632
|
+
ax[i].tick_params(axis="x", labelsize=fontsize)
|
|
633
|
+
ax[i].tick_params(axis="y", labelsize=fontsize)
|
|
634
|
+
|
|
635
|
+
def detection_rate(self, snr_obs, snr_fakes):
|
|
636
|
+
"""
|
|
637
|
+
Estimate the time fraction(per season) for which
|
|
638
|
+
snr_obs > snr_fakes = detection rate
|
|
639
|
+
For regular cadences one should get a result close to 1
|
|
640
|
+
|
|
641
|
+
Parameters
|
|
642
|
+
----------
|
|
643
|
+
snr_obs : array
|
|
644
|
+
array estimated using snr_slice(observations)
|
|
645
|
+
|
|
646
|
+
snr_fakes: array
|
|
647
|
+
array estimated using snr_slice(fakes)
|
|
648
|
+
|
|
649
|
+
Returns
|
|
650
|
+
-------
|
|
651
|
+
record array with the following fields:
|
|
652
|
+
fieldRA (float)
|
|
653
|
+
fieldDec (float)
|
|
654
|
+
season (float)
|
|
655
|
+
band (str)
|
|
656
|
+
frac_obs_name_ref (float)
|
|
657
|
+
"""
|
|
658
|
+
|
|
659
|
+
ra = np.mean(snr_obs["fieldRA"])
|
|
660
|
+
dec = np.mean(snr_obs["fieldDec"])
|
|
661
|
+
band = np.unique(snr_obs["band"])[0]
|
|
662
|
+
|
|
663
|
+
rtot = []
|
|
664
|
+
|
|
665
|
+
for season in np.unique(snr_obs["season"]):
|
|
666
|
+
idx = snr_obs["season"] == season
|
|
667
|
+
sel_obs = snr_obs[idx]
|
|
668
|
+
idxb = snr_fakes["season"] == season
|
|
669
|
+
sel_fakes = snr_fakes[idxb]
|
|
670
|
+
|
|
671
|
+
sel_obs.sort(order="MJD")
|
|
672
|
+
sel_fakes.sort(order="MJD")
|
|
673
|
+
r = [ra, dec, season, band]
|
|
674
|
+
names = [self.ra_col, self.dec_col, "season", "band"]
|
|
675
|
+
for sim in self.names_ref:
|
|
676
|
+
fakes = interpolate.interp1d(sel_fakes["MJD"], sel_fakes["SNR_" + sim])
|
|
677
|
+
obs = interpolate.interp1d(sel_obs["MJD"], sel_obs["SNR_" + sim])
|
|
678
|
+
mjd_min = np.max([np.min(sel_obs["MJD"]), np.min(sel_fakes["MJD"])])
|
|
679
|
+
mjd_max = np.min([np.max(sel_obs["MJD"]), np.max(sel_fakes["MJD"])])
|
|
680
|
+
mjd = np.arange(mjd_min, mjd_max, 1.0)
|
|
681
|
+
|
|
682
|
+
diff_res = obs(mjd) - fakes(mjd)
|
|
683
|
+
|
|
684
|
+
idx = diff_res >= 0
|
|
685
|
+
r += [len(diff_res[idx]) / len(diff_res)]
|
|
686
|
+
names += ["frac_obs_" + sim]
|
|
687
|
+
rtot.append(tuple(r))
|
|
688
|
+
|
|
689
|
+
return np.rec.fromrecords(rtot, names=names)
|
|
690
|
+
|
|
691
|
+
def check_seasons(self, tab):
|
|
692
|
+
"""Check whether seasons have no overlap
|
|
693
|
+
if it is the case: modify MJD_min and season length of
|
|
694
|
+
the corresponding season
|
|
695
|
+
return only seasons with season_length > 30 days
|
|
696
|
+
|
|
697
|
+
Parameters
|
|
698
|
+
-----------
|
|
699
|
+
tab : array with the following fields:
|
|
700
|
+
|
|
701
|
+
Returns
|
|
702
|
+
-------
|
|
703
|
+
tab : array with the following fields:
|
|
704
|
+
"""
|
|
705
|
+
if tab is None or len(tab) == 1:
|
|
706
|
+
return tab
|
|
707
|
+
|
|
708
|
+
if len(tab) > 1:
|
|
709
|
+
diff = tab["MJD_min"][1:] - tab["MJD_max"][:-1]
|
|
710
|
+
idb = np.argwhere(diff < 20.0)
|
|
711
|
+
if len(idb) >= 1:
|
|
712
|
+
tab["MJD_min"][idb + 1] = tab["MJD_max"][idb] + 20.0
|
|
713
|
+
tab["season_length"][idb + 1] = tab["MJD_max"][idb + 1] - tab["MJD_min"][idb + 1]
|
|
714
|
+
|
|
715
|
+
return tab[tab["season_length"] > 30.0]
|