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


Python views.Cutout类代码示例

本文整理汇总了Python中bossspatialdb.views.Cutout的典型用法代码示例。如果您正苦于以下问题:Python Cutout类的具体用法?Python Cutout怎么用?Python Cutout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_request_cutout_invalid_zargs

    def test_request_cutout_invalid_zargs(self):
        """
        Test initialization of cutout arguments for a invalid cutout request. The x-args are outside the coordinate
        frame
        :return:
        """
        url = '/' + version + '/cutout/col1/exp1/channel1/0/0:6/0:6/0:1040/'

        # Create the request
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = Cutout().initialize_request(request)
        drfrequest.version = version

        # Create the request dict
        request_args = {
            "service": "cutout",
            "collection_name": "col1",
            "experiment_name": "exp1",
            "channel_name": "channel1",
            "resolution": 2,
            "x_args": "0:6",
            "y_args": "0:6",
            "z_args": "0:1040",
            "time_args": None
        }
        with self.assertRaises(BossError):
            BossRequest(drfrequest, request_args)
开发者ID:jhuapl-boss,项目名称:boss,代码行数:28,代码来源:test_requests.py

示例2: test_request_cutout_filter_no_time

    def test_request_cutout_filter_no_time(self):
        """
        Test initialization of boss_key for a time sample range
        :return:
        """
        url = '/' + version + '/cutout/col1/exp1/channel3/2/0:5/0:6/0:2/?filter=1,2,3,4'
        expected_ids = np.array([1, 2, 3, 4])
        expected_ids = expected_ids.astype(np.uint64)

        # Create the request
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = Cutout().initialize_request(request)
        drfrequest.version = version

        # Create the request dict
        request_args = {
            "service": "cutout",
            "version": version,
            "collection_name": 'col1',
            "experiment_name": 'exp1',
            "channel_name": 'channel3',
            "resolution": 2,
            "x_args": "0:5",
            "y_args": "0:6",
            "z_args": "0:2",
            "time_args": None,
            "ids": '1,2,3,4'
        }

        ret = BossRequest(drfrequest, request_args)
        self.assertEqual(np.array_equal(ret.get_filter_ids(),expected_ids),True)
开发者ID:jhuapl-boss,项目名称:boss,代码行数:32,代码来源:test_requests.py

示例3: test_basic_resource_get_downsampled_extent_dims_isotropic

    def test_basic_resource_get_downsampled_extent_dims_isotropic(self):
        """Test downsample extent isotropic

        Returns:
            None

        """
        url = '/' + version + '/cutout/col1/exp_iso/channel1/0/0:5/0:6/0:2/'

        # Create the request
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = Cutout().initialize_request(request)
        drfrequest.version = version

        request_args = {
            "service": "cutout",
            "collection_name": "col1",
            "experiment_name": "exp_iso",
            "channel_name": "channel1",
            "resolution": 0,
            "x_args": "0:5",
            "y_args": "0:6",
            "z_args": "0:2",
            "time_args": None
        }

        req = BossRequest(drfrequest, request_args)
        resource = BossResourceDjango(req)

        extent_dims = resource.get_downsampled_extent_dims()
        self.assertEqual(len(extent_dims), 8)
        self.assertEqual(extent_dims[0], [2000, 5000, 200])
        self.assertEqual(extent_dims[1], [1000, 2500, 100])
        self.assertEqual(extent_dims[3], [250, 625, 25])
开发者ID:jhuapl-boss,项目名称:boss,代码行数:35,代码来源:test_djangoresource.py

示例4: test_request_cutout_init_cutoutargs_time_range

    def test_request_cutout_init_cutoutargs_time_range(self):
        """
        Test initialization of boss_key for a time sample range
        :return:
        """
        url = '/' + version + '/cutout/col1/exp1/channel1/2/0:5/0:6/0:2/1:5/'

        # Create the request
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = Cutout().initialize_request(request)
        drfrequest.version = version

        # Create the request dict
        request_args = {
            "service": "cutout",
            "version": version,
            "collection_name": 'col1',
            "experiment_name": 'exp1',
            "channel_name": 'channel1',
            "resolution": 2,
            "x_args": "0:5",
            "y_args": "0:6",
            "z_args": "0:2",
            "time_args": "1:5"
        }

        ret = BossRequest(drfrequest, request_args)
        time = ret.get_time()
        self.assertEqual(time, range(1, 5))
        self.assertEqual(ret.time_request, True)
开发者ID:jhuapl-boss,项目名称:boss,代码行数:31,代码来源:test_requests.py

