Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 2 additions & 32 deletions analysator/miscellaneous/vtkwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def write_vtk_file( filename, point_data ):

# Add the points to the dataset
linesPolyData.SetPoints(points)

# Add the lines to the dataset
linesPolyData.SetLines(lines)
#######################################
Expand All @@ -76,34 +76,4 @@ def write_vtk_file( filename, point_data ):
polyDataWriter.Write()
#######################################

# # Read and visualize the written line
# #######################################
# reader = vtk.vtkPolyDataReader()
# reader.SetFileName(filename)
#
# mapper = vtk.vtkPolyDataMapper()
# if vtk.VTK_MAJOR_VERSION <= 5:
# mapper.SetInput(reader.GetOutput())
# else:
# mapper.SetInputConnection(reader.GetOutputPort())
#
# actor = vtk.vtkActor()
# actor.SetMapper(mapper)
#
# # Create a rendering window and renderer
# ren = vtk.vtkRenderer()
# renWin = vtk.vtkRenderWindow()
# renWin.AddRenderer(ren)
#
# # Create a renderwindowinteractor
# iren = vtk.vtkRenderWindowInteractor()
# iren.SetRenderWindow(renWin)
#
# # Assign actor to the renderer
# ren.AddActor(actor)
#
# # Enable user interface interactor
# iren.Initialize()
# renWin.Render()
# iren.Start()
# #######################################

9 changes: 0 additions & 9 deletions analysator/vlsvfile/reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,15 +653,6 @@ def thermalvelocity( variables ):

def Vstream( variables ):
raise NotImplementedError("rhoVBackstream, rhoBackstream not defined here. Check implementaiton if required!")
Comment thread
lassejsc marked this conversation as resolved.
# rhoVstream = variables[0]
# rhostream = variables[1]
# rhoVNonBackstream = variables[2]
# rhoNonBackstream = variables[3]
# # get velocity of both populations:
# vBackstream = v( [rhoVBackstream, rhoBackstream] )
# vNonBackstream = v( [rhoVNonBackstream, rhoNonBackstream] )
# vBeam = vBackstream - vNonBackstream
# return vBeam # <- is a vector quantity

def v_beam( variables ):
vBackstream = variables[0]
Expand Down
28 changes: 2 additions & 26 deletions analysator/vlsvfile/vlsvreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,9 @@ def dict_keys_exist(dictionary, query_keys, prune_unique=False):
if prune_unique:
unique_keys, indices = np.unique(query_keys, axis=0, return_inverse=True)

# these are all about the same...
# if (unique_keys.ndim == 1):

mask = np.array([k in dictionary.keys() for k in unique_keys],dtype=bool)
# else: # and this isn't worth it?
# mask = np.array([tuple(k) in dictionary.keys() for k in unique_keys],dtype=bool)

# mask = np.empty(query_keys.shape, dtype=bool)
# for i,k in enumerate(query_keys):
# mask[i] = [k in dictionary.keys() for k in query_keys],dtype=bool)

# mask = np.array(list(map(lambda c: c in dictionary.keys(),query_keys)), dtype=bool)

# dlambda = np.frompyfunc(lambda c: c in dictionary.keys(),1,1)
# mask = np.array(dlambda(query_keys),dtype=bool)
mask = mask[indices]
else:
mask = np.array([k in dictionary.keys() for k in query_keys],dtype=bool)
Expand Down Expand Up @@ -478,7 +467,6 @@ def __read_fileindex_for_cellid(self):
#Check if it is not iterable. If it is a scale then make it a list
if(not isinstance(cellids, Iterable)):
cellids=[ cellids ]
# self.__fileindex_for_cellid = {cellid:index for index,cellid in enumerate(cellids)}
for index,cellid in enumerate(cellids):
self.__fileindex_for_cellid[cellid] = index

Expand Down Expand Up @@ -521,14 +509,11 @@ def __read_blocks(self, cellid, pop="proton"):
# Read in block values
if ("name" in child.attrib) and (child.attrib["name"] == pop) and (child.tag == "BLOCKVARIABLE"):
vector_size = ast.literal_eval(child.attrib["vectorsize"])
#array_size = ast.literal_eval(child.attrib["arraysize"])
element_size = ast.literal_eval(child.attrib["datasize"])
datatype = child.attrib["datatype"]

