DOI-USGS / mda.streams

backend tools for powstreams
Creative Commons Zero v1.0 Universal
3 stars 8 forks source link

Issue with locate_ts and dimensions of query #233

Closed jordansread closed 8 years ago

jordansread commented 8 years ago

weird bug that I am looking into:

mda.streams::locate_ts(site_name='nwis_0165389205', var_src='baro_nldas', by='either')
Error in query_out[tolower(query_out$title) == tolower(query$title[1]),  : 
  incorrect number of dimensions
jordansread commented 8 years ago
query_out <- query_item_in_folder(text=query$title[1], folder=query$parent[1], limit=limit)
query_out <- query_out[tolower(query_out$title) == tolower(query$title[1]), ]

query_out comes back as empty here

jordansread commented 8 years ago

This site has no ts'es, so I am not sure why this query wouldn't return NA.

chasing this down to the locate_x type of functions, including locate_metab_model and locate_ts.

I would think if no data comes back from one of these locate_ functions, it would return NA (I think?), so this simple query should return NA: locate_metab_model('not_a_model', by="either") instead of triggering that query error.

aappling-usgs commented 8 years ago

I can't reproduce the problem. Definitely strange.

> mda.streams::locate_ts(site_name='nwis_0165389205', var_src='baro_nldas', by='either')
Setting endpoint to www.sciencebase.gov
[1] NA

> query_out <- sbtools::query_item_in_folder("baro_nldas", "nwis_0165389205")
> query_out
data frame with 0 columns and 0 rows
> query_out <- query_out[tolower(query_out$title) == tolower("baro_nldas"), ]
> query_out
data frame with 0 columns and 0 rows

> sessionInfo()
R version 3.2.4 Revised (2016-03-16 r70336)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.4             rLakeAnalyzer_1.7.6     magrittr_1.5            sbtools_0.15.3          unitted_0.2.5           lattice_0.20-33         R6_2.1.2                stringr_1.0.0          
 [9] httr_1.1.0              plyr_1.8.3              dplyr_0.4.3             tools_3.2.4             grid_3.2.4              parallel_3.2.4          DBI_0.3.1               streamMetabolizer_0.9.3
[17] dataRetrieval_2.5.1     lazyeval_0.1.10         assertthat_0.1          readr_0.2.2             reshape2_1.4.1          LakeMetabolizer_1.4.1   tidyr_0.4.1             mda.streams_0.9.3      
[25] rsconnect_0.3.79        curl_0.9.6              geoknife_1.2.1          sp_1.2-2                stringi_1.0-1           XML_3.98-1.4            jsonlite_0.9.19         lubridate_1.5.0        
[33] foreign_0.8-66         
jordansread commented 8 years ago

Wonder if it is the difference in our versions of sbtools... I am sbtools_0.16.0

jordansread commented 8 years ago

guessing it is here: https://github.com/USGS-R/sbtools/commit/0f454e131d7b49f32573c6ca3ec6e7c217f8e4a1

aappling-usgs commented 8 years ago

bet you're right. I just installed sbtools 0.16.0 and now get the same error you do:

> mda.streams::locate_ts(site_name='nwis_0165389205', var_src='baro_nldas', by='either')
Setting endpoint to www.sciencebase.gov
Error in query_out[tolower(query_out$title) == tolower(query$title[1]),  : 
  incorrect number of dimensions

> query_out <- sbtools::query_item_in_folder("baro_nldas", "nwis_0165389205")
> query_out
list()
jordansread commented 8 years ago

created a new issue for this ( #234 ) . For the time being, I will be using < 0.16.0 until we take care of that issue.