NOAA-OWP / lstm

Other
12 stars 17 forks source link

BMI Bug Fixes #31

Closed madMatchstick closed 2 years ago

madMatchstick commented 2 years ago

Addresses assortment of bmi implementation concerns; many previously posted under GitHub's Issues. See listing below

Additions

  1. Reintroduces fractional update calls.

    def update_frac(self, time_frac):
        """Update model by a fraction of a time step.
        Parameters
        ----------
        time_frac : float
            Fraction fo a time step.
        """
        if self.verbose > 0:
            print("Warning: This version of the LSTM is designed to make predictions on one hour timesteps.")
        time_step = self.get_time_step()
        self._time_step_size = time_frac * self._time_step_size
        self.update()
        self._time_step_size = time_step

    Know this function is called in bmi.update_until() only.

  2. Include a python script, lstm_serialization_test.py, for testing serialization, similar to existing jupyter notebook. Fixes #15

Changes

  1. Use python's built-in getattr() or set_attr() approach vs self._values[var_name]. Fixes #5. For example,

    def get_value_ptr(self, var_name):
        """Reference to values.
        Parameters
        ----------
        var_name : str
            Name of variable as CSDMS Standard Name.
        Returns
        -------
        array_like
            Value array.
        """      
        return getattr(self, var_name)  # IN USE
    #       return self._values[var_name]   # NO LONGER IN USE

    This effects the following functions

    • create_scaled_input_tensor()
    • bmi.get_value_ptr()
    • bmi.initialize()
    • scale_output()
    • set_static_attributes()
    • set_value()
  2. Directory structure:

    • jupyter notebooks in /notebooks
    • python scripts in /src
    • all links and refs adjusted for pathing change
  3. Updates to readme & markdown docs

  4. Bound runoff to zero; fixes #17 self.surface_runoff_mm = max(self.surface_runoff_mm,0.0)

  5. Remove any - and replace with _ in py scripts

Testing

  1. Executables in /notebooks and /src
SnowHydrology commented 2 years ago

@madMatchstick can you resolve the merge conflicts?

SnowHydrology commented 2 years ago

https://www.youtube.com/watch?v=roRQ2mNwMMQ