예제 #1
0
 def execute(self):
     """Execute the request using the selected backend.
     
     :rtype: Path to an output file/folder or :class:`ocgis.OcgCollection`
     """
     interp = OcgInterpreter(self)
     return (interp.execute())
예제 #2
0
파일: operations.py 프로젝트: cjh1/ocgis
 def execute(self):
     """Execute the request using the selected backend.
     
     :rtype: Path to an output file/folder or dictionary composed of :class:`ocgis.api.collection.AbstractCollection` objects.
     """
     interp = OcgInterpreter(self)
     return(interp.execute())
예제 #3
0
파일: operations.py 프로젝트: imclab/ocgis
 def execute(self):
     """Execute the request using the selected backend.
     
     :rtype: Path to an output file/folder or dictionary composed of :class:`ocgis.api.collection.AbstractCollection` objects.
     """
     interp = OcgInterpreter(self)
     return (interp.execute())
예제 #4
0
 def execute(self):
     """Execute the request using the selected backend.
     
     :rtype: Path to an output file/folder or :class:`ocgis.OcgCollection`
     """
     interp = OcgInterpreter(self)
     return(interp.execute())
예제 #5
0
def _get_interpreter_return_(ops):
    try:
        interp = Interpreter.get_interpreter(ops)
    except InterpreterNotRecognized:
        interp = OcgInterpreter(ops)
    ret = interp.execute()
    return (ret)
예제 #6
0
파일: helpers.py 프로젝트: aashish24/ocgis
def _get_interpreter_return_(ops):
    try:
        interp = Interpreter.get_interpreter(ops)
    except InterpreterNotRecognized:
        interp = OcgInterpreter(ops)
    ret = interp.execute()
    return(ret)
예제 #7
0
 def test_get_progress_and_configure_logging(self):
     env.VERBOSE = True
     rd = self.test_data.get_rd('cancm4_tas')
     ops = OcgOperations(dataset=rd)
     outdir = self.current_dir_output
     prefix = 'foo'
     interp = OcgInterpreter(ops)
     self.assertIsNone(logging._warnings_showwarning)
     self.assertTrue(ocgis_lh.null)
     env.SUPPRESS_WARNINGS = False
     progress = interp._get_progress_and_configure_logging_(outdir, prefix)
     self.assertIsInstance(progress, ProgressOcgOperations)
     self.assertFalse(ocgis_lh.null)
     self.assertFalse(logging._warnings_showwarning)
예제 #8
0
    def test_get_converter(self):
        rd = self.test_data.get_rd('cancm4_tas')
        ops = OcgOperations(dataset=rd)
        outdir = self.current_dir_output
        prefix = 'foo'
        interp = OcgInterpreter(ops)
        so = SubsetOperation(ops)
        ret = interp._get_converter_(NumpyConverter, outdir, prefix, so)
        self.assertIsInstance(ret, NumpyConverter)

        ops = OcgOperations(dataset=rd, melted=True, output_format=constants.OUTPUT_FORMAT_SHAPEFILE)
        interp = OcgInterpreter(ops)
        ret = interp._get_converter_(ShpConverter, outdir, prefix, so)
        self.assertIsInstance(ret, ShpConverter)
        self.assertTrue(ret.melted)
예제 #9
0
파일: OLD_work.py 프로젝트: aashish24/ocgis
 def test_get_data(self):
     start = 0
             
     for ii,ops in self.iter_operations(start=start):
         print(ii)
         ret = None
         
         try:
             ret = OcgInterpreter(ops).execute()
             import ipdb;ipdb.set_trace()
         except Exception as e:
             if self._allowed_exception_(ops,e) is False:
                 print traceback.format_exc()
         finally:
             if ret is not None and ret.startswith(tempfile.gettempdir()):
                 print(ret)
                 if any([ret.endswith(ext) for ext in ['shp','csv','nc']]):
                     ret = os.path.split(ret)[0]
                 shutil.rmtree(ret)
예제 #10
0
파일: test_simple.py 프로젝트: imclab/ocgis
    def get_ret(self,
                ops=None,
                kwds={},
                shp=False,
                time_range=None,
                level_range=None):
        if ops is None:
            ops = self.get_ops(kwds,
                               time_range=time_range,
                               level_range=level_range)
        self.ops = ops
        ret = OcgInterpreter(ops).execute()

        if shp or self.return_shp:
            kwds2 = kwds.copy()
            kwds2.update({'output_format': 'shp'})
            ops2 = OcgOperations(**kwds2)
            OcgInterpreter(ops2).execute()

        return (ret)
예제 #11
0
파일: OLD_work.py 프로젝트: aashish24/ocgis
    def test_get_data(self):
        start = 0

        for ii, ops in self.iter_operations(start=start):
            print(ii)
            ret = None

            try:
                ret = OcgInterpreter(ops).execute()
                import ipdb
                ipdb.set_trace()
            except Exception as e:
                if self._allowed_exception_(ops, e) is False:
                    print traceback.format_exc()
            finally:
                if ret is not None and ret.startswith(tempfile.gettempdir()):
                    print(ret)
                    if any([ret.endswith(ext)
                            for ext in ['shp', 'csv', 'nc']]):
                        ret = os.path.split(ret)[0]
                    shutil.rmtree(ret)
예제 #12
0
파일: test_360.py 프로젝트: imclab/ocgis
 def test_high_res(self):
     ocgis.env.OVERWRITE = True
     nc_spatial = NcSpatial(0.5,(-90.0,90.0),(0.0,360.0))
     path = self.make_data(nc_spatial)
     
     dataset = {'uri':path,'variable':'foo'}
     output_format = 'nc'
     snippet = True
     geom = self.nebraska
     
     for s_abstraction in ['point','polygon']:
         interface = {'s_abstraction':s_abstraction}
         ops = OcgOperations(dataset=dataset,output_format=output_format,
                             geom=geom,snippet=snippet,abstraction=s_abstraction)
         ret = OcgInterpreter(ops).execute()
예제 #13
0
파일: test_360.py 프로젝트: imclab/ocgis
 def test_low_res(self):
     ocgis.env.OVERWRITE = True
     nc_spatial = NcSpatial(5.0,(-90.0,90.0),(0.0,360.0))
     path = self.make_data(nc_spatial)
     
     dataset = {'uri':path,'variable':'foo'}
     output_format = 'shp'
     geom = self.nebraska
     ip = Inspect(dataset['uri'],dataset['variable'])
     
     for s_abstraction in ['point','polygon']:
         interface = {'s_abstraction':s_abstraction}
         ops = OcgOperations(dataset=dataset,
                             output_format=output_format,
                             geom=geom,
                             abstraction=s_abstraction)
         ret = OcgInterpreter(ops).execute()
예제 #14
0
파일: OLD_work.py 프로젝트: aashish24/ocgis
    def test_profile(self):
        raise (SkipTest)
        prev = sys.stdout
        with open('/tmp/out.txt', 'w') as f:
            sys.stdout = f
            start = 0
            for ii, ops in self.iter_operations(start=start):
                t1 = time.time()
                OcgInterpreter(ops).execute()
                t2 = time.time()
                if int(ops.geom[0]['geom'].area) == 1096:
                    geom = 'states'
                else:
                    geom = 'bb'
                prnt = [
                    geom, ops.dataset[0]['uri'], ops.output_format, t2 - t1
                ]
                print ','.join(map(str, prnt))
                time.sleep(5)


#                break
        sys.stdout = prev
예제 #15
0
파일: test_simple.py 프로젝트: imclab/ocgis
 def make_shp(self):
     ops = OcgOperations(dataset=self.dataset, output_format='shp')
     OcgInterpreter(ops).execute()