Exemple #1
0
    def __init__(self, dataset):
        BaseResponse.__init__(self, dataset)
        self.headers.extend([("Content-description", "dods_form"), ("Content-type", "text/html; charset=utf-8")])

        # our default environment; we need to include the base template from
        # pydap as well since our template extends it
        self.loaders = [PackageLoader("pydap.responses.html", "templates"), PackageLoader("pydap.wsgi", "templates")]
Exemple #2
0
    def __init__(self, dataset):
        BaseResponse.__init__(self, dataset)
        self.headers.extend([('Content-description', 'dods_data'),
                             ('Content-type', 'application/octet-stream')])

        length = calculate_size(dataset)
        if length is not None:
            self.headers.append(('Content-length', str(length)))
 def __init__(self, dataset):
     BaseResponse.__init__(self, dataset)
     self.headers.extend([
         ('Content-description', 'dods_matlab'),
         ('Content-type', 'application/x-matlab'),
         #('Content-description', 'dods_matlab'),
         #('Content-type', 'text/plain; charset=ascii'),
     ])
Exemple #4
0
    def __init__(self, dataset):
        BaseResponse.__init__(self, dataset)
        self.headers.extend([('Content-description', 'dods_data'),
                             ('Content-type', 'application/octet-stream')])

        length = calculate_size(dataset)
        if length is not None:
            self.headers.append(('Content-length', str(length)))
Exemple #5
0
    def __init__(self, dataset):
        BaseResponse.__init__(self, dataset)
        self.headers.extend([
            ('Content-description', 'dods_dds'),
            ('Content-type', 'text/plain; charset=utf-8'),

            # CORS
            ('Access-Control-Allow-Origin', '*'),
            ('Access-Control-Allow-Headers',
                'Origin, X-Requested-With, Content-Type'),
        ])
    def __init__(self, dataset):
        BaseResponse.__init__(self, dataset)
        self.headers.extend([
            ("Content-description", "dods_form"),
            ("Content-type", "text/plain; charset=utf-8"),
        ])

        # our default environment;
        self.loaders = [
            PackageLoader("pydap.responses.html", "templates"),
        ]
    def __init__(self, dataset):
        BaseResponse.__init__(self, dataset)
        self.headers.extend([
            ("Content-description", "dods_form"),
            ("Content-type", "text/plain; charset=utf-8"),
        ])

        # our default environment;
        self.loaders = [
            PackageLoader("pydap.responses.html", "templates"),
        ]
Exemple #8
0
    def __init__(self, dataset):
        BaseResponse.__init__(self, dataset)
        self.headers.extend([
            ("Content-description", "dods_form"),
            ("Content-type", "text/html; charset=utf-8"),
        ])

        # our default environment; we need to include the base template from
        # pydap as well since our template extends it
        self.loaders = [
            PackageLoader("pydap.responses.html", "templates"),
            PackageLoader("pydap.wsgi", "templates"),
        ]
Exemple #9
0
    def __init__(self, dataset):
        BaseResponse.__init__(self, dataset)
        self.headers.extend([
            ('Content-description', 'dods_data'),
            ('Content-type', 'application/octet-stream'),

            # CORS
            ('Access-Control-Allow-Origin', '*'),
            ('Access-Control-Allow-Headers',
                'Origin, X-Requested-With, Content-Type'),
        ])

        length = calculate_size(dataset)
        if length is not None:
            self.headers.append(('Content-length', length))
Exemple #10
0
 def __init__(self, dataset):
     BaseResponse.__init__(self, dataset)
     self.headers.extend([
             ('Content-description', 'dods_netcdf'),
             ('Content-type', 'application/x-netcdf'),
             ])
Exemple #11
0
 def __init__(self, dataset):
     BaseResponse.__init__(self, dataset)
     self.headers.append(('Content-type', 'application/json'))
 def __init__(self, dataset):
     BaseResponse.__init__(self, dataset)
     self.headers.extend([
         ('Content-description', 'dods_xls'),
         ('Content-type', 'application/vnd.ms-excel'),
     ])
Exemple #13
0
 def __init__(self, dataset):
     BaseResponse.__init__(self, dataset)
     self.headers.extend([
         ('Content-type', 'text/html; charset=utf-8'),
     ])
Exemple #14
0
 def __init__(self, dataset):
     BaseResponse.__init__(self, dataset)
     self.headers.extend([("Content-description", "dods_dds"), ("Content-type", "text/plain; charset=utf-8")])
Exemple #15
0
 def __init__(self, dataset=None):
     BaseResponse.__init__(self, dataset)
     self.headers.extend([
         ('Content-description', 'dods_help'),
         ('Content-type', 'text/html'),
     ])
Exemple #16
0
 def __init__(self, dataset):
     BaseResponse.__init__(self, dataset)
     self.headers.extend([
         ('Content-type', 'text/html; charset=utf-8'),
     ])
Exemple #17
0
 def __init__(self, dataset, request=None):
     BaseResponse.__init__(self, dataset, request)
Exemple #18
0
 def __init__(self, dataset):
     BaseResponse.__init__(self, dataset)
     self.headers.extend([("Content-description", "dods_form"), ("Content-type", "text/html")])
 def __init__(self, dataset):
     BaseResponse.__init__(self, dataset)
     self.headers.extend([
             ('Content-description', 'dods_xlsx'),
             ('Content-type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'),
             ])
 def __init__(self, dataset):
     BaseResponse.__init__(self, dataset)
     self.headers.extend([("Content-description", "dods_xls"), ("Content-type", "application/vnd.ms-excel")])
Exemple #21
0
    def __init__(self, dataset):
        BaseResponse.__init__(self, dataset)

        self.nc = netcdf_file(None)
        if 'NC_GLOBAL' in self.dataset.attributes:
            self.nc._attributes.update(self.dataset.attributes['NC_GLOBAL'])

        dimensions = [var.dimensions for var in walk(self.dataset) if isinstance(var, BaseType)]
        dimensions = set(reduce(lambda x, y: x+y, dimensions))
        try:
            unlim_dim = self.dataset.attributes['DODS_EXTRA']['Unlimited_Dimension']
        except:
            unlim_dim = None

        # GridType
        for grid in walk(dataset, GridType):

            # add dimensions
            for dim, map_ in grid.maps.items():
                if dim in self.nc.dimensions:
                    continue

                n = None if dim == unlim_dim else grid[dim].data.shape[0]
                self.nc.createDimension(dim, n)
                if not n:
                    self.nc.set_numrecs(grid[dim].data.shape[0])
                var = grid[dim]

                # and add dimension variable
                self.nc.createVariable(dim, var.dtype.char, (dim,), attributes=var.attributes)

            # finally add the grid variable itself
            base_var = grid[grid.name]
            var = self.nc.createVariable(base_var.name, base_var.dtype.char, base_var.dimensions, attributes=base_var.attributes)

        # Sequence types!
        for seq in walk(dataset, SequenceType):

            self.nc.createDimension(seq.name, None)
            try:
                n = len(seq)
            except TypeError:
                # FIXME: materializing and iterating through a sequence to find the length
                # could have performance problems and could potentially consume the iterable
                # Do lots of testing here and determine the result of not calling set_numrecs()
                n = len( [ x for x in seq[seq.keys()[0]] ])
            self.nc.set_numrecs(n)

            dim = seq.name,

            for child in seq.children():
                dtype = child.dtype
                # netcdf does not have a date type, so remap to float
                if dtype == np.dtype('datetime64'):
                    dtype = np.dtype('float32')
                elif dtype == np.dtype('object'):
                    raise TypeError("Don't know how to handle numpy type {0}".format(dtype))
                        
                var = self.nc.createVariable(child.name, dtype.char, dim, attributes=child.attributes)

        self.headers.extend([
            ('Content-type', 'application/x-netcdf')
        ])
        # Optionally set the filesize header if possible
        try:
            self.headers.extend([('Content-length', self.nc.filesize)])
        except ValueError:
            pass
Exemple #22
0
 def __init__(self, dataset):
     BaseResponse.__init__(self, dataset)
     self.headers.append( ('Content-description', 'dods_wms') )
Exemple #23
0
 def __init__(self, dataset):
     BaseResponse.__init__(self, dataset)
     self.headers.extend([
         ('Content-description', 'dods_ascii'),
         ('Content-type', 'text/plain'),
     ])
Exemple #24
0
 def __init__(self, dataset=None):
     BaseResponse.__init__(self, dataset)
     self.headers.extend([
             ('Content-description', 'dods_version'),
             ('Content-type', 'text/plain'),
             ])
Exemple #25
0
 def __init__(self, dataset):
     BaseResponse.__init__(self, dataset)
     self.headers.append(('Content-description', 'dods_wms'))
Exemple #26
0
 def __init__(self, dataset):
     BaseResponse.__init__(self, dataset)
     self.headers.extend([
             ('Content-description', 'dods_dds'),
             ('Content-type', 'text/plain; charset=utf-8'),
             ])
Exemple #27
0
    def __init__(self, dataset):
        BaseResponse.__init__(self, dataset)

        self.nc = netcdf_file(None)
        if 'NC_GLOBAL' in self.dataset.attributes:
            self.nc._attributes.update(self.dataset.attributes['NC_GLOBAL'])

        dimensions = [
            var.dimensions for var in walk(self.dataset)
            if isinstance(var, BaseType)
        ]
        dimensions = set(reduce(lambda x, y: x + y, dimensions))
        try:
            unlim_dim = self.dataset.attributes['DODS_EXTRA'][
                'Unlimited_Dimension']
        except:
            unlim_dim = None

        # GridType
        for grid in walk(dataset, GridType):

            # add dimensions
            for dim, map_ in grid.maps.items():
                if dim in self.nc.dimensions:
                    continue

                n = None if dim == unlim_dim else grid[dim].data.shape[0]
                self.nc.createDimension(dim, n)
                if not n:
                    self.nc.set_numrecs(grid[dim].data.shape[0])
                var = grid[dim]

                # and add dimension variable
                self.nc.createVariable(dim,
                                       var.dtype.char, (dim, ),
                                       attributes=var.attributes)

            # finally add the grid variable itself
            base_var = grid[grid.name]
            var = self.nc.createVariable(base_var.name,
                                         base_var.dtype.char,
                                         base_var.dimensions,
                                         attributes=base_var.attributes)

        # Sequence types!
        for seq in walk(dataset, SequenceType):

            self.nc.createDimension(seq.name, None)
            try:
                n = len(seq)
            except TypeError:
                # FIXME: materializing and iterating through a sequence to find the length
                # could have performance problems and could potentially consume the iterable
                # Do lots of testing here and determine the result of not calling set_numrecs()
                n = len([x for x in seq[seq.keys()[0]]])
            self.nc.set_numrecs(n)

            dim = seq.name,

            for child in seq.children():
                dtype = child.dtype
                # netcdf does not have a date type, so remap to float
                if dtype == np.dtype('datetime64'):
                    dtype = np.dtype('float32')
                elif dtype == np.dtype('object'):
                    raise TypeError(
                        "Don't know how to handle numpy type {0}".format(
                            dtype))

                var = self.nc.createVariable(child.name,
                                             dtype.char,
                                             dim,
                                             attributes=child.attributes)

        self.headers.extend([('Content-type', 'application/x-netcdf')])
        # Optionally set the filesize header if possible
        try:
            self.headers.extend([('Content-length', self.nc.filesize)])
        except ValueError:
            pass