Skip to content

Accessing and appending met.no climate files #15

@pvanlaake

Description

@pvanlaake

On met.no climate observation data is stored as a single time step per file with a 6 hour resolution. These individual files can be retrieved efficiently by first subsetting to a smaller area, then downloading the data and merging it into a single CFVariable:

library(ncdfCF)

# Open the two files
ds   <- open_ncdf("https://thredds.met.no/thredds/dodsC/nora3/1961/08/01/00/fc1961080100_003_sfx.nc")
ds06 <- open_ncdf("https://thredds.met.no/thredds/dodsC/nora3/1961/08/01/06/fc1961080106_003_sfx.nc")

# Open TS variables - no data is being read
ts   <- ds[["TS"]]
ts06 <- ds06[["TS"]]
ts
#> <Variable> TS 
#> Long name: Surface temperature 
#> 
#> Values: (not loaded)
#> 
#> Coordinate reference system:
#>  name               grid_mapping           
#>  projection_lambert lambert_conformal_conic
#> 
#> Axes:
#>  axis name             long_name                        length values                      unit                                    
#>  X    x                x-coordinate in Cartesian system 889    [778360.875 ... 3442360.75] m
#>  Y    y                y-coordinate in Cartesian system 1489   [-1270477 ... 3193523]      m  
#>       grib1_vLevel1052 grib1-level 105                  1      [0] 
#>  T    time                                              1-U    [1961-08-01T03:00:00]       seconds since 1970-01-01 00:00:00 +00:00
#> 
#> Auxiliary longitude-latitude grid:
#>  axis name      extent               unit         
#>  X    longitude [-30.168 ... 85.793] degrees_east 
#>  Y    latitude  [44.025 ... 84.057]  degrees_north
#> 
#> Attributes:
#>  name          type    length value              
#>  units         NC_CHAR  1     K                  
#>  standard_name NC_CHAR 15     air_temperature    
#>  long_name     NC_CHAR 19     Surface temperature
#>  grid_mapping  NC_CHAR 18     projection_lambert 
#>  coordinates   NC_CHAR 18     longitude latitude 
#>  _ChunkSizes   NC_INT   4     1, 1, 1489, 889

# Subset to a smaller area of 200 x 400km - still no data being read
tssmall   <- ts$subset(x = c(2400000, 2600000), y = c(0, 400000))
ts06small <- ts06$subset(x = c(2400000, 2600000), y = c(0, 400000))
tssmall
#> <Variable> TS 
#> Long name: Surface temperature 
#> 
#> Values: (not loaded)
#> 
#> Coordinate reference system:
#>  name               grid_mapping           
#>  projection_lambert lambert_conformal_conic
#> 
#> Axes:
#>  axis name             long_name                        length values                        unit
#>  X    x                x-coordinate in Cartesian system 67     [2401360.75 ... 2599360.75]   m
#>  Y    y                y-coordinate in Cartesian system 133    [1523.02124 ... 397523.03125] m 
#>       grib1_vLevel1052 grib1-level 105                  1      [0] 
#>  T    time                                              1-U    [1961-08-01T03:00:00]         seconds since 1970-01-01 00:00:00 +00:00
#>                                      
#> Attributes:
#>  name          type    length value              
#>  units         NC_CHAR  1     K                  
#>  standard_name NC_CHAR 15     air_temperature    
#>  long_name     NC_CHAR 19     Surface temperature
#>  grid_mapping  NC_CHAR 18     projection_lambert 
#>  coordinates   NC_CHAR 18     longitude latitude 
#>  _ChunkSizes   NC_INT   4     1, 1, 1489, 889

# Merge the CFVariables along the time dimension - this forces data to be read
# from the server. Note that the "time" axis is now of length 2.
tssmall$append(ts06small, "time")
#> Warning in min(x): no non-missing arguments to min; returning Inf
#> Warning in max(x): no non-missing arguments to max; returning -Inf
tssmall
#> <Variable> TS 
#> Long name: Surface temperature 
#> 
#> Values: [272.76 ... 298.79] K
#>     NA: 5704 (32.0%)
#> 
#> Coordinate reference system:
#>  name               grid_mapping           
#>  projection_lambert lambert_conformal_conic
#> 
#> Axes:
#>  axis name             long_name                        length values                                        unit 
#>  X    x                x-coordinate in Cartesian system  67    [2401360.75 ... 2599360.75]                   m
#>  Y    y                y-coordinate in Cartesian system 133    [1523.02124 ... 397523.03125]                 m
#>       grib1_vLevel1052 grib1-level 105                    1    [0] 
#>  T    time                                                2    [1961-08-01T03:00:00 ... 1961-08-01T09:00:00] seconds since 1970-01-01 00:00:00 +00:00
#> 
#> Attributes:
#>  name          type      length value              
#>  units         NC_CHAR    1     K                  
#>  standard_name NC_CHAR   15     air_temperature    
#>  long_name     NC_CHAR   19     Surface temperature
#>  grid_mapping  NC_CHAR   18     projection_lambert 
#>  coordinates   NC_CHAR   18     longitude latitude 
#>  _ChunkSizes   NC_INT     4     1, 1, 1489, 889    
#>  actual_range  NC_DOUBLE  2     272.76, 298.79

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions