-
Notifications
You must be signed in to change notification settings - Fork 315
Update SIPNET documentation. Fixes #3703 #3880
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
Open
man080107
wants to merge
2
commits into
PecanProject:develop
Choose a base branch
from
man080107:task/SIPNET-documentation-cleanup
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
book_source/02_demos_tutorials_workflows/05_developer_workflows/07_model_documentation.Rmd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Model Documentation Maintenance {#model-documentation-maintenance} | ||
|
|
||
| This guide describes how to maintain and update the documentation for PEcAn model couplers. For every ecosystem model integrated with PEcAn, there are three primary documentation locations that should be kept in sync: | ||
|
|
||
| 1. **Package README (`models/[modelname]/README.md`):** This is the entry point for someone visiting the PEcAn repository or the `pkgdown` site. | ||
| 2. **Model Pkgdown site:** Generated from the README and function documentation using the `pkgdown` package. | ||
| 3. **PEcAn Book Page (`book_source/03_topical_pages/05_models/[modelname].Rmd`):** This is part of the central PEcAn documentation (the "Book") and should focus on how the model fits into the overall PEcAn workflow. | ||
|
|
||
| ## Documentation Structure | ||
|
|
||
| To avoid duplication, follows these guidelines: | ||
|
|
||
| ### 1. Package README (`README.md`) | ||
| The README should be the most comprehensive source for a specific model coupler. It should include: | ||
| - **What is [MODEL]?**: A brief summary of the standalone model. | ||
| - **Standalone Documentation Link**: Point users to the official docs for the underlying model logic. | ||
| - **Homepage & Source**: Links to the model's primary home and repository. | ||
| - **Using via PEcAn**: A high-level description of what the PEcAn coupler does (inputs/outputs). | ||
| - **Installation**: Clear steps for installing both the R package and the underlying model binary. | ||
| - **Documentation Links**: Links to the `pkgdown` site, book chapter, and source code. | ||
|
|
||
| ### 2. PEcAn Book Chapter | ||
| The book chapter should be a concise summary. **Do not duplicate long descriptions from the README.** Instead: | ||
| - Provide the standard "Model Information" table. | ||
| - Give a short introductory paragraph. | ||
| - List model-specific configuration file patterns. | ||
| - Link out to the `README.md` and the `pkgdown` site for detailed usage information and tutorials. | ||
|
|
||
| ### 3. Pkgdown Site | ||
| This is automatically generated. Ensure that your `README.md` is well-formatted and that your R functions have complete Roxygen documentation. | ||
|
|
||
| ## Updating a Model Coupler's Documentation | ||
|
man080107 marked this conversation as resolved.
Outdated
|
||
|
|
||
| If you are updating documentation for a model (like SIPNET), follow these steps: | ||
|
|
||
| 1. **Locate the README:** Usually found at `models/[modelname]/README.md`. | ||
| - *Tip:* Use the [models/template/README.md](https://github.com/PecanProject/pecan/tree/develop/models/template/README.md) as a starting point. | ||
|
man080107 marked this conversation as resolved.
Outdated
|
||
| 2. **Locate the Book Source:** Found in `book_source/03_topical_pages/05_models/[modelname].Rmd`. | ||
| 3. **Consolidate and Clean:** | ||
| - Combine relevant info from old book text into the new README. | ||
| - Add links to standalone model docs (e.g., [https://pecanproject.github.io/sipnet](https://pecanproject.github.io/sipnet)). | ||
| - Ensure the "Using via PEcAn" section includes a link to the [Basic Run Demo](https://pecanproject.github.io/pecan-documentation/develop/rendered-demo-notebooks/run_pecan.html). | ||
| 4. **Verify and Build:** | ||
| - Commit changes and check that links point to the `develop` branch. | ||
| - Ensure the book and pkgdown site render correctly (build instructions below). | ||
|
|
||
| ## Build Instructions | ||
|
|
||
| ### Building the PEcAn Book | ||
| To build the book locally: | ||
| ```bash | ||
| cd book_source | ||
| make | ||
| ``` | ||
|
|
||
| ### Building Pkgdown site | ||
| To build a specific package's documentation: | ||
| ```r | ||
| pkgdown::build_site("models/[modelname]") | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,100 +1,69 @@ | ||
| A generic template for adding a new model to PEcAn | ||
|
man080107 marked this conversation as resolved.
|
||
| ========================================================================== | ||
|
|
||
| Adding a new model to PEcAn in a few easy steps: | ||
|
|
||
| 1. add modeltype to BETY | ||
| 2. add a model and PFT to BETY for use with modeltype | ||
| 3. implement 3 functions as described below | ||
| 4. Add tests to `tests/testthat` | ||
| 5. Update README, documentation | ||
| 6. Update Dockerfile and model_info.json | ||
| 7. execute pecan with new model | ||
|
|
||
|
|
||
| ### Three Functions | ||
|
|
||
| There are 3 functions that will need to be implemented, each of these | ||
| functions will need to have MODEL be replaced with the actual modeltype as | ||
| it is defined in the BETY database. | ||
|
|
||
| * `write.config.MODEL.R` | ||
|
|
||
| This will write the configuratin file as well as the job launcher used by | ||
| PEcAn. There is an example of the job execution script in the template | ||
| folder. The configuration file can also be a template that is found based | ||
| on the revision number of the model. This should use the computed results | ||
| specified in defaults and trait.values to write a configuration file | ||
| based on the PFT and traits found. | ||
|
|
||
| * `met2model.MODEL.R` | ||
|
|
||
| This will convert the standard Met CF file to the model specific file | ||
| format. This will allow PEcAn to create metereological files for the | ||
| specific site and model. This will only be called if no meterological | ||
| data is found for that specific site and model combination. | ||
|
|
||
| * `model2netcdf.MODEL.R` | ||
|
|
||
| This will convert the model specific output to NACP Intercomparison | ||
| format. After this function is finished PEcAn will use the generated | ||
| output and not use the model specific outputs. The outputs should be | ||
| named YYYY.nc | ||
|
|
||
| ### Dockerization | ||
|
|
||
| The PEcAn system is leveraging Docker to encapsulate most of the code. | ||
| This will make it easier to share new model with others, without them | ||
| having to compile the models. The goal is for people to be able to | ||
| launch the model in docker, and it will register with PEcAn and is | ||
| almost immediatly available to be used. To accomplish this you will need to modify two files. | ||
|
|
||
| * `Dockerfile` | ||
|
|
||
| The [Dockerfile](https://docs.docker.com/engine/reference/builder/) is | ||
| like the Makefile for docker. This file is split in two pieces the | ||
| part at the top is to actually build the binary. This is where you | ||
| specify all the libraries that are needed, as well as all the build | ||
| tools to compile your model. The second part, starting at the second | ||
| `FROM` line, is where you will install only the libraries needed to | ||
| run the binary and copy the binary from the build stage, using the | ||
| `COPY --from` line. | ||
|
|
||
| * `model_info.json` | ||
|
|
||
| The model_info.json describes the model and is used to register the | ||
| model with PEcAn. In the model_info.json the only fields that are | ||
| really required are those at the top: `name`, `type`, `version` and | ||
| `binary`. All other fields are optional but are good to be filled | ||
| out. You can leave `version` and `binary` with the special values | ||
| which will be updated by the Dockerfile. | ||
|
|
||
| Once the image can be build it can be pushed so others can leverage | ||
| of the model. For PEcAn we have been using the following naming scheme | ||
| for the docker images: `pecan/model-<model>-<model_version>:<pecan_version>` | ||
| where the `model` and `model_version` are the same as those used to | ||
| build the model, and `pecan_version` is the version of PEcAn this | ||
| model is compiled for. | ||
|
|
||
| ### Additional Changes | ||
|
|
||
| * `README.md` | ||
|
|
||
| This file should contain basic background information about the model. | ||
| At a minimum, this should include the scientific motivation and scope, | ||
| name(s) of maintainer(s), links to project homepage, and a list of a few | ||
| key publications. | ||
| relevant publications. | ||
|
|
||
| * `/tests/testthat/` | ||
|
|
||
| Each package should have tests that cover the key functions of the package, | ||
| at a minimum, the three functions above. | ||
|
|
||
| * documentation | ||
|
|
||
| Update the `NAMESPACE`, `DESCRIPTION` and `man/*.Rd` files by running | ||
|
|
||
| ```r | ||
| devtools("models/<modelname>/") | ||
| # PEcAn.MODEL | ||
|
|
||
| <!-- badges: start --> | ||
|
|
||
| [](https://lifecycle.r-lib.org/articles/stages.html#experimental) | ||
| [](https://pecanproject.r-universe.dev/PEcAn.MODEL) | ||
|
|
||
| <!-- badges: end --> | ||
|
|
||
| PEcAn Functions for the MODEL model. | ||
|
|
||
| ## What is MODEL? | ||
|
|
||
| [Add a brief (1-2 sentence) description of the ecological model here.] | ||
|
|
||
| For full details about the model logic, compiling the source, inputs, and outputs, please see the **[Standalone MODEL Documentation](URL_TO_STANDALONE_DOCS)**. | ||
|
|
||
| * **Homepage**: [URL_TO_HOMEPAGE](URL_TO_HOMEPAGE) | ||
| * **Source Code**: [URL_TO_SOURCE](URL_TO_SOURCE) | ||
| * **Authors**: Maintainer Name, Original Author Name (PEcAn Integration) | ||
| * **License**: [e.g. BSD 3-Clause] | ||
|
|
||
| ## Using MODEL via PEcAn | ||
|
|
||
| The `PEcAn.MODEL` package provides the necessary functions to generate configuration files and process outputs for MODEL within the PEcAn workflow. | ||
|
|
||
| **Getting Started:** | ||
| - [Demo 1: Basic PEcAn Run](https://pecanproject.github.io/pecan-documentation/develop/rendered-demo-notebooks/run_pecan.html) | ||
|
man080107 marked this conversation as resolved.
Outdated
|
||
| - [MODEL in the PEcAn Book](https://pecanproject.github.io/pecan-documentation/develop/models-MODEL.html) | ||
|
|
||
| ### Model Configuration Files | ||
|
|
||
| MODEL is configured using [X] files which are placed in the run folder, along with any necessary input links: | ||
|
|
||
| * **`config.in`**: [Description of function and where template lives in `inst/`] | ||
| * **`params.file`**: [Description] | ||
|
man080107 marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## Installation | ||
|
|
||
| ### Install PEcAn.MODEL Package | ||
|
|
||
| You can install the development version of `PEcAn.MODEL` from R-universe: | ||
|
|
||
| ``` r | ||
| # Enable repository from pecanproject | ||
| options(repos = c( | ||
| pecanproject = 'https://pecanproject.r-universe.dev', | ||
| CRAN = 'https://cloud.r-project.org')) | ||
| # Download and install PEcAn.MODEL in R | ||
| install.packages('PEcAn.MODEL') | ||
| ``` | ||
|
|
||
| Or you can install directly from GitHub using the `remotes` package: | ||
|
|
||
| ``` r | ||
| library(remotes) | ||
| install_github('pecanproject/pecan', subdir = "models/template") | ||
| ``` | ||
|
|
||
| ### Install MODEL Model | ||
|
|
||
| To use PEcAn.MODEL, you also need the MODEL model executable installed on your system. Refer to the [MODEL installation guide](URL_TO_INSTALLATION_GUIDE) for instructions. | ||
|
|
||
| ## Documentation | ||
|
|
||
| - **PEcAn.MODEL pkgdown site:** [https://pecanproject.github.io/package-documentation/develop/PEcAn.MODEL/index.html](https://pecanproject.github.io/package-documentation/develop/PEcAn.MODEL/index.html) | ||
| - **Standalone MODEL Docs:** [URL_TO_STANDALONE_DOCS](URL_TO_STANDALONE_DOCS) | ||
| - **PEcAn Book - MODEL Chapter:** [https://pecanproject.github.io/pecan-documentation/develop/models-MODEL.html](https://pecanproject.github.io/pecan-documentation/develop/models-MODEL.html) | ||
| - **Source Code:** [https://github.com/PecanProject/pecan/tree/develop/models/template](https://github.com/PecanProject/pecan/tree/develop/models/template) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.