Giter Club home page Giter Club logo

ocean_model_grid_generator's Introduction

GFDL Ocean Model Grid Generator

A collection of tools for creating finite element spherical tripolar grids for GFDL's MOM based ocean models.

Required python packages:

To test this module quickly try

  • cd extras ; make -f Makefile.examples quick

Examples:

  • To build a grid consisting a 1/2 degree regular spherical grid between 50S and 70S, stitched with a displaced pole cap south of 70S with the south pole displaced to (60E,50S):

    ocean_grid_generator.py -r 2 --south_ocean_upper_lat -50 --south_cap_lat -70 --lon_dp 60.0 --lat_dp -85.85 --grids so sc [--skip_metrics --plot]

Technical guide

Build Status

ocean_model_grid_generator's People

Contributors

adcroft avatar nikizadehgfdl avatar underwoo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

ocean_model_grid_generator's Issues

A better way than subprocess

Currently ocean_grid_generator.py uses subprocess to get the script location, and check the git information. Below is a better way to get that information. Consider updating.

scriptpath = os.path.realpath(__file__)
scriptbasename = os.path.basename(scriptpath)
scriptdirname = os.path.dirname(scriptpath)
scriptgithash = subprocess.check_output(['git', 'rev-parse', 'HEAD'],
                                        cwd=scriptdirname)
scriptgithash = scriptgithash.decode('ascii').rstrip("\n")
scriptgitMod = subprocess.check_output(['git', 'status', '--porcelain',
                                        scriptbasename],
                                       cwd=scriptdirname)
scriptgitMod = scriptgitMod.decode('ascii').rstrip("\n")

Newer pip needed to test and install

On the GFDL workstations, this gives should work:

autoreconf -i
mkdir build
cd build
../configure --enable-venv
make
make check
make install

But it fails when trying to pip install adcroft/numpi, which uses does not use the old-style setup.py. Newer pips use setup.cfg instead of setup.py.

You are using pip version 9.0.3, however version 22.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting git+https://github.com/adcroft/numpypi.git
  Cloning https://github.com/adcroft/numpypi.git to /tmp/pip-1e9hnhfq-build
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib64/python3.6/tokenize.py", line 452, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-1e9hnhfq-build/setup.py'

Updating the pip version as the stderr suggests fixes this.

ocean_grid_generator not grabbing hash when installed

When running ocean_grid_generator.py from a pip installed location, the script is unable to get the git information from the subprocess commands. When run, the netCDF file will contain the following:

:source = "/Users/Seth.Underwood/tmp/testenv/bin/ocean_grid_generator.py had git hash fatal: not a git repository (or any of the parent directories): .gitfatal: not a git repository (or any of the parent directories): .git. To obtain the grid generating code do: git clone  https://github.com/nikizadehgfdl/grid_generation.git ; cd grid_generation;  git checkout fatal: not a git repository (or any of the parent directories): .git" ;

numpy.linspace required `int()` in third argument

Why attempting to run some of the tests, I found in some instances the command fails with a similar traceback:

  File ".../FRE-NCtools/tools/ocean_model_grid_generator/ocean_grid_generator.py", line 1388, in <module>
    main(sys.argv[1:])
  File ".../FRE-NCtools/tools/ocean_model_grid_generator/ocean_grid_generator.py", line 898, in main
    lamMerc,phiMerc = generate_mercator_grid(Ni,phi_s_Merc,phi_n_Merc,lon0,lenlon, refineR,shift_equator_to_u_point=shift_equator_to_u_point, ensure_nj_even=ensure_nj_even,enhanced_equatorial=enhanced_equatorial)
  File ".../FRE-NCtools/tools/ocean_model_grid_generator/ocean_grid_generator.py", line 337, in generate_mercator_grid
    phi4=np.linspace(phi_s,0,N_enh)
  File "<__array_function__ internals>", line 5, in linspace
  File ".../lib/python3.8/site-packages/numpy/core/function_base.py", line 120, in linspace
    num = operator.index(num)
TypeError: 'float' object cannot be interpreted as an integer

Looking at the numpy documentation, I can only assume the variable N_enh is to be used for the num argument in:

numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0)[source]

and must be an integer, as indicated in the documentation

numint, optional
Number of samples to generate. Default is 50. Must be non-negative.

Looking at the code, I see on line [337] (

phi4=np.linspace(phi_s,0,N_enh)
), the use of numpy.linspace:

phi4=np.linspace(phi_s,0,N_enh)

N_enh is defined on line 306 as:

N_enh=40    *refineR/2 

The division converts N_enh into a float.

Either line 306 or 337 need to cast the value to be stored or stored to an int.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.