# Navigate to the correct position
offset_avgs = int(offset * vector_size * element_size + ast.literal_eval(child.text))
# for i in range(0, cells_with_blocks_index[0]):
# offset_avgs += blocks_per_cell[i]*vector_size*element_size

fptr.seek(offset_avgs)
if datatype == "float" and element_size == 4:
Expand All @@ -541,7 +526,6 @@ def __read_blocks(self, cellid, pop="proton"):
# (note the special treatment in case the population is named 'avgs'
if (pop == 'avgs' or ("name" in child.attrib) and (child.attrib["name"] == pop)) and (child.tag == "BLOCKIDS"):
vector_size = ast.literal_eval(child.attrib["vectorsize"])
#array_size = ast.literal_eval(child.attrib["arraysize"])
element_size = ast.literal_eval(child.attrib["datasize"])
datatype = child.attrib["datatype"]

Expand Down Expand Up @@ -595,7 +579,6 @@ def __set_cell_offset_and_blocks(self, pop="proton"):
# Navigate to the correct position:
from copy import copy
offset = 0
#self.__fileindex_for_cellid_blocks[pop] = {}
self.__fileindex_for_cellid_blocks[pop] = dict.fromkeys(cells_with_blocks) # should be faster but negligible difference
for i in range(0, len(cells_with_blocks)):
self.__fileindex_for_cellid_blocks[pop][cells_with_blocks[i]] = [copy(offset), copy(blocks_per_cell[i])]
Expand Down Expand Up @@ -652,7 +635,6 @@ def __check_datareducer(self, name, reducer):
else:
in_vars = self.check_variable(popvar)

# print(popvar," is in vars: ",in_vars)
if in_vars:
self.__available_reducers.add(popvar)
break
Expand Down Expand Up @@ -1639,12 +1621,10 @@ def read_interpolated_variable(self, name, coords, operator="pass",periodic=[Tru
if value_length > 1:
read_vals = self.read_variable(name, cellids=cellids_neighbors_unique, operator=operator)
ngbrvalues[cellid_neighbors!=0,:] = read_vals[indices,:]
# ngbrvalues[cellid_neighbors!=0,:] = self.read_variable(name, cellids=cellid_neighbors[cellid_neighbors!=0], operator=operator)
else:
read_vals = self.read_variable(name, cellids=cellids_neighbors_unique, operator=operator)[:,np.newaxis]
ngbrvalues[cellid_neighbors!=0,:] = read_vals[indices,:]
# ngbrvalues[cellid_neighbors!=0,:] = self.read_variable(name, cellids=cellid_neighbors[cellid_neighbors!=0], operator=operator)[:,np.newaxis]
# ngbrvalues = np.reshape(ngbrvalues, (ncoords,2,2,2,value_length))

nvals = len(lower_cell_ids_unique)
ngbrvalues = np.reshape(ngbrvalues, (nvals,2,2,2,*value_shape))

Expand Down Expand Up @@ -2015,7 +1995,6 @@ def read_variable(self, name, cellids=-1,operator="pass"):
return False
return self.read_fsgrid_variable(name=name, operator=operator)

#if(self.check_variable(name) and (name.lower()[0:3]=="ig_")):
if name.lower()[0:3]=="ig_":
if not cellids == -1:
logging.warning("CellID requests not supported for ionosphere variables! Aborting.")
Expand Down Expand Up @@ -2380,7 +2359,6 @@ def get_unique_cellids(self, coords):

:returns: a list of unique cell ids
'''
# cids = [int(self.get_cellid(coord)) for coord in coords]
cids = self.get_cellid(coords)

#choose unique cids, keep ordering. This requires a bit of OrderedDict magic (python 2.7+)
Expand Down Expand Up @@ -2763,8 +2741,6 @@ def build_cell_neighborhoods(self, cids):
vertices_todo = set().union(*cell_vertex_sets.values())
neighbor_tuples_dict = self.build_dual_from_vertices(list(vertices_todo))
for c,verts in cell_vertex_sets.items():
# neighbor_tuples = self.build_dual_from_vertices(verts)
# cell_neighbor_sets[c].update(set().union(*neighbor_tuples.values()))
cell_neighbor_sets[c].update(set().union(*itemgetter(*cell_vertex_sets[c])(neighbor_tuples_dict)))

self.__cell_neighbours.update(cell_neighbor_sets)
Expand Down
Loading