4
$\begingroup$

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}

$\endgroup$
2
  • $\begingroup$ 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? $\endgroup$
    – Hugh
    Feb 20, 2018 at 20:38
  • $\begingroup$ 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. $\endgroup$ Feb 28, 2018 at 19:49

1 Answer 1

4
$\begingroup$

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}
$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$
    – Szabolcs
    Feb 26, 2018 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.