Skip to contents

Each obspack file has a header with metadata and this function reads selected fields from the metadata and add them as columns. This new columns are used later to be filtered

Usage

obs_read(
  index,
  categories = "flask",
  expr = NULL,
  verbose = TRUE,
  n_site_code = 15,
  n_site_latitude = 18,
  n_site_longitude = 19,
  n_site_name = 15,
  n_site_country = 18,
  n_dataset_project = 21,
  n_lab = 16,
  n_scales = 31,
  n_site_elevation = 20,
  n_altitude_comment = 22,
  n_utc = 18,
  fill_value = -1e+34,
  as_list = FALSE
)

Arguments

index

data.table

categories

character; ONE category : of c("aircraft-pfp", "aircraft-insitu", "surface-insitu", "tower-insitu", "aircore", "surface-pfp", "shipboard-insitu", "flask").

expr

String expressions to filter data.table internally

verbose

Logical to show more information

n_site_code

number of characters extratced from metadata after search

n_site_latitude

number of characters extracted from metadata after search

n_site_longitude

number of characters extracted from metadata after search

n_site_name

number of characters extracted from metadata after search

n_site_country

number of characters extracted from metadata after search

n_dataset_project

number of characters extracted from metadata after search

n_lab

number of characters extracted from metadata after search

n_scales

number of characters extracted from metadata after search

n_site_elevation

number of characters extracted from metadata after search

n_altitude_comment

number of characters extracted from metadata after search

n_utc

number of characters extracted from metadata after search

fill_value

fill value. Appeared in aoa_aircraft-flask_19_allvalid.txt

as_list

Logical to return as list

Value

A data.frame with with an index obspack.

Note

The identification of the altitude and type is critical. The approach used here consists of: 1. Identify agl from the name of the tile. 2. If magl not present, search dill_values used in elevation and transform them into NA (not available) 3. If magl is not present, agl = altitude - elevation 4. If there are some NA in elevation, will result some NA in agl 5. A new column is added named `altitude_final` to store agl or asl 6. Another column named `type_altitude` is added to identify "magl" or "masl" 7. If there is any case NA in `altitude_final`, `type_altitude` is "not available"

Then, the relationship with hysplit is:

type_altitudehysplitmagl
aglmaslasl
not availablef-PBL

Examples

