Skip to content
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

Improve timing in collector nightevents #476

Merged

Conversation

dngomez
Copy link
Contributor

@dngomez dngomez commented Jul 18, 2024

Change nightevents utc and local time lists to be created from scratch using pandas

@stroncod
Copy link
Contributor

is this faster somehow ? I don't understand the reason of the change, can you elaborate a bit?

@dngomez
Copy link
Contributor Author

dngomez commented Jul 18, 2024

Exactly, it is faster, the Time translation from astropy to datetime (to_datetime with an specific ZoneInfo) objects takes a couple of minutes and creating the events from scratch using pandas to have the same datetime objects takes just a few seconds.

Computing the time.time() I get.
The current code 112.71s
With the change 4.70s

for start, end in zip(dt_time_starts, dt_time_ends)]
local_times = [dt.tz_convert(self.site.timezone) for dt in utc_times]
utc_times = [dt.to_pydatetime() for dt in utc_times]
local_times = [dt.to_pydatetime() for dt in local_times]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the native python datetimes objects retain the timezone after transformation?

@stroncod
Copy link
Contributor

Great, thanks for the explanation. Approved!

@dngomez dngomez merged commit af901df into main Jul 18, 2024
3 checks passed
@stroncod stroncod deleted the GSCHED-709-improve-timing-in-collector-night-events-creation branch August 1, 2024 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants