using shape method find weeks for the given period - jupyter-notebook

Using the shape method on fb_5yrsw , we can tell that there are________ weeks inthe 5-years period 2012/05/18-2016/05/18
symbol_monthly.shape

Related

Function to calculate shift between to time series based on data points

I am trying to find a function that matches two time series such that the datetime corresponds to reality.
So I need a function that minimizes the distance between the two curves shown above and outputs a new dataframe that has TAIR time-shifted towards the values of tre200h0.
From my bare eyes, it looks like this shift is about 22h.
ggplot
Best,
Fabio
I don't know a function that does this job for me.
Solved by Ric Villalba in the comments to OG Question.
Two R base functions to analyze time series lags are acf and pacf. i.e. given you have x and y you can use acf(y-x) and seek the zeroes in the plot (if your series have adequate seasonal behaviour), or, if you prefer, acf(y-x, plot=F) and get the data. Try which.min( acf(x-y)$acf^2 ).
Of course, it is a simplification of otherwise complex matter

Changing x value's scale in ggplot2

I am undergoing my university dissertation and need to create some dive shape profiles for Yellowfin tuna. i have created the graph but am having issues with the scale of my X axis, as it is a time value and i have a 6 panel plot. My time-frame is in 5 minute intervals, adding up to 15 mins per graph. The time frames for my graph are as follows: (a)15-minute timespan 11:45AM-12 PM 20/1/2019. (b) 15-minute timespan 16:47-17:02PM 26/1/2019. (c) 15-minute timespan 16:40-16:55 8/2/2019. (d) 15-minute timespan 17:10-17:25 14/2/2019. (e) 15-minute timespan 16:15-16:30 26/2/2019. (f) 15-minute timespan 16:40-16:55 9/3/2019. Note that the dates do not matter necessarily, but would be an extra bonus to attach to my graph. Fixing the scale to 500m in depth would be fantastic also. Each of these panels, are a separate excel spreadsheet.
I'm a little unclear of what you're trying to do without more of an example but if you're trying to change the axis but look into ggplot scale_x_discrete()

Finding nearest neighbours in time and space in R using sf

I have a made up dataset of polling stations in Wales and I've attached a date column to it. We can imagine this date is the date this polling station was visited to check the facilities (for example).
What I'd like to do is work out :
I would like to work out whether geographic points are within a certain distance
This I've managed by self_joining and using st_buffer and st_within to calculate within 1000 m and then calculated the number of neighbours.
and also the interval between the sample dates
this I'm having a bit of a problem with
What I'd like to do, I think, is
for each polling station
calculate the number of neighbours (so far so easy)
for each neighbour determine the interval between the sampling dates
return a spatial object (for plotting in tmaps probably)
Here's some test code that I've got that generates the sf dataset, calculates the number of neighbours and returns that.
It's really the date interval that's stumping me. It's not so much the calculation of the date interval but it's the way to generate these clusters of polling stations with date intervals.
Is it better to generate the (in this case) 108 polling station clusters?
What I'm trying to do in my larger dataset is calculate clusters of points over time.
I have ~2000 records with a date. I'd like to say :
for each of these 2000 records calculate the number of neighbours within a distance and within a timeframe.
I think it's probably better to
calculate each cluster of neighbouring points and visualise
then
remove neighbours from the cluster that are outside of the time frame and visualise that
Although, on typing this, I wonder if excluding points that didn't fall within a timeframe first and then calculating neighbours would be more efficient?
polls<-st_as_sf(read.csv(url("https://www.caerphilly.gov.uk/CaerphillyDocs/FOI/Datasets_polling_stations_csv.aspx")),
coords = c("Easting","Northing"),crs = 27700)%>%
mutate(date = sample(seq(as.Date('2020/01/01'), as.Date('2020/05/31'), by="day"), 147))
test_stack<-polls%>%st_join(polls%>%st_buffer(dist=1000),join=st_within)%>%
filter(Ballot.Box.Polling.Station.x!=Ballot.Box.Polling.Station.y)%>%
add_count(Ballot.Box.Polling.Station.x)%>%
rename(number_of_neighbours = n)%>%
mutate(interval_date = date.x-date.y)%>%
subset(select = -c(6:8,10,11,13:18))## removing this comment will summarise the data so that only number of neighbours is returned %>%
distinct(Ballot.Box.Polling.Station.x,number_of_neighbours,date.x)%>%
filter(number_of_neighbours >=2)
I think it might be as simple as
tm_shape(test_stack)+tm_dots(col = "number_of_neighbours", clustering =T, size = 0.5)
I'm not sure how clustering works in leaflet, but that works quite nicely on this test data.

Interpolation of missing time series sensor data based on another sensor pattern

I have two sensors in the same place, but one of the sensors stopped working, and I therefore want to interpolate the missing values based on the pattern that exists in the other sensor that still works.
The Y axis is a value is degrees in celsius, and the X is aggregated data on 10 minute interval.
Picture of the graph and data I want to interpolate.
I am unsure how to do this, and which package and formula to use. Any ideas?

Interpretation of hydroplot in R (package: "hydroTSM")

I want to analyze mean daily runoff data by means of a hydroplot.
I was able to write the code for the hydroplot.
plot(MeteoZ,main="Runoff (m³/s) for Bad Aibling, Glonn station",xlab="Time")
However, I am not very sure how to interpret it. I have 3 main questions:
Since my data was daily, how are the monthly/yearly time series made? Is that averaged per month/year? What does the y-axis represent?
Same question for the boxplots.
What is the value of the y-axis in the hydroplot? Proportion?

Resources