Group Abstract Group Abstract

Message Boards Message Boards

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

A question about WeatherData and missing dates

Posted 2 years 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 2 years 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 2 years 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 2 years 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 2 years ago

Many thanks, Rohit.

POSTED BY: Alex Teymouri
Posted 2 years ago
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