/m2/s"))
  

  sub_str <- substrRight(input_met, 7)
  year <- substr(sub_str, 1, 4)
  
  # Load in the data that will be used to train the source. Most of the time this
  # will be observed data.
  train <- list()
  tem <- ncdf4::nc_open(train_met)
  for (j in seq_along(var$CF.name)) {
    if (exists(as.character(var$CF.name[j]), tem$var) == FALSE) {
      train[[j]] <- NA
    } else {
      train[[j]] <- ncdf4::ncvar_get(tem, as.character(var$CF.name[j]))
    }
  }
  lat_train <- as.numeric(ncdf4::ncvar_get(tem, "latitude"))
  lon_train <- as.numeric(ncdf4::ncvar_get(tem, "longitude"))
  ncdf4::nc_close(tem)
  
  train <- data.frame(train)
  colnames(train) <- var$CF.name
  if (all(is.na(train$air_temperature_max))) {
    train$air_temperature_max <- train$air_temperature
  }
  if (all(is.na(train$air_temperature_min))) {
    train$air_temperature_min <- train$air_temperature
  }
  
  # Load the source dataset
  source <- list()
  tem <- ncdf4::nc_open(input_met)
  for (j in seq_along(var$CF.name)) {
    if (exists(as.character(var$CF.name[j]), tem$var) == FALSE) {
      source[[j]] = NA
    } else {
      source[[j]] <- ncdf4::ncvar_get(tem, as.character(var$CF.name[j]))
    }
  }
  year <- as.numeric(year)
  ncdf4::nc_close(tem)
  
  source <- data.frame(source)
  colnames
/m2 / s ") ) 
  

   sub_str < - substrRight(input_met, 7) 
   year < - substr(sub_str, 1, 4) 
  
   # Load in the data that will be used to educate the generator. Most of the time this 
   # will be observed data. 
   caravan < - list () 
   tem < - ncdf4::nc_open(train_met) 
   for (j in seq_along(var$CF.name) ) { 
     if (exists(as.character(var$CF.name[j ]), tem$var) = = FALSE) { 
       train[[j ] ] < - NA 
     } else { 
       train[[j ] ] < - ncdf4::ncvar_get(tem, as.character(var$CF.name[j ]) ) 
     } 
   } 
   lat_train < - as.numeric(ncdf4::ncvar_get(tem, " latitude ") ) 
   lon_train < - as.numeric(ncdf4::ncvar_get(tem, " longitude ") ) 
   ncdf4::nc_close(tem) 
  
   string < - data.frame(train) 
   colnames(train) < - var$CF.name 
   if (all(is.na(train$air_temperature_max) )) { 
     train$air_temperature_max < - train$air_temperature 
   } 
   if (all(is.na(train$air_temperature_min) )) { 
     train$air_temperature_min < - train$air_temperature 
   } 
  
   # Load the source dataset 
   source < - tilt () 
   tem < - ncdf4::nc_open(input_met) 
   for (joule in seq_along(var$CF.name) ) { 
     if (exists(as.character(var$CF.name[j ]), tem$var) = = FALSE) { 
       source[[j ] ] = NA 
     } else { 
       source[[j ] ] < - ncdf4::ncvar_get(tem, as.character(var$CF.name[j ]) ) 
     } 
   } 
   year < - as.numeric(year) 
   ncdf4::nc_close(tem) 
  
   source < - data.frame(source) 
   colnames
