Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

processed_data, pad_top #62

@jmjech

Description

@jmjech

Hi Rick,
I seem to have found a bug in the pad_top function in processed_data.py. On line 537 (marked below in the code) the Sv data array was being populated by the attr vector, not the original Sv data. So I commented that line and repopulated with the old data.

However, what I'm not sure about is whether the resize operation (self.resize(...)) modifies the array and I'm not grabbing the correct values (see the line below the commented line 537). This seems to work, but it would be good to confirm.

mike

def pad_top(self, n_samples):
"""Shifts the data array vertically.

    This method shifts the data array vertically by the specified number of
    samples and inserts NaNs.  Range or depth are updated accordingly.
    This method differs from shift_pings in that you must shift by whole
    samples. No interpolation is performed.

    Args:
        n_samples (int): The number of samples to shift the data array by.
    """
    # Store the old sample number.
    old_samples = self.n_samples

    # Resize the sample data arrays.
    self.resize(self.n_pings, self.n_samples + n_samples)

    # Generate the new range/depth array.
    if hasattr(self, 'range'):
        attr = getattr(self, 'range')
    else:
        attr = getattr(self, 'depth')
    attr[:] = ((np.arange(self.n_samples) - n_samples) *
               self.sample_thickness + attr[0])

    # Shift and pad the data array.
    #self.data[:,n_samples:] = attr[:,0:old_samples]        LINE 537
    self.data[:,n_samples:] = self.data[:,0:old_samples]
    self.data[:,0:n_samples] = np.nan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions