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

5 overpass download #51

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rs_tools/_src/data/goes/downloader_goes16.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def download(
daily_window_t0=daily_window_t0,
daily_window_t1=daily_window_t1,
time_step=time_step,
save_dir=Path(save_dir).joinpath("goes16"),
save_dir=Path(save_dir), #.joinpath("goes16"),
)
logger.info("Downloading GOES 16 Data...")
goes16_filenames = dc_goes16_download.download()
Expand Down
2 changes: 1 addition & 1 deletion rs_tools/_src/data/modis/downloader_aqua.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def download(
end_date=end_date,
start_time=start_time,
end_time=end_time,
save_dir=Path(save_dir).joinpath("aqua"),
save_dir=Path(save_dir), #.joinpath("aqua"),
bounding_box=bounding_box,
)
logger.info("Downloading AQUA Data...")
Expand Down
2 changes: 1 addition & 1 deletion rs_tools/_src/data/modis/downloader_aqua_day.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def download(
end_date=end_date,
start_time=start_time,
end_time=end_time,
save_dir=Path(save_dir).joinpath("aqua"),
save_dir=Path(save_dir), #.joinpath("aqua"),
bounding_box=bounding_box,
)
logger.info("Downloading AQUA Data...")
Expand Down
2 changes: 1 addition & 1 deletion rs_tools/_src/data/modis/downloader_terra.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def download(
end_date=end_date,
start_time=start_time,
end_time=end_time,
save_dir=Path(save_dir).joinpath("terra"),
save_dir=Path(save_dir), #.joinpath("terra"),
bounding_box=bounding_box,
)
logger.info("Downloading TERRA Data...")
Expand Down
2 changes: 1 addition & 1 deletion rs_tools/_src/data/modis/downloader_terra_day.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def download(
end_date=end_date,
start_time=start_time,
end_time=end_time,
save_dir=Path(save_dir).joinpath("terra"),
save_dir=Path(save_dir), #.joinpath("terra"),
bounding_box=bounding_box,
)
logger.info("Downloading TERRA Data...")
Expand Down
42 changes: 21 additions & 21 deletions rs_tools/_src/data/msg/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,19 @@ def msg_download(
if sub_files_list is None:
logger.info(f"Could not find data for time {itime}. Skipping to next time.")
else:
logger.info(f"Successfully downloaded data for time {itime}.")
files += sub_files_list
successful_queries.append(itime)

return (files, successful_queries)

def _download(time: datetime, data_product: str, save_dir: str, datastore):
products = _compile_msg_products(data_product=data_product, time=time, datastore=datastore)
sub_files_list = _msg_data_download(products=products, save_dir=save_dir)
try:
products = _compile_msg_products(data_product=data_product, time=time, datastore=datastore)
sub_files_list = _msg_data_download(products=products, save_dir=save_dir)
except Exception as error:
logger.error(f"Error downloading data: {error}")
sub_files_list = None
return sub_files_list

def _compile_msg_products(data_product: str, time: datetime, datastore):
Expand All @@ -162,25 +167,20 @@ def _compile_msg_products(data_product: str, time: datetime, datastore):
return products

def _msg_data_download(products, save_dir: str):
try:
for product in products:
for entry in product.entries:
if entry.endswith(".nat") or entry.endswith(".grb"):
with product.open(entry=entry) as fsrc:
# Create a full file path for saving the file
save_path = os.path.join(save_dir, os.path.basename(fsrc.name))
# Check if file already exists
if os.path.exists(save_path):
print(f"File {save_path} already exists. Skipping download.")
return [save_path]
else:
with open(save_path, mode='wb') as fdst:
shutil.copyfileobj(fsrc, fdst)
print(f"Successfully downloaded {entry}.")
return [save_path]
except Exception as error:
print(f"Error downloading product': '{error}'")
pass
for product in products:
for entry in product.entries:
if entry.endswith(".nat") or entry.endswith(".grb"):
with product.open(entry=entry) as fsrc:
# Create a full file path for saving the file
save_path = os.path.join(save_dir, os.path.basename(fsrc.name))
# Check if file already exists
if os.path.exists(save_path):
return [save_path]
else:
with open(save_path, mode='wb') as fdst:
shutil.copyfileobj(fsrc, fdst)
print(f"Successfully downloaded {entry}.")
return [save_path]

def _check_eumdac_login(eumdac_key: str, eumdac_secret: str) -> bool:
"""check if eumdac login is available in environment variables / as input arguments"""
Expand Down
2 changes: 1 addition & 1 deletion rs_tools/_src/data/msg/downloader_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def download(
daily_window_t0=daily_window_t0,
daily_window_t1=daily_window_t1,
time_step=time_step,
save_dir=Path(save_dir).joinpath("msg"),
save_dir=Path(save_dir), #.joinpath("msg"),
)
logger.info("Downloading MSG Data...")
msg_filenames = dc_msg_download.download()
Expand Down
Loading