Skip to content

Channel mobility operations produce outputs outside of [0,1] #233

Description

@lbakerstahl

I've found that the channel mobility operations Planform Overlap and Reworking Fraction return outputs outside the range [0,1]. Datasets used are two different PyDeltaRCM outputs.

Is this intended given that they are both supposed to be fractions? If not, should a check be done so that the final output is always [0,1].

My current workflow as a class method including the workaround I've been using to overwrite values outside [0,1]:

def compute_channel_metrics(self, window=2):
        print(f"Computing channel metrics with a window of {window}...")
        
        # bound the loop to prevent out-of-bounds indexing at the end of the time series
        max_valid_timestep = self.time_steps - window
        
        # sandplover expects a list/array for basevalues
        vals = np.arange(max_valid_timestep)
        
        #calculate channel metrics across whole time range
        self.dryfrac = splm.calculate_channel_decay(self.channel_masks, self.land_masks, basevalues_idx=vals, window_idx=window)
        self.Ophi = splm.calculate_planform_overlap(self.channel_masks, self.land_masks, basevalues_idx=vals, window_idx=window)
        self.fr = splm.calculate_reworking_fraction(self.channel_masks, self.land_masks, basevalues_idx=vals, window_idx=window)
        self.PwetA = splm.calculate_channel_abandonment(self.channel_masks, basevalues_idx=vals, window_idx=window)
        
        # make sure if dry fraction has error, value is 0
        self.dryfrac = xr.where( self.dryfrac < 1, self.dryfrac, 0)
        self.dryfrac = xr.where( self.dryfrac > 0, self.dryfrac, 0)
        # make sure if planform overlap has error, value is 1
        self.Ophi = xr.where( self.Ophi < 1, self.Ophi, 1)
        self.Ophi = xr.where( self.Ophi > 0, self.Ophi, 1)
        # make sure if reworked fraction has error, value is 0
        self.fr = xr.where( self.fr < 1, self.fr, 0)
        self.fr = xr.where( self.fr > 0, self.fr, 0)
        # make sure if channel decay  has error, value is 0
        self.PwetA = xr.where( self.PwetA < 1, self.PwetA, 0)
        self.PwetA = xr.where( self.PwetA > 0, self.PwetA, 0)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions