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

TypeError: 'NoneType' object is not iterable when trying to get available scans in range for current day #14

Open
ajdas1 opened this issue Oct 11, 2023 · 0 comments

Comments

@ajdas1
Copy link

ajdas1 commented Oct 11, 2023

Hello,

I've been working with your package to retrieve a list of files for a specific radar from an AWS bucket, and ran into a problem with retrieving a list of radar scans for the current day.

Example code that throws an error:

import nexradaws as nexr
from datetime import datetime, timedelta

start_time = datetime.now().replace(hour=10, minute=0, second=0, microsecond=0)
end_time = start_time + timedelta(hours=2)
radar_id = "KEAX"

conn = nexr.NexradAwsInterface()
file_list = conn.get_avail_scans_in_range(start_time, end_time, radar_id)

>>> TypeError: 'NoneType' object is not iterable

We have linked this error to the _datetime_range() function within get_avail_scans_in_range(), which is defined as:

    def _datetime_range(self, start=None, end=None):
        span = end - start
        if span.seconds > 0:
            numdays = span.days + 1
        else:
            numdays = span.days
        for i in range(0, numdays + 1):
            yield start + timedelta(days=i)

The issue is with the +1s in the above function, and the datetime range it returns includes the current and following day to what is defined as end_time.
Therefore, if the end_time is defined as the current day, it is trying to look for files from the following day, which do not exist, and returns the TypeError. The function performs as expected for all other days that are not the current day.

Thank you for looking into this.

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

No branches or pull requests

1 participant