Opened 7 months ago

Closed 7 months ago

#2917 closed help (fixed)

cdo in python

Reported by: NoelClancy Owned by: pmcguire
Component: Other Keywords: CDO, python
Cc: pmcguire Platform: JASMIN
UM Version:

Description

I can merge yearly files with the “cdo mergetime” command and how to get monthly averages with the “cdo monmean” command.

I want to try to use these commands within a python script loop so that I can merge all netCDF files by year (and loop through all 30 FLUXNET sites) and I also want to try to loop through all 30 FLUXNET sites in python that executes the “cdo monmean” command.

I checked the version of python installed on my PC with
Python –V
And it’s python 2.6.6 (Is that the same as python 2.7?)

However, I cannot install cdo

from cdo import Cdo

ImportError?: No module named cdo


Do you know how to install cdo in python?

Change History (7)

comment:1 Changed 7 months ago by pmcguire

  • Cc pmcguire added; mcguirepatr@… removed
  • Keywords CDO, python added
  • Owner changed from um_support to pmcguire
  • Status changed from new to accepted

comment:2 Changed 7 months ago by pmcguire

Hi Noel
Will you do this on JASMIN or your PC? If you are on JASMIN, python2.7 has a lot more packages installed than python. If it's not installed in python2.7 on JASMIN or in python on your PC, you will need to install the package with a package manager like anaconda or PyPip? or miniconda. You might want to search the CMS tickets (for example) for guidance on installing packages.

For the cdo python package, there is more info here:
https://code.mpimet.mpg.de/projects/cdo/wiki/Cdo%7Brbpy%7D
Patrick

comment:3 Changed 7 months ago by NoelClancy

But jasmin does not use python2.7??? It uses python2.6.6

[nmc@jasmin-sci2 ~]$ python -V
Python 2.6.6
[nmc@jasmin-sci2 ~]$

comment:4 Changed 7 months ago by NoelClancy

I do all of this work on jasmin

However, I import Andy Heapes environment to do my work, I can't install anything?

comment:5 Changed 7 months ago by pmcguire

Hi Noel
With the standard JASMIN setup, if you type python2.7 at the command line, it will start python 2.7 instead of python 2.6.
Patrick

comment:6 Changed 7 months ago by pmcguire

Hi Noel
I am not sure about Andy Heaps' set up on JASMIN, but with the standard setup, it is possible to create a special, personalized installation on python using anaconda, miniconda or PyPip.
Patrick

Last edited 7 months ago by pmcguire (previous) (diff)

comment:7 Changed 7 months ago by andy

  • Resolution set to fixed
  • Status changed from accepted to closed

Hi Noel,
After typing:

export PATH=/home/users/ajh/anaconda_feb2019/bin:$PATH

try:

pip install cdo —user

Then type python and import cdo

Cheers
Andy

Note: See TracTickets for help on using tickets.