Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Hazard classmethod for loading xarray Datasets #507

Commits on Jul 5, 2022

  1. Add Hazard classmethod for loading NetCDF file

    * Add classmethod `from_raster_netcdf` that loads a dataset from a
      NetCDF file and reads the appropriate data into a Hazard instance.
    * Add a new test file for testing this method.
    
    This is still WIP.
    peanutfun committed Jul 5, 2022
    Configuration menu
    Copy the full SHA
    4a9a520 View commit details
    Browse the repository at this point in the history

Commits on Jul 6, 2022

  1. Configuration menu
    Copy the full SHA
    755f11e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    525394b View commit details
    Browse the repository at this point in the history
  3. Read Hazard from datasets with varying dim/coord definitions

    Make `Hazard.from_raster_netcdf` handle cases where coordinates with
    other names than dimensions are supposed to be read, and where
    coordinates are not flattened. The first is achieved by adding another
    method parameter so that users may specify *dimensions* and
    *coordinates* separately. The second is achieved by stacking the entire
    dataset, which also applies to possibly multi-dimensional coordinates,
    instead of flattening only the respective array.
    
    Add a new test case to cover the new capabilities.
    peanutfun committed Jul 6, 2022
    Configuration menu
    Copy the full SHA
    17564d5 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    cbc1dc5 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    d90ca87 View commit details
    Browse the repository at this point in the history

Commits on Jul 7, 2022

  1. Extract dimension names from coordinates

    This avoids relying on user input which dimensions to use.
    peanutfun committed Jul 7, 2022
    Configuration menu
    Copy the full SHA
    939968b View commit details
    Browse the repository at this point in the history
  2. Use lazy formatting for logger messages

    This fixes some linter complaints.
    peanutfun committed Jul 7, 2022
    Configuration menu
    Copy the full SHA
    b110a94 View commit details
    Browse the repository at this point in the history

Commits on Jul 11, 2022

  1. Merge branch 'develop' into 487-add-classmethod-to-hazard-for-reading…

    …-raster-like-data-from-netcdf-file
    peanutfun committed Jul 11, 2022
    Configuration menu
    Copy the full SHA
    4283cf6 View commit details
    Browse the repository at this point in the history

Commits on Jul 15, 2022

  1. Reorganize test_base_netcdf.py

    Move more complicated test case down
    peanutfun committed Jul 15, 2022
    Configuration menu
    Copy the full SHA
    ab40d1a View commit details
    Browse the repository at this point in the history
  2. Consolidate tests for Hazard.intensity

    np.testing.assert_array_equal already checks for matching array shapes.
    peanutfun committed Jul 15, 2022
    Configuration menu
    Copy the full SHA
    2a4283d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    dac5dd5 View commit details
    Browse the repository at this point in the history

Commits on Jul 27, 2022

  1. Make from_raster_xarray read all Hazard data

    Add capability of reading all "optional" Hazard data through the
    `data_vars` parameter. "Optional" means that default values can be
    provided and hence the data is not strictly necessary. Changes:
    
    * Add possibility to read `date`, `event_id`, `event_name`, and
      `frequency` from data.
    * Add possibility to supply `haz_type` and `unit` through method
      parameters.
    * Provide defaults for all optionals.
    * Update docstrings.
    * Update tests.
    peanutfun committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    026a33f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    528b99e View commit details
    Browse the repository at this point in the history
  3. Remove 'fraction' parameter from 'from_raster_xarray'

    * Make 'fraction' an optional argument and move it into `data_vars`.
    * Update tests.
    peanutfun committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    d96a278 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f817bca View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    fb94fc6 View commit details
    Browse the repository at this point in the history

Commits on Jul 28, 2022

  1. Apply suggestions from code review

    Use pathlib for more elegant file handling in tests
    
    Co-authored-by: Chahan M. Kropf <chahan.kropf@usys.ethz.ch>
    peanutfun and chahank authored Jul 28, 2022
    Configuration menu
    Copy the full SHA
    bda69a6 View commit details
    Browse the repository at this point in the history
  2. Improve docstrings and simplify from_raster_xarray

    * Improve docstrings of "internal" functions.
    * Rename `read_or default` to `load_data_or_default` and use argument
      list instead of `pd.Series` as single argument.
    * Avoid single letter variables.
    * Avoid unnecessary local variables.
    * Add more type hints.
    peanutfun committed Jul 28, 2022
    Configuration menu
    Copy the full SHA
    9c68a9e View commit details
    Browse the repository at this point in the history
  3. Simplify user_key update

    peanutfun committed Jul 28, 2022
    Configuration menu
    Copy the full SHA
    87033ea View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    abc9d32 View commit details
    Browse the repository at this point in the history

