Skip to content

Conversation

lizziel
Copy link
Contributor

@lizziel lizziel commented Jul 25, 2023

This PR brings in several cubed-sphere utilities that were never formally added to GCPy.

A new module gcpy/cstools.py has been added. This module contains cubed-sphere grid functions from Liam Bindle and Sebastian Easatham. Most importantly, a new function to compute the cubed-sphere grid indices corresponding to a given (lat,lon) location has been added.

The gcpy/cstools.py module was incorporated into GCPy by Lizzie Lundgren and Bob Yantosca. Several Python style updates suggested by Pylint were applied as well. The resulting code has a Pylint score of 9.43/10.

lizziel and others added 2 commits July 25, 2023 12:14
The new tools file, cstools.py, includes an example of how to extract
cubed-sphere grid indexes (nf, Ydim, Xdim) given a target latitude and
longitude, and how to use them to extract data for a specific lat-lon box.

Using this tool requires python package pyproj not previously required.
GCPy will still function without this package. However, you will not be
able to call function find_index.

The code added was originally developed by Liam Bindle and Sebastian
Eastham and was taken directly from the gcgridobj repository. I made
a minor change to remove np.int (deprecated) and add example and header.

Signed-off-by: Lizzie Lundgren <elundgren@seas.harvard.edu>
docs/environment_files/environment.yml
- The updates to the cubed-sphere tools require the pyproj library.
  We have now added pyproj==3.6.0 as a PyPi dependency.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
@lizziel lizziel added the category: Feature Request New feature or request label Jul 25, 2023
@lizziel lizziel self-assigned this Jul 25, 2023
@lizziel lizziel changed the base branch from main to dev July 25, 2023 16:58
gcpy/cstools.py
- Ran through the Pylint linter and adopted several style suggestions:
  - Updated Pydoc strings / Added missing Pydoc strings
  - Redefined variable names to adhere to snake_case style
  - Now define radians to degrees & vice versa constants
    at the top of the module
  - Make sure most lines are within 80 characters
@yantosca yantosca added the topic: Cubed-Sphere Grid Pertains to cubed-sphere grids and/or regridding label Jul 25, 2023
@yantosca yantosca added this to the 1.4.0 milestone Jul 25, 2023
CHANGELOG.py
- Added sentence about adding gcpy/cstools.py

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
@yantosca yantosca marked this pull request as ready for review July 25, 2023 20:27
@yantosca yantosca self-requested a review July 25, 2023 20:27
CHANGELOG.md
- Add sentence about the environment.yml file being updated
  to install pyproj version 3.6.0 via pip.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
Copy link
Contributor

@yantosca yantosca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to merge! Thanks @lizziel!

@yantosca yantosca merged commit 9d0d089 into dev Jul 25, 2023
@yantosca yantosca deleted the feature/gcgridobj_tools_for_cs_grids branch July 25, 2023 20:40
hannahnesser pushed a commit to hannahnesser/gcpy that referenced this pull request Jan 22, 2024
This merge brings PR geoschem#239 (GCGridObj tools for cubed-sphere grids,
by @lizziel) into GCPy.  This adds several utility functions for
working with data on cubed-sphere grids.  These were from the GcGridObj
repository by Liam Bindle and Sebastian Eastham, but had never been
formally merged into GCPy.

Of note, there is now a function find_index, which will allow a user
to find the indices of a cubed-sphere grid box given the lat & lon
values.  This is necessary in several benchmarking contexts.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Feature Request New feature or request topic: Cubed-Sphere Grid Pertains to cubed-sphere grids and/or regridding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants