Message Boards Message Boards

1
|
2537 Views
|
9 Replies
|
4 Total Likes
View groups...
Share
Share this post:

A question about WeatherData and missing dates

Posted 11 months ago

Dear All,

The year 2019 has 365 days.

The "WeatherData" output shows 357 data for Istanbul city. How do I use the Datepath command or any other commands to find the missing dates?

I appreciate your time. Alex

enter image description here

POSTED BY: Alex Teymouri
9 Replies

Hello friends, here is one way:

{dateStart, dateEnd} = DateObject /@ {{2019, 1, 1, 0, 0, 0}, {2019, 12, 31, 0, 0, 0}};
data = WeatherData["Istambul", "WindSpeed", {dateStart, dateEnd, "Day"}];
allDays = DateRange[dateStart, dateEnd];
DateObject /@ Complement[DateString /@ allDays, DateString /@ data["Dates"]]
POSTED BY: Henrik Schachner
Posted 11 months ago

Hi Dr.Schachner,

That is a great solution. I found the missing dates easily. Thank you so much.

For filling up the missing dates, interpolating is a good way? Regards,

enter image description here

POSTED BY: Alex Teymouri

Hi Alex,

glad to help (and please just call me Henrik)! Yes, I think interpolation is a good way. And

data["PathFunction"]

gives already the respective InterpolatingFunction. Regards -- Henrik

POSTED BY: Henrik Schachner
Posted 11 months ago

I appreciate your help, Henrik.

I tried to fill in the missing data for 23rd January. I got a strange value!

It is the same for other dates.

In[16]:= data["PathFunction"];

In[15]:= %8[23]

Out[15]= Quantity[249937., ("Kilometers")/("Hours")]
POSTED BY: Alex Teymouri
Posted 11 months ago

Alex,

You need to pass an AbsoluteTime to the PathFunction.

data["PathFunction"][AbsoluteTime[{2019, 1, 23}]]
(* Quantity[13.52, ("Kilometers")/("Hours")] *)
POSTED BY: Rohit Namjoshi
Posted 11 months ago

Many thanks, Rohit.

POSTED BY: Alex Teymouri
Posted 11 months ago

Hi Henrik,

I was wondering why the conversion to DateString is required. Here is why

allDays[[1]] // InputForm
(* DateObject[{2019, 1, 1, 0, 0, 0.}, "Instant", "Gregorian", -5.] *)

data["Dates"][[1]] // InputForm
(* DateObject[{2019, 1, 1, 0, 0, 0}, "Instant", "Gregorian", -5.] *)

The DateObject generated by DateRange has Real seconds 0. while the DateObject in WeatherData has Integer seconds 0. Even though the date specifications passed to DateRange have Integer seconds. This seems like an oversight or bug in the implementation of DateRange. Thanks for revealing this, I will keep it in mind when dealing with DateRange.

POSTED BY: Rohit Namjoshi

Hi Rohit,

I freely admit that I could not make sense of why these DateObject[] do not work in combination with Complement[] - now I know, many thanks!

Regards -- Henrik

POSTED BY: Henrik Schachner

Alex,

I had the same problem several times. Thank you for the inquiry.

Cheers,

POSTED BY: M.A. Ghorbani
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract