mikejohnson51 / opendap.catalog

Flexible backend for getting data from Web and local NetCDF resources into R
https://mikejohnson51.github.io/opendap.catalog
Other
7 stars 2 forks source link

Improve tiling output in dap_summary #11

Closed mikejohnson51 closed 2 years ago

mikejohnson51 commented 2 years ago

TODOs:

In the event of XY or T aggregate, summary now produces three "erroneous" outputs:

Collective these

XY example

# Find MODIS PET in Florida for January 2010
(
  [dap](https://mikejohnson51.github.io/opendap.catalog/reference/dap.html) = dap(
    catolog = dplyr::[filter](https://dplyr.tidyverse.org/reference/filter.html)(params, 
                            id == 'MOD16A2.006', 
                            varname == 'PET_500m'),
    AOI = AOI::[aoi_get](https://rdrr.io/pkg/AOI/man/aoi_get.html)(state = "FL"),
    startDate = "2010-01-01",
    endDate   = "2010-01-31"
  )
)
#> source:        https://opendap.cr.usgs.gov/opendap/hyrax/MOD16A2.006/h10v05.ncml 
#> varname(s):
#>    > PET_500m [kg/m^2/8day] (MODIS Gridded 500m 8-day Composite potential Evapotranspiration (ET))
#>    > PET_500m [kg/m^2/8day] (MODIS Gridded 500m 8-day Composite potential Evapotranspiration (ET))
#> ==================================================
#> diminsions:  1336 - 1336, 240 - 1321, 5 (names: XDim,YDim,time)
#> resolution:  463.313, 463.313, 8 days
#> extent:      -8404029.365, -7785506.889, 3336314.872, 3447046.611 (xmin, xmax, ymin, ymax) -8404029.365, -7785506.889, 2724278.773, 3335851.559 (xmin, xmax, ymin, ymax)
#> crs:         +proj=sinu +lon_0= +x_0= +y_0= +units=m +a=6371007...
#> time:        2010-01-02 to 2010-02-03
#> ==================================================
#> values: 5,658,834,278,400 (vars*X*Y*T)

T example

maca_ex = filter(tmp,  scenario %in% c("historical", 'rcp85'))

system.time({
  dap = dap_crop(catolog = maca_ex, 
                 AOI =  AOI::aoi_get(state = "NC"), 
                 startDate = "2005-12-25", endDate = "2006-01-05") |> 
    dap_get()
})

#> source:        http://thredds.northwestknowledge.net:8080/thredds/dodsC/agg_macav2metdata_huss_BNU-ESM_r1i1p1_historical_1950_2005_CONUS_daily.nc 
#> varname(s):
#>    > specific_humidity [kg kg-1] (Daily Mean Near-Surface Specific Humidity)
#>    > specific_humidity [kg kg-1] (Daily Mean Near-Surface Specific Humidity)
#> ==================================================
#> diminsions:  214, 67, 7 (names: lon,lat,time) 214, 67, 5 (names: lon,lat,time)
#> resolution:  0.042, 0.042, 1 days
#> extent:      -84.314, -75.44, 33.855, 36.605 (xmin, xmax, ymin, ymax)
#> crs:         +proj=longlat +a=6378137 +f=0.00335281066474748 +p...
#> time:        2005-12-25 to 2005-12-31
#> ==================================================
#> values: 200,732 143,380 (vars*X*Y*T)
#>    user  system elapsed 
#>   0.106   0.040   1.659

Solution

When duplicate variables arise merge and aggregate summary stats!

#> source:        http://thredds.northwestknowledge.net:8080/thredds/dodsC/agg_macav2metdata_huss_BNU-ESM_r1i1p1_historical_1950_2005_CONUS_daily.nc 
#> varname(s):
#>    > [2 T tiles] specific_humidity [kg kg-1] (Daily Mean Near-Surface Specific Humidity)
#> ==================================================
#> dimensions:  214, 67, 11 (names: lon,lat,time) 214, 67, 5 (names: lon,lat,time)
#> resolution:  0.042, 0.042, 1 days
#> extent:      -84.314, -75.44, 33.855, 36.605 (xmin, xmax, ymin, ymax)
#> crs:         +proj=longlat +a=6378137 +f=0.00335281066474748 +p...
#> time:        2005-12-25 to 2006-01-05
#> ==================================================
#> values: 157,718 (vars*X*Y*T)