pik-piam / remind

Contains the REMIND-specific routines for data and model output manipulation.
3 stars 18 forks source link

unit format US$2005/(tCO2/yr) does not conform to magclass unit format #118

Open 0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q opened 3 years ago

0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q commented 3 years ago

https://github.com/pik-piam/remind/blob/6dad76df6a813cf64da815f84a2b9f7b59433a28/R/reportTechnology.R#L233-L238

The unit US$2005/(tCO2/yr) breaks the magclass unit convention, which does not support nested parentheses. Specifically

library(remind)
library(quitte)

a <- convGDX2MIF(gdx = './tests/testgdxs/fulldata.gdx')

as.quitte(a)
Error in magclass::`getNames<-`(`*tmp*`, value = sub(" \\(([^\\()]*)\\)($|\\.)",  : 
  Inconsistent names! Number of dots per name has always to be the same as it is separating different data dimensions
In addition: There were 21 warnings (use warnings() to see them)

as.quitte(a[,,'(US$2005/(tCO2/yr))', pmatch = TRUE, invert = TRUE])
# A tibble: 371,241 x 7
   model  scenario region variable    unit               period value
   <fct>  <fct>    <fct>  <fct>       <fct>               <int> <dbl>
 1 REMIND default  CAZ    Consumption billion US$2005/yr   2005 1123.
 2 REMIND default  CHA    Consumption billion US$2005/yr   2005 1625.
 3 REMIND default  EUR    Consumption billion US$2005/yr   2005 8759.
 4 REMIND default  IND    Consumption billion US$2005/yr   2005  520.
 5 REMIND default  JPN    Consumption billion US$2005/yr   2005 3031.
 6 REMIND default  LAM    Consumption billion US$2005/yr   2005 1867.
 7 REMIND default  MEA    Consumption billion US$2005/yr   2005  985.
 8 REMIND default  NEU    Consumption billion US$2005/yr   2005  942.
 9 REMIND default  OAS    Consumption billion US$2005/yr   2005 1324.
10 REMIND default  REF    Consumption billion US$2005/yr   2005  597.
# … with 371,231 more rows