Code Monkey home page Code Monkey logo

environmentalsetting_toolkit's Issues

Micro-drought: confirm run count logic

Confirm logic and add getRunCounts() function.

Phone/email convo with Keith Eggleston (ACIS) Google Doc confirmed run logic

  • Cannot specify run length, so need getRunCounts() function
  • Can request values down to 0.01 if desired
  • Do not need to specify add: mcnt or maxMissing since runs cannot have missing values

Add getStationMetrics()

Decision: overload existing functions:
getWxObservations() - add metric
getGrids() - add metric and customBBox

No additional function needed.

Iterate using metric lookups; climateMetrics.Request == elem reduce

alter reduceFlags for CSP3 (micro-drought): reduceFlags <- c("date","mcnt","rmcnt")

Fix request for micro-drought (CSP3)

modify formatWxObservations() for nested missing values
at row # 444 (ack)

matrix(unlist(lapply(rList$data, "[", itemCount + 1)), ncol = 2, byrow = TRUE)[, 1]
where rList$data row like ["1957", ["29", "1957-09-06", 2, 0]],
instead of ["1957", ["11", 2]],

The date is messing with the unlist and lapply operations

Add dbConn

Add optional database connection when requesting protocol metrics

Add 'base' element when requesting degree days

params = {
"uid": 31702,
"sdate": "1998-02-10",
"edate": "por",
"elems": [{
"name": "gdd",
"base": 32,
"interval": "yly",
"duration": "yly",
"reduce": [{
"reduce": "cnt_gt_0",
"add": "mcnt"
}],
"maxmissing": 1
}]

Valid rows missing from CSP3 - micro-drought metric

Records with valid runs missing from output. Due to use of sapply() to request data and incorrect logic in getRunCounts() when decomposing nested column pcpn_in_run. Also, hiccuping may have occured due to erroneous check for countMissing element in ACIS response. Run requests do not return count missing since by definition a run cannot have a missing value.

Example affected uids: 67667, 77478, 79362, 69577

Debugging on 20180518 using lapply() instead of sapply() results in a list of data frames with consistent structure that can be bound into a single data frame and passed to getRunCounts(). Edits made to getStationMetrics() and cleanNestedLists() although the latter is not used when producing metric CSP3.

Resulting code:
metricSource <- lapply(climateStations, function(x){ getWxObservations( climateStations = x, climateParameters = cParam, sdate = sdate, edate = edate, duration = duration, interval = interval, reduceCodes = rCode, maxMissing = 10, metric = metric ) }) metricSourceCombo <- do.call(rbind, metricSource) metricSourceComboCleaned <- metricSourceCombo[metricSourceCombo$uid != "no data available",] metricData <- getRunCounts(rawCounts = metricSourceComboCleaned, runLength = 7, metric = metric) outputMetricFile(metricData, metric, filePathAndRootname)

Some records coming back with "no data available" even though the records have data in ACIS:
example uids: 44104, 44837(chunk 3). Others from chunk 4 (328 stations) and 5 (30) need additional QA checks and diagnosis. 360 stations total.

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.