Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified header for rvh.write #2

Merged
merged 5 commits into from
Mar 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions R/rvh.cleanHRUs.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ rvh.cleanHRUs<-function(HRUtab,SBtab,area_tol=0.001,merge=FALSE,elev_tol=50,slop
#-----------------------------------------------------------

# get fraction of SB area in each HRU
areavec<-merge(HRUtab["SBID"],SBtab[c("SBID","Area")],by="SBID")$Area
#areavec<-base::merge(HRUtab["SBID"],SBtab[c("SBID","Area")],by="SBID")$Area
SBtab$AreaSB <- SBtab$Area

#areavec=SBtab$Area[HRUtab$SBID] #using index, not ID!!
HRUtab$areafrac<-HRUtab$Area/areavec
HRUtab <- base::merge(HRUtab,SBtab[c("SBID","AreaSB")],by="SBID")
HRUtab$areafrac<-HRUtab$Area/HRUtab$AreaSB

# re-sort HRU dataframe by SBID then by area frac
HRUtab<-HRUtab[with(HRUtab, order(SBID, areafrac)),]
Expand All @@ -61,9 +62,9 @@ rvh.cleanHRUs<-function(HRUtab,SBtab,area_tol=0.001,merge=FALSE,elev_tol=50,slop
HRUtab$remove<-(HRUtab$areafrac<area_tol) & !(HRUtab$ID %in% ProtectedHRUList) # (&& HRUtab$cumareafrac<0.25)

# calculate area correction factors for all HRUs
A<-aggregate(areafrac ~ SBID, FUN = sum, data=HRUtab[HRUtab$remove==FALSE, ])
A<-stats::aggregate(areafrac ~ SBID, FUN = sum, data=HRUtab[HRUtab$remove==FALSE, ])
rownames(A)<-A$SBID
B<-merge(HRUtab["SBID"],A[c("SBID","areafrac")],by="SBID")$areafrac
B<-base::merge(HRUtab["SBID"],A[c("SBID","areafrac")],by="SBID")$areafrac

# unremove HRUs which were eradicating an entire SB
B=ifelse(B==0,1.0,B)
Expand Down
4 changes: 2 additions & 2 deletions R/rvh.write.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ rvh.write<-function(filename,SBtable,HRUtable)#add HRUgroups later
write("# -------------------------------------------------",append=TRUE,file=filename)

write(":SubBasins",append=TRUE,file=filename)
write(":Properties,SBID,Name,Downstream_ID,Profile,ReachLength,Gauged",append=TRUE,file=filename)
write(":Units ,none,none ,none ,km ,none",append=TRUE,file=filename)
write(":Attributes, NAME,DOWNSTREAM_ID,PROFILE,REACH_LENGTH,GAUGED",append=TRUE,file=filename)
write(":Units, none,none ,none ,km ,none",append=TRUE,file=filename)
write.table(SBtable[c('SBID','Name','Downstream_ID','Profile','ReachLength','Gauged')],quote=FALSE,row.names=FALSE,col.names=FALSE,sep=", ",append=TRUE,file=filename)
write(":EndSubBasins",append=TRUE,file=filename)
write(" ",append=TRUE,file=filename)
Expand Down
100 changes: 53 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,53 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->
RavenR
======

RavenR is an R package for handling Raven hydrologic modelling framework inputs, outputs, and diagnostics. Please contact Robert Chlumsky (<rchlumsk@uwaterloo.ca>) for any troubleshooting, bug fixes, or recommendations on future releases.

Installation
------------

You can install RavenR from github with:

``` r
# install.packages("devtools")
library(devtools)
devtools::install_github("rchlumsk/RavenR")
```

Tutorials and Quick Start Guide
-------------------------------

Please see the vignettes or pdf folder for RavenR Tutorials and Quick Start Guides. Sample data is included in the package, so you need only to install the RavenR library and follow along in the guide documents to get started.

\*\*Note that as of v1.2, the vignettes are out of date and will be updated in the next update.

RavenR Wishlist
---------------

Any issues or feature requests can be submitted on Github via the Issues tab. You may also submit feature requests directly to Robert Chlumsky (<rchlumsk@uwaterloo.ca>) via email.

Dependency Installs
-------------------

Note that some of the package dependencies may require the installation of programs outside of R, particularly for Linux users. Refer to specific function helps on how to install various package materials, such as [ImageMagick](https://www.imagemagick.org/script/download.php).

Version Update Notes
--------------------

### 1.2

*Currently in Beta mode for v1.2, please test and submit comments to <rchlumsk@uwaterloo.ca>*

Updated functionality and test data sets for use. New functions include: \* subbasin and HRU plotting from shapefile from custom data or tabular input \* animation of subbasin plots for custom data \* watershed network plotting from HRU file \* RVH file handling \* time series infilling \* creation of observation rvt files

New sample data sets, including raw data for testing read-type functions.

Updated examples for each function and improved documentation.

<!-- README.md is generated from README.Rmd. Please edit that file -->
RavenR
======

RavenR is an R package for handling Raven hydrologic modelling framework inputs, outputs, and diagnostics. Please contact Robert Chlumsky (<rchlumsk@uwaterloo.ca>) for any troubleshooting, bug fixes, or recommendations on future releases.

This is a forked version by Joel Trubilowicz, contacted at (<jwtrubil@gmail.com>)

Installation
------------

You can install RavenR from github with:

``` r
# install.packages("devtools")
# library(devtools)
#for this forked version:
devtools::install_github("jwtrubil/RavenR")

#for real version:
devtools::install_github("rchlumsk/RavenR")
```

Tutorials and Quick Start Guide
-------------------------------

Please see the vignettes or pdf folder for RavenR Tutorials and Quick Start Guides. Sample data is included in the package, so you need only to install the RavenR library and follow along in the guide documents to get started.

\*\*Note that as of v1.2, the vignettes are out of date and will be updated in the next update.

RavenR Wishlist
---------------

Any issues or feature requests can be submitted on Github via the Issues tab. You may also submit feature requests directly to Robert Chlumsky (<rchlumsk@uwaterloo.ca>) via email.

Dependency Installs
-------------------

Note that some of the package dependencies may require the installation of programs outside of R, particularly for Linux users. Refer to specific function helps on how to install various package materials, such as [ImageMagick](https://www.imagemagick.org/script/download.php).

Version Update Notes
--------------------

### 1.2

*Currently in Beta mode for v1.2, please test and submit comments to <rchlumsk@uwaterloo.ca>*

Updated functionality and test data sets for use. New functions include: \* subbasin and HRU plotting from shapefile from custom data or tabular input \* animation of subbasin plots for custom data \* watershed network plotting from HRU file \* RVH file handling \* time series infilling \* creation of observation rvt files

New sample data sets, including raw data for testing read-type functions.

Updated examples for each function and improved documentation.
42 changes: 21 additions & 21 deletions RavenR.Rproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace