예제 #1
0
    def run(self, args):
        
        print 'OCG args=%s' % args
        
        # apply time_range and time_region constraints to each dataset
        for dataset in args['datasets']:
            dataset['time_range'] = args['time_range']
            dataset['time_region'] = args['time_region']
        del args['time_range']
        del args['time_region']
      
        print 'Running OCGIS job with arguments=%s' % args

        # fake invocation on laptop
        if self.debug:
            time.sleep(SLEEP_SECONDS)
            download_path = "/usr/NCPP/static/ocgis/ocgis_output/MaurerNew_ARRM-CGCM3_bias_tasmax_mean_mon1_1971-2000_US48.jpg"
           
         # real invocation on NOAA servers 
        else:
            import ocgis
            
            # create output directory
            dir_output = os.path.join(self.rootDir, args['dir_output'])
            # remove existing directory, generated by previous installation
            if os.path.exists(dir_output):
                rmtree(dir_output)
            # generate empty directory
            os.makedirs(dir_output)             
                                    
            # build up the list of request datasets
            print "ocgis.RequestDatasetCollection(args['datasets']): %s" % args['datasets']
            datasets = ocgis.RequestDatasetCollection(args['datasets'])

            ## construct the operations call
            ops = ocgis.OcgOperations(dataset=datasets, 
                                      geom=args['geom'],
                                      select_ugid=args['select_ugid'],
                                      agg_selection=args['agg_selection'],
                                      aggregate=args['aggregate'], 
                                      spatial_operation=args['spatial_operation'], 
                                      calc=args['calc'], 
                                      calc_grouping=args['calc_grouping'],
                                      calc_raw=args['calc_raw'],
                                      prefix=args['prefix'],
                                      output_format=args['output_format'], 
                                      dir_output=dir_output,
                                      headers=args['headers'])

            # execute the operation
            # 'path' points to the top-level folder containing the output data
            path = ops.execute()
            # 'download_path' points to single file for user to download
            download_path = ocgis.format_return(path, ops, with_auxiliary_files=args['with_auxiliary_files'])

        # return ouput
        url = download_path.replace(self.rootDir, self.rootUrl)
        return url
예제 #2
0
    def run(self, args):
        
        print 'Running OCGIS job with arguments=%s' % args

        # fake invocation on laptop
        if self.debug:
            time.sleep(SLEEP_SECONDS)
            download_path = "/usr/NCPP/static/ocgis/ocgis_output/MaurerNew_ARRM-CGCM3_bias_tasmax_mean_mon1_1971-2000_US48.jpg"
           
         # real invocation on NOAA servers 
        else:
            import ocgis
            
            # create output directory
            dir_output = os.path.join(self.rootDir, args['dir_output'])
            # remove existing directory, generated by previous installation
            if os.path.exists(dir_output):
                rmtree(dir_output)
            # generate empty directory
            os.makedirs(dir_output)             
                                    
            # build up the list of request datasets
            '''
            datasets = []
            iter_tuple = [args[key] for key in ['uri', 'variable', 't_calendar', 't_units', 'alias']]
            time_range=args['time_range']
            time_region=args['time_region']
            for uri,variable,t_calendar,t_units,alias in zip(*iter_tuple):
                rd = ocgis.RequestDataset(uri=uri,variable=variable,t_calendar=t_calendar,t_units=t_units,
                                  time_range=time_range,time_region=time_region,alias=alias)
                datasets.append(rd)
            '''      
            datasets = ocgis.RequestDatasetCollection(args['datasets'])

            ## construct the operations call
            ops = ocgis.OcgOperations(dataset=datasets, 
                                      geom=args['geom'],
                                      select_ugid=args['select_ugid'],
                                      agg_selection=args['agg_selection'],
                                      aggregate=args['aggregate'], 
                                      spatial_operation=args['spatial_operation'], 
                                      calc=args['calc'], 
                                      calc_grouping=args['calc_grouping'],
                                      calc_raw=args['calc_raw'],
                                      prefix=args['prefix'],
                                      output_format=args['output_format'], 
                                      dir_output=dir_output,
                                      headers=args['headers'])

            # execute the operation
            # 'path' points to the top-level folder containing the output data
            path = ops.execute()
            # 'download_path' points to single file for user to download
            download_path = ocgis.format_return(path, ops, with_auxiliary_files=args['with_auxiliary_files'])

        # return ouput
        url = download_path.replace(self.rootDir, self.rootUrl)
        return url