示例5: test_request_cutout_invalid_resolution

    def test_request_cutout_invalid_resolution(self):
        """
        Test initialization of cutout requests for an invalid datamodel - experiment  does not exist for the collection
        :return:
        """
        url = '/' + version + '/cutout/col2/exp1/channel1/92/0:5/0:6/0:2/'
        col = 'col1'
        exp = 'exp1'
        channel = 'channel1'

        # Create the request
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = Cutout().initialize_request(request)
        drfrequest.version = version

        # Create the request dict
        request_args = {
            "service": "cutout",
            "version": version,
            "collection_name": col,
            "experiment_name": exp,
            "channel_name": channel,
            "resolution": 92,
            "x_args": "0:5",
            "y_args": "0:6",
            "z_args": "0:2",
            "time_args": None
        }

        with self.assertRaises(BossError):
            BossRequest(drfrequest, request_args)
开发者ID:jhuapl-boss,项目名称:boss,代码行数:32,代码来源:test_requests.py

示例6: test_basic_resource_get_iso_level_isotropic

    def test_basic_resource_get_iso_level_isotropic(self):
        """Test get iso level isotropic

        Returns:
            None

        """
        url = '/' + version + '/cutout/col1/exp_iso/channel1/0/0:5/0:6/0:2/'

        # Create the request
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = Cutout().initialize_request(request)
        drfrequest.version = version

        request_args = {
            "service": "cutout",
            "collection_name": "col1",
            "experiment_name": "exp_iso",
            "channel_name": "channel1",
            "resolution": 0,
            "x_args": "0:5",
            "y_args": "0:6",
            "z_args": "0:2",
            "time_args": None
        }

        req = BossRequest(drfrequest, request_args)
        resource = BossResourceDjango(req)

        self.assertEqual(resource.get_isotropic_level(), 0)
开发者ID:jhuapl-boss,项目名称:boss,代码行数:31,代码来源:test_djangoresource.py

示例7: test_request_cutout_lookupkey

    def test_request_cutout_lookupkey(self):
        """
        Test initialization of boss_key for a time sample range
        :return:
        """
        url = '/' + version + '/cutout/col1/exp1/channel1/2/0:5/0:6/0:2/1:5/'

        # Create the request
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = Cutout().initialize_request(request)
        drfrequest.version = version

        # Create the request dict
        request_args = {
            "service": "cutout",
            "version": version,
            "collection_name": 'col1',
            "experiment_name": 'exp1',
            "channel_name": 'channel1',
            "resolution": 2,
            "x_args": "0:5",
            "y_args": "0:6",
            "z_args": "0:2",
            "time_args": "1:5"
        }

        ret = BossRequest(drfrequest, request_args)
        col_id = ret.collection.pk
        exp_id = ret.experiment.pk
        channel_id = ret.channel.pk
        base_lookup = str(col_id) + '&' + str(exp_id) + '&' + str(channel_id)
        self.assertEqual(base_lookup, ret.get_lookup_key())
开发者ID:jhuapl-boss,项目名称:boss,代码行数:33,代码来源:test_requests.py

示例8: test_get_object_bounding_box_single_cuboid

    def test_get_object_bounding_box_single_cuboid(self):
        """ Test getting the bounding box of a object"""

        test_mat = np.ones((128, 128, 16))
        test_mat[0:128, 0:128, 0:16] = 4
        test_mat = test_mat.astype(np.uint64)
        test_mat = test_mat.reshape((16, 128, 128))
        bb = blosc.compress(test_mat, typesize=64)

        # Create request
        factory = APIRequestFactory()
        request = factory.post('/' + version + '/cutout/col1/exp1/bbchan1/0/1536:1664/1536:1664/0:16/', bb,
                               content_type='application/blosc')
        # log in user
        force_authenticate(request, user=self.user)

        # Make request
        response = Cutout.as_view()(request, collection='col1', experiment='exp1', channel='bbchan1',
                                    resolution='0', x_range='1536:1664', y_range='1536:1664', z_range='0:16', t_range=None)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # Create Request to get data you posted
        request = factory.get('/' + version + '/cutout/col1/exp1/bbchan1/0/1536:1664/1536:1664/0:16/',
                              accepts='application/blosc')

        # log in user
        force_authenticate(request, user=self.user)

        # Make request
        response = Cutout.as_view()(request, collection='col1', experiment='exp1', channel='bbchan1',
                                    resolution='0', x_range='1536:1664', y_range='1536:1664', z_range='0:16', t_range=None).render()
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # Decompress
        raw_data = blosc.decompress(response.content)
        data_mat = np.fromstring(raw_data, dtype=np.uint64)
        data_mat = np.reshape(data_mat, (16, 128, 128), order='C')

        # Test for data equality (what you put in is what you got back!)
        np.testing.assert_array_equal(data_mat, test_mat)

        # get the bounding box

        # Create request
        factory = APIRequestFactory()
        request = factory.get('/' + version + '/boundingbox/col1/exp1/bbchan1/0/4')
        # log in user
        force_authenticate(request, user=self.user)

        # Make request
        response = BoundingBox.as_view()(request, collection='col1', experiment='exp1', channel='bbchan1',
                                         resolution='0', id='4')

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        bb = response.data
        self.assertEqual(bb['t_range'], [0, 1])
        self.assertEqual(bb['x_range'], [1536, 2048])
        self.assertEqual(bb['y_range'], [1536, 2048])
        self.assertEqual(bb['z_range'], [0, 16])
开发者ID:jhuapl-boss,项目名称:boss,代码行数:59,代码来源:bounding_box_view.py

示例9: test_channel_uint64_cuboid_aligned_no_offset_no_time_blosc

    def test_channel_uint64_cuboid_aligned_no_offset_no_time_blosc(self):
        """ Test uint64 data, cuboid aligned, no offset, no time samples"""

        test_mat = np.ones((128, 128, 16))
        test_mat = test_mat.astype(np.uint64)
        test_mat = test_mat.reshape((16, 128, 128))
        bb = blosc.compress(test_mat, typesize=64)

        # Create request
        factory = APIRequestFactory()
        request = factory.post('/' + version + '/cutout/col1/exp1/layer1/0/0:128/0:128/0:16/', bb,
                               content_type='application/blosc')
        # log in user
        force_authenticate(request, user=self.user)

        # Make request
        response = Cutout.as_view()(request, collection='col1', experiment='exp1', channel='layer1',
                                    resolution='0', x_range='0:128', y_range='0:128', z_range='0:16', t_range=None)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # Create Request to get data you posted
        request = factory.get('/' + version + '/cutout/col1/exp1/layer1/0/0:128/0:128/0:16/',
                              accepts='application/blosc')

        # log in user
        force_authenticate(request, user=self.user)

        # Make request
        response = Cutout.as_view()(request, collection='col1', experiment='exp1', channel='layer1',
                                    resolution='0', x_range='0:128', y_range='0:128', z_range='0:16', t_range=None).render()
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # Decompress
        raw_data = blosc.decompress(response.content)
        data_mat = np.fromstring(raw_data, dtype=np.uint64)
        data_mat = np.reshape(data_mat, (16, 128, 128), order='C')

        # Test for data equality (what you put in is what you got back!)
        np.testing.assert_array_equal(data_mat, test_mat)

        # get the bounding box

        # Create request
        factory = APIRequestFactory()
        request = factory.get('/' + version + '/ids/col1/exp1/layer1/0/0:128/0:128/0:16/')
        # log in user
        force_authenticate(request, user=self.user)

        # Make request
        response = Ids.as_view()(request, collection='col1', experiment='exp1', channel='layer1',
                                         resolution='0', x_range='0:128', y_range='0:128', z_range='0:16',
                                         t_range=None)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['ids'], ['1'])
开发者ID:jhuapl-boss,项目名称:boss,代码行数:55,代码来源:ids_view.py

示例10: test_channel_uint64_time_npygz_upload

    def test_channel_uint64_time_npygz_upload(self):
        """ Test uint8 data, using the npygz interface with time series support while uploading in that format as well

        """
        test_mat = np.random.randint(1, 256, (3, 4, 128, 128))
        test_mat = test_mat.astype(np.uint64)

        # Save Data to npy
        npy_file = io.BytesIO()
        np.save(npy_file, test_mat, allow_pickle=False)

        # Compress npy
        npy_gz = zlib.compress(npy_file.getvalue())

        # Send file
        npy_gz_file = io.BytesIO(npy_gz)
        npy_gz_file.seek(0)

        # Create request
        factory = APIRequestFactory()
        request = factory.post('/' + version + '/cutout/col1/exp1/layer1/0/0:128/0:128/0:4/10:13', npy_gz_file.read(),
                               content_type='application/npygz')
        # log in user
        force_authenticate(request, user=self.user)

        # Make request
        response = Cutout.as_view()(request, collection='col1', experiment='exp1', channel='layer1',
                                    resolution='0', x_range='0:128', y_range='0:128', z_range='0:4',
                                    t_range='10:13')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # Create Request to get data you posted
        request = factory.get('/' + version + '/cutout/col1/exp1/layer1/0/0:128/0:128/0:4/10:13',
                              HTTP_ACCEPT='application/npygz')

        # log in user
        force_authenticate(request, user=self.user)

        # Make request
        response = Cutout.as_view()(request, collection='col1', experiment='exp1', channel='layer1',
                                    resolution='0', x_range='0:128', y_range='0:128', z_range='0:4',
                                    t_range='10:13').render()
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # Decompress
        data_bytes = zlib.decompress(response.content)

        # Open
        data_obj = io.BytesIO(data_bytes)
        data_mat = np.load(data_obj)

        # Test for data equality (what you put in is what you got back!)
        np.testing.assert_array_equal(data_mat, test_mat)
开发者ID:jhuapl-boss,项目名称:boss,代码行数:53,代码来源:cutout_view_uint64.py

示例11: setUp

    def setUp(self):
        """ Copy params from the Layer setUpClass
        """
        # Setup config
        self.kvio_config = self.layer.kvio_config
        self.state_config = self.layer.state_config
        self.object_store_config = self.layer.object_store_config
        self.user = self.layer.user

        # Log Django User in
        self.client.force_login(self.user)

        if not self.test_data_loaded:
            # Flush cache between tests
            client = redis.StrictRedis(host=self.kvio_config['cache_host'],
                                       port=6379, db=1, decode_responses=False)
            client.flushdb()
            client = redis.StrictRedis(host=self.state_config['cache_state_host'],
                                       port=6379, db=1, decode_responses=False)
            client.flushdb()

            # load some data for reading
            self.test_data_8 = np.random.randint(1, 254, (16, 1024, 1024), dtype=np.uint8)
            bb = blosc.compress(self.test_data_8, typesize=8)

            # Post data to the database
            factory = APIRequestFactory()
            request = factory.post('/' + version + '/cutout/col1/exp1/channel1/0/0:1024/0:1024/0:16/', bb,
                                   content_type='application/blosc')
            force_authenticate(request, user=self.user)
            _ = Cutout.as_view()(request, collection='col1', experiment='exp1', channel='channel1',
                                 resolution='0', x_range='0:1024', y_range='0:1024', z_range='0:16', t_range=None)
            self.test_data_loaded = True
开发者ID:jhuapl-boss,项目名称:boss,代码行数:33,代码来源:int_test_tiles_view_uint8.py

示例12: test_request_cutout_init_cutoutargs_channel

    def test_request_cutout_init_cutoutargs_channel(self):
        """
        Test initialization of cutout arguments for a cutout request
        :return:
        """
        url = '/' + version + '/cutout/col1/exp1/channel1/2/0:5/0:6/0:2/'

        res = 2
        (x_start, x_stop) = (0, 5)
        (y_start, y_stop) = (0, 6)
        (z_start, z_stop) = (0, 2)

        # Create the request
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = Cutout().initialize_request(request)
        drfrequest.version = version

        # Create the request dict
        request_args = {
            "service": "cutout",
            "version": version,
            "collection_name": 'col1',
            "experiment_name": 'exp1',
            "channel_name": 'channel1',
            "resolution": 2,
            "x_args": "0:5",
            "y_args": "0:6",
            "z_args": "0:2",
            "time_args": None
        }
        ret = BossRequest(drfrequest, request_args)

        self.assertEqual(ret.get_resolution(), res)
        self.assertEqual(ret.get_x_start(), x_start)
        self.assertEqual(ret.get_x_stop(), x_stop)
        self.assertEqual(ret.get_x_span(), x_stop - x_start)

        self.assertEqual(ret.get_y_start(), y_start)
        self.assertEqual(ret.get_y_stop(), y_stop)
        self.assertEqual(ret.get_y_span(), y_stop - y_start)

        self.assertEqual(ret.get_z_start(), z_start)
        self.assertEqual(ret.get_z_stop(), z_stop)
        self.assertEqual(ret.get_z_span(), z_stop - z_start)
开发者ID:jhuapl-boss,项目名称:boss,代码行数:45,代码来源:test_requests.py

