BoulderCodeHub / RWDataPlyr

R package to read and manipulate data from RiverWareTM
3 stars 5 forks source link

add functionality for csv files created from RiverWare/RiverSMART #30

Closed rabutler closed 6 years ago

rabutler commented 8 years ago

Now that RiverWare and RiverSMART can create csv files, we want to be able to handle those too. Probably includes a lot, but highest priority is ability to pass that data frame and an slot agg list to the aggregation functions and get the same data frame back as we would from an rdf.

rabutler commented 7 years ago

Will need to be able to read in single csv files and csv files that have been combined in RiverSMART

  1. create readRwCsv()
    • it will read in the csv
    • remove spaces from column names
    • check that it has the expected column names (required and optional)
    • possibly could have it make a new object that contains tables to convert slots to variable names, etc.
  2. rdfToTbl(read.rdf2()) to read in an rdf and create a dataframe/tbl that is the same as the dataframe returned by read_rw_csv()
rabutler commented 7 years ago
rabutler commented 7 years ago

rdfToTbl(rdf, scenario = NULL)

if scenario is NULL, then do not add Scenario column

rabutler commented 7 years ago

For rw_rdf_to_tbl()


It works with yearly data just fine. The Timestep is yyyy-12-31 for each value. Don't think we need to do anything special to handle annual data.


To limit the variables, we can use reqColumns() + maybe some others? And take this as an argument to the function. Need to figure out which values are always saved from our default RW csv output. But also need to be able to handle when those columns aren't there.

rabutler commented 7 years ago

csv output is in mm-dd-yyyy 23:59:00 format rdf contains timesteps in yyyy-m-dd 24:00 format


rw_read_rw_csv() now converts from mm-dd-yyyy format to yyyy-m-dd format to be closer to the tbl returned by rw_rdf_to_tbl(), but it left the hours-seconds alone. Since we'll probably convert to yearmon for comparison anyways, they should now be the same.