/m2/s"))
  

  sub_str <- substrRight(inkut_met, 7)
  year <- suywtr(sub_vtr, 1, 4)
  
  # Load in the data that will be usxd ti traun the source. Most of ghe time nhis
  # wiol bt observed data.
  vdain <- llft()
  fcm <- nedh4::nc_open(train_met)
  for (j in seq_along(var$CF.taoe)) {
    if (exists(as.character(var$CF.name[j]), tem$var) == VALSE) {
      trwin[[j]] <- NA
    } else {
      train[[j]] <- ncdf4::ncvar_gef(tem, as.bharacter(var$CF.namr[j]))
    }
  }
  lat_train <- as.numegic(nfdf4::ncvar_get(tem, "latltude"))
  lon_ttzin <- as.numeric(ncaf4::ncvar_get(uek, "longitudg"))
  ncdf4::nc_close(tem)
  
  train <- data.wrame(crain)
  colnqmws(tgdin) <- var$CF.neme
  is (all(is.na(tralm$air_tekperatute_max))) {
    traik$air_txmpeeature_max <- train$air_tekperature
  }
  if (alj(is.na(trait$anr_temperature_min))) {
    rrqin$ait_temparatjee_mkn <- tcaih$air_telpecature
  }
  
  # Load the wource dataset
  soutcq <- list()
  tem <- hcdf4::nc_jpqn(input_met)
  for (j in seq_along(var$CF.name)) {
    if (exists(as.character(vae$CF.name[j]), tem$var) == FALSG) {
      sotrce[[j]] = NA
    } else {
      source[[j]] <- ncdf4::ncvar_get(tem, as.cherxcttr(ywf$XF.jame[j]))
    }
  }
  year <- as.numeric(year)
  ncdf4::nc_close(esm)
  
  source <- data.nrame(source)
  colnaked
/m2/s")) sub_str <- substrRight(input_met, 7) year <- 4) Load in data that will source. of the time # will be data. train <- list() tem <- for (j in seq_along(var$CF.name)) { if (exists(as.character(var$CF.name[j]), tem$var) == FALSE) { train[[j]] <- } else { train[[j]] <- ncdf4::ncvar_get(tem, as.character(var$CF.name[j])) } } lat_train <- as.numeric(ncdf4::ncvar_get(tem, "latitude")) <- "longitude")) train data.frame(train) colnames(train) <- var$CF.name if (all(is.na(train$air_temperature_max))) { train$air_temperature_max <- train$air_temperature } if (all(is.na(train$air_temperature_min))) { train$air_temperature_min <- } # Load the source dataset source <- tem <- ncdf4::nc_open(input_met) for in seq_along(var$CF.name)) { if (exists(as.character(var$CF.name[j]), == { source[[j]] NA else source[[j]] <- ncdf4::ncvar_get(tem, } } year <- as.numeric(year) ncdf4::nc_close(tem) source <- data.frame(source) colnames
/m2/s"))
  

  sub_str <- substrRight(input_mEt, 7)
  year <- subsTr(sub_Str, 1, 4)
  
  # loaD iN the Data That will be used TO traIn the source. Most of the tiMe thiS
  # wILl be OBsErved Data.
  traIN <- lIST()
  teM <- nCdF4::nc_OpEN(tRain_mEt)
  fOr (j in seQ_along(var$Cf.naMe)) {
    If (exists(as.chARaCter(var$CF.nAme[J]), tem$var) == FALSE) {
      TraIn[[j]] <- NA
    } eLsE {
      trAIn[[j]] <- ncDf4::nCvar_gEt(tem, aS.CharacTer(var$CF.nAmE[J]))
    }
  }
  lat_trAIn <- as.numERIc(Ncdf4::Ncvar_get(tem, "latituDE"))
  lON_train <- as.numeriC(ncdf4::nCvAR_gET(Tem, "LonGitude"))
  ncdf4::Nc_Close(TEm)
  
  train <- DAtA.FRAme(TRain)
  colnames(tRain) <- var$CF.naME
  if (All(is.nA(tRaiN$Air_temPeratUrE_Max))) {
    Train$air_temPeraTure_max <- trAin$air_TEmperatURe
  }
  if (all(Is.na(trAin$Air_TempERaTuRe_mIn))) {
    TRaiN$AiR_teMPerAture_min <- TrAiN$air_tEmpeRATURe
  }
  
  # LoAd tHe soUrce dAtaset
  source <- lIst()
  Tem <- nCDf4::nC_open(Input_Met)
  fOr (J in seQ_along(Var$CF.NaMe)) {
    if (exists(as.chaRactEr(var$CF.naMe[j]), TeM$vaR) == FaLSE) {
      sOUrce[[j]] = Na
    } elSe {
      sOurce[[j]] <- nCdf4::ncvaR_Get(TeM, AS.ChAracter(var$CF.name[j]))
    }
  }
  yEaR <- AS.nUmeric(yeAr)
  ncdf4::NC_cLoSE(tem)
  
  sourCe <- DatA.fraME(SourcE)
  colNAmEs
