Last active
August 21, 2020 00:43
-
-
Save AdrianoPereira/c1b251ad85e15f8505ee9cad27a10ef6 to your computer and use it in GitHub Desktop.
Script to download GoAmazon data from ARM
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
import numpy as np | |
from goamazondownloader import SBandRadar | |
import tarfile as tar | |
import os | |
''' | |
Before to running, install the `goamazondownloader` library using the command | |
below: | |
pip install goamazondownloader | |
''' | |
if __name__ == "__main__": | |
years = [2014] # years | |
months = np.arange(1, 13) # From jan to dec | |
days = np.arange(1, 32) # From day 1 to day 31 | |
hours = np.arange(0, 24) # From 0 to 23 hours | |
minutes = np.arange(0, 60, 12) # 0, 12, 24, 36, 48 | |
for year in years: | |
for month in months: | |
for day in days: | |
for hour in hours: | |
for minute in minutes: | |
info = dict(year=year, month=month, day=day, hour=hour, | |
minute=minute) | |
try: | |
downloader = SBandRadar(**info) | |
downloader.login(username="") # Enter your username here | |
downloader.set_remote_url() | |
downloader.download() | |
if os.path.exists(downloader.filename): | |
tarfilename = '%s.tar.gz'%downloader.filename | |
shortname = downloader.filename.split('/')[-1].replace('.nc', '') | |
compress = tar.open(tarfilename, 'w:gz') | |
compress.add(downloader.filename) | |
compress.close() | |
os.remove(downloader.filename) | |
except IndexError: | |
print('There is no data for this datetime') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment