Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement /target/parents endpoint #38

Merged
merged 8 commits into from
Aug 8, 2024
Merged

Implement /target/parents endpoint #38

merged 8 commits into from
Aug 8, 2024

Conversation

albireox
Copy link
Member

@albireox albireox commented Aug 7, 2024

Implements a new endpoint /target/parents/{catalog}/{sdss_id} which returns parent catalog information for a given sdss_id. The response model is

{
"sdss_id": 129055990,
"catalogid": 63050395068163877,
"catalog": "gaia_dr3_source",
"field_name": "source_id",
"parent_catalog_id": 2605275489003187072
}

I'm not sure about the route name or the response contents or field names.

>> curl -L "http://127.0.0.1:8000/target/parents/gaia_dr3_source/129055990"            
{"sdss_id":129055990,"catalogid":63050395068163877,"source_id":2605275489003187072,"solution_id":1636148068921376768,"designation":"Gaia DR3 2605275489003187072","random_index":1020005880,"ref_epoch":2016.0,"ra":342.8413714603454,"ra_error":0.842067,"dec":-10.239850309221548,"dec_error":0.9484852,"parallax":10.907291430285165,"parallax_error":1.0142229,"parallax_over_error":10.754334,"pm":46.691307,"pmra":-21.311661454841314,"pmra_error":1.2463797,"pmdec":-41.543848204958365,"pmdec_error":1.1763526,"ra_dec_corr":0.21672651,"ra_parallax_corr":0.09093504,"ra_pmra_corr":0.21584736,"ra_pmdec_corr":-0.0879561,"dec_parallax_corr":-0.33626717,"dec_pmra_corr":-0.04698392,"dec_pmdec_corr":0.14418805,"parallax_pmra_corr":-0.051337507,"parallax_pmdec_corr":-0.2278784,"pmra_pmdec_corr":0.124743745,"astrometric_n_obs_al":157,"astrometric_n_obs_ac":0,"astrometric_n_good_obs_al":152,"astrometric_n_bad_obs_al":5,"astrometric_gof_al":33.453407,"astrometric_chi2_al":2294.282,"astrometric_excess_noise":6.3394456,"astrometric_excess_noise_sig":59.842293,"astrometric_params_solved":95,"astrometric_primary_flag":false,"nu_eff_used_in_astrometry":null,"pseudocolour":0.85462797,"pseudocolour_error":0.21192579,"ra_pseudocolour_corr":-0.060202982,"dec_pseudocolour_corr":0.013923447,"parallax_pseudocolour_corr":0.051621795,"pmra_pseudocolour_corr":-0.004585662,"pmdec_pseudocolour_corr":-0.039514143,"astrometric_matched_transits":18,"visibility_periods_used":14,"astrometric_sigma5d_max":1.7950424,"matched_transits":20,"new_matched_transits":20,"matched_transits_removed":0,"ipd_gof_harmonic_amplitude":0.30820587,"ipd_gof_harmonic_phase":100.369415,"ipd_frac_multi_peak":31,"ipd_frac_odd_win":10,"ruwe":3.4963603,"scan_direction_strength_k1":0.28656563,"scan_direction_strength_k2":0.30943793,"scan_direction_strength_k3":0.43368298,"scan_direction_strength_k4":0.9103226,"scan_direction_mean_k1":-86.198715,"scan_direction_mean_k2":-51.241356,"scan_direction_mean_k3":-52.53388,"scan_direction_mean_k4":24.666033,"duplicated_source":false,"phot_g_n_obs":157,"phot_g_mean_flux":382.4679932200233,"phot_g_mean_flux_error":8.176602,"phot_g_mean_flux_over_error":46.775906,"phot_g_mean_mag":19.230879,"phot_bp_n_obs":11,"phot_bp_mean_flux":52.38008810924284,"phot_bp_mean_flux_error":11.834996,"phot_bp_mean_flux_over_error":4.425864,"phot_bp_mean_mag":21.040627,"phot_rp_n_obs":15,"phot_rp_mean_flux":711.6966545848484,"phot_rp_mean_flux_error":13.853812,"phot_rp_mean_flux_over_error":51.3719,"phot_rp_mean_mag":17.617159,"phot_bp_rp_excess_factor":1.9977534,"phot_bp_n_contaminated_transits":0,"phot_bp_n_blended_transits":0,"phot_rp_n_contaminated_transits":0,"phot_rp_n_blended_transits":0,"phot_proc_mode":0,"bp_rp":3.4234676,"bp_g":1.8097477,"g_rp":1.6137199,"radial_velocity":null,"radial_velocity_error":null,"rv_method_used":null,"rv_nb_transits":null,"rv_nb_deblended_transits":null,"rv_visibility_periods_used":null,"rv_expected_sig_to_noise":null,"rv_renormalised_gof":null,"rv_chisq_pvalue":null,"rv_time_duration":null,"rv_amplitude_robust":null,"rv_template_teff":null,"rv_template_logg":null,"rv_template_fe_h":null,"rv_atm_param_origin":null,"vbroad":null,"vbroad_error":null,"vbroad_nb_transits":null,"grvs_mag":null,"grvs_mag_error":null,"grvs_mag_nb_transits":null,"rvs_spec_sig_to_noise":null,"phot_variable_flag":"NOT_AVAILABLE","l":58.00400837113424,"b":-57.076535885991916,"ecl_lon":340.27793716202996,"ecl_lat":-2.7293360537442064,"in_qso_candidates":false,"in_galaxy_candidates":false,"non_single_star":0,"has_xp_continuous":false,"has_xp_sampled":false,"has_rvs":false,"has_epoch_photometry":false,"has_epoch_rv":false,"has_mcmc_gspphot":false,"has_mcmc_msc":false,"in_andromeda_survey":false,"classprob_dsc_combmod_quasar":1.02187715e-13,"classprob_dsc_combmod_galaxy":5.1042254e-13,"classprob_dsc_combmod_star":0.9999836,"teff_gspphot":null,"teff_gspphot_lower":null,"teff_gspphot_upper":null,"logg_gspphot":null,"logg_gspphot_lower":null,"logg_gspphot_upper":null,"mh_gspphot":null,"mh_gspphot_lower":null,"mh_gspphot_upper":null,"distance_gspphot":null,"distance_gspphot_lower":null,"distance_gspphot_upper":null,"azero_gspphot":null,"azero_gspphot_lower":null,"azero_gspphot_upper":null,"ag_gspphot":null,"ag_gspphot_lower":null,"ag_gspphot_upper":null,"ebpminrp_gspphot":null,"ebpminrp_gspphot_lower":null,"ebpminrp_gspphot_upper":null,"libname_gspphot":null}

