Skip to content

Commit

Permalink
update the website with all pages from the wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
2320sharon committed Apr 12, 2024
1 parent 59299b9 commit 0f9f902
Show file tree
Hide file tree
Showing 13 changed files with 1,051 additions and 27 deletions.
78 changes: 78 additions & 0 deletions docs/CoastSeg-API-Guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# CoastSeg API Guide

This guide provides instructions on how to use the CoastSeg API to download imagery, extract shorelines, and apply tide correction.

## Contents

- [Script 1: Download Imagery and Initial Shoreline Extraction](#script-1-download-imagery-and-initial-shoreline-extraction)
- [Script 2: Extract Shorelines from a previously downloaded session](#script-2-extract-shorelines-from-a-previously-downloaded-session)
- [Applying Tide Correction (Optional)](#applying-tide-correction-optional)

## Prerequisites

- Ensure you have the CoastSeg conda environment set up and activated. If not, please follow the setup instructions provided in the CoastSeg documentation.
- Download the tide model required for tide correction. You can find instructions and download links [here](https://github.com/Doodleverse/CoastSeg/wiki/09.-How-to-Download-and-clip-Tide-Model).

## Running the Scripts

### Script 1: Download Imagery and Initial Shoreline Extraction

1. **Activate the CoastSeg Conda Environment:**
Open your terminal and activate the CoastSeg conda environment by running:
```bash
conda activate coastseg
```
2. **Launch the Script**
- Navigate to the directory containing your script and run:
```bash
python 1_download_imagery.py
```
The script performs the following actions:
- Initializes the Google Earth Engine.
- Downloads imagery based on specified regions of interest (ROIs).
- Extracts shorelines from the downloaded imagery.
- Optionally applies tide correction (uncomment the tide correction section if needed).
3. **Understanding the Script Output:**
- The script will download imagery to the specified data folder.
- Extracted shorelines will be saved in the session's directory.
- Check the terminal for logs and messages indicating the progress and completion of tasks.

### Script 2: Extract Shorelines from a previously downloaded session
After completing the imagery download and initial extraction, you can proceed with the second script for further shoreline extraction.
Note: This script should be run after the first one because it loads the 'sample_session1' created by the first script

1. **Activate the CoastSeg Conda Environment:**
Open your terminal and activate the CoastSeg conda environment by running:
```bash
conda activate coastseg
```
2. **Apply Tide Correction (Optional)**
- Ensure you have downloaded the tide model as per the prerequisites.
- Uncomment the tide correction section in the script:
- make sure to enter the `beach slope` and `reference_elevation` for your site.
```python
# coastsegmap.compute_tidal_corrections(roi_ids, beach_slope, reference_elevation)
```
3. **Launch the Script**
- Navigate to the directory containing your script and run:
```bash
python 2_extract_shorelines.py
```
It performs the following:
- Loads the session created by the first script.
- Applies new settings for shoreline extraction.
- Optionally, applies tide correction (uncomment and configure if needed).

## Applying Tide Correction (Optional)
To apply tide correction:

1. **Ensure you have downloaded the tide model as per the prerequisites.**

2. **Uncomment the tide correction section in each script:**
```python
# coastsegmap.compute_tidal_corrections(roi_ids, beach_slope, reference_elevation)
```
Replace beach_slope and reference_elevation with the appropriate values for your region of interest.
3. **Re-run the script after uncommenting and modifying the tide correction section.**

Remember, tide correction is optional and should be applied based on your specific requirements and the characteristics of the imagery and region of interest.
185 changes: 185 additions & 0 deletions docs/Contribution-Guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# Contributing

Thank you for your interest in contributing to CoastSeg we appreciate any contributions. Every
little bit helps, and credit will always be given.
You can contribute in many ways:

## Types of Contributions

### Report Bugs

Report bugs at <https://github.com/SatelliteShorelines/CoastSeg/issues/new/choose>.

If you are reporting a bug, please include:

- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.

### Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with "bug" and "help wanted" is open to whoever wants to implement it.

### Implement Features

Look through the GitHub issues for features. Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it.

### Write Documentation

CoastSeg could always use more documentation, whether as part of the official wiki, in docstrings, or even updates to the readme. Submit an issue with your updated documentation and our team will merge it in and credit you.

### Submit Feedback

The best way to send feedback is to file an issue at <https://github.com/SatelliteShorelines/CoastSeg/issues/new/choose>.

If you are proposing a feature:

- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Make sure it passes all of CoastSeg's tests if it doesn't tag one of our developers.

## Testing Guide

---

In the activated anaconda environment `coastseg_dev` change directories to be in the main coastseg directory. Within the main coastseg directory is a directory named `tests` within anaconda prompt use the command `cd tests` to change to this directory. Run the command `pytest` to run all the tests in the `tests` directory

### How to Run All Tests

Run the following commands within the coastseg directory.

```bash
conda activate coastseg_dev
cd tests
pytest .
```

### CoastSeg Directory Structure

Coastseg has a source layout which is the recommend layout for pypi packages. This means all the source code for coastseg is located under the `src`(short for source) directory. Within the `src` directory is another directory `coastseg`, which contains the source code for coastseg. The source code is what provides all the functions that coastseg uses in notebooks located within the main `CoastSeg` directory (aka not within the `src/coastseg` directory). If you want to make any changes to the functionality of coastseg you will be changing the code within the source directory.

The UI used in the two notebooks is stored within `map_UI.py` and `models_UI.py`. In these files you will find one class that creates all the buttons, widgets and even a map that coastseg uses. By separating the UI from the source code it makes it easier to make UI changes without having to change the source code.

```
├── CoastSeg
│   ├── src
│   | |_ coastseg
│   | | |_ __init__.py
│   | | |_bbox.py
│   | | |_roi.py
│   | | |_shoreline.py
│   | | |_transects.py
│   | | |_coastseg_map.py
│   | | |_exception_handler.py
│   | | |_extracted_shoreline.py
│   | | |_common.py
│   | | |_exceptions.py
│   | | |_map_UI.py
│   | | |_models_UI.py
│   | | |_zoo_model.py
│   | | |_coastseg_logs.py
│   | | |
│   | | |bounding_boxes # contains geojson files for the bounding boxes for the shorelines coastseg automatically loads on the map
│   | | |downloaded_models # directory created by coastseg after a model is downloaded
│   | | |shorelines # contains geojson files the shorelines coastseg automatically loads on the map
│   | | |transects # contains geojson files the transects coastseg automatically loads on the map
|
├── docs
| |_config.md
| |_install.md # not showing them all here
|
├── tests # this directory contains automated tests and test data used to run tests
| |_ test_data # this directory contains data used by the automated tests
| | |_<data used to test coastseg>
| |_ __init__.py
| | |_ conftest.py # creates objects and variables used by the rest of the tests
| | |_ test_roi.py # this test file tests roi.py
|
|___data
| |_ <data downloaded here> # directory automatically created by coastseg when imagery is downloaded
|
├── README.md
├── .github
└── .gitignore
└── pyproject.toml
```

# How to Release a New Package ( CoastSeg Maintainers only)

---

CoastSeg has a github action that publishes a new pypi package if the commit is tagged with the version number of the package to release on pypi.
To ensure a consistent and smooth package release process, follow this step-by-step guide. The release procedure centers around tagging the commit properly.

## Tagging Format

When you're ready to release a new package, push a commit with a tag that matches one of the following formats:

- Major, minor, and patch versions: `v[0-9]+.[0-9]+.[0-9]+`

- Example: `v1.0.3`

- Alpha versions: `v[0-9]+.[0-9]+.[0-9]+a[0-9]+`

- Beta versions: `v[0-9]+.[0-9]+.[0-9]+b[0-9]+`

- Release candidate versions: `v[0-9]+.[0-9]+.[0-9]+rc[0-9]+`

- Development versions: `v[0-9]+.[0-9]+.[0-9]+dev[0-9]+`
- Example: `v1.2.0dev1`

### ✅ Good Tag Names

- v1.0.3
- v1.2.0dev1

### ❌ Bad Tag Names

- 1.2.0 : Missing the "v"

## Release Steps

1. Ensure your local branch is up-to-date with the main branch.

```bash
git pull origin main
```

2. Commit your changes.

```bash
git commit -m "Release v1.0.3" # Replace with your version number
```

3. If you're tagging the most recent commit, simply use:

```bash
git tag v1.0.3
```

4. If you need to tag a specific commit (other than the most recent one), first find the commit's hash using:

```bash
git log --oneline
```

This will display a list of recent commits with their shortened hash. Identify the commit you want to tag, then tag it using:

```bash
git tag v1.0.3 COMMIT_HASH # Replace with your version number and the appropriate commit hash
```

5. Push the tag to the repository.

```bash
git push origin v1.0.3 # Replace with your version number
```

6. Push the commit to the repository.

```bash
git push origin main
```

Following these steps ensures that the release process is structured and standardized across different versions and packages.
109 changes: 109 additions & 0 deletions docs/Getting-Started_to_contribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
## Getting Started Guide for Contributors

---

Ready to contribute? Here's how to set up _CoastSeg_ for local development.
This guide will walk you through the installation process, testing procedures, and best practices for contributing to CoastSeg.

1. Make a Fork

Click the `fork` button located at the top right of the coastseg repository. This will create a fork copy of the coastseg repository that you can edit on your GitHub account. [Learn How to Fork from GitHub Docs](https://docs.github.com/en/get-started/quickstart/fork-a-repo)

![image](https://user-images.githubusercontent.com/61564689/212405847-047511d1-961f-43f3-a5e4-7145795ea17f.png)

2. Clone your fork locally:

- git clone your fork of coastseg onto your local computer
```bash
git clone https://github.com/your-username/CoastSeg.git
```

3. Create an Anaconda Environment for CoastSeg Development

- We will install the CoastSeg package and its development dependencies in this environment.

```bash
conda create --name coastseg_dev python=3.10 -y
```

4. Activate the Conda Environment

```bash
conda activate coastseg_dev
```

5. Change Directory to the CoastSeg

- Go to the location where CoastSeg was installed on your computer.
<br> `cd <directory where you have coastseg source code installed>`
<br>**Example:** `cd c:\users\CoastSeg`
```bash
cd CoastSeg
```

6. Install CoastSeg locally as a pip editable installation
```bash
pip install -e .
```

- This command reads the required dependencies from CoastSeg's `pyproject.toml` file and installs them within your anaconda environment.
- Make sure to run this command in the `CoastSeg` directory that contains the `pyproject.toml` file otherwise this command will fail because pip won't find the `pyproject.toml` file
- `-e` means create an editable install of the package. This will add the files to the python path on your computer making it possible to find the sub directories of the package.See the [official documentation](https://pip-python3.readthedocs.io/en/latest/reference/pip_install.html#editable-installs).
- `.` means use the current working directory to install

7. Install Geopandas and JupyterLab Locally

```bash
conda install -c conda-forge jupyterlab geopandas -y
```

8. Install the Development Dependencies
```bash
pip install build pytest black
```

- `black` is a python formater that you can run on the code
- `pytest` is used to automatically run tests on the code

9. Create a branch for local development:

```
git checkout -b name-of-your-bugfix-or-feature
```

Now you can make your changes locally.

10. When you're done making changes, use `pytest` to check that your changes pass the tests.

```
conda activate coastseg_dev
cd CoastSeg
cd tests
pytest .
```
11. Format the code using Black
To make your code adhere to python style standards use the `black` code formatter to automatically format the code. You'll need to change directories to the `src` directory, then to the sub directory `coastseg` and run the `black` here. If you were to run `black` in the main coastseg directory it would not format the code because the code for coastseg is located in directory `coastseg>src>coastseg`.
```bash
conda activate coastseg_dev
cd src
cd coastseg
black .
```

12. Commit your changes and push your branch to GitHub:

```
git add .
```
```
git commit -m "Your detailed description of your changes."
```
```
git push origin name-of-your-bugfix-or-feature
```
13. Submit a pull request through the GitHub website.
Loading

0 comments on commit 0f9f902

Please sign in to comment.