How to work with catalogs

library(panstarrs)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(data.table)
#> 
#> Attaching package: 'data.table'
#> The following objects are masked from 'package:dplyr':
#> 
#>     between, first, last

Example 1

Get MeanPSFMag in the grizy filters from PS1 catalog for the KQ Uma source.

1. Get coords for the source

coords <- ps1_mast_resolve('KQ Uma')
coords
#> $ra
#> [1] 139.3343
#> 
#> $decl
#> [1] 68.63514

2. Search sources in the circle around the KQ position

df_cone <- ps1_cone(
  coords$ra, 
  coords$decl,
  r_arcmin = 0.01, 
  table = 'mean',
  release = 'dr2'
)
#> Warning in convert_function[[types[i]]](dt[[i]]): NAs introduced by coercion to
#> integer range

#> Warning in convert_function[[types[i]]](dt[[i]]): NAs introduced by coercion to
#> integer range

# tidyverse approach
df_cone |>
  dplyr::select(dplyr::matches('[grizy]MeanPSFMag$'))
#>    gMeanPSFMag rMeanPSFMag iMeanPSFMag zMeanPSFMag yMeanPSFMag
#> 1:    0.999487    0.999573    0.999369    0.999257    0.999801

# or if you prefer data.table approach
df_cone[, .SD, .SDcols = grepl('[grizy]MeanPSFMag$', names(df_cone))]
#>    gMeanPSFMag rMeanPSFMag iMeanPSFMag zMeanPSFMag yMeanPSFMag
#> 1:    0.999487    0.999573    0.999369    0.999257    0.999801