-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Time zones / Time references #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm all for being helpful with timezones. This was my motivation for adding a Guaranteeing that time zones are handled correctly is hard unless you're very restrictive about it. My inclination is to leave the vast majority of the work to pandas. All localized times in pandas are stored as utc internally, so we can and should take advantage of that (as the description above does). We could require that all times be localized, or we could throw warnings whenever we detect that people are using non-localized times. Concerning solar time... I just rely on the zenith and azimuth calculations for a given lat/lon. Is there an application for solar time other than for the actual calculation of those quantities of interest? I don't know how pandas would reasonably incorporate something that requires a specific lat/lon. Maybe we're talking about two different quantities? I think of solar time as the local time shifted to make the minimum zenith occur at 12:00 noon. |
I mean true or apparent solar time, so I think we talk about the same quantities. It is often useful to plot some quantities against this time e.g. to detect the azimuth angle of a system or to detect misalignments between irradiance sensor and modules, ... I would also like to rely on pandas for time conversion, as it is the best python implementation I am aware of. However I may be difficult to detect the exact format that a user is assigning to a function. As a default I think |
Agreed on using pandas and default UTC, and I think one critical component I am still trying to wrap my head around how true solar time and mean solar On Sun, Apr 5, 2015 at 11:51 PM, bmu notifications@github.com wrote:
|
That sounds like a good use case.
I'm not sure what you mean by this. My thought is that you can always do one of these:
I don't think there can be any ambiguity because the pd.DatetimeIndex(['2015-1-1T00']).tz_localize(pytz.FixedOffset(120))
<class 'pandas.tseries.index.DatetimeIndex'>
[2015-01-01 00:00:00+02:00]
Length: 1, Freq: None, Timezone: pytz.FixedOffset(120) We could consider making a rule that all timezones must always be specified (even if it's UTC).
Interesting idea; a correct and consistent implementation sounds hard. ( In any case, I will improve the Location docstring and make a tutorial. We could also make a page on the rtd docs just for timezones. I will also change the Location default tz to be UTC. |
I think, we misunderstand each other a little bit until now; my English may be the reason ;-) My use cases include up to now:
So I need
Hope this is understandable ;-) @jforbess |
Yes, those cases are generally what I would assume, though in my experience From my past experience, using UTC internally usually ends up resulting in On Mon, Apr 6, 2015 at 10:45 AM, bmu notifications@github.com wrote:
|
These use cases are helpful and cover a pretty broad range. I think that properly used IANA timezones (the pytz/pandas convention) can cover all except for solar time. For example, here in the US we have pd.DatetimeIndex(['2015-4-1T00']).tz_localize('US/Mountain')
<class 'pandas.tseries.index.DatetimeIndex'>
[2015-04-01 00:00:00-06:00]
Length: 1, Freq: None, Timezone: US/Mountain
pd.DatetimeIndex(['2015-4-1T00']).tz_localize('MST')
<class 'pandas.tseries.index.DatetimeIndex'>
[2015-04-01 00:00:00-07:00]
Length: 1, Freq: None, Timezone: MST Note the difference in the UTC offset between the two. So long as I specify times consistent with the timezone, pandas will use the same integer to represent them: # US/Mountain
pd.DatetimeIndex(['2015-4-1T01']).tz_localize('US/Mountain').astype(int)
array([1427871600000000000])
# MST
pd.DatetimeIndex(['2015-4-1T00']).tz_localize('MST').astype(int)
array([1427871600000000000])
# UTC
pd.DatetimeIndex(['2015-4-1T07']).tz_localize('UTC').astype(int)
array([1427871600000000000])
# No specification
pd.DatetimeIndex(['2015-4-1T07']).astype(int)
array([1427871600000000000]) So I think we already have all of the tools we need, and the On solar time... maybe I see part of the remaining problem now. We've been talking about a way to go from a UTC-based timestamp to solar time (e.g. |
Ok, I was aware of the pandas time conversion / localization, but not the non-DST ones. I agree, that in this case most of the tools are available. For the conversion from true solar time to UTC one needs the time difference of mean solar time to utc (depending on longitude) and the equation of time, should also be included in the solar position algorithms. What about the handling of tz-naive timestamps? Do I have to localize before up to now? |
@jforbess: just ask the German weather service ;-) the other comment: you won't have a peak at 12:35 if you plot one year data against local time. the peak shifts from 12:20 to 12:50 due to equation of time. and if you want to detect small sensor misalignments, this is a problem. |
There are other use cases (see e.g. this paper, section 5.1.). However, I'm not sure if it should be the first priority, as you seem to see no need for true solar time, and maybe most of the users also do not need it. |
The pandas integer representation of a tz-naive timestamp is the same as that for a UTC timestamp (see above). Is that what you meant? You've convinced me that including solar time in the |
Yes, I'm not saying that true solar time isn't a key concept, I am just Though I suspect that the large German operations performance community On Mon, Apr 6, 2015 at 12:03 PM, Will Holmgren notifications@github.com
|
Ok, I'm fine with a lower priority for the reverse calculation (not sure about "the large German operations performance community", though) |
@wholmgren: I had a look on the code (especially But I think something in the documentation on this topic would be useful, as not all users will be aware of the time zone handling. |
Just a reminder to myself and others as to the huge install base outside my On Mon, Apr 6, 2015 at 12:18 PM, bmu notifications@github.com wrote:
|
After some sleep, I see my initial confusion: From my point of view, the time zone is related to the data, not to the location. Maybe it is good to have information on the (legal) time zone of a location, but this is not necessarily an indicator for the time stamp used in e.g. measurement files (and I don't know, if this is clear for a user in general). |
My thought is to go in the other direction. Make the solar position methods only accept tz localized times, raise an error with naive times, and ignore the location object's tz attribute. This makes it so that there is only one way to do it and the user must be very explicit about it. If you have data, then it was recorded with a specific time convention (UTC, Europe/Berlin, US/Arizona) and I think the very first thing you should do when you import that data is to use |
I think this could be right, but I didn't used to do it this way. Time zone conversion was complicated before pandas, should be possible today for a user. |
I just discovered that pandas doesn't seem to behave well in one situation: I have data from PVsyst (no DST) that I am trying to load into pvlib to compare to a pvlib model. I am trying to align the timestamps, but pandas doesn't seem capable of localizing timestamps without applying DST. (I'd like to just specify UTC-5, instead of 'US/Eastern'.) I asked a question about this on stackexchange because it seems to be more of a pandas issue than pvlib issue, but perhaps people here have solved this problem already? If not, it's something that we can't rely on pandas for, though perhaps support is coming in 0.17. |
I think you want to localize with I suppose I should finish writing the pvlib timezone tutorial. |
I checked 'EST', and it still applied the UTC-4 to the periods between March and November, but the pytz.FixedOffset worked great. I had something in mind like that, but couldn't quite figure out how pytz and tz_localize interacted. Thanks! |
I think there were two potential actions:
Finally, I do think that better documentation can cover item 1 if others On Sun, Jun 21, 2015 at 12:36 PM, Will Holmgren notifications@github.com
|
I agree with @jforbess in both points. But I think we can shift both of them to a later release. |
Ok, thanks for the clarification. I am going to mark this issue as 0.3 and think about it again after this release is out. |
I think that the new code and the new documentation can close this issue. Here's the new proposed documentation: http://wholmgren-pvlib-python-new.readthedocs.org/en/contributing/timetimezones.html Please provide comments in #135, if you have them. Assuming no objections, I will close this when #135 is merged. A new issue could be created for adding true solar time to more functions, if desired. |
Just an idea: Am 15. März 2016 20:55:40 MEZ, schrieb Will Holmgren notifications@github.com:
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet. |
Regarding Santa Clara pvlib sprint: |
@bmu a Santa Clara milestone is good idea and it's great to hear that you'll be able to attend. Did you rsvp to Josh Stein? I did not see your name on a recent list of attendees. @dacoex and others: We don't yet know exactly what the agenda will be, but I expect that there will be a way to contribute remotely. We'll still be using GitHub, of course. I'll make a milestone and a new issue for further discussion. |
I think we should make sure, that time zones, other time references are used correctly.
We can have time stamps given as UTC, really related to a time zone, local time (without DST), mean solar time, true solar time, ...? This is an everyday problem from my experience, so we should be able to handle all of these formats at least in the future.
For now it could be ok to define, that all times should be given as UTC and leave all time conversion issue to the user.
As pandas has support for Julian dates since 0.14 (this is the pull request). I was thinking about creating a pull request to implement
to_solar_time
in pandas. However this is not easy to implement and I am not sure, if they accept it. But this way all time conversion would be in pandas an we could implement thinks based on pandas.The text was updated successfully, but these errors were encountered: