Exemple #1
0
    def __init__(self, ds, io, filename, file_id):
        with open(filename, "rb") as f:
            self.header = read_record(f, ds._header_spec)
            self._position_offset = f.tell()
            f.seek(0, os.SEEK_END)
            self._file_size = f.tell()

        super(ReboundBinaryFile, self).__init__(ds, io, filename, file_id)
    def __init__(self, ds, io, filename, file_id):
        with open(filename, "rb") as f:
            self.header = read_record(f, ds._header_spec)
            self._position_offset = f.tell()
            f.seek(0, os.SEEK_END)
            self._file_size = f.tell()

        super(GadgetBinaryFile, self).__init__(ds, io, filename, file_id)
Exemple #3
0
    def _get_hvals(self):
        # The entries in this header are capitalized and named to match Table 4
        # in the GADGET-2 user guide.

        f = open(self.parameter_filename, 'rb')
        hvals = read_record(f, self._header_spec)
        for i in hvals:
            if len(hvals[i]) == 1:
                hvals[i] = hvals[i][0]
        return hvals
    def _get_hvals(self):
        # The entries in this header are capitalized and named to match Table 4
        # in the GADGET-2 user guide.

        f = open(self.parameter_filename)
        hvals = read_record(f, self._header_spec)
        for i in hvals:
            if len(hvals[i]) == 1:
                hvals[i] = hvals[i][0]
        return hvals
Exemple #5
0
    def __init__(self, ds, io, filename, file_id):
        with open(filename, "rb") as f:
            if _get_gadget_format(filename) == 2:
                f.seek(f.tell()+16)
            self.header = read_record(f, ds._header_spec)
            self._position_offset = f.tell()
            f.seek(0, os.SEEK_END)
            self._file_size = f.tell()

        super(GadgetBinaryFile, self).__init__(ds, io, filename, file_id)
Exemple #6
0
 def _get_hvals(self):
     # The entries in this header are capitalized and named to match Table 4
     # in the GADGET-2 user guide.
     gformat = _get_gadget_format(self.parameter_filename)
     f = open(self.parameter_filename, 'rb')
     if gformat[0] == 2:
         f.seek(f.tell() + SNAP_FORMAT_2_OFFSET)
     hvals = read_record(f, self._header_spec, endian=gformat[1])
     for i in hvals:
         if len(hvals[i]) == 1:
             hvals[i] = hvals[i][0]
     return hvals
Exemple #7
0
    def __init__(self, ds, io, filename, file_id):
        gformat = _get_gadget_format(filename)
        with open(filename, "rb") as f:
            if gformat[0] == 2:
                f.seek(f.tell() + SNAP_FORMAT_2_OFFSET)
            self.header = read_record(f, ds._header_spec, endian=gformat[1])
            if gformat[0] == 2:
                f.seek(f.tell() + SNAP_FORMAT_2_OFFSET)
            self._position_offset = f.tell()
            f.seek(0, os.SEEK_END)
            self._file_size = f.tell()

        super(GadgetBinaryFile, self).__init__(ds, io, filename, file_id)
Exemple #8
0
 def value(self):
     """Header values as a dictionary."""
     # The entries in this header are capitalized and named to match Table 4
     # in the GADGET-2 user guide.
     gformat, endianswap = self.gadget_format
     # Read header
     with self.open() as f:
         hvals = {}
         for spec in self.spec:
             if gformat == 2:
                 f.seek(f.tell() + SNAP_FORMAT_2_OFFSET)
             hvals_new = read_record(f, spec, endian=endianswap)
             hvals.update(hvals_new)
     # Remove placeholder keys
     for key in self._placeholder_keys:
         if key in hvals:
             del hvals[key]
     # Convert length 1 list to scalar value
     for i in hvals:
         if len(hvals[i]) == 1:
             hvals[i] = hvals[i][0]
     return hvals