Download orbit file in separate folders.
Agupta662 opened this issue · comments
I have a hundred Sentinel-1 SLC products and want to download an orbit file for each product. Instead of downloading all the orbit files into one folder, I want to download each orbit file into separate folders and name the folders according to the date of the SLC product.
Hmm, this seems a little specific to include as a feature in the main library, since it immediately raises a bunch of questions (what would the naming scheme be? should the folders by named by the orbit date? the SAFE date? the start or the end acquisition time?).
But the products
module should make it pretty easy to separate things out, since you can do products.Sentinel('./path/to/file.SAFE').start_time
and get the datetime of the slc.
alternatively, you can call the function that runs in the main CLI, something like
from pathlib import Path
from eof.download import download_eofs, find_scenes_to_download
dts, missions = find_scenes_to_download(
search_path=search_path, save_dir=save_dir
)
orbit_paths = download_eofs(orbit_dts=dts, missions=missions)
for dt, orbit_path in zip(dts, orbit_paths):
# Make a new folder for the date
date_str = dt.strftime("%Y-%m-%d") # or however you want it named
# Move the location to the new folder you want
p = Path(date_str)
p.mkdir()
orbit_path.rename(p / orbit_path.name)
It is working. Thanks a lot @scottstanie !