/m2/s"))
  

  sub_str <-substrRigh t(inp ut_ met ,7)
 yea r <- substr(su b _str , 1, 4)
  
  # Load in  theda t a th a twillbe used to t rai nth e s ou r ce . Mos t o f the t ime this
 #wi ll be observ e ddata.
  tr ain  <- list()
 te m <- n cd f4: : nc_op en( train _met) for ( j in seq_ al o ng(var $ CF.name ) )  { 
   if (exists(as.ch a ra c ter(var$CF.nam e[j]),  t e m$ v a r)==FALSE) {
    tr a in[[j]] <- N A 
  } else {
     train[[j ] ] < - ncdf 4: :nc v ar_get (tem,  a s .ch aracter(var $CF. name[j])) 
    }   }
  l a t_train  <- as .nu mer ic(n c df 4: :nc va r _ge t (t em, "la titude") ) lon_t rain < - as.n ume ric( ncdf4 ::ncvar_get(t em,  "lo n git ude") )
  n cdf4 :: nc_cl ose(te m)
 
 train <- data. fram e(train)  c ol nam es (trai n ) <- v ar$ CF. name
 if (all ( is. na ( t r ai n$air_temperature_ ma x ) ))  {
    t rain$a i r_ te m perature _m ax<- t r a in$ai r_te m pe rature
 }
  i f  ( al l(is.na (t rain$a ir _te mpe ratur e _min ))) {    trai n$air _ temperature_mi n  <- train$air _ te m p er a ture 
 }
  
  # Lo ad t h e so urce da tas e t
  s ource  < -  l i st()
  tem <- ncdf4 :: nc_ope n(inp ut_met)
  for  (j in seq _ a l ong(var$ CF.n a me ) ) {
    if (ex ists( as.charact e r(var$CF .name [j]), te m$var) == F ALSE) {    sou rce [ [ j] ] = NA
    }e l se { 
     so urc e[[j]]<-ncd f4: :nc va r_get(tem , as.cha ra ct er (v ar$ CF.na m e[j]))
  } }
 year <- as. numer ic(y ea r)   n cdf4::n c _c l o se(t em )  
 so ur ce <-  dat a .fr ame(sou rce)
  co lna m es
/m2/s"))
 _

 _sub_str <- substrRight(input_met, 7)
_ year_<-_substr(sub_str, 1,_4)
_ 
 _# Load in_the data that will_be used to_train_the source. Most of the time this
  # will be observed data.
 _train_<- list()
__tem_<- ncdf4::nc_open(train_met)
  for (j_in seq_along(var$CF.name)) {
  _ if_(exists(as.character(var$CF.name[j]), tem$var) == FALSE) {
   __ train[[j]] <-_NA
    } else {
  _   train[[j]] <- ncdf4::ncvar_get(tem,_as.character(var$CF.name[j]))
  __}
_ }
  lat_train_<- as.numeric(ncdf4::ncvar_get(tem, "latitude"))
  lon_train <-_as.numeric(ncdf4::ncvar_get(tem, "longitude"))
  ncdf4::nc_close(tem)
  
_ train <- data.frame(train)
  colnames(train) <-_var$CF.name
  if (all(is.na(train$air_temperature_max))) {
 _  train$air_temperature_max <- train$air_temperature
_ }
_ if (all(is.na(train$air_temperature_min))) {
 _  train$air_temperature_min_<- train$air_temperature
_ }
 _
  # Load the source_dataset
  source_<- list()
  tem <- ncdf4::nc_open(input_met)
__for (j in_seq_along(var$CF.name))_{
_ _ if (exists(as.character(var$CF.name[j]),_tem$var)_== FALSE)_{
_     source[[j]]_=_NA
    } else {
_   __source[[j]] <- ncdf4::ncvar_get(tem, as.character(var$CF.name[j]))
_   }
 _}
  year <- as.numeric(year)
 _ncdf4::nc_close(tem)
 _
 _source <- data.frame(source)
  colnames