Skip to content

Commit

Permalink
add environment file, local settings, and drop localizesl (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
bolliger32 authored Mar 22, 2023
1 parent c1780f3 commit d009d85
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 234 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ target/
.mypy_cache/

# dask
dask-worker-space
dask-worker-space
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

8 changes: 7 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
History
=======

v1.1.1
------
* Update settings file for local development
* Add environment.yml
* Drop no longer used LocalizeSL submodule

v1.1.0
----------
------
* Updates consistent with revisions to Depsky et al. 2023

v1.0.2
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ This repository hosts the code used to create the [SLIIDERS](https://doi.org/10.

## Installation

Most users will want to just use the datasets directly, accessible at the DOIs linked above. If you wish to recreate and/or modify the datasets, which we encourage, you will need to run the Jupyter notebooks in this repository. A collection of helper functions, organized into a Python package, is necessary to run the notebooks and can be found within the `sliiders` directory. A simple pip install will install this package
Most users will want to just use the datasets directly, accessible at the DOIs linked above. If you wish to recreate and/or modify the datasets, which we encourage, you will need to run the Jupyter notebooks in this repository.

A first step is to create a conda environment with the necessary packages. First install [mamba](https://mamba.readthedocs.io/en/latest/) and then, from the root directory of this repo, run

```bash
mamba env create -f environment/environment.yml
mamba activate sliiders
```

Next, a collection of helper functions, organized into a Python package, is necessary to run the notebooks and can be found within the `sliiders` directory. A simple pip install will install this package

```bash
pip install -e sliiders
Expand Down Expand Up @@ -59,6 +68,7 @@ We encourage community contributions. At the moment, we have no contribution tem
## Authors

The original authors of this code include:

* Daniel Allen
* Ian Bolliger
* Junho Choi
Expand All @@ -74,4 +84,4 @@ Please use the following citation when citing the preprint (this will be updated

```
Depsky, N., Bolliger, I., Allen, D., Choi, J. H., Delgado, M., Greenstone, M., Hamidi, A., Houser, T., Kopp, R. E., and Hsiang, S.: DSCIM-Coastal v1.0: An Open-Source Modeling Platform for Global Impacts of Sea Level Rise, EGUsphere [preprint], https://doi.org/10.5194/egusphere-2022-198, 2022.
```
```
35 changes: 35 additions & 0 deletions environment/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: sliiders
channels:
- conda-forge
dependencies:
- beautifulsoup4
- cartopy
- contextily
- dask-geopandas
- distributed
- fsspec
- jupyterlab
- matplotlib
- networkx
- numba
- numpy
- numpy_groupies
- pandas
- pandas-datareader
- pint
- pygeos
- pyinterp
- python
- pypdf2
- pyreadr
- regionmask
- requests
- rioxarray
- scikit-learn
- scipy
- shapely
- statsmodels
- tqdm
- xarray
- xesmf
- zarr
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
"outputs": [],
"source": [
"df.to_parquet(\n",
" str(sset.PATH_EXPOSURE_POP_INT), storage_options={\"token\": str(sset.CRED_PATH)}\n",
" str(sset.PATH_EXPOSURE_POP_INT), storage_options=sset.STORAGE_OPTIONS\n",
")"
]
},
Expand Down

Large diffs are not rendered by default.

14 changes: 4 additions & 10 deletions sliiders/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import rioxarray as rio
import xarray as xr

from sliiders.settings import CRED_PATH

CRED_PATH_STR = str(CRED_PATH)
from sliiders.settings import STORAGE_OPTIONS


def read_gdf(fpath):
Expand Down Expand Up @@ -50,19 +48,15 @@ def save(obj, path, *args, **kwargs):
meth = "to_parquet"
else:
raise ValueError(type(obj))
getattr(obj, meth)(
str(path), *args, storage_options={"token": CRED_PATH_STR}, **kwargs
)
getattr(obj, meth)(str(path), *args, storage_options=STORAGE_OPTIONS, **kwargs)


def open_zarr(path, **kwargs):
return xr.open_zarr(str(path), storage_options={"token": CRED_PATH_STR}, **kwargs)
return xr.open_zarr(str(path), storage_options=STORAGE_OPTIONS, **kwargs)


def read_parquet_dask(path, **kwargs):
return ddf.read_parquet(
str(path), storage_options={"token": CRED_PATH_STR}, **kwargs
)
return ddf.read_parquet(str(path), storage_options=STORAGE_OPTIONS, **kwargs)


def _fuseify(path):
Expand Down
Loading

0 comments on commit d009d85

Please sign in to comment.