16 July 2026
Problem with some leap years
Problem with some leap years
The time series covers years 1980 through 2026.
Only 1988, 1992, 1996 and 2024 cause problems (some leap years).
Only 1988, 1992, 1996 and 2024 cause problems (some leap years).
In[]:=
dateslevel=;(*arraywithdatesandwaterlevels.Therearenoduplicateddates*)
A continuous time series is created with TemporalRegularity False
In[]:=
tseriescontinuous=TimeSeries[dateslevel[[All,2]],{dateslevel[[All,1]]},TemporalRegularity->False]
Out[]=
TimeSeries
Now we create an array with a time series for each of the 47 years.
In[]:=
lastyear=2026;tseriesyearly=Table[TimeSeriesWindow[tseriescontinuous,{{i,1,1},{i,12,31}}],{i,Range[1980,lastyear]}];
We shift all years to 2026 to compare the water level on the same dates, but different years.
In[]:=
tsshifted=TimeSeriesShift[tseriesyearly[[#-1979]],{{lastyear-#,"Year"},{0,"Day"}}]&/@Range[1980,lastyear];
Everything works fine, except for the iconization - NOT QUITE
Everything works fine, except for the iconization - NOT QUITE
In[]:=
Iconize[tsshifted,"tsshifted"]
Out[]=
Now there is a problem with the iconized array of time series.
In[]:=
In[]:=
[[9]],[[13]],[[17]],[[-3]]
Out[]=
TimeSeriesFailure,TabularColumn,ResamplingMethodLinearInterpolation,TimeSeriesFailure,TabularColumn,ResamplingMethodLinearInterpolation,TimeSeriesFailure,TabularColumn,ResamplingMethodLinearInterpolation,TimeSeriesFailure,TabularColumn,ResamplingMethodLinearInterpolation
detail - one of your original tsshifted problem data items
detail - one of your original tsshifted problem data items
In[]:=
aProblemTS=tsshifted[[9]];aProblemTS["Properties"]aProblemTS["Tabular"]
Out[]=
{ComponentKeys,ComponentTypes,Dates,DatePath,DatesQ,FirstDate,FirstTime,FirstTimestamp,LastDate,LastTime,LastTimestamp,MetaInformation,MinimumTimeIncrement,NormalPath,NormalValues,OptionsSummary,Path,PathComponent,PathComponents,PathLength,ResamplingType,Tabular,TimeObservationWindow,Times,Timestamps,TimestampType,TimeZone,UniformlySpacedQ,Values,ValueType}
Out[]=
Tabular
We can see that the underlying Tabular structure has a problem (it is blank). Tally the Timestamps of the aProblemTS and we see we have 2 entries for one Timestamp. Clearly there is a Duplicate Timestamp in tsshifted.
In[]:=
Select[Tally[Normal[aProblemTS][[All,1]]],Last[#]>1&]
Out[]=
,2
In[]:=
{aProblemTS[[59]],aProblemTS[[60]]}
Out[]=
,553.4,,552.574
The tsshifted looks fine as the element only lives within the one sub entry.
The Iconized function itself fails as this DUPLICATED Timestamp is obviously not unique.
To reiterate, the problem is with the Timeseries itself and NOT with the Iconization.
Applying the previously supplied shiftAndJitterDuplicates workaround of jittering the Timestamp data works.
TimeSeries[Failure["NotUnique",<||>],...]
The Iconized function itself fails as this DUPLICATED Timestamp is obviously not unique.
To reiterate, the problem is with the Timeseries itself and NOT with the Iconization.
Applying the previously supplied shiftAndJitterDuplicates workaround of jittering the Timestamp data works.
In[]:=
tsshifted2=shiftAndJitterDuplicates/@(TimeSeriesShift[tsv[[#-1979]],{{aniofinal-#,"Year"},{0,"Day"}}]&/@Range[1980,aniofinal]);Iconize[tsshifted2,"tsshifted2"]
Out[]=
In[]:=
aProblemTS2=tsshifted2[[9]];aProblemTS2["Properties"]aProblemTS2["Tabular"]
Out[]=
{ComponentKeys,ComponentTypes,Dates,DatePath,DatesQ,FirstDate,FirstTime,FirstTimestamp,LastDate,LastTime,LastTimestamp,MetaInformation,MinimumTimeIncrement,NormalPath,NormalValues,OptionsSummary,Path,PathComponent,PathComponents,PathLength,ResamplingType,Tabular,TimeObservationWindow,Times,Timestamps,TimestampType,TimeZone,UniformlySpacedQ,Values,ValueType}
Out[]=
Tabular
Here the aProblemTS2 entry’s Tabular shows correctly. Tally the Timestamps and we see we have No Duplicates.
In[]:=
Select[Tally[Normal[aProblemTS2][[All,1]]],Last[#]>1&]
Out[]=
{}