Commits on Jul 29, 2022

  1. Configuration menu
    Copy the full SHA
    29b74f3 View commit details
    Browse the repository at this point in the history
  2. Preprocess dict arguments to save indentation level

    This hopefully decreases code complexity slightly.
    peanutfun committed Jul 29, 2022
    Configuration menu
    Copy the full SHA
    7678d1f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c0fb24b View commit details
    Browse the repository at this point in the history

Commits on Aug 3, 2022

  1. Configuration menu
    Copy the full SHA
    b8c46a3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7a9ea42 View commit details
    Browse the repository at this point in the history

Commits on Aug 4, 2022

  1. Configuration menu
    Copy the full SHA
    b2eea56 View commit details
    Browse the repository at this point in the history

Commits on Aug 5, 2022

  1. Update Hazard.from_raster_xarray

    (Hopefully) improve the readability of the method and its signature.
    
    * Move default coordinate keys and attribute keys out of the `Hazard`
      class by defining constants.
    * Rename `time` to `event` in `coordinate_vars` argument, as CLIMADA
      operates on events.
    * Rename `load_data_or_default` to `load_from_xarray_or_return_default`.
    * Rename `identifier` to `default_key`.
    * Update docstrings and extend comments.
    peanutfun committed Aug 5, 2022
    Configuration menu
    Copy the full SHA
    1be9772 View commit details
    Browse the repository at this point in the history

Commits on Aug 8, 2022

  1. Add CRS argument

    Skip test for now as it is unclear how this can be tested
    peanutfun committed Aug 8, 2022
    Configuration menu
    Copy the full SHA
    ccec87f View commit details
    Browse the repository at this point in the history

Commits on Sep 29, 2022

  1. Merge branch 'develop' into 487-add-classmethod-to-hazard-for-reading…

    …-raster-like-data-from-netcdf-file
    peanutfun committed Sep 29, 2022
    Configuration menu
    Copy the full SHA
    c19f9ea View commit details
    Browse the repository at this point in the history

Commits on Oct 5, 2022

  1. Fix bug where wrong Hazard attribute was set

    Type: Hazard.unit was set instead of Hazard.units. This was not catched
    by the test because they were consistent.
    peanutfun committed Oct 5, 2022
    Configuration menu
    Copy the full SHA
    07e8bf7 View commit details
    Browse the repository at this point in the history

Commits on Oct 6, 2022

  1. Configuration menu
    Copy the full SHA
    84b0795 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a72112c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d777785 View commit details
    Browse the repository at this point in the history
  4. Format test_base_xarray

    peanutfun committed Oct 6, 2022
    Configuration menu
    Copy the full SHA
    d36bcc2 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    68c1459 View commit details
    Browse the repository at this point in the history

Commits on Oct 7, 2022

  1. Merge branch 'develop' into 487-add-classmethod-to-hazard-for-reading…

    …-raster-like-data-from-netcdf-file
    emanuel-schmid committed Oct 7, 2022
    Configuration menu
    Copy the full SHA
    2cffc9a View commit details
    Browse the repository at this point in the history

Commits on Oct 14, 2022

  1. Promote single-valued coordinates to dimensions

    In Hazard.from_raster_xarray, promote coordinates to dimensions if they
    have a single value. This enables loading datasets with lower dimensions
    as long as the "missing" dimensions are specified as coordinates.
    
    Update docstring and tests.
    peanutfun committed Oct 14, 2022
    Configuration menu
    Copy the full SHA
    1ff075d View commit details
    Browse the repository at this point in the history
  2. Merge branch '487-add-classmethod-to-hazard-for-reading-raster-like-d…

    …ata-from-netcdf-file' of https://github.com/CLIMADA-project/climada_python into 487-add-classmethod-to-hazard-for-reading-raster-like-data-from-netcdf-file
    peanutfun committed Oct 14, 2022
    Configuration menu
    Copy the full SHA
    1eea94c View commit details
    Browse the repository at this point in the history