Giter Site home page Giter Site logo

smwrbase's Introduction

smwrBase

Base R functions to support statistical methods in water resources.

Reporting bugs

Please consider reporting bugs and asking questions on the Issues page: https://code.usgs.gov/water/analysis-tools/smwrBase/-/issues

Code of Conduct

We want to encourage a warm, welcoming, and safe environment for contributing to this project. See the code of conduct for more information.

Package Installation

Those within the USGS network can ask to have the prod-legacy R Package Manager added to their R enviornment. Installation and updates are done using the standard install.packages command.

External to the USGS network, first install the "remotes" package. Then, using the remotes package, install "smwrData", then "smwrBase":

remotes::install_gitlab("water/analysis-tools/smwrData",
                        host = "code.usgs.gov")
remotes::install_gitlab("water/analysis-tools/smwrBase",
                        host = "code.usgs.gov")

Disclaimer

This software is in the public domain because it contains materials that originally came from the U.S. Geological Survey, an agency of the United States Department of Interior. For more information, see the official USGS copyright policy at https://www.usgs.gov/visual-id/credit_usgs.html#copyright

Although this software program has been used by the U.S. Geological Survey (USGS), no warranty, expressed or implied, is made by the USGS or the U.S. Government as to the accuracy and functioning of the program and related program material nor shall the fact of distribution constitute any such warranty, and no responsibility is assumed by the USGS in connection therewith.

This software is provided "AS IS."

smwrbase's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smwrbase's Issues

regularSeries,

regularSeries seems to fail when times has a mixture of EDT and EST data and the variable tzone is computed internally as a vector rather than a single value. (

times <- as.POSIXlt(ct1$date)
times
[1] "1999-03-17 EST" "1999-04-27 EDT" "1999-05-11 EDT" "1999-05-25 EDT" "1999-06-08 EDT" "1999-07-07 EDT"
[7] "1999-07-20 EDT" "1999-08-04 EDT" "1999-08-17 EDT" "1999-09-21 EDT" "1999-10-06 EDT" "2000-03-14 EST"
...[removed for brevity]...
[43] "2002-07-30 EDT" "2002-08-13 EDT" "2002-08-27 EDT" "2002-09-17 EDT" "2002-10-15 EDT" "2003-03-11 EST"
...[removed for brevity]...
[73] "2005-04-05 EDT" "2005-04-19 EDT" "2005-05-11 EDT" "2005-05-25 EDT" "2005-06-14 EDT" "2005-06-28 EDT"
[79] "2005-07-12 EDT" "2005-07-26 EDT" "2005-08-09 EDT" "2005-08-24 EDT" "2005-09-13 EDT" "2006-03-08 EST"
[85] "2006-04-06 EDT" "2006-04-18 EDT" "2006-05-09 EDT" "2006-05-23 EDT" "2006-06-06 EDT" "2006-06-20 EDT"
...[removed for brevity]...
[169] "2013-09-17 EDT" "2013-10-14 EDT" "2014-05-13 EDT" "2014-06-03 EDT" "2014-07-08 EDT"

tzone <- attr(times, "tzone")
tzone
[1] "America/New_York" "EST" "EDT"

In the above example if I throw in a
tzone <- tzone[1]
the rest of the code works fine.

Jon

export to csv file

I'm successfully using as.qw to create variables. However, in some cases i want to log transform the data, and export the results to a csv file. Exporting less-thans (i.e.,"<"), left censored (e.g., -Inf - 4) seem to work well. Interval censored also work well with positive values. However, if the interval censored has a negative initial value, importing the data into excel treats it as an equation. but if the field has a preceeding space, then the import seems ok.

In the attached example, note the difference between the 3rd and 4th row of data for the variable 'lnpp'. So, can you add a preceeding space so these imports work ok also? Thanks.

ct1_1orig_2016_07_27_174516.zip

regularSeries cut

I'm using regularSeries and seeking to take a data set to a single value per month. But I'm getting different results.

Option 1: I use a pretty simple call with no begin/end values. However the end of 2014 is not filled in, which is what I want .... so to Option 2

df1<- regularSeries(df[ ,names(df)=="secchi"] , df$date, which = mean,

  •                 k.period = 1 )
    

df1ts <- ts(df1[ ,names(df1)=="Value"],start=1999,frequency=12)
df1ts
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1999 1.80 0.60 0.40 0.90 1.00 1.20 1.10 1.10 0.80 0.50 0.40 1.20
2000 0.80 0.80 0.60 0.50 0.85 0.70 1.05 1.05 1.20 1.40 1.00 0.60
2001 0.50 0.70 0.50 0.40 0.60 0.60 0.90 1.00 1.20 0.70 1.00 1.20
2002 1.00 0.70 0.70 0.55 0.55 0.60 0.95 1.05 1.10 1.10 1.00 0.60
2003 0.50 NA 0.60 0.35 0.55 0.30 0.45 0.45 0.50 0.40 0.20 0.20
2004 0.50 0.90 0.40 0.35 0.55 0.60 0.75 0.80 0.10 0.50 0.60 0.40
2005 0.30 0.60 0.70 0.30 0.60 0.65 0.45 0.45 0.70 0.70 0.40 0.30
2006 0.50 0.30 0.60 0.45 0.80 0.55 0.20 0.55 0.60 0.80 0.40 0.20
2007 0.40 NA 0.40 0.55 0.80 0.65 0.70 0.65 1.10 1.10 0.80 0.80
2008 0.30 0.20 0.20 0.60 0.70 0.50 0.80 0.65 0.80 0.90 0.90 0.30
2009 NA 0.50 0.30 0.40 0.60 0.70 0.90 0.65 0.80 0.60 0.60 0.60
2010 NA NA 0.20 0.30 0.60 0.65 0.70 0.65 0.60 0.50 0.60 0.40
2011 NA 0.40 0.10 0.30 0.30 0.50 0.50 0.45 0.30 0.25 0.50 0.40
2012 0.40 0.30 0.70 0.50 0.40 0.60 0.40 0.55 0.80 0.60 0.40 0.50
2013 0.60 0.10 0.30 0.40 0.40 0.45 0.40 0.40 1.00 0.70 0.80 0.60
2014 NA 0.70 0.30 NA 0.35 0.40 0.60

Option 2: I include begin/end to fill out the time series through the end of Dec 2014. All seems good; however, the Jan-May2014 values in example 1 of "NA 0.70 0.30 NA 0.35 0.40" vs. "NA 0.70 0.30 0.30 0.40"). In example 2, a value for May 1, 2014 gets cut into April while it is averaged in with May data in Example 1.

df1<- regularSeries(df[ ,names(df)=="secchi"] , as.Date(df$date),

  •                 period = "month", which = mean,
    
  •                    begin="1999-01-01",
    
  •                    end  ="2015-01-01", k.period = 1)
    

