Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • startR startR
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 29
    • Issues 29
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 7
    • Merge requests 7
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Earth SciencesEarth Sciences
  • startRstartR
  • Issues
  • #118
Closed
Open
Issue created Oct 20, 2021 by acarreri@acarreriDeveloper

Returning the attributes of the variable with retrieve=F in a StartR load

Hi @aho , @nperez ,

Right now, we don't have the attributes of the variables (such as the units for instance) when using retrieve=F in a startR call.

Would it be possible to add it at some point? It's useful for me when I want then to save the data in a netcdf file with the correct metadata for instance.

Part of a script that can be used (part of this one: /esarchive/scratch/Earth/acarreri/scripts/bkup_scripts_HR_forecast/scripts_R/1-1.Load_and_save_seasonal_forecast_timeseries_rawvalues_ocean_seaice_variables.R):

library(startR)

expid <- 'a3vg'
model <- 'EC-Earth3-HR'
compo  <- 'Omon'
grid <- 'gn'
vari <- 'tosmean'
reg <- 'Nino3'
startdates <- as.character(c(seq(1990,1992)))
init_month <- 5
length_forecast <- 4
membs_num <- c(seq(1,2))

forecast_month <- c(seq(init_month,(init_month+length_forecast-1)))
membs <- paste0('r', membs_num, 'i1p1f1', sep="")

path <- paste0('/esarchive/exp/ecearth/', expid, '/diags/DCPP/EC-Earth-Consortium/', model, '/dcppA-hindcast/$memb$/', compo, '/$var$/', grid, '/v*/$var$_', compo, '_', model, '_dcppA-hindcast_s$sdate$-$memb$_', grid, '_$chunk$.nc')

data_exp_retrieved <- startR::Start(dat = path,
                          var = vari,
                          memb = membs,
                          region = reg,
                          region_var = 'region',
                          sdate = startdates,
                          time = c(1:length(forecast_month)), 
                          chunk = 'all',
                          chunk_depends = 'sdate',
                          time_across = 'chunk', 
                          merge_across_dims = TRUE,
                          return_vars = list(time=c('sdate','chunk'), region=NULL), 
                          retrieve = T)

print(attr(data_exp_retrieved,"Variables")$common[[vari]]$units)

return the correct units with retrieve=T but returns NULL with retrieve=F.

Many thanks

Edited Oct 20, 2021 by acarreri
Assignee
Assign to
Time tracking