{
# Do not run
obs <- system.file("data-raw", package = "rtorf")
index <- obs_summary(obs)
dt <- obs_read(index)
obs_read(index, expr = "altitude_final == '5800'")
}
#> Number of files of index: 1
#>           sector     N
#>           <char> <int>
#> 1:         flask     1
#> 2: Total sectors     1
#> Detected 0 files with agl
#> Detected 1 files without agl
#> Searching flask...
#> 1: ch4_aoa_aircraft-flask_19_allvalid.txt
#> Searching flask...
#> 1: ch4_aoa_aircraft-flask_19_allvalid.txt
#>       year month   day  hour minute second       time start_time midpoint_time
#>      <int> <int> <int> <int>  <int>  <int>      <int>      <int>         <int>
#>   1:  2011     2    16     2     17     30 1297822650 1297822440    1297822650
#>   2:  2011     2    16     2     26     30 1297823190 1297822980    1297823190
#>   3:  2011     2    16     2     33     30 1297823610 1297823400    1297823610
#>   4:  2011     2    16     2     40     30 1297824030 1297823820    1297824030
#>   5:  2011     2    16     2     47     30 1297824450 1297824240    1297824450
#>  ---                                                                          
#> 226:  2019     3    14     2     15     30 1552529730 1552529520    1552529730
#> 227:  2019     3    14     2     22     30 1552530150 1552529940    1552530150
#> 228:  2019     5    15     5     10     30 1557897030 1557896820    1557897030
#> 229:  2019     9     4     7     54     30 1567583670 1567583460    1567583670
#> 230:  2020     3    10     6     42     30 1583822550 1583822340    1583822550
#>      time_decimal      value nvalue latitude longitude altitude elevation
#>             <num>      <num>  <int>    <num>     <num>    <num>     <num>
#>   1:     2011.126 1.8464e-06      1   34.429   141.037     5800  -999.999
#>   2:     2011.126 1.8428e-06      1   34.058   141.830     5800  -999.999
#>   3:     2011.126 1.8502e-06      1   33.770   142.447     5800  -999.999
#>   4:     2011.126 1.8477e-06      1   33.480   143.052     5800  -999.999
#>   5:     2011.126 1.8393e-06      1   33.162   143.708     5800  -999.999
#>  ---                                                                     
#> 226:     2019.198 1.9945e-06      1   33.249   143.529     5800  -999.999
#> 227:     2019.198 1.9745e-06      1   32.885   144.267     5800  -999.999
#> 228:     2019.368 1.8902e-06      1   24.819   152.060     5800  -999.999
#> 229:     2019.675 1.8798e-06      1   24.327   152.091     5800  -999.999
#> 230:     2020.189 1.9433e-06      1   24.885   151.834     5800  -999.999
#>      intake_height qcflag method unique_sample_location_num obs_flag obs_num
#>              <num>  <int>  <int>                      <int>    <int>   <int>
#>   1:      -999.999      1     18                    8768042        1       1
#>   2:      -999.999      1     18                    8767980        1       2
#>   3:      -999.999      1     18                    8767880        1       3
#>   4:      -999.999      1     18                    8767781        1       4
#>   5:      -999.999      1     18                    8767708        1       5
#>  ---                                                                        
#> 226:      -999.999      1     18                    8767761        1    2278
#> 227:      -999.999      1     18                    8767655        1    2279
#> 228:      -999.999      1     18                    8766225        1    2339
#> 229:      -999.999      1     18                    8765601        1    2441
#> 230:      -999.999      1     18                   44498114        1    2573
#>      obspack_num
#>            <int>
#>   1:     5536255
#>   2:     5536256
#>   3:     5536257
#>   4:     5536258
#>   5:     5536259
#>  ---            
#> 226:     5538532
#> 227:     5538533
#> 228:     5538593
#> 229:     5538695
#> 230:     5538827
#>                                                                                   obspack_id
#>                                                                                       <char>
#>   1: obspack_ch4_1_GLOBALVIEWplus_v4.0_2021-10-14~ch4_aoa_aircraft-flask_19_allvalid~5536255
#>   2: obspack_ch4_1_GLOBALVIEWplus_v4.0_2021-10-14~ch4_aoa_aircraft-flask_19_allvalid~5536256
#>   3: obspack_ch4_1_GLOBALVIEWplus_v4.0_2021-10-14~ch4_aoa_aircraft-flask_19_allvalid~5536257
#>   4: obspack_ch4_1_GLOBALVIEWplus_v4.0_2021-10-14~ch4_aoa_aircraft-flask_19_allvalid~5536258
#>   5: obspack_ch4_1_GLOBALVIEWplus_v4.0_2021-10-14~ch4_aoa_aircraft-flask_19_allvalid~5536259
#>  ---                                                                                        
#> 226: obspack_ch4_1_GLOBALVIEWplus_v4.0_2021-10-14~ch4_aoa_aircraft-flask_19_allvalid~5538532
#> 227: obspack_ch4_1_GLOBALVIEWplus_v4.0_2021-10-14~ch4_aoa_aircraft-flask_19_allvalid~5538533
#> 228: obspack_ch4_1_GLOBALVIEWplus_v4.0_2021-10-14~ch4_aoa_aircraft-flask_19_allvalid~5538593
#> 229: obspack_ch4_1_GLOBALVIEWplus_v4.0_2021-10-14~ch4_aoa_aircraft-flask_19_allvalid~5538695
#> 230: obspack_ch4_1_GLOBALVIEWplus_v4.0_2021-10-14~ch4_aoa_aircraft-flask_19_allvalid~5538827
#>                                        name sector site_code
#>                                      <char> <char>    <char>
#>   1: ch4_aoa_aircraft-flask_19_allvalid.txt  flask       AOA
#>   2: ch4_aoa_aircraft-flask_19_allvalid.txt  flask       AOA
#>   3: ch4_aoa_aircraft-flask_19_allvalid.txt  flask       AOA
#>   4: ch4_aoa_aircraft-flask_19_allvalid.txt  flask       AOA
#>   5: ch4_aoa_aircraft-flask_19_allvalid.txt  flask       AOA
#>  ---                                                        
#> 226: ch4_aoa_aircraft-flask_19_allvalid.txt  flask       AOA
#> 227: ch4_aoa_aircraft-flask_19_allvalid.txt  flask       AOA
#> 228: ch4_aoa_aircraft-flask_19_allvalid.txt  flask       AOA
#> 229: ch4_aoa_aircraft-flask_19_allvalid.txt  flask       AOA
#> 230: ch4_aoa_aircraft-flask_19_allvalid.txt  flask       AOA
#>                                                   site_name site_country
#>                                                      <char>       <char>
#>   1: Aircraft Observation of Atmospheric trace gases by JMA        Japan
#>   2: Aircraft Observation of Atmospheric trace gases by JMA        Japan
#>   3: Aircraft Observation of Atmospheric trace gases by JMA        Japan
#>   4: Aircraft Observation of Atmospheric trace gases by JMA        Japan
#>   5: Aircraft Observation of Atmospheric trace gases by JMA        Japan
#>  ---                                                                    
#> 226: Aircraft Observation of Atmospheric trace gases by JMA        Japan
#> 227: Aircraft Observation of Atmospheric trace gases by JMA        Japan
#> 228: Aircraft Observation of Atmospheric trace gases by JMA        Japan
#> 229: Aircraft Observation of Atmospheric trace gases by JMA        Japan
#> 230: Aircraft Observation of Atmospheric trace gases by JMA        Japan
#>      site_elevation site_latitude site_longitude dataset_project lab_1_abbr
#>              <lgcl>        <char>         <char>          <char>     <char>
#>   1:             NA        -1e+34         -1e+34  aircraft-flask        JMA
#>   2:             NA        -1e+34         -1e+34  aircraft-flask        JMA
#>   3:             NA        -1e+34         -1e+34  aircraft-flask        JMA
#>   4:             NA        -1e+34         -1e+34  aircraft-flask        JMA
#>   5:             NA        -1e+34         -1e+34  aircraft-flask        JMA
#>  ---                                                                       
#> 226:             NA        -1e+34         -1e+34  aircraft-flask        JMA
#> 227:             NA        -1e+34         -1e+34  aircraft-flask        JMA
#> 228:             NA        -1e+34         -1e+34  aircraft-flask        JMA
#> 229:             NA        -1e+34         -1e+34  aircraft-flask        JMA
#> 230:             NA        -1e+34         -1e+34  aircraft-flask        JMA
#>      dataset_calibration_scale
#>                         <char>
#>   1:            WMO CH4 X2004A
#>   2:            WMO CH4 X2004A
#>   3:            WMO CH4 X2004A
#>   4:            WMO CH4 X2004A
#>   5:            WMO CH4 X2004A
#>  ---                          
#> 226:            WMO CH4 X2004A
#> 227:            WMO CH4 X2004A
#> 228:            WMO CH4 X2004A
#> 229:            WMO CH4 X2004A
#> 230:            WMO CH4 X2004A
#>                                                              altitude_comment
#>                                                                        <char>
#>   1: Altitude (in meters above sea level). See provider_comment if available.
#>   2: Altitude (in meters above sea level). See provider_comment if available.
#>   3: Altitude (in meters above sea level). See provider_comment if available.
#>   4: Altitude (in meters above sea level). See provider_comment if available.
#>   5: Altitude (in meters above sea level). See provider_comment if available.
#>  ---                                                                         
#> 226: Altitude (in meters above sea level). See provider_comment if available.
#> 227: Altitude (in meters above sea level). See provider_comment if available.
#> 228: Altitude (in meters above sea level). See provider_comment if available.
#> 229: Altitude (in meters above sea level). See provider_comment if available.
#> 230: Altitude (in meters above sea level). See provider_comment if available.
#>      site_utc2lst   agl type_altitude altitude_final    id
#>             <num> <num>         <num>          <num> <int>
#>   1:            9    NA             1           5800     1
#>   2:            9    NA             1           5800     1
#>   3:            9    NA             1           5800     1
#>   4:            9    NA             1           5800     1
#>   5:            9    NA             1           5800     1
#>  ---                                                      
#> 226:            9    NA             1           5800     1
#> 227:            9    NA             1           5800     1
#> 228:            9    NA             1           5800     1
#> 229:            9    NA             1           5800     1
#> 230:            9    NA             1           5800     1