当前位置: 首页>>代码示例>>Python>>正文


Python SOAPProxy.searchForFiles方法代码示例

本文整理汇总了Python中SOAPpy.SOAPProxy.searchForFiles方法的典型用法代码示例。如果您正苦于以下问题:Python SOAPProxy.searchForFiles方法的具体用法?Python SOAPProxy.searchForFiles怎么用?Python SOAPProxy.searchForFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SOAPpy.SOAPProxy的用法示例。


在下文中一共展示了SOAPProxy.searchForFiles方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: range

# 需要导入模块: from SOAPpy import SOAPProxy [as 别名]
# 或者: from SOAPpy.SOAPProxy import searchForFiles [as 别名]

	for i in range(len(starts)): # for each time period
		st=starts[i]
		et=ends[i]
		print "time interval ", st, '<---->', et
		for p in ps: # for each product
			for dnb in dnbs: # for each Day/Night/Both Setting
				print "searching for: ", p, dnb
				try:
					# search for files
					fIDs=client.searchForFiles(product=p,
								   collection=c, 
								   startTime=st, 
								   endTime=et, 
								   north=n, 
								   south=s, 
								   east=e, 
								   west=w, 
								   coordsOrTiles='coords', 
								   dayNightBoth=dnb)
				except:
					print "exception raised, tring client again." 
					
					client = SOAPProxy(clientUrl);
					time.sleep(10)
					fIDs=client.searchForFiles(product=p,
								   collection=c, 
								   startTime=st, 
								   endTime=et, 
								   north=n, 
								   south=s, 
开发者ID:BDHudson,项目名称:modisSed,代码行数:33,代码来源:SoapPyDownloadModisv003.py

示例2: MoDis

# 需要导入模块: from SOAPpy import SOAPProxy [as 别名]
# 或者: from SOAPpy.SOAPProxy import searchForFiles [as 别名]
class MoDis(object):
    '''
    如果文件未上传到网络,则得不到下载地址
    测试:依次输入:MOD021KM,5,2008-10-23,2008-10-23
    '''
    def __init__(self):
        self.url = 'http://modwebsrv.modaps.eosdis.nasa.gov/axis2/services/MODAPSservices'
        self.client = SOAPProxy(self.url)

    # 检查日期的正确性
    def is_valid_date(self, date_string):

        try:
            date = datetime.strptime(date_string, "%Y-%m-%d")
            if date <= datetime.now():
                return True
            else:
                return False
        except:
            return False

    # 得到文件ID
    def get_id(self):
        product_code = raw_input('Enter Product Code (default:MOD09):')
        collection = raw_input('Enter Collection  Number:')

        start_date = raw_input('Enter Start Date(YYYY-MM-DD):')
        while not self.is_valid_date(start_date):
            start_date = raw_input('Wrong start date code,please enter again:')

        stop_date = raw_input('Enter Stop Date(YYYY-MM-DD):')
        while not self.is_valid_date(start_date):
            start_date = raw_input('Wrong stop date code,please enter again:')

        id_list = self.client.searchForFiles(
                                         product=product_code if product_code else 'MOD09',
                                         collection=collection,
                                         start=start_date,
                                         stop=stop_date,
                                         coordsOrTiles='global',
                                         dayNightBoth='DNB',
                                         north='90',
                                         south='-90',
                                         west='-180',
                                         east='180',
                                         )
        # 对ID分组,防止ID过多网站不响应
        group_number = divmod(len(id_list), 130)[0]
        print id_list,group_number
        if group_number > 0:
            id_lists = []
            start = 0
            for i in range(group_number):
                id_lists.append(id_list[start:start+130])
                start += 130
            id_lists.append(id_list[start:])
            print id_lists, len(id_lists)
        else:
            id_lists = id_list
        return id_lists

    #获得下载地址
    def get_urls(self):
        id_lists = self.get_id()
        for ids in id_lists:
            print ','.join(ids)
            urls = self.client.getFileUrls(fileIds=','.join(ids))
            print urls
            # 写入文件
            with open('modisurls.txt','a+') as f:
                f.write('\n'.join(urls) + '\n')
开发者ID:ycroft,项目名称:MDA,代码行数:73,代码来源:modis.py

示例3: modis_download

# 需要导入模块: from SOAPpy import SOAPProxy [as 别名]
# 或者: from SOAPpy.SOAPProxy import searchForFiles [as 别名]
def modis_download(product='MOD05_L2',
                    collection='5',
                    startTime='2008-01-01 00:00:00',
                    endTime='2008-01-01 23:59:59',
                    #startTime='2008-01-01',
                    #endTime='2008-01-01',
                    north=40,
                    south=30,
                    west=-80,
                    east=-70,
                    coordsOrTiles='coords',
                    dayNightBoth='DNB',
                    outPath='',
                    download_all=True):
  url = 'http://modwebsrv.modaps.eosdis.nasa.gov/axis2/services/MODAPSservices';
  client = SOAPProxy(url);
  fileIdList = client.searchForFiles(product=product,collection=collection,startTime=startTime,endTime=endTime,north=north,south=south,west=west,east=east,coordsOrTiles=coordsOrTiles,dayNightBoth=dayNightBoth);

  fileIds = string.join(fileIdList, sep=',')
  #print fileIds
  fileUrlList = client.getFileUrls(fileIds=fileIds);
  nFiles = len(fileUrlList)
  if nFiles == 0:
    print 'failed to fetch any file'
    exit()
  
  if not download_all:
    nFiles = 1
    
  logFile = open(listFile, 'wb')
  #for fileUrl in fileUrlList:
  #  logFile.write('%s\n' %fileUrl)
  #logFile.close()
  for iFile in range(0,nFiles):    
    logFile.write('%s\n' %fileUrlList[iFile])
  logFile.close()
    
  HOST = os.path.basename(urlparse.urlsplit(fileUrlList[0])[1])
  DIRN = os.path.dirname(urlparse.urlsplit(fileUrlList[0])[2])
  f = MYFTP(HOST, '', '', DIRN)
  f.login()

  i = 1
  for iFile in range(0,nFiles):
  #for fileUrl in fileUrlList:
    fileUrl = fileUrlList[iFile]
    print '%d of %d..' %(i, nFiles)
    file_name = fileUrl.split('/')[-1]
    HOST = os.path.basename(urlparse.urlsplit(fileUrl)[1])
    DIRN = os.path.dirname(urlparse.urlsplit(fileUrl)[2])
    FILE = os.path.basename(urlparse.urlsplit(fileUrl)[2])
    try:
      f.ftp.cwd(DIRN)
    except ftplib.error_perm:
      print 'ERRORL cannot CD to "%s"' % DIRN
      continue
    if outPath == '':
      outFile = FILE
    else:
      outFile = outPath + r'/' + FILE
    f.download_file(FILE, outFile)
    i += 1
开发者ID:loongfee,项目名称:codefragment,代码行数:64,代码来源:modis_downloader.py


注:本文中的SOAPpy.SOAPProxy.searchForFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。