---
title: "How to work with catalogs"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{How to work with catalogs}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r setup}
library(panstarrs)
library(dplyr)
library(data.table)
```

# Example 1

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

### 1. Get coords for the source

```{r}
coords <- ps1_mast_resolve('KQ Uma')
coords
```
### 2. Search sources in the circle around the KQ position

```{r}
df_cone <- ps1_cone(
  coords$ra, 
  coords$decl,
  r_arcmin = 0.01, 
  table = 'mean',
  release = 'dr2'
)

# tidyverse approach
df_cone |>
  dplyr::select(dplyr::matches('[grizy]MeanPSFMag$'))

# or if you prefer data.table approach
df_cone[, .SD, .SDcols = grepl('[grizy]MeanPSFMag$', names(df_cone))]
```






