flekspy 0.3.2__tar.gz → 0.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flekspy
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Python utilities for processing FLEKS data
5
5
  Author-email: Yuxi Chen <yuxichen@umich.edu>, Hongyang Zhou <hyzhou@umich.edu>
6
6
  License-File: LICENSE.md
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "flekspy"
3
- version = "0.3.2"
3
+ version = "0.3.3"
4
4
  description = "Python utilities for processing FLEKS data"
5
5
  authors = [
6
6
  {name = "Yuxi Chen", email = "yuxichen@umich.edu"},
@@ -212,14 +212,14 @@ class IDLData(object):
212
212
  with open(saveName, "w") as f:
213
213
  f.write(self.unit + "\n")
214
214
  f.write(
215
- "{:d}\t{:e}\t{:d}\t{:d}\t{:d}\n".format(
215
+ "{0:d}\t{1:e}\t{2:d}\t{3:d}\t{4:d}\n".format(
216
216
  self.iter, self.time, self.ndim, self.nparam, self.nvar
217
217
  )
218
218
  )
219
- [f.write("{:d}\t".format(i)) for i in self.grid]
219
+ [f.write("{0:d}\t".format(i)) for i in self.grid]
220
220
  f.write("\n")
221
221
  if self.nparam > 0:
222
- [f.write("{:e}\t".format(i)) for i in self.para]
222
+ [f.write("{0:e}\t".format(i)) for i in self.para]
223
223
  f.write("\n")
224
224
  [f.write(i + " ") for i in self.variables]
225
225
  f.write("\n")
@@ -231,7 +231,7 @@ class IDLData(object):
231
231
  for jj in range(nj):
232
232
  for ii in range(ni):
233
233
  [
234
- f.write("{:e}\t".format(i))
234
+ f.write("{0:e}\t".format(i))
235
235
  for i in self.data.array[:, ii, jj, kk]
236
236
  ]
237
237
  f.write("\n")
@@ -424,30 +424,30 @@ class IDLData(object):
424
424
  def read_binary_instance(self, infile):
425
425
  self.get_file_head(infile)
426
426
  nrow = self.ndim + self.nvar
427
- self.data.array = np.zeros((nrow, self.npoints), dtype=np.float32)
428
427
 
429
- # Get the grid points...
428
+ if self.pformat == "f":
429
+ dtype = np.float32
430
+ else:
431
+ dtype = np.float64
432
+
433
+ self.data.array = np.empty((nrow, self.npoints), dtype=dtype)
434
+ dtype_str = f"{self.end_char}{self.pformat}"
435
+
436
+ # Get the grid points
430
437
  (old_len, record_len) = struct.unpack(self.end_char + "2l", infile.read(8))
431
- for i in range(0, self.ndim):
432
- # Read the data into a temporary grid
433
- tempgrid = np.array(
434
- struct.unpack(
435
- "{0}{1}{2}".format(self.end_char, self.npoints, self.pformat),
436
- infile.read(int(record_len // self.ndim)),
437
- )
438
- )
439
- self.data.array[i, :] = tempgrid
438
+ buffer = infile.read(record_len)
439
+ grid_data = np.frombuffer(
440
+ buffer, dtype=dtype_str, count=self.npoints * self.ndim
441
+ )
442
+ self.data.array[0 : self.ndim, :] = grid_data.reshape((self.ndim, self.npoints))
440
443
 
441
444
  # Get the actual data and sort
442
445
  for i in range(self.ndim, self.nvar + self.ndim):
443
446
  (old_len, record_len) = struct.unpack(self.end_char + "2l", infile.read(8))
444
- tmp = np.array(
445
- struct.unpack(
446
- "{0}{1}{2}".format(self.end_char, self.npoints, self.pformat),
447
- infile.read(record_len),
448
- )
447
+ buffer = infile.read(record_len)
448
+ self.data.array[i, :] = np.frombuffer(
449
+ buffer, dtype=dtype_str, count=self.npoints
449
450
  )
450
- self.data.array[i, :] = tmp
451
451
  # Consume the last record length
452
452
  infile.read(4)
453
453
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes