Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.5K Views
|
4 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Function to turn Dataset columns into time series by year?

Posted 4 years ago

I'm dabbling with a workbook to watch snow pack in Utah where I live. I'm able to get the data and can get the visualization that I want, but expanding it out to include past year would get tedious quickly.

I have a function that allows for passing the year as a variable them using it to select both the column and set the date range. The dates start Oct. 10 each year as that is when the water year starts. So water year 2022, started Oct. 10, 2021.

Here is what I have so far:

url = "https://www.nrcs.usda.gov/Internet/WCIS/AWS_PLOTS/basinCharts/\
POR/WTEQ/assocHUCut3/state_of_utah.csv";

dataset = Import[url, "Dataset", HeaderLines -> 1]

ts0 = TimeSeries[Normal@Values@dataset[All, {ToString[ToExpression[#] - 1]}], {"Oct 10 " <> #}] & /@ {"2020", "2021", "2022"}

DateListPlot[ts0, PlotRange -> All]

I tried a few different things, but can't figure out a good way to capture the output in discrete variables. The dates line up right, but I would like to capture each as a separate variable but do it programmatically so I can change the date range without have to set all the variables. Like this without having to set the output list. I would like to be able to process as an event service at time so I can overlap them and see how one year tracks compared to the next. That part of still work in progress. Any insight are welcome.

{ts0,ts1,ts2} = TimeSeries[Normal@Values@dataset[All, {ToString[ToExpression[#] - 1]}], {"Oct 10 " <> #}] & /@ {"2020", "2021", "2022"}

DateListPlot[{ts0, ts1, ts2}, PlotRange -> All]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard
Be respectful. Review our Community Guidelines to understand your role and responsibilities. Community Terms of Use