kwb-r / kwb.abimo Goto Github PK
View Code? Open in Web Editor NEWR Package with Functions for Working with Water Balance Model ABIMO
Home Page: https://kwb-r.github.io/kwb.abimo
License: MIT License
R Package with Functions for Working with Water Balance Model ABIMO
Home Page: https://kwb-r.github.io/kwb.abimo
License: MIT License
This should be possible:
# Define some reference input file
input_file <- "~/qt-projects/abimo/data/abimo_2019_mitstrassen.dbf"
# Define some reference config file
config_file <- "~/qt-projects/abimo/data/config.xml"
# Read input data from reference file
input_data <- foreign::read.dbf(input_file)
# Read configuration file into list
config <- read_config(config_file)
# Modify the input data by modifying the data frame...
# Take care! Make sure that integer columns keep integer, therefore use "L" here!
input_data$REGENJA <- 600L
# Modify the configuration by modifying the list...
config$Infiltrationsfaktoren$Dachflaechen <- 0.2
# Either run Abimo by giving the paths to the files
result1 <- run_abimo(input_file = input_file, config_file = config_file)
# Or run Abimo by giving the R data structures
result2 <- run_abimo(input_data = input_data, config = config)
# In each case, the result is a data frame, containing the data from the dbf
# file that was written by the Abimo executable
# Let Abimo.exe output results of the Bagrov calculation
bagrov_lines <- kwb.abimo::run_abimo_command_line("--write-bagrov-table")
# Convert the text lines to a data frame
bagrov <- read.table(text = bagrov_lines, header = TRUE, sep = ",")
and put in subfolder inst/extdata
with the code below:
# source: http://st-on-it.blogspot.com/2010/01/how-to-move-folders-between-git.html
# First of all you need to have a clean clone of the source repository so we didn't screw the things up.
git clone https://github.com/amatzi/abimo
cd abimo
# After that you need to do some preparations on the source repository, nuking all the entries except the folder you need to move. Use the following command
git filter-branch --subdirectory-filter data -- -- all
# This will nuke all the other entries and their history, creating a clean git repository that contains only data and history from the directory you need. If you need to move several folders, you have to collect them in a single directory using the git mv command.
# You also might need to move all your content into some directory so it didn't conflict with the new repository when you merge it. Use commands like that
mkdir -p inst/extdata
git mv * inst/extdata/
# Once you've done commit your changes, but don't push!
git commit -m "Collected the data I need to move"
# This is all about the source repository preparations.
# Now go to your destination repository
cd ..
git clone https://github.com/kwb-r/kwb.abimo
cd kwb.abimo/
# And here is the trick. You need to connect your source repository as a remote using a local reference.
git remote add abimo ../abimo/
# After that simply fetch the remote source, create a branch and merge it with the destination repository in usual way
git fetch abimo
git branch abimo remotes/abimo/master
git merge abimo --allow-unrelated-histories
# This is pretty much it, all your code and history were moved from one repository to another. All you need is to clean up a bit and push the changes to the server
git remote rm abimo
git branch -d abimo
git push origin master
# That's all. After that you can nuke the temporary source repository.
Otherwise there will be a warning by the min
and max
functions that are called within foreign::write.dbf
to determine the precision.
by using xml2/rvest to modify the potential evatranspiration (as required for https://github.com/KWB-R/urbanAnnualRunoff/blob/dev/vignettes/workflow_beijing.Rmd) as current approach misses one row <item bezirke="1,5,6,7,11"
```
</section>
<section name="PotentielleVerdunstung">
<item bezirke="15,16,18,19,20" etp="807.767283333333" etps="606.903833333333" />
<item bezirke="8,9,10,12,21,22,23" etp="807.767283333333" etps="606.903833333333" />
<item bezirke="13,14,17" etp="807.767283333333" etps="606.903833333333" />
<item bezirke="2,3,4" etp="807.767283333333" etps="606.903833333333" />
<item bezirke="1,5,6,7,11" etp="774" etps="606" />
<!-- das ist der default wert (Bezirk=0) -->
<item etp="807.767283333333" etps="606.903833333333" />
</section>
</section>
UNIX (Linux and Mac OS) paths is using "/" as separator, unlike Windows which uses "\"
Unfortunately, the R package is using a "fullWinPath" function which does not handle other platform than window. For example, see https://github.com/KWB-R/kwb.abimo/blob/master/R/run_abimo.R#L53
This way, a path input_file <- '/Users/matthieu/dev/kwb.abimo/data/abimo_input_2019.rda'
becomes Usersmatthieudevkwb.abimodataabimo_input_2019.rda
and it fails...
Warning: Codoc mismatches from documentation object 'extdata_file':
extdata_file
Code: function(..., must_exist = TRUE, dbg = FALSE)
Docs: function(...)
Argument names in code not in docs:
must_exist dbg
https://github.com/KWB-R/kwb.abimo/runs/7011878517?check_suite_focus=true#step:9:67
due to:
Line 5 in e216744
which seems not to correctly use the set parameters defined here:
One could add that not only the "remotes" but also the "archive" package is required to install abimo :-)
If Abimo was not installed before, there is no chance that it succeeds currently.
Easy fix for Windows:
The script checks for version 3.3.0, but then installs 3.2.2, see https://github.com/KWB-R/kwb.abimo/blob/master/R/install_abimo.R#L22
I would advise to use a "global-ish" variable to store the "recommended" version to avoid these problem in the future.
Also, it enforces a "win64" platform, which is problematic to be ran on a server (Linux) or a Mac OS software. See https://github.com/KWB-R/kwb.abimo/blob/master/R/install_abimo.R#L16
Ideally, the original packages Abimo should be available for all main platforms.
In the meantime, the R package should identify the operating system using something like https://stat.ethz.ch/R-manual/R-devel/library/base/html/Sys.info.html and for non-windows platform warn that it cannot be installed automatically but hint that the software should be built from source and then linked with the fitting suffix in the R-site-library folder.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.