data_fetcher.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:scikit-dataaccess 作者: MITHaystack 项目源码 文件源码
def downloadFullDataset(cls, out_file=None, use_file=None):
        '''
        Download GLDAS data

        @param out_file: Output filename for parsed data
        @param use_file: Directory of downloaded data. If None, data will be downloaded.

        @return Absolute path of parsed data
        '''

        # No post processing for this data is necessary. If local data is
        # specified, just set its location.
        if use_file != None:
            print('Setting data location for local data')
            return os.path.abspath(use_file)


        # If no local data, download data from server
        print("Downloading GLDAS Land Mass Data")
        ftp = FTP("podaac-ftp.jpl.nasa.gov")
        ftp.login()
        ftp.cwd('allData/tellus/L3/gldas_monthly/netcdf/')
        dir_list = list(ftp.nlst(''))
        file_list = [file for file in dir_list if re.search('.nc$', file)]
        if len(file_list) > 1:
            raise ValueError('Too many files found in GLDAS directory')

        if out_file == None:
            out_file = file_list[0]

        ftp.retrbinary('RETR ' + file_list[0], open(''+out_file, 'wb').write)


        cls.setDataLocation('gldas', os.path.abspath(file_list[0]))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号