---
title: "summary"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{summary}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

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

```{r setup}
library(rtorf)
library(data.table)
```


## ObsPack summary

The first step consists in constructing a summary for the ObsPack.
This is required to read the data, but also, identify `agl`, 
which is present in some of the file names.
This function returns a `data.frame`.
Optionally, the user can indicate a path to store the `data.frame`.
`obs_summary` also prints a summary of the data. The second
argument is the categories, and by default includes the categories
shown below, to account for all the files.
Then the summary `data.frame` contains 
the columns `id` as the full path to each
file, `name` which is the name or relative path of the file, `n`
just an id, `sector` such as tower, and the column `agl`
which indicates the `agl` indicated in the name of the file
if available. To read the documentation of this function,
the user must run `?obs_summary`.

>  We first define the categories


```{r read1, eval = F}

cate = c("aircraft-pfp",
         "aircraft-insitu",
         "aircraft-flask",
         "surface-insitu",
         "surface-flask", 
         "surface-pfp",   
         "tower-insitu",  
         "aircore",       
         "shipboard-insitu",
         "shipboard-flask") 

obs <- "Z:/obspack/obspack_ch4_1_GLOBALVIEWplus_v5.1_2023-03-08/data/nc/"
index <- obs_summary(obs = obs, 
                     categories = cate)

```

```
Number of files of index: 429
              sector     N
              <char> <int>
 1:     aircraft-pfp    40
 2:  aircraft-insitu    15
 3:    surface-flask   106
 4:   surface-insitu   174
 5:   aircraft-flask     4
 6:          aircore     1
 7:      surface-pfp    33
 8:     tower-insitu    51
 9:  shipboard-flask     4
10: shipboard-insitu     1
11:    Total sectors   429
Detected 190 files with agl
Detected 239 files without agl

```

We can check the table now

```{r check, eval = F}
index
```

```
  1: Z:/torf/obspack_ch4_1_GLOBALVIEWplus_v5.1_2023-03-08/data/nc/ch4_aao_aircraft-pfp_1_allvalid.nc
  2: Z:/torf/obspack_ch4_1_GLOBALVIEWplus_v5.1_2023-03-08/data/nc/ch4_above_aircraft-insitu_1_allvalid.nc
  3: Z:/torf/obspack_ch4_1_GLOBALVIEWplus_v5.1_2023-03-08/data/nc/ch4_abp_surface-flask_1_representative.nc
  4: Z:/torf/obspack_ch4_1_GLOBALVIEWplus_v5.1_2023-03-08/data/nc/ch4_abt_surface-insitu_6_allvalid.nc
  5: Z:/torf/obspack_ch4_1_GLOBALVIEWplus_v5.1_2023-03-08/data/nc/ch4_acg_aircraft-pfp_1_allvalid.nc
 ---                                                                                                           
425: Z:/torf/obspack_ch4_1_GLOBALVIEWplus_v5.1_2023-03-08/data/nc/ch4_yon_surface-insitu_19_representative.nc
426: Z:/torf/obspack_ch4_1_GLOBALVIEWplus_v5.1_2023-03-08/data/nc/ch4_zep_surface-flask_1_representative.nc
427: Z:/torf/obspack_ch4_1_GLOBALVIEWplus_v5.1_2023-03-08/data/nc/ch4_zep_surface-insitu_442_allvalid-15magl.nc
428: Z:/torf/obspack_ch4_1_GLOBALVIEWplus_v5.1_2023-03-08/data/nc/ch4_zot_surface-flask_45_representative.nc
429: Z:/torf/obspack_ch4_1_GLOBALVIEWplus_v5.1_2023-03-08/data/nc/ch4_zsf_surface-insitu_442_allvalid-3magl.nc
                                              name     n          sector   agl
                                            <char> <int>          <char> <num>
  1:            ch4_aao_aircraft-pfp_1_allvalid.nc     1    aircraft-pfp    NA
  2:       ch4_above_aircraft-insitu_1_allvalid.nc     2 aircraft-insitu    NA
  3:     ch4_abp_surface-flask_1_representative.nc     3   surface-flask    NA
  4:          ch4_abt_surface-insitu_6_allvalid.nc     4  surface-insitu    NA
  5:            ch4_acg_aircraft-pfp_1_allvalid.nc     5    aircraft-pfp    NA
 ---                                                                          
425:   ch4_yon_surface-insitu_19_representative.nc   425  surface-insitu    NA
426:     ch4_zep_surface-flask_1_representative.nc   426   surface-flask    NA
427: ch4_zep_surface-insitu_442_allvalid-15magl.nc   427  surface-insitu    15
428:    ch4_zot_surface-flask_45_representative.nc   428   surface-flask    NA
```