示例13: test_channel_uint64_filter_ids_not_found

    def test_channel_uint64_filter_ids_not_found(self):
        """ Test filter_cutout by ids not in the region"""

        test_mat = np.ones((128, 128, 4))
        test_mat[0][0][0] = 2
        test_mat[0][0][1] = 3
        test_mat[0][0][2] = 4
        test_mat = test_mat.reshape(4, 128, 128)
        test_mat = test_mat.astype(np.uint64)
        h = test_mat.tobytes()
        bb = blosc.compress(h, typesize=64)

        # Create request
        factory = APIRequestFactory()
        request = factory.post('/' + version + '/cutout/col1/exp1/layer1/0/128:256/256:384/16:20/', bb,
                               content_type='application/blosc')
        # log in user
        force_authenticate(request, user=self.user)

        # Make request
        response = Cutout.as_view()(request, collection='col1', experiment='exp1', channel='layer1',
                                    resolution='0', x_range='128:256', y_range='256:384', z_range='16:20', t_range=None)

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # Create Request to get data you posted
        request = factory.get('/' + version + '/cutout/col1/exp1/layer1/0/128:256/256:384/16:20/?filter=5,6,7',
                              accepts='application/blosc')

        # log in user
        force_authenticate(request, user=self.user)

        # Make request
        response = Cutout.as_view()(request, collection='col1', experiment='exp1', channel='layer1',
                                    resolution='0', x_range='128:256', y_range='256:384', z_range='16:20', t_range=None).render()
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # Decompress
        raw_data = blosc.decompress(response.content)
        data_mat = np.fromstring(raw_data, dtype=np.uint64)
        data_mat = np.reshape(data_mat, (4, 128, 128), order='C')

        # Test for data equality (what you put in is what you got back!)
        np.testing.assert_array_equal(np.unique(data_mat), np.arange(0, 1, dtype=np.uint64))
开发者ID:jhuapl-boss,项目名称:boss,代码行数:44,代码来源:cutout_view_uint64.py

示例14: test_channel_uint64_time_npygz_download

    def test_channel_uint64_time_npygz_download(self):
        """ Test uint8 data, using the npygz interface with time series support

        """
        test_mat = np.random.randint(1, 256, (3, 4, 128, 128))
        test_mat = test_mat.astype(np.uint64)
        bb = blosc.pack_array(test_mat)

        # Create request
        factory = APIRequestFactory()
        request = factory.post('/' + version + '/cutout/col1/exp1/layer1/0/0:128/0:128/0:4/10:13', bb,
                               content_type='application/blosc-python')
        # log in user
        force_authenticate(request, user=self.user)

        # Make request
        response = Cutout.as_view()(request, collection='col1', experiment='exp1', channel='layer1',
                                    resolution='0', x_range='0:128', y_range='0:128', z_range='0:4',
                                    t_range='10:13')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # Create Request to get data you posted
        request = factory.get('/' + version + '/cutout/col1/exp1/layer1/0/0:128/0:128/0:4/10:13',
                              HTTP_ACCEPT='application/npygz')

        # log in user
        force_authenticate(request, user=self.user)

        # Make request
        response = Cutout.as_view()(request, collection='col1', experiment='exp1', channel='layer1',
                                    resolution='0', x_range='0:128', y_range='0:128', z_range='0:4',
                                    t_range='10:13').render()
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # Decompress
        data_bytes = zlib.decompress(response.content)

        # Open
        data_obj = io.BytesIO(data_bytes)
        data_mat = np.load(data_obj)

        # Test for data equality (what you put in is what you got back!)
        np.testing.assert_array_equal(data_mat, test_mat)
开发者ID:jhuapl-boss,项目名称:boss,代码行数:43,代码来源:cutout_view_uint64.py

示例15: test_request_cutout_invalid_deleted_channel

    def test_request_cutout_invalid_deleted_channel(self):
        """
        Test initialization of cutout requests for channel that was just deleted
        """
        # Post a new channel
        url = '/' + version + '/collection/col1/experiment/exp1/channel/channel33/'
        data = {'description': 'This is a new channel', 'type': 'annotation', 'datatype': 'uint64',
                'sources': ['channel1'], 'related': ['channel2']}
        response = self.client.post(url, data=data)
        self.assertEqual(response.status_code, 201)

        url = '/' + version + '/collection/col1/experiment/exp1/channel/channel33'
        response = self.client.delete(url)
        self.assertEqual(response.status_code, 204)

        url = '/' + version + '/cutout/col2/exp1/channel33/0/0:5/0:6/0:2/'
        col = 'col1'
        exp = 'exp1'
        channel = 'channel33'

        # Create the request
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = Cutout().initialize_request(request)
        drfrequest.version = version

        # Create the request dict
        request_args = {
            "service": "cutout",
            "version": version,
            "collection_name": col,
            "experiment_name": exp,
            "channel_name": channel,
            "resolution": 0,
            "x_args": "0:5",
            "y_args": "0:6",
            "z_args": "0:2",
            "time_args": None
        }

        with self.assertRaises(BossError):
            BossRequest(drfrequest, request_args)
开发者ID:jhuapl-boss,项目名称:boss,代码行数:42,代码来源:test_requests.py


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