NREL / rplexos

Other
18 stars 13 forks source link

[Question] How to query samples #25

Closed danielsjf closed 9 years ago

danielsjf commented 9 years ago

Hi eibanez,

I'm trying to query samples. According to the help file this should be possible by adding a filter, but I can't get it to work. Could you maybe include some examples in the next version of Rplexos for the different filters? Sometimes it is hard to guess which format is required without starting to dig in the sql tables. E.g. the function getSamples(db) returns all the possible samples that you can query.

> getSamples(db)
[1] "Mean" "Sample1" "Sample2"

I tried some variations on Sample1, but I have the feeling that only Mean is included. Is it possible that I have done something wrong in the generation of the .db file? My Plexos file has different samples.

MyQuery=query_interval(db,
                       "Generator",
                       "Generation",
                       phase=4,
                       c("category","region"),
                       filter=list(sample='Sample1') )

Kind regards

danielsjf commented 9 years ago

I found a query which returns different samples, but there is no way to select them. The normal query (without filter) returns the samples as 'Mean', '1', '2', '3', ... However, no single input in the filter yields only one sample. I tried integers, numerics, characters, and combinations with the word 'sample'.

Any advice?

eibanez commented 9 years ago

I tried and these work for me:

query_year(db, "Generator", "Generation", filter = list(sample = "Mean"))
query_year(db, "Generator", "Generation", filter = list(sample = "2"))
query_year(db, "Generator", "Generation", filter = list(sample = 1))
query_interval(db, "Generator", "Generation", filter = list(sample = "Mean"))
query_interval(db, "Generator", "Generation", filter = list(sample = "2"))
query_interval(db, "Generator", "Generation", filter = list(sample = 1))
eibanez commented 9 years ago

The new function query_sample will return the correct samples that are available. Let me know if you still have problems.