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

wrapper functions for SCAN/SNOTEL, CDEC, etc #5

Open
dylanbeaudette opened this issue Jun 28, 2022 · 1 comment
Open

wrapper functions for SCAN/SNOTEL, CDEC, etc #5

dylanbeaudette opened this issue Jun 28, 2022 · 1 comment

Comments

@dylanbeaudette
Copy link
Member

Would be nice to have some convivence functions for converting the output from e.g. fetchSCAN() into the format used in batch mode. Mostly preservation of IDs, long → wide format, etc..

@brownag
Copy link
Member

brownag commented Jun 30, 2022

I think this would be useful, though for jNSMR we would need to have SCAN/SNOTEL/CDEC data aggregated to a monthly timestep. I think we probably could customize a single function so generic ~daily data in long format can be put into the jNSM "batch CSV" format.

Sketching out one of these convenience functions:

  • A key focus for use in jNSMR would be aggregation from long format -> monthly data in wide format.
    • This aggregation would need to be aware of site ID, date (or at least month), and data/aggregation type (temperature v.s. precipitation).
    • Aggregation for temp v.s. precip will vary because temp is aggregated w/ the average, or some other measure of central tendency/distribution for the month, whereas the precip is summed within months for a specific year

Arguments to this function might include:

  • x (a data.frame in "long" format, containing observations of precipitation and/or temperature that need to have at least information on month+year for independent records)
  • site.id (site identifier column name)
  • date (date column name; column containing character or POSIX time used to extract year and month)
  • data_type (data type column name; character column containing "temperature" or "precipitation"),
  • FUN (optional custom function, defaults to mean() for data_type="temperature" and sum() for data_type="precipitation")
  • ... (maybe explicit additional arguments related to date/formats, ... passed to FUN)

I think this function could be written such that it could deal with a wide range of time intervals converted to monthly. Range from very fine scale measurements on e.g. 10 minute intervals, to daily, to weekly, to one per month for one or more years should be possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants