Max[] is being inconsistent when applied to time series

4

I am trying to create a list of annual maxima wind speeds. However the code I have come up with works inconsistently. i.e will produce a list for one weather station but will return Max[Missing[NotAvailable],"the max wind speed"] for another. And the error displayed is

Max::nord2: Comparison of 44.45km/h and -[Infinity] is invalid.

I also can't just select the second value as this is part of an overall function that is meant to return a list of lists as such(I want a list of lists of 20 year maximas). Therefore I was wondering if there is a fix that won't affect the already working part.

I have also tried DeleteCases, DeleteMissing but as you can see the value I want is there. So any thoughts on how to extract it would be greatly appreciated!

Example of station that works:

x = (1996 + #) &;
y = (1997 + #) &;
years = {{x[#]}, {y[#]}} & /@ Range[20];

QuantityMagnitude[
  UnitConvert[
    Max[
      WindSpeedData[
        Entity["WeatherStation", "EGAA"]
      , Flatten[{#, "Day"}, 1]
      , UnitSystem -> "Metric"
      ]
    ]
  , "Meters/Seconds"
  ]
] & /@ years

{12.45, 13.325, 11.6778, 11.6278, 11.6278, 12.1917, 9.00278, 10.5472, 9.61944, 11.1111, 11.8833, 12.1417, 11.2139, 11.2667, 11.4722, 10.8556, 13.2222, 10.2361, 12.0389, 10.65}

A list of maxima.

Station that does not work:

x = (1996 + #) &;
y = (1997 + #) &;
years = {{x[#]}, {y[#]}} & /@ Range[20];
QuantityMagnitude[
  UnitConvert[
    Max[
      WindSpeedData[
        Entity["WeatherStation", "EGAE"]
      , Flatten[{#, "Day"}, 1]
      , UnitSystem -> "Metric"
      ]
    ]
  , "Meters/Seconds"
  ]
] & /@ years

{13.4778, 14.4556, 16.6667, 13.375, QuantityMagnitude[UnitConvert[ Max[Missing["NotAvailable"], Quantity[44.45, ("Kilometers")/("Hours")]], "Meters/Seconds"]], 13.1694, 12.7056, 12.5, 14.25, 14.9194, 15.4333, 14.2, 13.2722, 12.7056, 17.3889, 14.6111, 15.8444, 13.7361,14.8167, 13.7361}

M Fotheringham

Posted 2018-02-20T19:51:11.063

Reputation: 41

If you look at the time series for 2001 to 2002 then you will see Missing["NotAvailable"] for two entries. I suggest you drop those entries from the list and work with the remaining data. Are you happy to drop such entries? – Hugh – 2018-02-20T20:38:11.667

I simply wanted to delete them. But have the "delete function" as part of the original line of code. As I said the functions I normally use i.e DeleteCases weren't working. – M Fotheringham – 2018-02-28T19:49:41.823

Answers

4

You need to specify what you want to do with the missing data in the TimeSeries as described here.

For example, if you want to interpolate over Missings:

x = (1996 + #) &;
y = (1997 + #) &;
years = {{x[#]}, {y[#]}} & /@ Range[20];
QuantityMagnitude[
  UnitConvert[
    Max[
      TimeSeries[ WindSpeedData[
        Entity["WeatherStation", "EGAE"]
      , Flatten[{#, "Day"}, 1]
      , UnitSystem -> "Metric"
      ],MissingDataMethod->"Interpolation"]
    ]
  , "Meters/Seconds"
  ]
] & /@ years

{13.4778, 14.4556, 16.6667, 13.375, 12.3472, 13.1694, 12.7056, 12.5, 14.25, 
14.9194, 15.4333, 14.2, 13.2722, 12.7056, 17.3889, 14.6111, 15.8444, 
13.7361, 14.8167, 13.7361}

Sarah Stanley

Posted 2018-02-20T19:51:11.063

Reputation: 76

It would be nice to also have some tutorial-style documentation for TimeSeries, e.g. something comparable to the FEM tutorials, which not only introduces functions, but also shows how they are meant to be used together and what is the usual workflow.

– Szabolcs – 2018-02-26T21:18:42.930