{"id":26766049,"url":"https://github.com/ucl/pycascadia","last_synced_at":"2025-09-01T16:46:37.548Z","repository":{"id":45080296,"uuid":"340412666","full_name":"UCL/pyCascadia","owner":"UCL","description":"Implementation of GEBCO cookbook remove-restore and other cleaning of topography/bathymetry. Uses `pyGMT`.","archived":false,"fork":false,"pushed_at":"2022-01-10T11:27:33.000Z","size":719,"stargazers_count":10,"open_issues_count":6,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-18T06:24:19.046Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/UCL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-19T15:36:05.000Z","updated_at":"2025-04-17T13:44:10.000Z","dependencies_parsed_at":"2022-08-27T19:01:39.359Z","dependency_job_id":null,"html_url":"https://github.com/UCL/pyCascadia","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/UCL/pyCascadia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UCL%2FpyCascadia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UCL%2FpyCascadia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UCL%2FpyCascadia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UCL%2FpyCascadia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UCL","download_url":"https://codeload.github.com/UCL/pyCascadia/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UCL%2FpyCascadia/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273158353,"owners_count":25055859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-28T20:18:56.058Z","updated_at":"2025-09-01T16:46:37.520Z","avatar_url":"https://github.com/UCL.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyCascadia\nImplementation of GEBCO cookbook remove-restore and other cleaning of topography/bathymetry. Uses `pyGMT`.\n\n## Dependencies\n\nThe non-python dependencies are:\n\n- gdal\n- GMT\n\n## Installation\nSome dependencies of the package are a bit fiddly to install, especially on Windows.\nWe recommend using a conda environment, and installing the more difficult dependencies through `conda-forge`,\nby running the commands below in sequence:\n\n1. The proceeding steps assume your current working directory is your local copy of the repository. A mixture of conda and pip is used to install the dependencies (due to the complex dependencies gdal and rasterio). The conda dependencies are listed in [environment.yml](https://github.com/UCL/pyCascadia/blob/main/environment.yml) which will be automatically used by conda when creating a new environment:\n```\nconda env create\n```\n3. This will create a new conda environment named `pycascadia` which should be activated with:\n```\nconda activate pycascadia\n```\n4. Install `pyCascadia`. This will also automatically install the remaining dependencies (a list of which can be found in [setup.cfg](https://github.com/UCL/pyCascadia/blob/main/setup.cfg)).\n```\npip install pycascadia\n```\n5. Once you've done your work with `pyCascadia`, you may want to deactivate the environment and return to your base python environment. You can do so by running:\n```\nconda deactivate\n```\n\n## Usage\nBefore using any part of `pyCascadia`, make sure you've got its conda environment activated (change `pycascadia` to the name of your environment if you've named it differently when following the installation instructions).\n```\nconda activate pycascadia\n```\n### Remove restore\n\n`pyCascadia` provides the remove restore algorithm as a command line tool called `remove-restore`, e.g.\n```\nremove-restore --base gebco_base_grid.nc higher_res_grid.tiff --output merged_grid.nc\n```\nInput base and source grids are accepted in both GeoTiff or NetCDF formats. It is possible to provide more than one source grid, e.g with three source grids one would call:\n```\nremove-restore --base gebco_base_grid.nc higher_res_grid1.tiff higher_res_grid2.tiff higher_res_grid3 --output merged_grid.nc\n```\n\nFor more details on these and other input arguments of `remove-restore`, run\n```\nremove-restore -h\n```\non your command line.\n\nFor more fine-grained control of the `remove-restore` functionality, there is an example Jupyter notebook under `./notebooks/`. Note that to use this, you will need to `pip install jupyter` in the conda environment, too.\n\nDetails of the full API can be found in the [documentation](https://github-pages.ucl.ac.uk/pyCascadia/).\n\n### Variable deletion from NetCDF files\n\n`remove-restore` expects a single variable per netCDF file, which is not always the case (see issue #59). The `delete-variable` tool can be used to remove a single variable from a netCDF file in the following way:\n\n```\ndelete-variable --input \u003cinput.nc\u003e --output \u003coutput.nc\u003e --variable \u003cvarname\u003e\n```\n\n### Shape file closing\n\nThe script `close_boundary.py` provides a way to replace values along the domain boundary. This can be used to create \"closed\" shape files, that are necessary for meshing in OceanMesh2D, in combination with the GDAL command `gdal_contour`. The `close_boundary.py` file can be found in the `scripts/` subfolder of your local copy of this GitHub repository, so you should navigate there to use them (or replace the relative path in the commands below, e.g. `python close_boundary.py` -\u003e `python ./scripts/close_boundary.py`).\n```\ncd scripts/\n```\nInstructions for the main use case - creating shapefiles that consist of closed contours at a certain value $z$ and on the domain boundary, where the values are $\u003ez$:\n\n1. Generate a new netCDF file with all domain boundaries $\u003ez$ set to a value slightly lower than $z$, i.e. $z-epsilon$:\n\n`python close_boundary.py --value \u003cz-epsilon\u003e --input \u003cinput.nc\u003e --output \u003coutput.nc\u003e`\n\nThe reason for using a slightly lower value here is because if the value is exactly equal to $z$, `gdal_contour` does not interpret these locations as a contour line at $z$.\n\n1. Run `gdal_contour` on the `output.nc` file of the previous step to create the final `closed.shp` shape file:\n\n`gdal_contour -fl \u003cz\u003e \u003coutput.nc\u003e \u003cclosed.shp\u003e`\n\nIn our wider Cascadia pipeline, we use contours based on the proximity-to-the-coast map, as these are smoother and avoid discontinuities in the contour lines, which would prevent us from meshing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucl%2Fpycascadia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fucl%2Fpycascadia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucl%2Fpycascadia/lists"}