Problem iconizing an array of TimeSeries in Wolfram 15

For a couple of years I’ve been using an array of Time series, which I Iconize in order to insert in an application. Recently I upgraded to Wolfram 15 and get an error message.

See attached file showing the problem.

The error message is Failure, Tag not Unique. See the image below.
The array is fine, but there is a problem when it is Iconized

Iconize problem TimeSeries.nb (1.58 MB)

Hi Ricardo,

Thank you for reporting this. Relevant teams are aware of this issue, but the notebook you provided is helpful and they have it now. They are actively working on it.

Thank you Ahmed. Anything you suggest I should do while the problem is fixed?

Hi Ricardo,

The issue is some of the input time series already contains duplicate timestamps after the shift. Probably something like:

  • the source data already had repeated timestamps,
  • the shift changes leap-year alignment,
  • the series has irregular timestamps that become duplicated after normalization,
  • or the time series includes identical dates at different positions.

You need to disambiguate the duplicated timestamps, one way being to add a tiny jitter (10^9 seconds) only when a year has exact duplicate timestamps, which should preserve the original order. So rebuild each series with explicit {time, value} pairs and then create the TimeSeries with TemporalRegularity → False so not to force a regular grid.

ClearAll[shiftAndJitterDuplicates];
shiftAndJitterDuplicates[ts_] := Module[{pairs, adjustedPairs},
     pairs = Normal @ ts;
     adjustedPairs = Flatten[
         Map[
            Function[group,
               Module[{n = Length[group], times, values},
                  times = group[[All, 1]];
                  values = group[[All, 2]];    
        Transpose[{times + Range[0, n - 1]*Quantity[10^-9, "Seconds"],
           values}]]
             ],
            GatherBy[pairs, First]
          ], 1];
     TimeSeries[adjustedPairs, TemporalRegularity -> False]];

tsvsh2 = shiftAndJitterDuplicates /@ 
     (TimeSeriesShift[
       tsv[[# - 1979]], {{aniofinal - #, "Year"}, {0, "Day"}}] & /@ 
     Range[1980, aniofinal]);

Other series are not affected.
tsvsh[[44]] === tsvsh2[[44]] - TRUE

Hope this helps.

Thank you Karl. I will try it with my data.

Hi Karl,

The function shiftAndJitterDuplicates[ts_] solved the specific problem of one of the arrays, tahnk you.
Now I have to make several corrections to the application. I wonder if the time series can be corrected from its origin in order to avoid making changes to the rest of the code.

There are no duplicate dates. The problem seems to occur only with some leap years: 1988, 1992, 1996, and 2024. The problem only occurs when the array is iconized. Please see the attached notebook with the original time series.

I am also attaching the end result. I just wanted to update the data.

◔

Hi Ricardo,

The problem is not with Iconize itself, but the underlying Timeseries.
Please see the mod notebooks detail section :wink:

Thank you Karl for taking the time to clarify the issue. I will read in detail your comments later today or over the weekend. Have a nice weekend!

Hi Ricardo,
Ok, I went down the rabbit hole… new approach takes your tseriesyearly and remaps to give a direct replacement for your 2. Comparación de comportamiento anual Manipulates tsvsh data.

HTH.
Hope you have a great weekend :wink:

Iconize problem TimeSeries-better approach.nb (2.09 MB)

Hi Karl. I saw the notebook in detail. Very useful, not only for this example. Thank you. I guess the moral of the story is to be careful with leap years. If a leap year is shifted to a non leap year, February 28 will repeat.