df1ts <- ts(df1[ ,names(df1)=="Value"],start=1999,frequency=12)
df1ts
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1999 1.80 0.60 0.40 0.90 1.00 1.20 1.10 1.10 0.80 0.50 0.40 1.20
2000 0.80 0.80 0.60 0.50 0.85 0.70 1.05 1.05 1.20 1.40 1.00 0.60
2001 0.50 0.70 0.50 0.40 0.60 0.60 0.90 1.00 1.20 0.70 1.00 1.20
2002 1.00 0.70 0.70 0.55 0.55 0.60 0.95 1.05 1.10 1.10 1.00 0.60
2003 0.50 NA 0.60 0.35 0.55 0.30 0.45 0.45 0.50 0.40 0.20 0.20
2004 0.50 0.90 0.40 0.35 0.55 0.60 0.75 0.80 0.10 0.50 0.60 0.40
2005 0.30 0.60 0.70 0.30 0.60 0.65 0.45 0.45 0.70 0.70 0.40 0.30
2006 0.50 0.30 0.60 0.45 0.80 0.55 0.20 0.55 0.60 0.80 0.40 0.20
2007 0.40 NA 0.40 0.55 0.80 0.65 0.70 0.65 1.10 1.10 0.80 0.80
2008 0.30 0.20 0.20 0.60 0.70 0.50 0.80 0.65 0.80 0.90 0.90 0.30
2009 NA 0.50 0.30 0.40 0.60 0.70 0.90 0.65 0.80 0.60 0.60 0.60
2010 NA NA 0.20 0.30 0.60 0.65 0.70 0.65 0.60 0.50 0.60 0.40
2011 NA 0.40 0.10 0.30 0.30 0.50 0.50 0.45 0.30 0.25 0.50 0.40
2012 0.40 0.30 0.70 0.50 0.40 0.60 0.40 0.55 0.80 0.60 0.40 0.50
2013 0.60 0.10 0.30 0.40 0.40 0.45 0.40 0.40 1.00 0.70 0.80 0.60
2014 NA 0.70 0.30 0.30 0.40 0.40 0.60 NA NA NA NA NA

New disclaimer

We need to adjust the language of the disclaimer on GRAN to:

.onAttach <- function(libname, pkgname) {
  packageStartupMessage("This information is preliminary or provisional and is subject to revision. It is being provided to meet the need for timely best science. The information has not received final approval by the U.S. Geological Survey (USGS) and is provided on the condition that neither the USGS nor the U.S. Government shall be held liable for any damages resulting from the authorized or unauthorized use of the information.")
}

https .gov changeover

Found these lines with http .gov URLs using https://github.com/wdwatkins/gran_http_gov

HTTPS is supposed be available for everything by the end of December, but may not be yet.

Some of these URLs in .md and other documentation files won't show up on github unless you go to the raw file. Line numbers reference the number in the raw file when opened in a text editor, so the link may not point you to the right spot in some cases if lines are wrapping, etc.

dplyr masking filter funciton for movingAve

Dear smwrBase creators! Thank you so much for this package and all your hard work to make data management and analysis easier. I was using the movingAve() function and kept getting an error like this: "Error in UseMethod("filter_") : no applicable method for 'filter_' applied to an object of class "c('integer', 'numeric')". In case others like me have the dplyr package loaded in their R session and try to use movingAve(), could you please specify the filter function for movingAve is coming from the stats package? This seemed to work for me when I modified your code.

Thanks again!
Sheila

NOTICE: upcoming default branch name change

The master branch of this repository will soon be renamed from master to main, as part of a coordinated change across the USGS-R and USGS-VIZLAB organizations. This is part of a broader effort across the git community to use more inclusive language. For instance, git, GitHub, and GitLab have all changed or are in the process of changing their default branch name.

We will make this change early in the week of February 6, 2022. The purpose of this issue is to give notification of the change and provide information on how to make it go smoothly.

When this change is made, forks and clones of the repository will need to be updated as well. Here are instructions for making the necessary changes.

  • On GitHub, change the default branch name from master to main (<your repository> -> Settings -> Branches).
  • Change the default branch on any forks you have, as well as local clones. (See details below)
  • If you have collaborators on this repository, let them know that they will need to change their forked/local repos. Point them to this issue to facilitate the process!
  • Search within your repository for "master" so that you can change references (e.g. URLs pointing to specific commit points of files) to point to "main" instead.
  • When you are done, feel free to close this issue!

Changing default branches on forks and local clones

First, update your local git configuration so that new repositories created locally will have the correct default branch: git config --global init.defaultBranch main.

Now, for any forks, do the following:

  1. Go to <your fork> -> Settings -> Branches and edit the default branch from master to main.
  2. Update the settings for your local clone of this fork to match this change.
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.