Skip to content

Latest commit

 

History

History
99 lines (59 loc) · 4.58 KB

python.md

File metadata and controls

99 lines (59 loc) · 4.58 KB

[TOC]

Prerequisites

You will need a working python 3.7 installation, with the following packages.

These depend on other non-python packages being installed, such as udunits and netcdf4. Most of these packages are usually installed on a linux system. If they are missing, you can ask an IT guy to install them on the system or install them yourself.

In addition, these packages are required (developed by Knut and available on github), and as a part of the hycom-code under the directory NERSC-HYCOM-CICE/pythonlibs/:

  • gridxsec, a tool for creating cross-sections on 2D grids

  • abfile, a tool for reading HYCOM .[ab] files

  • modelgrid, a tool for creating modelgrids using Bentsen et al conformal mapping or standard projections

  • modeltools, a collection of various tools ..

Checking for missing python modules

When running the HYCOM-CICE python routines you will usually get an error message if a module is missing. But you can also check more directly.

A quick way to check is to start python (or ipython) and write import <name_of_module>. The following shows the error message if a module is missing

import numpy
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-5a8446063dec> in <module>()
----> 1 import numpy
ImportError: No module named numpy

If you find some packages are missing have an IT guy install them on the system you are working on, or install them yourself (some tips below).

Installation of missing packages

There are many ways of installing python packages, you can install binary packages (.rpm, .deb etc) for your distribution, you can download source code and compile and install locally, or use python installation tool "pip". If you need to install a package locally, try to use pip, as it is usually the easiest. The following will install f90nml under your local user account:

knutal@debian:~$ pip install --user f90nml
Downloading/unpacking f90nml
  Downloading f90nml-0.19.tar.gz
  Running setup.py (path:/tmp/pip-build-2D2rgF/f90nml/setup.py) egg_info for package f90nml

Installing collected packages: f90nml
  Running setup.py install for f90nml

Successfully installed f90nml
Cleaning up...
knutal@debian:~$ ls -altr

Note that some machines (ex hexagon) have issues with SSL certificates. If you get errors when running the command above (or if "pip search f90nml" returns errors about SSL certificates), you can try this command in stead:

pip install --user  --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org f90nml

These files will be installed in your home directory under $HOME/.local/lib/python2.7/site-packages/, where python will automatically find them.

Installing the python modules from github

We have currently moved all python tools to our NERSC-HYCOM-CICE repository (pythonlibs). Replace "path-to-NERSC-HYCOM-CICE" with your local NERSC-HYCOM-CICE git folder path:

e.g. pip install --user file:/cluster/home/cagyum/NERSC-HYCOM-CICE/pythonlibs/modeltools

   pip install --user file:path-to-NERSC-HYCOM-CICE/pythonlibs/modeltools
   pip install --user file:path-to-NERSC-HYCOM-CICE/pythonlibs/modelgrid
   pip install --user file:path-to-NERSC-HYCOM-CICE/pythonlibs/gridxsec 
   pip install --user file:path-to-NERSC-HYCOM-CICE/pythonlibs/abfile 

If not already exist, one may need to install:

   pip install --user pyproj==1.9.6
   pip install --user netcdftime

To upgrade the libraries after a change in these libraries, just call the same install commands with the extra option: "--upgrade"

e.g. pip install --user file:path-to-NERSC-HYCOM-CICE/pythonlibs/gridxsec --upgrade

These files will be installed in your home directory under $HOME/.local/lib/python2.7/site-packages/, where python will automatically find them.