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,158 @@
|
|
|
1
|
+
import glob
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
# from rubin_sim.utils import ObservationMetaData
|
|
5
|
+
import healpy as hp
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
# Modifying createStarDensityMap to use GAIA DR1 catalog
|
|
9
|
+
|
|
10
|
+
# Use the catsim framework to loop over a healpy map and generate a
|
|
11
|
+
# stellar density map
|
|
12
|
+
|
|
13
|
+
# Connect to fatboy with: ssh -L 51433:fatboy.phys.washington.edu:1433
|
|
14
|
+
# gateway.astro.washington.edu
|
|
15
|
+
# If non-astro user, use simsuser@gateway.astro.washington.edu
|
|
16
|
+
|
|
17
|
+
# NOTE: fatboy is no longer operative
|
|
18
|
+
|
|
19
|
+
if __name__ == "__main__":
|
|
20
|
+
# Hide imports here so documentation builds
|
|
21
|
+
from lsst.sims.catalogs.db import DBObject
|
|
22
|
+
from lsst.sims.utils import angular_separation, halfSpaceFromRaDec
|
|
23
|
+
|
|
24
|
+
# from lsst.sims.catalogs.generation.db import CatalogDBObject
|
|
25
|
+
# Import the bits needed to get the catalog to work
|
|
26
|
+
# from rubin_sim.catUtils.baseCatalogModels import *
|
|
27
|
+
# from rubin_sim.catUtils.exampleCatalogDefinitions import *
|
|
28
|
+
# connect to fatboy
|
|
29
|
+
gaia_db = DBObject(
|
|
30
|
+
database="LSSTCATSIM",
|
|
31
|
+
host="fatboy.phys.washington.edu",
|
|
32
|
+
port=1433,
|
|
33
|
+
driver="mssql+pymssql",
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# get all of the column names for the gaia table in a list
|
|
37
|
+
gaia_columns = gaia_db.get_column_names(tableName="gaia_2016")
|
|
38
|
+
|
|
39
|
+
# Set up healpy map and ra, dec centers
|
|
40
|
+
nside = 64
|
|
41
|
+
|
|
42
|
+
# Set the min to 15 since we saturate there. CatSim max is 28
|
|
43
|
+
mag_max = 15.2
|
|
44
|
+
bins = np.arange(0.0, mag_max, 0.2)
|
|
45
|
+
star_density = np.zeros((hp.nside2npix(nside), np.size(bins) - 1), dtype=float)
|
|
46
|
+
over_max_mask = np.zeros(hp.nside2npix(nside), dtype=bool)
|
|
47
|
+
lat, ra = hp.pix2ang(nside, np.arange(0, hp.nside2npix(nside)))
|
|
48
|
+
dec = np.pi / 2.0 - lat
|
|
49
|
+
ra = np.degrees(ra)
|
|
50
|
+
dec = np.degrees(dec)
|
|
51
|
+
|
|
52
|
+
# Square root of pixel area.
|
|
53
|
+
hpsize_deg = hp.nside2resol(nside, arcmin=True) / 60.0
|
|
54
|
+
|
|
55
|
+
# Limit things to a 10 arcmin radius
|
|
56
|
+
hpsize_deg = np.min([10.0 / 60.0, hpsize_deg])
|
|
57
|
+
|
|
58
|
+
indx_min = 0
|
|
59
|
+
|
|
60
|
+
restore_file = glob.glob("gaiaStarDensity_nside_%i.npz" % (nside))
|
|
61
|
+
if len(restore_file) > 0:
|
|
62
|
+
data = np.load(restore_file[0])
|
|
63
|
+
star_density = data["star_density"].copy()
|
|
64
|
+
indx_min = data["icheck"].copy()
|
|
65
|
+
over_max_mask = data["over_max_mask"].copy()
|
|
66
|
+
|
|
67
|
+
print("")
|
|
68
|
+
# Look at a circular area the same area as the healpix it's centered on.
|
|
69
|
+
bound_length = hpsize_deg / np.pi**0.5
|
|
70
|
+
radius = bound_length
|
|
71
|
+
|
|
72
|
+
block_area = hpsize_deg**2 # sq deg
|
|
73
|
+
|
|
74
|
+
checksize = 1000
|
|
75
|
+
printsize = 10
|
|
76
|
+
npix = float(hp.nside2npix(nside))
|
|
77
|
+
|
|
78
|
+
# If the area has more than this number of objects, flag it as a max
|
|
79
|
+
break_limit = 1e6
|
|
80
|
+
chunk_size = 10000
|
|
81
|
+
for i in np.arange(indx_min, int(npix)):
|
|
82
|
+
last_cp = ""
|
|
83
|
+
# wonder what the units of bound_length are...degrees!
|
|
84
|
+
# And it's a radius
|
|
85
|
+
# The newer interface:
|
|
86
|
+
# obs_metadata = ObservationMetaData(bound_type='circle',
|
|
87
|
+
## pointing_ra=np.degrees(ra[i]),
|
|
88
|
+
# pointing_dec=np.degrees(dec[i]),
|
|
89
|
+
# bound_length=bound_length,
|
|
90
|
+
# mjd=5700)
|
|
91
|
+
|
|
92
|
+
# t = dbobj.getCatalog('ref_catalog_star', obs_metadata=obs_metadata)
|
|
93
|
+
hs = halfSpaceFromRaDec(ra[i], dec[i], radius)
|
|
94
|
+
current_level = 7
|
|
95
|
+
n_bits_off = 2 * (21 - current_level)
|
|
96
|
+
|
|
97
|
+
tx_list = hs.findAllTrixels(current_level)
|
|
98
|
+
|
|
99
|
+
# actually construct the query
|
|
100
|
+
query = "SELECT ra, dec, phot_g_mean_mag "
|
|
101
|
+
query += "FROM gaia_2016 "
|
|
102
|
+
query += "WHERE "
|
|
103
|
+
for i_pair, pair in enumerate(tx_list):
|
|
104
|
+
min_tx = int(pair[0] << n_bits_off)
|
|
105
|
+
max_tx = int((pair[1] + 1) << n_bits_off)
|
|
106
|
+
query += "(htmid>=%d AND htmid<=%d)" % (min_tx, max_tx)
|
|
107
|
+
if i_pair < len(tx_list) - 1:
|
|
108
|
+
query += " OR "
|
|
109
|
+
|
|
110
|
+
dtype = np.dtype([("ra", float), ("dec", float), ("mag", float)])
|
|
111
|
+
|
|
112
|
+
results = gaia_db.get_arbitrary_chunk_iterator(query, dtype=dtype, chunk_size=10000)
|
|
113
|
+
result = list(results)[0]
|
|
114
|
+
|
|
115
|
+
distances = angular_separation(result["ra"], result["dec"], ra[i], dec[i])
|
|
116
|
+
result = result[np.where(distances < radius)]
|
|
117
|
+
|
|
118
|
+
# I could think of setting the chunksize to something really large,
|
|
119
|
+
# then only doing one chunk?
|
|
120
|
+
# Or maybe setting up a way to break out of the loop if
|
|
121
|
+
# everything gets really dense?
|
|
122
|
+
temp_hist = np.zeros(np.size(bins) - 1, dtype=float)
|
|
123
|
+
counter = 0
|
|
124
|
+
col_name = "phot_g_mean_mag"
|
|
125
|
+
for chunk in results:
|
|
126
|
+
chunk_hist, bins = np.histogram(chunk[col_name], bins)
|
|
127
|
+
temp_hist += chunk_hist
|
|
128
|
+
counter += chunk_size
|
|
129
|
+
if counter >= break_limit:
|
|
130
|
+
over_max_mask[i] = True
|
|
131
|
+
break
|
|
132
|
+
|
|
133
|
+
star_density[i] = np.add.accumulate(temp_hist) / block_area
|
|
134
|
+
|
|
135
|
+
# Checkpoint
|
|
136
|
+
if (i % checksize == 0) & (i != 0):
|
|
137
|
+
np.savez(
|
|
138
|
+
"gaiaStarDensity_nside_%i.npz" % (nside),
|
|
139
|
+
starDensity=star_density,
|
|
140
|
+
bins=bins,
|
|
141
|
+
icheck=i,
|
|
142
|
+
overMaxMask=over_max_mask,
|
|
143
|
+
)
|
|
144
|
+
last_cp = "Checkpointed at i=%i of %i" % (i, npix)
|
|
145
|
+
if i % printsize == 0:
|
|
146
|
+
sys.stdout.write("\r")
|
|
147
|
+
per_complete = float(i) / npix * 100
|
|
148
|
+
sys.stdout.write(r"%.2f%% complete. " % (per_complete) + last_cp)
|
|
149
|
+
sys.stdout.flush()
|
|
150
|
+
|
|
151
|
+
np.savez(
|
|
152
|
+
"gaiaStarDensity_nside_%i.npz" % (nside),
|
|
153
|
+
starDensity=star_density,
|
|
154
|
+
bins=bins,
|
|
155
|
+
overMaxMask=over_max_mask,
|
|
156
|
+
)
|
|
157
|
+
print("")
|
|
158
|
+
print("Completed!")
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
__all__ = ("DustMap",)
|
|
2
|
+
|
|
3
|
+
import warnings
|
|
4
|
+
|
|
5
|
+
from rubin_sim.maf.maps import BaseMap
|
|
6
|
+
|
|
7
|
+
from .ebv_hp import eb_vhp
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class DustMap(BaseMap):
|
|
11
|
+
"""Add the E(B-V) values to the slice points.
|
|
12
|
+
|
|
13
|
+
Primarily, this calls eb_vhp to read a healpix map of E(B-V) values over
|
|
14
|
+
the sky, then assigns ebv values to each slice_point.
|
|
15
|
+
If the slicer is a healpix slicer, this is trivial.
|
|
16
|
+
Otherwise, it either uses the nearest healpix grid point or interpolates.
|
|
17
|
+
|
|
18
|
+
The key added to the slice points is `ebv`.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
interp : `bool`, opt
|
|
23
|
+
Interpolate the dust map at each slice_point (True)
|
|
24
|
+
or just use the nearest value (False).
|
|
25
|
+
Default is False.
|
|
26
|
+
nside : `int`, opt
|
|
27
|
+
Default nside value to read the dust map from disk.
|
|
28
|
+
Primarily useful if the slicer is not a healpix slicer.
|
|
29
|
+
Default 128.
|
|
30
|
+
map_path : `str`, opt
|
|
31
|
+
Define a path to the directory holding the dust map files.
|
|
32
|
+
Default None, which uses RUBIN_SIM_DATA_DIR.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
def __init__(self, interp=False, nside=128, map_path=None):
|
|
36
|
+
self.keynames = ["ebv"]
|
|
37
|
+
self.interp = interp
|
|
38
|
+
self.nside = nside
|
|
39
|
+
self.map_path = map_path
|
|
40
|
+
|
|
41
|
+
def run(self, slice_points):
|
|
42
|
+
# If the slicer has nside,
|
|
43
|
+
# it's a healpix slicer so we can read the map directly
|
|
44
|
+
if "nside" in slice_points:
|
|
45
|
+
if slice_points["nside"] != self.nside:
|
|
46
|
+
warnings.warn(
|
|
47
|
+
f"Slicer value of nside {slice_points['nside']} different "
|
|
48
|
+
f"from map value {self.nside}, using slicer value"
|
|
49
|
+
)
|
|
50
|
+
slice_points["ebv"] = eb_vhp(
|
|
51
|
+
slice_points["nside"],
|
|
52
|
+
pixels=slice_points["sid"],
|
|
53
|
+
map_path=self.map_path,
|
|
54
|
+
)
|
|
55
|
+
# Not a healpix slicer,
|
|
56
|
+
# look up values based on RA,dec with possible interpolation
|
|
57
|
+
else:
|
|
58
|
+
slice_points["ebv"] = eb_vhp(
|
|
59
|
+
self.nside,
|
|
60
|
+
ra=slice_points["ra"],
|
|
61
|
+
dec=slice_points["dec"],
|
|
62
|
+
interp=self.interp,
|
|
63
|
+
map_path=self.map_path,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
return slice_points
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
__all__ = ("DustMap3D",)
|
|
2
|
+
|
|
3
|
+
import warnings
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
from rubin_sim.maf.maps import BaseMap
|
|
8
|
+
from rubin_sim.phot_utils import DustValues
|
|
9
|
+
|
|
10
|
+
from .ebv_3d_hp import ebv_3d_hp, get_x_at_nearest_y
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class DustMap3D(BaseMap):
|
|
14
|
+
"""Add 3-d E(B-V) values to the slice points.
|
|
15
|
+
|
|
16
|
+
See "notes" below for a discussion of the content of the map keys,
|
|
17
|
+
and functionality that can be accessed by calling
|
|
18
|
+
`DustMap3d.distance_at_mag` with the key values at a given slice point.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
nside : `int`
|
|
23
|
+
Healpixel resolution (2^x) to read from disk.
|
|
24
|
+
map_file : `str`, opt
|
|
25
|
+
Path to dust map file.
|
|
26
|
+
interp : `bool`, opt
|
|
27
|
+
Should returned values be interpolated (True)
|
|
28
|
+
or just nearest neighbor (False).
|
|
29
|
+
Default True, but is ignored if 'pixels' is provided.
|
|
30
|
+
filtername : 'str', opt
|
|
31
|
+
Name of the filter (to match the lsst filter names in
|
|
32
|
+
rubin_sim.photUtils.DustValues) in which to calculate dust
|
|
33
|
+
extinction magnitudes
|
|
34
|
+
dist_pc : `float`, opt
|
|
35
|
+
Distance at which to precalculate the nearest ebv value (pc)
|
|
36
|
+
d_mag : `float`, opt
|
|
37
|
+
Calculate the maximum distance which matches this `d_mag`
|
|
38
|
+
d_mag == m-mO (dust extinction + distance modulus)
|
|
39
|
+
r_x : `dict` {`str`: `float`}, opt
|
|
40
|
+
Per-filter dust extinction curve coefficients.
|
|
41
|
+
Calculated by rubin_sim.photUtils.DustValues if "None".
|
|
42
|
+
|
|
43
|
+
Notes
|
|
44
|
+
-----
|
|
45
|
+
The slice point dictionary keys are expanded with the following keys:
|
|
46
|
+
ebv3d_dists -
|
|
47
|
+
the distances from the 3d dust map at each slice_point (in pc)
|
|
48
|
+
`ebv3d_ebvs` -
|
|
49
|
+
the E(B-V) values corresponding to each distance at each slice_point
|
|
50
|
+
`ebv3d_ebv_at_<dist_pc>` -
|
|
51
|
+
the (single) ebv value at the nearest distance to dist_pc
|
|
52
|
+
`ebv3d_dist_at_<d_mag>` -
|
|
53
|
+
the (single) distance value corresponding to where extinction and
|
|
54
|
+
distance modulus combine to create a m-Mo value of d_mag, for the filter
|
|
55
|
+
specified in filtername (in pc).
|
|
56
|
+
Note that <dist_pc> and <d_mag> will be formatted with a
|
|
57
|
+
single decimal place.
|
|
58
|
+
|
|
59
|
+
The additional method 'distance_at_mag' can be called either with the
|
|
60
|
+
distances and ebv values for the entire map or with the values from a
|
|
61
|
+
single slice_point, in order to calculate the distance at which
|
|
62
|
+
extinction and distance modulus combine to create a m-Mo value closest
|
|
63
|
+
to 'dmag' in any filter. This is the same value as would be reported in
|
|
64
|
+
ebv3d_dist_at_<d_mag>, but can be calculated on the fly,
|
|
65
|
+
allowing variable filters and dmag values.
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
def __init__(
|
|
69
|
+
self,
|
|
70
|
+
nside=64,
|
|
71
|
+
map_file=None,
|
|
72
|
+
interp=True,
|
|
73
|
+
filtername="r",
|
|
74
|
+
dist_pc=3000,
|
|
75
|
+
d_mag=15.2,
|
|
76
|
+
r_x=None,
|
|
77
|
+
):
|
|
78
|
+
self.nside = nside
|
|
79
|
+
self.interp = interp
|
|
80
|
+
self.map_file = map_file
|
|
81
|
+
self.filtername = filtername
|
|
82
|
+
self.dist_pc = dist_pc
|
|
83
|
+
self.d_mag = d_mag
|
|
84
|
+
# r_x is the extinction coefficient (A_v = R_v * E(B-V) ..
|
|
85
|
+
# A_x = r_x * E(B-V)) per filter
|
|
86
|
+
# This is equivalent to calculating A_x
|
|
87
|
+
# (using rubin_sim.photUtils.Sed.addDust) in each
|
|
88
|
+
# filter and setting E(B-V) to 1 [so similar to the values
|
|
89
|
+
# calculated in DustValues.
|
|
90
|
+
if r_x is None:
|
|
91
|
+
self.r_x = DustValues().r_x.copy()
|
|
92
|
+
else:
|
|
93
|
+
self.r_x = r_x
|
|
94
|
+
# The values that will be added to the slicepoints
|
|
95
|
+
self.keynames = [
|
|
96
|
+
"ebv3d_ebvs",
|
|
97
|
+
"ebv3d_dists",
|
|
98
|
+
f"ebv3d_ebv_at_{self.dist_pc:.1f}",
|
|
99
|
+
f"ebv3d_dist_at_{self.d_mag:.1f}",
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
def run(self, slice_points):
|
|
103
|
+
# If the slicer has nside,
|
|
104
|
+
# it's a healpix slicer so we can read the map directly
|
|
105
|
+
if "nside" in slice_points:
|
|
106
|
+
if slice_points["nside"] != self.nside:
|
|
107
|
+
warnings.warn(
|
|
108
|
+
f"Slicer value of nside {slice_points['nside']} different "
|
|
109
|
+
f"from map value {self.nside}, will use correct slicer value here."
|
|
110
|
+
)
|
|
111
|
+
dists, ebvs = ebv_3d_hp(
|
|
112
|
+
slice_points["nside"],
|
|
113
|
+
pixels=slice_points["sid"],
|
|
114
|
+
map_file=self.map_file,
|
|
115
|
+
)
|
|
116
|
+
# Not a healpix slicer,
|
|
117
|
+
# look up values based on RA,dec with possible interpolation
|
|
118
|
+
else:
|
|
119
|
+
dists, ebvs = ebv_3d_hp(
|
|
120
|
+
self.nside,
|
|
121
|
+
ra=slice_points["ra"],
|
|
122
|
+
dec=slice_points["dec"],
|
|
123
|
+
interp=self.interp,
|
|
124
|
+
map_file=self.map_file,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
# Calculate the map ebv and dist values at the initialized distance
|
|
128
|
+
dist_closest, ebv_at_dist = get_x_at_nearest_y(dists, ebvs, self.dist_pc)
|
|
129
|
+
|
|
130
|
+
# Calculate the distances at which m_minus_Mo values
|
|
131
|
+
# of 'dmag' are reached
|
|
132
|
+
dist_dmag = self.distance_at_dmag(self.d_mag, dists, ebvs, self.filtername)
|
|
133
|
+
|
|
134
|
+
slice_points["ebv3d_dists"] = dists
|
|
135
|
+
slice_points["ebv3d_ebvs"] = ebvs
|
|
136
|
+
slice_points[f"ebv3d_ebv_at_{self.dist_pc:.1f}"] = ebv_at_dist
|
|
137
|
+
slice_points[f"ebv3d_dist_at_{self.d_mag:.1f}"] = dist_dmag
|
|
138
|
+
|
|
139
|
+
return slice_points
|
|
140
|
+
|
|
141
|
+
def distance_at_dmag(self, dmag, dists, ebvs, filtername=None):
|
|
142
|
+
"""Calculate the distance at which a given change of magnitude would
|
|
143
|
+
occur (including distance modulus and dust extinction).
|
|
144
|
+
|
|
145
|
+
Parameters
|
|
146
|
+
----------
|
|
147
|
+
dmag : `float`
|
|
148
|
+
The magnitude change expected.
|
|
149
|
+
dists : `np.ndarray`, (N,)
|
|
150
|
+
The distances corresponding to the ebv values.
|
|
151
|
+
ebvs : `np.ndarray`, (N,)
|
|
152
|
+
The ebv values at each distance.
|
|
153
|
+
filtername : `str` or None
|
|
154
|
+
The filter in which to evaluate the magnitude change.
|
|
155
|
+
If None, uses the default filter for the map.
|
|
156
|
+
The filter translates ebv into magnitudes of extinction.
|
|
157
|
+
|
|
158
|
+
Returns
|
|
159
|
+
-------
|
|
160
|
+
dist_dmag : `float`
|
|
161
|
+
The distance at which the specified dmag occurs.
|
|
162
|
+
"""
|
|
163
|
+
# Provide this as a method which could be used for a single
|
|
164
|
+
# slice_point as well as for whole map
|
|
165
|
+
# (single slice_point means you could calculate this for any
|
|
166
|
+
# arbitrary magnitude or filter if needed)
|
|
167
|
+
# This method is here because some metrics require it.
|
|
168
|
+
if filtername is None:
|
|
169
|
+
filtername = self.filtername
|
|
170
|
+
# calculate distance modulus for each distance
|
|
171
|
+
dmods = 5.0 * np.log10(dists) - 5.0
|
|
172
|
+
# calculate dust extinction at each distance, for the filtername
|
|
173
|
+
a_x = self.r_x[filtername] * ebvs
|
|
174
|
+
# calculate the (m-Mo) = distmod + a_x -- combination of extinction
|
|
175
|
+
# due to distance and dust
|
|
176
|
+
m_minus__mo = dmods + a_x
|
|
177
|
+
|
|
178
|
+
# Maximum distance for the given m-Mo (dmag) value
|
|
179
|
+
# first do the 'within the map' closest distance
|
|
180
|
+
m_minus__mo_at_mag, dist_closest = get_x_at_nearest_y(m_minus__mo, dists, dmag)
|
|
181
|
+
# calculate distance modulus for an object with the maximum dust
|
|
182
|
+
# extinction (and then the distance)
|
|
183
|
+
if a_x.ndim == 2:
|
|
184
|
+
dist_mods_far = dmag - a_x[:, -1]
|
|
185
|
+
else:
|
|
186
|
+
dist_mods_far = dmag - a_x.max()
|
|
187
|
+
dists_far = 10.0 ** (0.2 * dist_mods_far + 1.0)
|
|
188
|
+
# Use furthest of the two
|
|
189
|
+
dist_dmag = np.where(dists_far > dist_closest, dists_far, dist_closest)
|
|
190
|
+
return dist_dmag
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
__all__ = ("ebv_3d_hp", "get_x_at_nearest_y")
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
import healpy as hp
|
|
7
|
+
import numpy as np
|
|
8
|
+
from astropy.io import fits
|
|
9
|
+
from rubin_scheduler.data import get_data_dir
|
|
10
|
+
|
|
11
|
+
from rubin_sim.maf.utils import radec2pix
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def ebv_3d_hp(
|
|
15
|
+
nside,
|
|
16
|
+
map_file=None,
|
|
17
|
+
ra=None,
|
|
18
|
+
dec=None,
|
|
19
|
+
pixels=None,
|
|
20
|
+
interp=False,
|
|
21
|
+
):
|
|
22
|
+
"""Reads and saves a 3d dust extinction file from disk, return extinction
|
|
23
|
+
at specified points (ra/dec/ or pixels).
|
|
24
|
+
|
|
25
|
+
Parameters
|
|
26
|
+
----------
|
|
27
|
+
nside : `int`
|
|
28
|
+
Healpixel resolution (2^x).
|
|
29
|
+
map_file : `str`, opt
|
|
30
|
+
Path to dust map file.
|
|
31
|
+
ra : `np.ndarray` or `float`, opt
|
|
32
|
+
RA (can take numpy array).
|
|
33
|
+
Default None sets up healpix array of nside. Radians.
|
|
34
|
+
dec : `np.ndarray` or `float`, opt
|
|
35
|
+
Dec (can take numpy array).
|
|
36
|
+
Default None set up healpix array of nside. Radians.
|
|
37
|
+
pixels : `np.ndarray`, opt
|
|
38
|
+
Healpixel IDs, to sub-select particular healpix points.
|
|
39
|
+
Default uses all points.
|
|
40
|
+
Easiest way to access healpix values.
|
|
41
|
+
Note that the pixels in the healpix array MUST come from a h
|
|
42
|
+
ealpix grid with the same nside as the ebv_3d_hp map.
|
|
43
|
+
Using different nsides can potentially fail silently.
|
|
44
|
+
interp : `bool`, opt
|
|
45
|
+
Should returned values be interpolated (True)
|
|
46
|
+
or just nearest neighbor (False).
|
|
47
|
+
Default False.
|
|
48
|
+
"""
|
|
49
|
+
if (ra is None) & (dec is None) & (pixels is None):
|
|
50
|
+
raise RuntimeError("Need to set ra,dec or pixels.")
|
|
51
|
+
|
|
52
|
+
# Set up path to map data
|
|
53
|
+
if map_file is None:
|
|
54
|
+
if nside == 64:
|
|
55
|
+
map_name = "merged_ebv3d_nside64_defaults.fits"
|
|
56
|
+
map_file = os.path.join(get_data_dir(), "maps/DustMaps3D", map_name)
|
|
57
|
+
elif nside == 128:
|
|
58
|
+
map_name = "merged_ebv3d_nside128_defaults.fits"
|
|
59
|
+
map_file = os.path.join(get_data_dir(), "maps/DustMaps3D", map_name)
|
|
60
|
+
else:
|
|
61
|
+
raise Exception(
|
|
62
|
+
f"map_file not specified, and nside {nside} not one of 64 or 128. "
|
|
63
|
+
"Please specify a known map_file, as a basis for interpolation."
|
|
64
|
+
)
|
|
65
|
+
else:
|
|
66
|
+
# Check if user specified map name but not full map path
|
|
67
|
+
if not os.path.isfile(map_file):
|
|
68
|
+
test_path = os.path.join(get_data_dir(), "maps/DustMaps3D", map_file)
|
|
69
|
+
if os.path.isfile(test_path):
|
|
70
|
+
map_file = test_path
|
|
71
|
+
# Keep track of what nside and what map_file we're using
|
|
72
|
+
if not hasattr(ebv_3d_hp, "map_file"):
|
|
73
|
+
ebv_3d_hp.mapFile = map_file
|
|
74
|
+
ebv_3d_hp.nside = nside
|
|
75
|
+
|
|
76
|
+
# Do we need to re-read from disk?
|
|
77
|
+
if (not hasattr(ebv_3d_hp, "ebvs")) | (not hasattr(ebv_3d_hp, "dists")) | (map_file != ebv_3d_hp.mapFile):
|
|
78
|
+
ebv_3d_hp.mapFile = map_file
|
|
79
|
+
ebv_3d_hp.nside = nside
|
|
80
|
+
# Read map from disk
|
|
81
|
+
hdul = fits.open(map_file)
|
|
82
|
+
# hpids = hdul[0].data
|
|
83
|
+
dists = hdul[1].data
|
|
84
|
+
ebvs = hdul[2].data
|
|
85
|
+
hdr = hdul[0].header
|
|
86
|
+
# Close map file
|
|
87
|
+
hdul.close()
|
|
88
|
+
|
|
89
|
+
# Check additional healpix information from the header
|
|
90
|
+
map_nside = hdr["NSIDE"]
|
|
91
|
+
nested = hdr["NESTED"]
|
|
92
|
+
if nside != map_nside:
|
|
93
|
+
warnings.warn(
|
|
94
|
+
f"Map nside {map_nside} did not match expected nside {nside}; "
|
|
95
|
+
f"Will use nside from map data."
|
|
96
|
+
)
|
|
97
|
+
if pixels is not None:
|
|
98
|
+
# We're just going to raise an exception here
|
|
99
|
+
# because this could mean bad things.
|
|
100
|
+
raise ValueError(
|
|
101
|
+
f"Map nside {map_nside} did not match expected nside {nside}, "
|
|
102
|
+
f"and pixels provided; this can potentially indicate a serious "
|
|
103
|
+
f"error. Make nsides match or specify ra/dec instead of pixels."
|
|
104
|
+
)
|
|
105
|
+
nside = map_nside
|
|
106
|
+
# Nested healpix data will not match the healpix arrays
|
|
107
|
+
# for the slicers (at this time)
|
|
108
|
+
if nested:
|
|
109
|
+
warnings.warn("Map has nested (not ring order) data; will reorder.")
|
|
110
|
+
for i in np.arange(0, len(dists[0])):
|
|
111
|
+
dists[:, i] = hp.reorder(dists[:, i], "nest", "ring")
|
|
112
|
+
ebvs[:, i] = hp.reorder(ebvs[:, i], "nest", "ring")
|
|
113
|
+
ebv_3d_hp.dists = dists
|
|
114
|
+
ebv_3d_hp.ebvs = ebvs
|
|
115
|
+
print(f"Read map {map_file} from disk")
|
|
116
|
+
|
|
117
|
+
if pixels is not None:
|
|
118
|
+
# Assume if pixels is set, then interp is irrelevant
|
|
119
|
+
dists = ebv_3d_hp.dists[pixels]
|
|
120
|
+
ebvs = ebv_3d_hp.ebvs[pixels]
|
|
121
|
+
# BUT, if we were provided ra/dec then have to see if we should interpolate
|
|
122
|
+
else:
|
|
123
|
+
if interp: # find interpolated values at given ra/dec
|
|
124
|
+
distlen = len(ebv_3d_hp.dists[0])
|
|
125
|
+
dists = np.zeros([len(ra), distlen], float)
|
|
126
|
+
ebvs = np.zeros([len(ra), distlen], float)
|
|
127
|
+
for i in np.arange(0, distlen):
|
|
128
|
+
dists[:, i] = hp.get_interp_val(ebv_3d_hp.dists[:, i], np.pi / 2.0 - dec, ra)
|
|
129
|
+
ebvs[:, i] = hp.get_interp_val(ebv_3d_hp.ebvs[:, i], np.pi / 2.0 - dec, ra)
|
|
130
|
+
else: # just fine nearest neighbor pixel value and return those
|
|
131
|
+
pixels = radec2pix(nside, ra, dec)
|
|
132
|
+
dists = ebv_3d_hp.dists[pixels]
|
|
133
|
+
ebvs = ebv_3d_hp.ebvs[pixels]
|
|
134
|
+
|
|
135
|
+
return dists, ebvs
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def get_x_at_nearest_y(x, y, x_goal):
|
|
139
|
+
"""Given a goal x value, find y values at the closest x value.
|
|
140
|
+
|
|
141
|
+
This could be used to fetch the nearest ebv value at a given distance,
|
|
142
|
+
or the nearest distance to a given m-Mo value, for example.
|
|
143
|
+
|
|
144
|
+
Parameters
|
|
145
|
+
----------
|
|
146
|
+
x : `np.array`
|
|
147
|
+
Can be either a map with x at each point in the map (2d array) or
|
|
148
|
+
the x at a single point of the map (1d array)
|
|
149
|
+
y : `np.array`
|
|
150
|
+
Can be either a map with y at each point in the map (2d array) or
|
|
151
|
+
the y at a single point of the map (1d array) -
|
|
152
|
+
but should match x dimensionality
|
|
153
|
+
x_goal : `float'
|
|
154
|
+
The goal x value to look for the nearest y value
|
|
155
|
+
|
|
156
|
+
Returns
|
|
157
|
+
-------
|
|
158
|
+
x_closest, y_closest : `np.array`, `np.array`
|
|
159
|
+
1-d array of x and y (single value or over map).
|
|
160
|
+
"""
|
|
161
|
+
if x.ndim == 2:
|
|
162
|
+
idx_min = np.argmin(np.abs(x - x_goal), axis=1)
|
|
163
|
+
i_expand = np.expand_dims(idx_min, axis=-1)
|
|
164
|
+
x_closest = np.take_along_axis(x, i_expand, axis=-1).squeeze()
|
|
165
|
+
y_closest = np.take_along_axis(y, i_expand, axis=-1).squeeze()
|
|
166
|
+
else:
|
|
167
|
+
idx_min = np.argmin(np.abs(x - x_goal))
|
|
168
|
+
x_closest = x[idx_min]
|
|
169
|
+
y_closest = y[idx_min]
|
|
170
|
+
return x_closest, y_closest
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
__all__ = ("eb_vhp",)
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
import healpy as hp
|
|
6
|
+
import numpy as np
|
|
7
|
+
from rubin_scheduler.data import get_data_dir
|
|
8
|
+
|
|
9
|
+
from rubin_sim.maf.utils import radec2pix
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def eb_vhp(nside, ra=None, dec=None, pixels=None, interp=False, map_path=None):
|
|
13
|
+
"""Read in a healpix dust map and return values for given RA, Dec values.
|
|
14
|
+
|
|
15
|
+
This is primarily a tool for the rubin_sim.maf.DustMap class.
|
|
16
|
+
|
|
17
|
+
nside : `int`
|
|
18
|
+
Healpixel resolution (2^x).
|
|
19
|
+
ra : `np.ndarray` or `float`, opt
|
|
20
|
+
RA (can take numpy array).
|
|
21
|
+
Default None sets up healpix array of nside. Radians.
|
|
22
|
+
dec : `np.ndarray` or `float`, opt
|
|
23
|
+
Dec (can take numpy array).
|
|
24
|
+
Default None set up healpix array of nside. Radians.
|
|
25
|
+
pixels : `np.ndarray`, opt
|
|
26
|
+
Healpixel IDs, to sub-select particular healpix points.
|
|
27
|
+
Default uses all points.
|
|
28
|
+
NOTE - to use a healpix map, set pixels and not ra/dec.
|
|
29
|
+
interp : `bool`, opt
|
|
30
|
+
Should returned values be interpolated (True)
|
|
31
|
+
or just nearest neighbor (False)
|
|
32
|
+
map_path : `str`, opt
|
|
33
|
+
Path to directory containing dust map files.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
if (ra is None) & (dec is None) & (pixels is None):
|
|
37
|
+
raise RuntimeError("Need to set ra,dec or pixels.")
|
|
38
|
+
|
|
39
|
+
# Load the map
|
|
40
|
+
if map_path is not None:
|
|
41
|
+
ebv_data_dir = map_path
|
|
42
|
+
else:
|
|
43
|
+
ebv_data_dir = os.path.join(get_data_dir(), "maps", "DustMaps")
|
|
44
|
+
if not hasattr(eb_vhp, "nside"):
|
|
45
|
+
eb_vhp.nside = nside
|
|
46
|
+
|
|
47
|
+
if (not hasattr(eb_vhp, "dustmap")) | (eb_vhp.nside != nside):
|
|
48
|
+
eb_vhp.nside = nside
|
|
49
|
+
filename = "dust_nside_%i.npz" % eb_vhp.nside
|
|
50
|
+
eb_vhp.dustMap = np.load(os.path.join(ebv_data_dir, filename))["ebvMap"]
|
|
51
|
+
|
|
52
|
+
# If we are interpolating to arbitrary positions
|
|
53
|
+
if interp:
|
|
54
|
+
result = hp.get_interp_val(eb_vhp.dustMap, np.pi / 2.0 - dec, ra)
|
|
55
|
+
else:
|
|
56
|
+
# If we know the pixel indices we want
|
|
57
|
+
if pixels is not None:
|
|
58
|
+
result = eb_vhp.dustMap[pixels]
|
|
59
|
+
# Look up
|
|
60
|
+
else:
|
|
61
|
+
pixels = radec2pix(eb_vhp.nside, ra, dec)
|
|
62
|
+
result = eb_vhp.dustMap[pixels]
|
|
63
|
+
|
|
64
|
+
return result
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
__all__ = ("GalCoordsMap",)
|
|
2
|
+
|
|
3
|
+
from astropy import units as u
|
|
4
|
+
from astropy.coordinates import SkyCoord
|
|
5
|
+
|
|
6
|
+
from rubin_sim.maf.maps import BaseMap
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class GalCoordsMap(BaseMap):
|
|
10
|
+
"""Add `gall` and `galb` (in radians) to the slice point dictionaries."""
|
|
11
|
+
|
|
12
|
+
def __init__(self):
|
|
13
|
+
self.keynames = ["gall", "galb"]
|
|
14
|
+
|
|
15
|
+
def run(self, slice_points):
|
|
16
|
+
coords = SkyCoord(ra=slice_points["ra"] * u.rad, dec=slice_points["dec"] * u.rad)
|
|
17
|
+
gal = coords.galactic
|
|
18
|
+
gall = gal.l.rad
|
|
19
|
+
galb = gal.b.rad
|
|
20
|
+
slice_points["gall"] = gall
|
|
21
|
+
slice_points["galb"] = galb
|
|
22
|
+
return slice_points
|