Note that this PR also bumps sdssdb to 0.12.4 as there was a bug in the SDSS_ID_To_Catalogs that prevented querying or ordering by catalogid.

Closes #33.

@albireox albireox requested a review from havok2063 as a code owner August 7, 2024 22:47
@havok2063
Copy link
Contributor

havok2063 commented Aug 8, 2024

I'm a little confused on what exactly this is returning in the response? What I was imagining was a route like /targets/parents/{sdss_id}/?catalog={value} or /targets/parents/{sdss_id}/{catalog}/ that returns the row from the parent catalog.

For example, for sdss_id=81743650, and catalog='gaia_dr3_source', it returns the output of catalogdb.Gaia_DR3.select().where(catalogdb.Gaia_DR3.source_id==4049509060477169024).dicts(),

{'source_id': 4049509060477169024, 'solution_id': 1636148068921376768, 'designation': 'Gaia DR3 4049509060477169024', 'random_index': 1760972837, ...}

I think the route name /target/parents is ok. I don't have a strong preference if catalog is a path or query parameter. The response model for this route would be a model for any one of the parent catalog tables. It'd be nice to have a schema in valis for those tables, but that might be difficult since the tables vary.

@albireox
Copy link
Member Author

albireox commented Aug 8, 2024

Ah! I misinterpreted what that route meant. Not difficult to implement, let me change it.

@albireox
Copy link
Member Author

albireox commented Aug 8, 2024

Have a look now. This is what it will return

