def _get_url_for_date(self, date, **kwargs): """ Return URL for corresponding date. Parameters ---------- date : Python datetime object Returns ------- string The URL for the corresponding date. """ # default urllib password anonymous@ is not accepted by the NoRH FTP # server. include an accepted password in base url baseurl = 'ftp://*****:*****@[email protected]/pub/nsro/norh/data/tcx/' # We allow queries with no Wavelength but error here so that the query # does not get passed to VSO and spit out garbage. if 'wavelength' not in kwargs.keys() or not kwargs['wavelength']: raise ValueError( "Queries to NORH should specify either 17GHz or 34GHz as a Wavelength." "see http://solar.nro.nao.ac.jp/norh/doc/manuale/node65.html") else: wavelength = kwargs['wavelength'] # If wavelength is a single value GenericClient will have made it a # Quantity in the kwargs. if not isinstance(wavelength, u.Quantity): raise ValueError( "Wavelength to NORH must be one value not {}.".format( wavelength)) wavelength = wavelength.to(u.GHz, equivalencies=u.spectral()) if wavelength == 34 * u.GHz: final_url = urljoin(baseurl, date.strftime('%Y/%m/' + 'tcz' + '%y%m%d')) elif wavelength == 17 * u.GHz: final_url = urljoin(baseurl, date.strftime('%Y/%m/' + 'tca' + '%y%m%d')) else: raise ValueError( "NORH Data can be downloaded for 17GHz or 34GHz," " see http://solar.nro.nao.ac.jp/norh/doc/manuale/node65.html") return final_url
def _get_url_for_date(self, date, **kwargs): """ Return URL for corresponding date. Parameters ---------- date : Python datetime object Returns ------- string The URL for the corresponding date. """ filename = "lyra_{0:%Y%m%d-}000000_lev{1:d}_std.fits".format(date, kwargs.get('level',2)) base_url = "http://proba2.oma.be/lyra/data/bsd/" url_path = urljoin(date.strftime('%Y/%m/%d/'), filename) return urljoin(base_url, url_path)
def _get_url_for_date(self, date, **kwargs): """ Return URL for corresponding date. Parameters ---------- date : Python datetime object Returns ------- string The URL for the corresponding date. """ # default urllib password anonymous@ is not accepted by the NoRH FTP # server. include an accepted password in base url baseurl = 'ftp://*****:*****@[email protected]/pub/nsro/norh/data/tcx/' # We allow queries with no Wavelength but error here so that the query # does not get passed to VSO and spit out garbage. if 'wavelength' not in kwargs.keys() or not kwargs['wavelength']: raise ValueError("Queries to NORH should specify either 17GHz or 34GHz as a Wavelength." "see http://solar.nro.nao.ac.jp/norh/doc/manuale/node65.html") else: wavelength = kwargs['wavelength'] # If wavelength is a single value GenericClient will have made it a # Quantity in the kwargs. if not isinstance(wavelength, u.Quantity): raise ValueError("Wavelength to NORH must be one value not {}.".format(wavelength)) wavelength = wavelength.to(u.GHz, equivalencies=u.spectral()) if wavelength == 34 * u.GHz: final_url = urljoin(baseurl, date.strftime('%Y/%m/' + 'tcz' + '%y%m%d')) elif wavelength == 17 * u.GHz: final_url = urljoin(baseurl, date.strftime('%Y/%m/' + 'tca' + '%y%m%d')) else: raise ValueError("NORH Data can be downloaded for 17GHz or 34GHz," " see http://solar.nro.nao.ac.jp/norh/doc/manuale/node65.html") return final_url
def _get_url_for_date(self, date, **kwargs): """ Return URL for corresponding date. Parameters ---------- date : Python datetime object Returns ------- URL : string """ base_url = 'http://lasp.colorado.edu/eve/data_access/evewebdata/quicklook/L0CS/SpWx/' return urljoin(base_url, date.strftime('%Y/%Y%m%d') + '_EVE_L0CS_DIODES_1m.txt')
def check_download_file(filename, remotepath, download_dir, remotename=None, replace=False): """ Downloads a file from remotepath to localpath if it isn't there. This function checks whether a file with name filename exists in the location, localpath, on the user's local machine. If it doesn't, it downloads the file from remotepath. Parameters ---------- filename : string Name of file. remotepath : string URL of the remote location from which filename can be downloaded. download_dir : string The files directory. remotename : (optional) string filename under which the file is stored remotely. Default is same as filename. replace : (optional) bool If True, file will be downloaded whether or not file already exists locally. Examples -------- >>> from sunpy.util.net import check_download_file >>> remotepath = "http://www.download_repository.com/downloads/" >>> check_download_file("filename.txt", remotepath, download_dir='.') # doctest: +SKIP """ # Check if file already exists locally. If not, try downloading it. if replace or not os.path.isfile(os.path.join(download_dir, filename)): # set local and remote file names be the same unless specified # by user. if not isinstance(remotename, six.string_types): remotename = filename download_file(urljoin(remotepath, remotename), download_dir, default=filename, overwrite=replace)