Skip to content

Commit

Permalink
include trim_output_dict
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Apr 17, 2020
1 parent d8051e7 commit 8aebdae
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions ROSCO_toolbox/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,45 @@ def trim_output(self, info, data, tmin=0, tmax=100000):
data[:, info['channels'].index('Time')]) - tmin
return data

def trim_output_dict(self, fast_data, tmin=0, tmax=100000):
'''
Trim loaded fast output data
Parameters
----------
info : dict
info from load_output containing:
- name: filename
- description: description of dataset
- channels: list of channel names
- attribute_units: list of attribute units
fast_data : ndarray
List of all output data from load_outputinfo (list containing dictionaries)
tmin : float, optional
start time
tmax : float, optional
end time
Returns
-------
data : ndarray
input data ndarray with values trimed to times tmin and tmax
'''
# initial time array and associated index
for fd in fast_data:
# time_init = np.ndarray.flatten(data[:, fast_dict['channels'].index('Time')])
T0ind = np.searchsorted(fd['Time'], tmin)
Tfind = np.searchsorted(fd['Time'], tmax) + 1
# tvals = [time.tolist() for time in time_init[Tinds]]

# Remove all vales in data where time is not in desired range
for key in fd.keys():
if key.lower() == 'time':
fd['Time'] = fd['Time'][T0ind:Tfind] - fd['Time'][T0ind]
elif key != 'meta':
fd[key] = fd[key][T0ind:Tfind]

return fast_dict

class FileProcessing():
"""
Expand Down

0 comments on commit 8aebdae

Please sign in to comment.