-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add LIS, validate/modify all existing
- Loading branch information
Showing
21 changed files
with
1,716 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import datetime | ||
import requests | ||
import re | ||
|
||
from bs4 import BeautifulSoup | ||
|
||
|
||
class ESI_Iterator: | ||
start_date = None | ||
end_date = None | ||
root_url = None | ||
date_format = "YYYYMMDD" | ||
|
||
# Default Constructor using datetime date | ||
def __init__(self, start_date, end_date, options): | ||
self.start_date = start_date | ||
self.end_date = end_date | ||
self.root_url = options['root_url'] | ||
self.week_type = options['week_type'] | ||
self.delta = 28 if self.week_type == '4WK' else 84 | ||
|
||
def get_range(self): | ||
return_obj = [] | ||
response = requests.get(self.root_url) | ||
soup = BeautifulSoup(response.text, 'html.parser') | ||
for _, link in enumerate(soup.findAll('a')): | ||
if link.get('href').endswith('.tif.gz'): | ||
_, wk, rest = link.get('href').split('_') | ||
if wk == self.week_type: | ||
end_time = datetime.datetime.strptime('{} {}'.format(rest[4:].replace('.tif.gz', ''), rest[:4]), | ||
'%j %Y') | ||
date = end_time - datetime.timedelta(days=self.delta) | ||
filename = link.get_text() | ||
if self.start_date <= date.date() <= self.end_date: | ||
return_obj.append({ | ||
'date': date.strftime('%Y%m%d'), | ||
'filename': filename, | ||
'source': self.root_url + filename, | ||
}) | ||
|
||
return return_obj |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.