>> curl -L "http://127.0.0.1:8000/target/parents/gaia_dr3_source/129055990"                                                          
{"sdss_id":129055990,"catalogid":63050395068163877,"source_id":2605275489003187072,"solution_id":1636148068921376768,"designation":"Gaia DR3 2605275489003187072","random_index":1020005880,"ref_epoch":2016.0,"ra":342.8413714603454,"ra_error":0.842067,"dec":-10.239850309221548,"dec_error":0.9484852,"parallax":10.907291430285165,"parallax_error":1.0142229,"parallax_over_error":10.754334,"pm":46.691307,"pmra":-21.311661454841314,"pmra_error":1.2463797,"pmdec":-41.543848204958365,"pmdec_error":1.1763526,"ra_dec_corr":0.21672651,"ra_parallax_corr":0.09093504,"ra_pmra_corr":0.21584736,"ra_pmdec_corr":-0.0879561,"dec_parallax_corr":-0.33626717,"dec_pmra_corr":-0.04698392,"dec_pmdec_corr":0.14418805,"parallax_pmra_corr":-0.051337507,"parallax_pmdec_corr":-0.2278784,"pmra_pmdec_corr":0.124743745,"astrometric_n_obs_al":157,"astrometric_n_obs_ac":0,"astrometric_n_good_obs_al":152,"astrometric_n_bad_obs_al":5,"astrometric_gof_al":33.453407,"astrometric_chi2_al":2294.282,"astrometric_excess_noise":6.3394456,"astrometric_excess_noise_sig":59.842293,"astrometric_params_solved":95,"astrometric_primary_flag":false,"nu_eff_used_in_astrometry":null,"pseudocolour":0.85462797,"pseudocolour_error":0.21192579,"ra_pseudocolour_corr":-0.060202982,"dec_pseudocolour_corr":0.013923447,"parallax_pseudocolour_corr":0.051621795,"pmra_pseudocolour_corr":-0.004585662,"pmdec_pseudocolour_corr":-0.039514143,"astrometric_matched_transits":18,"visibility_periods_used":14,"astrometric_sigma5d_max":1.7950424,"matched_transits":20,"new_matched_transits":20,"matched_transits_removed":0,"ipd_gof_harmonic_amplitude":0.30820587,"ipd_gof_harmonic_phase":100.369415,"ipd_frac_multi_peak":31,"ipd_frac_odd_win":10,"ruwe":3.4963603,"scan_direction_strength_k1":0.28656563,"scan_direction_strength_k2":0.30943793,"scan_direction_strength_k3":0.43368298,"scan_direction_strength_k4":0.9103226,"scan_direction_mean_k1":-86.198715,"scan_direction_mean_k2":-51.241356,"scan_direction_mean_k3":-52.53388,"scan_direction_mean_k4":24.666033,"duplicated_source":false,"phot_g_n_obs":157,"phot_g_mean_flux":382.4679932200233,"phot_g_mean_flux_error":8.176602,"phot_g_mean_flux_over_error":46.775906,"phot_g_mean_mag":19.230879,"phot_bp_n_obs":11,"phot_bp_mean_flux":52.38008810924284,"phot_bp_mean_flux_error":11.834996,"phot_bp_mean_flux_over_error":4.425864,"phot_bp_mean_mag":21.040627,"phot_rp_n_obs":15,"phot_rp_mean_flux":711.6966545848484,"phot_rp_mean_flux_error":13.853812,"phot_rp_mean_flux_over_error":51.3719,"phot_rp_mean_mag":17.617159,"phot_bp_rp_excess_factor":1.9977534,"phot_bp_n_contaminated_transits":0,"phot_bp_n_blended_transits":0,"phot_rp_n_contaminated_transits":0,"phot_rp_n_blended_transits":0,"phot_proc_mode":0,"bp_rp":3.4234676,"bp_g":1.8097477,"g_rp":1.6137199,"radial_velocity":null,"radial_velocity_error":null,"rv_method_used":null,"rv_nb_transits":null,"rv_nb_deblended_transits":null,"rv_visibility_periods_used":null,"rv_expected_sig_to_noise":null,"rv_renormalised_gof":null,"rv_chisq_pvalue":null,"rv_time_duration":null,"rv_amplitude_robust":null,"rv_template_teff":null,"rv_template_logg":null,"rv_template_fe_h":null,"rv_atm_param_origin":null,"vbroad":null,"vbroad_error":null,"vbroad_nb_transits":null,"grvs_mag":null,"grvs_mag_error":null,"grvs_mag_nb_transits":null,"rvs_spec_sig_to_noise":null,"phot_variable_flag":"NOT_AVAILABLE","l":58.00400837113424,"b":-57.076535885991916,"ecl_lon":340.27793716202996,"ecl_lat":-2.7293360537442064,"in_qso_candidates":false,"in_galaxy_candidates":false,"non_single_star":0,"has_xp_continuous":false,"has_xp_sampled":false,"has_rvs":false,"has_epoch_photometry":false,"has_epoch_rv":false,"has_mcmc_gspphot":false,"has_mcmc_msc":false,"in_andromeda_survey":false,"classprob_dsc_combmod_quasar":1.02187715e-13,"classprob_dsc_combmod_galaxy":5.1042254e-13,"classprob_dsc_combmod_star":0.9999836,"teff_gspphot":null,"teff_gspphot_lower":null,"teff_gspphot_upper":null,"logg_gspphot":null,"logg_gspphot_lower":null,"logg_gspphot_upper":null,"mh_gspphot":null,"mh_gspphot_lower":null,"mh_gspphot_upper":null,"distance_gspphot":null,"distance_gspphot_lower":null,"distance_gspphot_upper":null,"azero_gspphot":null,"azero_gspphot_lower":null,"azero_gspphot_upper":null,"ag_gspphot":null,"ag_gspphot_lower":null,"ag_gspphot_upper":null,"ebpminrp_gspphot":null,"ebpminrp_gspphot_lower":null,"ebpminrp_gspphot_upper":null,"libname_gspphot":null}⏎

Copy link
Contributor

@havok2063 havok2063 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Related to this, I think it'd also be nice to have a new route for listing all the available parent catalogs. I'll create a new issue for it.

python/valis/db/models.py Outdated Show resolved Hide resolved
python/valis/routes/target.py Outdated Show resolved Hide resolved
python/valis/routes/target.py Outdated Show resolved Hide resolved
python/valis/routes/target.py Outdated Show resolved Hide resolved
@havok2063
Copy link
Contributor

Looks good to me. I approve.

@albireox albireox merged commit 89c4c78 into main Aug 8, 2024
2 checks passed
@albireox albireox deleted the albireox/issue33 branch August 8, 2024 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add endpoint to retrieve source catalog details
2 participants