Skip to content

Commit

Permalink
Merge branch 'issue42_rebranding'
Browse files Browse the repository at this point in the history
  • Loading branch information
doutriaux1 committed Aug 28, 2014
2 parents b37e215 + 9c12f05 commit 9562abe
Show file tree
Hide file tree
Showing 35 changed files with 108 additions and 155 deletions.
2 changes: 1 addition & 1 deletion doc/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
WGNE/WGCM metrics panel package - alpha v0.1
PCMDI metrics panel package - alpha v0.1

mean_climate_metrics_driver.py
------------------------------
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 0 additions & 53 deletions doc/wgne_input_parameters_allcmip5_jan22.py

This file was deleted.

32 changes: 16 additions & 16 deletions install_metrics.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## SYSTEM SPECIFIC OPTIONS, EDIT THESE TO MATCH YOUR SYSTEM

## Directory where to install UVCDAT and the METRICS Packages
install_prefix="WGNE"
install_prefix="PCMDI_METRICS"

## Temporary build directory
build_directory="${install_prefix}/tmp"
Expand Down Expand Up @@ -346,9 +346,9 @@ main() {
cdat_repo_http=http://github.com/UV-CDAT/uvcdat.git
cdat_repo_https=https://github.com/UV-CDAT/uvcdat.git
cdat_version="master"
metrics_repo=git://github.com/PCMDI/wgne-wgcm_metrics.git
metrics_repo_http=http://github.com/PCMDI/wgne-wgcm_metrics.git
metrics_repo_https=https://github.com/PCMDI/wgne-wgcm_metrics.git
metrics_repo=git://github.com/PCMDI/pcmdi_metrics.git
metrics_repo_http=http://github.com/PCMDI/pcmdi_metrics.git
metrics_repo_https=https://github.com/PCMDI/pcmdi_metrics.git
metrics_checkout="master"
install_prefix=$(_full_path ${install_prefix})
if [ $? != 0 ]; then
Expand All @@ -367,19 +367,19 @@ main() {
cdat_home=${install_prefix}
echo "Installing into: "${install_prefix}
echo "Temporary build directory: "${build_directory}
## clone wgne repo
## clone pcmdi_metrics repo
git clone ${metrics_repo} ${metrics_build_directory}
if [ ! -e ${metrics_build_directory}/.git/config ]; then
echo " WARN: Could not clone metrics repo via git protocol (port 9418)! Trying https protocol"
git clone ${metrics_repo_https} ${metrics_build_directory}
git clone ${metrics_repo_https} ${metrics_build_directory}
if [ ! -e ${metrics_build_directory}/.git/config ]; then
echo " WARN: Could not clone metrics repo via https (port 22)! Trying http protocol (port 80)"
git clone ${metrics_repo_http} ${metrics_build_directory}
if [ ! -e ${metrics_build_directory}/.git/config ]; then
echo " WARN: Could not clone metrics repoi via https (port 22)! Trying http protocol (port 80)"
git clone ${metrics_repo_http} ${metrics_build_directory}
if [ ! -e ${metrics_build_directory}/.git/config ]; then
echo " ERROR: Could not clone metrics repo via git/https/http! Check you are connected to the internet or your firewall settings"
exit 1
fi
echo " ERROR: Could not clone metrics repo via git/https/http! Check you are connected to the internet or your firewall settings"
exit 1
fi
fi
fi

cd ${metrics_build_directory} >& /dev/null
Expand Down Expand Up @@ -415,13 +415,13 @@ main() {
echo "*******************************"
echo "Please test as follow:"
echo "source ${cdat_home}/bin/setup_runtime.sh"
echo "wgne_metrics_driver.py -p ${install_prefix}/test/wgne/basic_test_parameters_file.py"
echo "compare: ${install_prefix}/test/wgne/tos_2.5x2.5_esmf_linear_metrics.json.good with wgne_install_test_results/metrics_results/installationTest/tos_2.5x2.5_esmf_linear_metrics.json"
echo "pcmdi_metrics_driver.py -p ${install_prefix}/test/pcmdi/basic_test_parameters_file.py"
echo "compare: diff ${install_prefix}/test/pcmdi/tos_2.5x2.5_esmf_linear_metrics.json.good pcmdi_install_test_results/metrics_results/installationTest/tos_2.5x2.5_esmf_linear_metrics.json"
echo "*******************************"
echo "Create your customized input_parameters.py (inspire yourself from examples in ${install_prefix}/doc/wgne_input_parameters_sample.py"
echo "Create your customized input_parameters.py (inspire yourself from examples in ${install_prefix}/doc/pcmdi_input_parameters_sample.py"
echo "Once you have a parameter file run:"
echo "source ${install_prefix}/bin/setup_runtime.sh"
echo "wgne_metrics_driver.py -p /path/to/your/edited/parameter_file.py"
echo "pcmdi_metrics_driver.py -p /path/to/your/edited/parameter_file.py"
echo "*******************************"
echo "Once everything is ok, you can safely remove the temporary directory: ${build_directory}"
echo "*******************************"
Expand Down
30 changes: 15 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from distutils.core import setup, Extension
import os,sys
import numpy
Version="0.1.0"
Version="0.2.0"
import subprocess
p = subprocess.Popen(("git","log","-n1","--pretty=short"),stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
try:
Expand All @@ -13,26 +13,26 @@
print >>f, "__git_sha1__ = '%s'" % commit
f.close()

setup (name = "metrics",
setup (name = "pcmdi_metrics",
version=Version,
author='PCMDI',
description = "model metrics tools",
url = "http://github.com/PCMDI/wgne-wgcm_metrics",
packages = ['metrics','metrics.io','metrics.wgne'],
package_dir = {'metrics': 'src/python',
'metrics.io': 'src/python/io',
'metrics.wgne': 'src/python/wgne'},
scripts = ["src/python/wgne/scripts/wgne_metrics_driver.py",
"src/python/wgne/scripts/build_obs_meta_dictionary.py"],
data_files = [('share/wgne',('doc/obs_info_dictionary.json',)),
('doc',('doc/wgne_input_parameters_sample.py',)),
('test/wgne',('test/wgne/basic_test_parameters_file.py','test/wgne/tos_GFDL-ESM2G_Omon_historical_r1i1p1_198501-200512-clim.nc','test/wgne/sftlf_GFDL-ESM2G_fx_historical_r0i0p0_198501-200512-clim.nc','test/wgne/tos_2.5x2.5_esmf_linear_metrics.json.good')),
('test/wgne/obs/ocn/mo/tos/UKMETOFFICE-HadISST-v1-1/ac',('test/wgne/tos_pcmdi-metrics_Omon_UKMETOFFICE-HadISST-v1-1_198002-200501-clim.nc',)),
('test/wgne/obs/fx/mo/sftlf/UKMETOFFICE-HadISST-v1-1/ac',('test/wgne/sftlf_pcmdi-metrics_fx_UKMETOFFICE-HadISST-v1-1_198002-200501-clim.nc',)),
url = "http://github.com/PCMDI/pcmdi_metrics",
packages = ['pcmdi_metrics','pcmdi_metrics.io','pcmdi_metrics.pcmdi'],
package_dir = {'pcmdi_metrics': 'src/python',
'pcmdi_metrics.io': 'src/python/io',
'pcmdi_metrics.pcmdi': 'src/python/pcmdi'},
scripts = ["src/python/pcmdi/scripts/pcmdi_metrics_driver.py",
"src/python/pcmdi/scripts/build_obs_meta_dictionary.py"],
data_files = [('share/pcmdi',('doc/obs_info_dictionary.json',)),
('doc',('doc/pcmdi_input_parameters_sample.py',)),
('test/pcmdi',('test/pcmdi/basic_test_parameters_file.py','test/pcmdi/tos_GFDL-ESM2G_Omon_historical_r1i1p1_198501-200512-clim.nc','test/pcmdi/sftlf_GFDL-ESM2G_fx_historical_r0i0p0_198501-200512-clim.nc','test/pcmdi/tos_2.5x2.5_esmf_linear_metrics.json.good')),
('test/pcmdi/obs/ocn/mo/tos/UKMETOFFICE-HadISST-v1-1/ac',('test/pcmdi/tos_pcmdi-metrics_Omon_UKMETOFFICE-HadISST-v1-1_198002-200501-clim.nc',)),
('test/pcmdi/obs/fx/mo/sftlf/UKMETOFFICE-HadISST-v1-1/ac',('test/pcmdi/sftlf_pcmdi-metrics_fx_UKMETOFFICE-HadISST-v1-1_198002-200501-clim.nc',)),
]
#include_dirs = [numpy.lib.utils.get_include()],
# ext_modules = [
# Extension('metrics.exts',
# Extension('pcmdi_metrics.exts',
# ['src/C/add.c',],
# library_dirs = [],
# libraries = [],
Expand Down
2 changes: 1 addition & 1 deletion src/python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# put here the impor calls to expose whatever we want to the user
import io
import wgne
import pcmdi
from version import __version__ , __git_sha1__

2 changes: 1 addition & 1 deletion src/python/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#init for metrics.io
#init for pcmdi_metrics.io
import base
6 changes: 3 additions & 3 deletions src/python/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import MV2
import genutil
import os
import metrics
import pcmdi_metrics
import cdat_info

value = 0
Expand Down Expand Up @@ -64,7 +64,7 @@ def write(self,data, type="json", mode="w", *args, **kargs):
raise RuntimeError, "Could not create output directory: %s" % (os.path.split(fnm)[0])
if type.lower() == "json":
f=open(fnm,mode)
data["metrics_git_sha1"] = metrics.__git_sha1__
data["metrics_git_sha1"] = pcmdi_metrics.__git_sha1__
data["uvcdat_version"] = cdat_info.get_version()
json.dump(data,f,*args,**kargs)
elif type.lower() in ["asc","ascii","txt"]:
Expand All @@ -74,7 +74,7 @@ def write(self,data, type="json", mode="w", *args, **kargs):
elif type.lower() == "nc":
f=cdms2.open(fnm,mode)
f.write(data,*args,**kargs)
f.metrics_git_sha1 = metrics.__git_sha1__
f.metrics_git_sha1 = pcmdi_metrics.__git_sha1__
f.uvcdat_version = cdat_info.get_version()
else:
raise RuntimeError,"Unknown type: %s" % type
Expand Down
6 changes: 3 additions & 3 deletions src/python/io/getOurModelData.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cdms2
import string
import os

##############################################################################
# PJG 20130522
Expand All @@ -23,9 +23,9 @@ def getOurModelData(exp,var):

filename_tmp = 'cmip5.NorESM1-M.historical.r1i1p1.mo.atm.Amon.VARNAME.ver-1.1980-1999.AC.nc'

filename_new = string.replace(filename_tmp,'VARNAME',var)
filename_new = filename_tmp.replace('VARNAME',var)

f = cdms.open(pathin + var + '/' + filename_new)
f = cdms.open(os.path.join(pathin, var, filename_new))
d = f(var + '_ac')
f.close()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import cdms2
import string, os
import ESMP

######################################
value = 0
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/python/wgne/io.py → src/python/pcmdi/io.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import metrics
class OBS(metrics.io.base.Base):
import pcmdi_metrics
class OBS(pcmdi_metrics.io.base.Base):
def __init__(self,root,var,obs_dic,reference="default"):

template = "%(realm)/mo/%(variable)/%(reference)/ac/%(variable)_pcmdi-metrics_%(obs_table)_%(reference)_%(period)-clim.%(ext)"
metrics.io.base.Base.__init__(self,root,template)
pcmdi_metrics.io.base.Base.__init__(self,root,template)
obs_name = obs_dic[var][reference]
ref = obs_dic[var][obs_name]
period = ref["period"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import cdms2 as cdms
from genutil import statistics
import cdutil
import metrics
import pcmdi_metrics



Expand Down Expand Up @@ -35,21 +35,21 @@ def compute_metrics(var,dm_glb,do_glb):

### ANNUAL CYCLE SPACE-TIME RMS AND CORRELATION
print '---- shapes ', dm.shape,' ', do.shape
rms_xyt = metrics.wgne.rms_xyt.compute(dm,do)
cor_xyt = metrics.wgne.cor_xyt.compute(dm,do)
rms_xyt = pcmdi_metrics.pcmdi.rms_xyt.compute(dm,do)
cor_xyt = pcmdi_metrics.pcmdi.cor_xyt.compute(dm,do)

### CALCUALTE ANNUAL MEANS OF DATA
do_am, dm_am = metrics.wgne.annual_mean.compute(dm,do)
do_am, dm_am = pcmdi_metrics.pcmdi.annual_mean.compute(dm,do)

### ANNUAL MEAN BIAS
bias_xy = metrics.wgne.bias.compute(dm_am,do_am)
bias_xy = pcmdi_metrics.pcmdi.bias.compute(dm_am,do_am)
print var,' ', 'annual mean bias is ' , bias_xy

### MEAN ABSOLOUTE ERROR
mae_xy = metrics.wgne.meanabs_xy.compute(dm_am,do_am)
mae_xy = pcmdi_metrics.pcmdi.meanabs_xy.compute(dm_am,do_am)

### ANNUAL MEAN RMS
rms_xy = metrics.wgne.rms_xy.compute(dm_am,do_am)
rms_xy = pcmdi_metrics.pcmdi.rms_xy.compute(dm_am,do_am)

conv = 1.
if var == 'pr': conv = 1.e5
Expand All @@ -68,14 +68,14 @@ def compute_metrics(var,dm_glb,do_glb):

for sea in ['djf','mam','jja','son']:

dm_sea = metrics.wgne.seasonal_mean.compute(dm,sea)
do_sea = metrics.wgne.seasonal_mean.compute(do,sea)
dm_sea = pcmdi_metrics.pcmdi.seasonal_mean.compute(dm,sea)
do_sea = pcmdi_metrics.pcmdi.seasonal_mean.compute(do,sea)

### SEASONAL RMS AND CORRELATION
rms_sea = metrics.wgne.rms_xy.compute(dm_sea,do_sea)
cor_sea = metrics.wgne.cor_xy.compute(dm_sea,do_sea)
mae_sea = metrics.wgne.meanabs_xy.compute(dm_sea,do_sea)
bias_sea = metrics.wgne.bias.compute(dm_sea,do_sea)
rms_sea = pcmdi_metrics.pcmdi.rms_xy.compute(dm_sea,do_sea)
cor_sea = pcmdi_metrics.pcmdi.cor_xy.compute(dm_sea,do_sea)
mae_sea = pcmdi_metrics.pcmdi.meanabs_xy.compute(dm_sea,do_sea)
bias_sea = pcmdi_metrics.pcmdi.bias.compute(dm_sea,do_sea)

metrics_dictionary['bias_xy_' + sea + '_' + dom] = format(bias_sea*conv,sig_digits)
metrics_dictionary['rms_xy_' + sea + '_' + dom] = format(rms_sea*conv,sig_digits)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!python
import cdms2 as cdms
import json, os, sys, string
import cdms2
import json, os, sys
if len(sys.argv)>1:
data_path = sys.argv[1]
else:
Expand Down Expand Up @@ -39,22 +39,22 @@


for l in lst:
subp = string.split(l,'obs')[1]
subp = l.split('obs')[1]
# print subp

var = string.split(subp,'/')[3]
var = subp.split('/')[3]

if var not in obs_dic.keys(): obs_dic[var] = {}

product = string.split(subp,'/')[4]
product = subp.split('/')[4]

if product not in obs_dic[var].keys(): obs_dic[var][product] = {}

partial_filename = string.split(subp,'pcmdi-metrics')[1]
partial_filename = subp.split('pcmdi-metrics')[1]

realm = string.split(partial_filename,'_')[1]
period = string.split(partial_filename,'_')[3]
period = string.split(period,'-clim.nc')[0]
realm = partial_filename.split('_')[1]
period = partial_filename.split('_')[3]
period = period.split('-clim.nc')[0]

obs_dic[var][product]['CMIP_CMOR_TABLE'] = realm
obs_dic[var][product]['period'] = period
Expand All @@ -67,7 +67,7 @@

print var,' ', product,' ', realm,' ', period

f = cdms.open(l[:-1])
f = cdms2.open(l[:-1])
d = f(var)
shape = d.shape
f.close()
Expand Down

0 comments on commit 9562abe

Please sign in to comment.